Subject: Re: CCL:C Hacker question

From: Szilveszter Juhos <[email-masked]>
Date: Fri, 28 Jun 2002 09:21:14 +0000 (GMT)

On Thu, 27 Jun 2002, Joe Leonard wrote:

> Does anybody know a way to determine the name of the calling
> routine from C - Routine A calls Routine B, and B wishes to know
> the name of whatever routine called it...

If you compile with -g (and no optimization) than debug it? cvd under SGI
is a very neat stuff or ddd/gdb under Linux. Even easier check the xref of
the sourece tree (ie in [x]emacs or sourcenavigator) or use ctags. M-x 
speedbar can help a lot in xemacs, ctags-exuberant in vim.

Cheers
Szilva

---

From: Andrey Khavryuchenko <[email-masked]>
Date: 28 Jun 2002 12:14:47 +0300

Joe,

"JL" == Joe Leonard wrote:

 JL> Does anybody know a way to determine the name of the calling
 JL> routine from C - Routine A calls Routine B, and B wishes to know
 JL> the name of whatever routine called it...

 JL> If it's a real hack, something which works on Linux (or Linux and SGI)
 JL> would do the trick. Pointers to these kinds of programmer tricks
 JL> are appreciated as well!

If you're developing such code, you'd better to supply an additional flag,
which signifies who called the B routine.

Otherwise, you have to build debug version of your program (with symbols)
and do hard tricks parsing gdb output.

I wonder why would you need that?

-- 
Andrey V Khavryuchenko          http://www.kds.com.ua/
Offshore Software Development

---

From: "David E. Konerding" <[email-masked]>
Date: Fri, 28 Jun 2002 09:31:11 -0700

> and do hard tricks parsing gdb output.

Actually, it could be solved by compiling with symbols, and then doing 
stack unwinding to find the function pointer of the calling function and 
then looking that up in the symbol table.

It could by done, but it's not really appropriate for this list (Usenet 
has groups full of people who can answer this) nor is it an advisable 
technique.

Dave