Article View: comp.unix.programmer
Article #3695Re: Is there a C 'traceback' function?
From: Larry Weiss
Date: Fri, 18 Nov 1994 15:45
Date: Fri, 18 Nov 1994 15:45
32 lines
2096 bytes
2096 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?
On a SUN OS 4.1 workstation here is what I do. I define an include file
named where.h that contains:
#define WHERE(programnamestring) \
{{{ \
char buffer[512]; \
sprintf(buffer,"echo 'where ; detach' | dbx %s %d", \
programnamestring, getpid()); \
system(buffer); \
}}}
and #include it in a module where I need traceback info.
Then I insert expansions of the form:
WHERE("myprog");
where, "myprog" is the name of the executable program.
This will invoke an external debugger (dbx) that will interact with the program
to create the traceback list whenever the expansion of WHERE() is executed.
The traceback will be written to stdout.
--
Larry Weiss, lfw@oc.com
214/888-0471
Technical Details
Message-ID:
<3aii63$lr0@pssparc2.oc.com>Path:
arc1-ca.pugleaf.net!nntp.gmd.de!xlink.net!howland.reston.ans.net!gatech!udel!news.mathworks.com!news.kei.com!hermes.oc.com!pssparc2.oc.com!not-for-mailReferences:
<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-18 08:47:14 PST Path: arc1-ca.pugleaf.net!nntp.gmd.de!xlink.net!howland.reston.ans.net!gatech!udel!news.mathworks.com!news.kei.com!hermes.oc.com!pssparc2.oc.com!not-for-mail From: lfw@pssparc2.oc.com (Larry Weiss) Newsgroups: comp.unix.programmer,comp.lang.c,gnu.gcc.help Subject: Re: Is there a C 'traceback' function? Date: 18 Nov 1994 09:45:07 -0600 Organization: OpenConnect Systems, Dallas, TX, USA Lines: 33 Message-ID: <3aii63$lr0@pssparc2.oc.com> References: <CzF2zG.2C7@world.std.com> NNTP-Posting-Host: pssparc2.oc.com