2008-11-19 13:26:10 +01:00
|
|
|
/*
|
|
|
|
stacktrace.c
|
|
|
|
|
|
|
|
Created: Jan 19, 1993 by Philip Homburg
|
|
|
|
|
|
|
|
Copyright 1995 Philip Homburg
|
|
|
|
*/
|
|
|
|
|
2009-08-17 20:48:57 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2008-11-19 13:26:10 +01:00
|
|
|
typedef unsigned int reg_t;
|
|
|
|
|
2012-08-07 13:10:05 +02:00
|
|
|
extern reg_t get_bp(void);
|
2008-11-19 13:26:10 +01:00
|
|
|
|
2012-08-07 13:10:05 +02:00
|
|
|
void util_stacktrace(void)
|
2008-11-19 13:26:10 +01:00
|
|
|
{
|
2011-09-16 14:57:49 +02:00
|
|
|
#if USE_SYSDEBUG
|
2012-08-07 13:10:05 +02:00
|
|
|
reg_t bp, pc, hbp;
|
|
|
|
|
|
|
|
bp= get_bp();
|
|
|
|
while(bp)
|
|
|
|
{
|
|
|
|
pc= ((reg_t *)bp)[1];
|
|
|
|
hbp= ((reg_t *)bp)[0];
|
|
|
|
printf("0x%lx ", (unsigned long) pc);
|
|
|
|
if (hbp != 0 && hbp <= bp)
|
|
|
|
{
|
|
|
|
printf("0x%lx ", (unsigned long) -1);
|
|
|
|
break;
|
2008-11-19 13:26:10 +01:00
|
|
|
}
|
2012-08-07 13:10:05 +02:00
|
|
|
bp= hbp;
|
2008-11-19 13:26:10 +01:00
|
|
|
}
|
|
|
|
printf("\n");
|
2011-09-16 14:57:49 +02:00
|
|
|
#endif /* USE_SYSDEBUG */
|
2008-11-19 13:26:10 +01:00
|
|
|
}
|
|
|
|
|