1433d6423SLionel Sambuc /* 2433d6423SLionel Sambuc stacktrace.c 3433d6423SLionel Sambuc 4433d6423SLionel Sambuc Created: Jan 19, 1993 by Philip Homburg 5433d6423SLionel Sambuc 6433d6423SLionel Sambuc Copyright 1995 Philip Homburg 7433d6423SLionel Sambuc */ 8433d6423SLionel Sambuc 9433d6423SLionel Sambuc #include <stdio.h> 10433d6423SLionel Sambuc #include <string.h> 11*685aa793SDavid van Moolenbroek #include <minix/sysutil.h> 12433d6423SLionel Sambuc 13433d6423SLionel Sambuc typedef unsigned int reg_t; 14433d6423SLionel Sambuc 15433d6423SLionel Sambuc extern reg_t get_bp(void); 16433d6423SLionel Sambuc util_stacktrace(void)17433d6423SLionel Sambucvoid util_stacktrace(void) 18433d6423SLionel Sambuc { 19433d6423SLionel Sambuc #if USE_SYSDEBUG 20433d6423SLionel Sambuc reg_t bp, pc, hbp; 21433d6423SLionel Sambuc 22433d6423SLionel Sambuc bp= get_bp(); 23433d6423SLionel Sambuc while(bp) 24433d6423SLionel Sambuc { 25433d6423SLionel Sambuc pc= ((reg_t *)bp)[1]; 26433d6423SLionel Sambuc hbp= ((reg_t *)bp)[0]; 27433d6423SLionel Sambuc printf("0x%lx ", (unsigned long) pc); 28433d6423SLionel Sambuc if (hbp != 0 && hbp <= bp) 29433d6423SLionel Sambuc { 30433d6423SLionel Sambuc printf("0x%lx ", (unsigned long) -1); 31433d6423SLionel Sambuc break; 32433d6423SLionel Sambuc } 33433d6423SLionel Sambuc bp= hbp; 34433d6423SLionel Sambuc } 35433d6423SLionel Sambuc printf("\n"); 36433d6423SLionel Sambuc #endif /* USE_SYSDEBUG */ 37433d6423SLionel Sambuc } 38433d6423SLionel Sambuc 39