home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Supreme Volume 6 #1
/
swsii.zip
/
swsii
/
215
/
DDJ9209.ZIP
/
TRACE.ASC
< prev
next >
Wrap
INI File
|
1992-08-19
|
1KB
|
63 lines
[LISTING ONE]
/* stackdump.c -- a program to dump the stack */
#define SPARC 1
#define IBM 0
void fun1a();
void fun1b();
void fun2();
void stackdump();
main() /* call function fun1a or function fun1b */
{
char text[16];
strcpy(text,"main text");
fun1a();
}
void fun1a()
{
char text[16];
strcpy(text,"fun1a text");
fun2();
}
void fun1b()
{
char text[16];
strcpy(text,"fun1b text");
fun2();
}
void fun2()
{ int jj;
char text[16];
strcpy(text,"fun2 text");
#if SPARC
printf("main address=%x\n",main);
printf("fun1a address=%x\n",fun1a);
printf("fun1b address=%x\n",fun1b);
printf("fun2 address=%x\n\n",fun2);
#else if IBM
printf("main address=%x -> %x\n",main, *(unsigned long *)main);
printf("fun1a address=%x -> %x\n",fun1a, *(unsigned long *)fun1a);
printf("fun1b address=%x -> %x\n",fun1b, *(unsigned long *)fun1b);
printf("fun2 address=%x -> %x\n",fun2, *(unsigned long *)fun2);
#endif
stackdump(&jj-32); /* the 32 gives us the stack before variable jj */
}
void stackdump(start)
unsigned long start;
{
int i,j;
for (i=0;i<128;i++)
{
printf("%08x ", (long)start);
printf("%08x ", *(unsigned long *)(start));
for (j=0;j<4;j++,start++)
printf("%c", isprint( *(unsigned char *)(start)) ?
*(unsigned char *)(start) : ' ');
printf("\n");
}
}