Article View: comp.unix.programmer
Article #3692Re: Is there a C 'traceback' function?
From: Dave Hayden
Date: Thu, 17 Nov 1994 16:08
Date: Thu, 17 Nov 1994 16:08
60 lines
2341 bytes
2341 bytes
aep@world.std.com (Andrew E Page) writes:
> I'm working a on a significant body of someone elses code that I'm
>translating to unix from the Mac and PC world.
> Is there a function that can tell you the calling history of your
>program? For example:
>----------------------------
>static void foo2(void)
>{
>char history_string_buffer[2048] ;
>get_history(buffer, sizeof(buffer)) ;
>printf("history is:\n%s\n", buffer) ;
>}
>static void foo1(void)
>{
>foo2() ;
>}
>main()
>{
>foo1() ;
>}
>---------------------------------
>That would produce something along the lines of:
>history is:
>foo2
>called from foo1
>called from main.
> Is there such a beast? If not could someone point me to a reference
>so that I may create it?
It depends on the specific compiler and options you use. You would need
to know the stack frame format and then write a "stack crawler" that would
crawl up the frames.
Debuggers are designed to do this sort of thing. Why not just use a debugger
to get this info for you?
Dave Hayden
dave@babel.ho.att.com
>--
>Andrew E. Page (Warrior Poet) | Decision and Effort The Archer and Arrow
>Mac Consultant | The difference between what we are
>Macintosh and DSP Technology | and what we want to be.
Technical Details
Message-ID:
<dave.785088490@babel.ho.att.com>Path:
arc1-ca.pugleaf.net!nntp.gmd.de!urmel.informatik.rwth-aachen.de!newsserver.rrzn.uni-hannover.de!aix11.hrz.uni-oldenburg.de!nordwest.germany.eu.net!pophh!Germany.EU.net!howland.reston.ans.net!math.ohio-state.edu!magnus.acs.ohio-state.edu!csn!gw1.att.com!nntpa!babel.ho.att.com!daveReferences:
<CzF2zG.2C7@world.std.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,7119e05035b91c13 X-Google-Attributes: gid11318c,public X-Google-Thread: fc89c,7119e05035b91c13 X-Google-Attributes: gidfc89c,public X-Google-Thread: 1014db,7119e05035b91c13 X-Google-Attributes: gid1014db,public X-Google-ArrivalTime: 1994-11-19 12:45:05 PST Newsgroups: comp.unix.programmer,comp.lang.c,gnu.gcc.help Path: arc1-ca.pugleaf.net!nntp.gmd.de!urmel.informatik.rwth-aachen.de!newsserver.rrzn.uni-hannover.de!aix11.hrz.uni-oldenburg.de!nordwest.germany.eu.net!pophh!Germany.EU.net!howland.reston.ans.net!math.ohio-state.edu!magnus.acs.ohio-state.edu!csn!gw1.att.com!nntpa!babel.ho.att.com!dave From: dave@edo.ho.att.com (Dave Hayden) Subject: Re: Is there a C 'traceback' function? Message-ID: <dave.785088490@babel.ho.att.com> Sender: news@nntpa.cb.att.com (Netnews Administration) Nntp-Posting-Host: edo.ho.att.com Organization: AT&T References: <CzF2zG.2C7@world.std.com> Date: Thu, 17 Nov 1994 16:08:10 GMT Lines: 62