Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Stack tracing?

0 views
Skip to first unread message

Don Bowman

unread,
Aug 31, 1995, 3:00:00 AM8/31/95
to
Does anyone know of, or have, code to trace the stack
on a MIPS (R4K) processor? I've got the algorithm in
the SYS V ABI, but it would be nice not to have to write
it myself.

It needn't be symbolic, just straight hex addresses is fine.

--
bow...@waterloo.hp.com ** 519-883-3019 ** http://www.waterloo.hp.com/~bowman

David B.Anderson

unread,
Aug 31, 1995, 3:00:00 AM8/31/95
to
In article <42562j$4...@hppadbk.waterloo.hp.com>,

Don Bowman <bow...@waterloo.hp.com> wrote:
>Does anyone know of, or have, code to trace the stack
>on a MIPS (R4K) processor? I've got the algorithm in
>the SYS V ABI, but it would be nice not to have to write
>it myself.
>
>It needn't be symbolic, just straight hex addresses is fine.

hp?

It's quite hard to do without some debug information.

There is no standard supported way to do it at present.

By far the simplest way to do this is to use dbx:

#include <stdio.h>
#include <signal.h>
extern char *sys_errlist[];
extern int sys_nerr;
#define DIED -1
int proc3(i,j)
int i,j;
{
int mypid, errno, termsig;
static char *dbxstring = " ";
static char *createfile =" ";
static char *filename = "/tmp/tttttttttt";
static char *rmfile = " ";
int irr;
mypid = getpid();
sprintf(filename + 7, "%d" , mypid);
sprintf (dbxstring, "echo \"where\nquit\" | dbx -p %d 1>&2",mypid);
sprintf (createfile, "echo \"where\nquit\" > %s",filename);
sprintf (rmfile, "rm -rf %s",filename);
irr = system (dbxstring);
if (irr != 0)
perror ("Unable to call dbx for trace");
if (system (rmfile) < 0)
fprintf (stderr, "Error unable to remove temp file: %s\n", filename);
return (0);
}
proc2(i,j)
int i,j;
{
int kk;
kk = proc3(j,i);
if (kk == 0)
printf ("successfull return from trace\n");
}
main()
{
int i,j;
i = 10;
j = 12;
proc2(i,j);
}

[ David B. Anderson (415)390-4263 da...@sgi.com ]
[ Suddenly to me that no verb in this sentence. -m.toy]

0 new messages