diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2002-05-18 18:22:47 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2002-05-18 18:22:47 +0000 |
commit | b53874f6b4b19059defc84c141d0269b1aad1957 (patch) | |
tree | a199c5ceb349fc4755c6f4b62a079b060a17fca9 /sys | |
parent | 8f7044cbf127a7ac249e1b339722f078b855d609 (diff) |
Implement db_stack_dump - a function that will print a stack
trace with printf (to the console and into the msgbuf).
Diffstat (limited to 'sys')
-rw-r--r-- | sys/ddb/db_output.c | 22 | ||||
-rw-r--r-- | sys/ddb/db_output.h | 5 |
2 files changed, 25 insertions, 2 deletions
diff --git a/sys/ddb/db_output.c b/sys/ddb/db_output.c index bc55e0f9723..01e43954719 100644 --- a/sys/ddb/db_output.c +++ b/sys/ddb/db_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_output.c,v 1.18 2002/05/14 16:12:33 art Exp $ */ +/* $OpenBSD: db_output.c,v 1.19 2002/05/18 18:22:46 art Exp $ */ /* $NetBSD: db_output.c,v 1.13 1996/04/01 17:27:14 christos Exp $ */ /* @@ -240,3 +240,23 @@ db_format(char *buf, size_t bufsize, long val, int format, int alt, int width) return (buf); } + +void +db_stack_dump(void) +{ + static int intrace; + + if (intrace) { +db_panic = 1; +panic("foo"); + printf("Faulted in traceback, aborting...\n"); + return; + } + + intrace = 1; + printf("Starting stack trace...\n"); + db_stack_trace_print((db_expr_t)__builtin_frame_address(0), TRUE, + 256 /* low limit */, "", printf); + printf("End of stack trace.\n"); + intrace = 0; +} diff --git a/sys/ddb/db_output.h b/sys/ddb/db_output.h index e2dbc4c2bf4..dc9d9ca357c 100644 --- a/sys/ddb/db_output.h +++ b/sys/ddb/db_output.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db_output.h,v 1.11 2002/05/14 16:12:33 art Exp $ */ +/* $OpenBSD: db_output.h,v 1.12 2002/05/18 18:22:46 art Exp $ */ /* $NetBSD: db_output.h,v 1.9 1996/04/04 05:13:50 cgd Exp $ */ /* @@ -57,3 +57,6 @@ void db_end_line(int); #define DB_FORMAT_N 3 #define DB_FORMAT_BUF_SIZE 64 /* should be plenty for all formats */ char *db_format(char *, size_t, long, int, int, int); + +/* XXX - this is the wrong place, but we have no better. */ +void db_stack_dump(void); |