Re: Getting call stack (like dbx where cmd)
From: CBFalconer (cbfalconer_at_yahoo.com)
Date: 10/30/04
- Next message: Nathan Dietsch: "Re: Solaris 10 N1 Containers vs AIX 5.3 Micro-Partitioning"
- Previous message: GMNelson: "Re: Backup Solutions"
- In reply to: Adrian: "Getting call stack (like dbx where cmd)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 30 Oct 2004 06:25:30 GMT
Adrian wrote:
>
> Is there a way (understandably non-portable) to get the
> call stack from within a function? That is, assuming the
> application has been compiled with symbols, get the list
> of calling function names (similar to dbx "where" command").
>
> I am working with IBM compiler and AIX but any other
> OS/compiler solution would be interesting as well.
>
> To answer the inevitable question why I want this,
> I am writing a simple profiler for my library. However,
> within the library I want to distinguish which part of
> the application I was called from....
Since you know the CPU things are running on, it should not be hard
to write a couple of callable assembly language routines to return
those values. Something like:
void *getbp(void);
void *getsp(void);
They might even be implemented as inline, since they should be very
short, and that will avoid complications of digging into the
stack. getbp would probable resolve to "mov ax,bp".
Implementation is OT here, however how they should be integrated
into a C program is not.
-- Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net) Available for consulting/temporary embedded and systems. <http://cbfalconer.home.att.net> USE worldnet address!
- Next message: Nathan Dietsch: "Re: Solaris 10 N1 Containers vs AIX 5.3 Micro-Partitioning"
- Previous message: GMNelson: "Re: Backup Solutions"
- In reply to: Adrian: "Getting call stack (like dbx where cmd)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|