summaryrefslogtreecommitdiff
path: root/minix/lib/libsys/stacktrace.c
blob: d7e87eb9c7140027525ce5ae728aa8199d22adac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
stacktrace.c

Created:	Jan 19, 1993 by Philip Homburg

Copyright 1995 Philip Homburg
*/

#include <stdio.h>
#include <string.h>
#include <minix/sysutil.h>

typedef unsigned int reg_t;

extern reg_t get_bp(void);

void util_stacktrace(void)
{
#if USE_SYSDEBUG
	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;
		}
		bp= hbp;
	}
	printf("\n");
#endif /* USE_SYSDEBUG */
}