ddb: New db_stack_trace_print_ra.
Takes an optional extra argument for the return address so that the stack parser has a chance to use instruction-dependent interpretation of the frame to find parent frames. Implemented only on Alpha for now, which needs it. Other architectures just ignore the extra argument. PR port-alpha/57716 XXX pullup-10 XXX pullup-9 XXX pullup-8
This commit is contained in:
parent
0d92cf4b8d
commit
fddc6b2f61
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: db_trace.c,v 1.32 2022/07/21 01:52:28 thorpej Exp $ */
|
||||
/* $NetBSD: db_trace.c,v 1.33 2023/11/21 14:35:01 riastradh Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
|
@ -35,7 +35,7 @@
|
|||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.32 2022/07/21 01:52:28 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.33 2023/11/21 14:35:01 riastradh Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -210,6 +210,17 @@ void
|
|||
db_stack_trace_print(db_expr_t addr, bool have_addr, db_expr_t count,
|
||||
const char *modif, void (*pr)(const char *, ...))
|
||||
{
|
||||
|
||||
db_stack_trace_print_ra(/*ra*/0, /*have_ra*/false, addr, have_addr,
|
||||
count, modif, pr);
|
||||
}
|
||||
|
||||
void
|
||||
db_stack_trace_print_ra(db_expr_t ra, bool have_ra,
|
||||
db_expr_t addr, bool have_addr,
|
||||
db_expr_t count,
|
||||
const char *modif, void (*pr)(const char *, ...))
|
||||
{
|
||||
db_addr_t callpc, frame, symval;
|
||||
struct prologue_info pi;
|
||||
db_expr_t diff;
|
||||
|
@ -261,6 +272,9 @@ db_stack_trace_print(db_expr_t addr, bool have_addr, db_expr_t count,
|
|||
addr = (db_expr_t)pcbp->pcb_hw.apcb_ksp;
|
||||
callpc = pcbp->pcb_context[7];
|
||||
(*pr)("at 0x%lx\n", addr);
|
||||
} else if (have_ra) {
|
||||
callpc = ra;
|
||||
(*pr)("at 0x%lx pc 0x%lx\n", addr, callpc);
|
||||
} else {
|
||||
(*pr)("alpha trace requires known PC =eject=\n");
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: db_machdep.h,v 1.19 2017/11/06 03:47:45 christos Exp $ */
|
||||
/* $NetBSD: db_machdep.h,v 1.20 2023/11/21 14:35:01 riastradh Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 Carnegie-Mellon University.
|
||||
|
@ -183,4 +183,11 @@ typedef long kgdb_reg_t;
|
|||
/* Too much? Must be large enough for register transfer. */
|
||||
#define KGDB_BUFLEN 1024
|
||||
|
||||
/*
|
||||
* Extra ddb options.
|
||||
*/
|
||||
#define __HAVE_DB_STACK_TRACE_PRINT_RA
|
||||
void db_stack_trace_print_ra(db_expr_t, bool, db_expr_t, bool,
|
||||
db_expr_t, const char *, void (*)(const char *, ...));
|
||||
|
||||
#endif /* _ALPHA_DB_MACHDEP_H_ */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: db_interface.h,v 1.43 2023/11/02 10:31:55 martin Exp $ */
|
||||
/* $NetBSD: db_interface.h,v 1.44 2023/11/21 14:35:01 riastradh Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 2023 The NetBSD Foundation, Inc.
|
||||
|
@ -89,11 +89,19 @@ void db_show_condvar(db_expr_t, bool, db_expr_t, const char *);
|
|||
/* kern/sys_select.c */
|
||||
void db_show_selinfo(db_expr_t, bool, db_expr_t, const char *);
|
||||
|
||||
#ifndef __HAVE_DB_STACK_TRACE_PRINT_RA
|
||||
#define db_stack_trace_print_ra(ra, have_ra, addr, have_addr, c, m, pr) \
|
||||
((void)(ra), (void)(have_ra), \
|
||||
db_stack_trace_print(addr, have_addr, c, m, pr))
|
||||
#endif
|
||||
|
||||
/* The db_stacktrace_print macro may be overridden by an MD macro */
|
||||
#ifndef db_stacktrace_print
|
||||
#define db_stacktrace_print(prfunc) \
|
||||
db_stack_trace_print((db_expr_t)(intptr_t)__builtin_frame_address(0), \
|
||||
true, 65535, "", prfunc)
|
||||
db_stack_trace_print_ra( \
|
||||
(db_expr_t)(intptr_t)__builtin_return_address(0), true, \
|
||||
(db_expr_t)(intptr_t)__builtin_frame_address(0), true, \
|
||||
65535, "", prfunc)
|
||||
#endif /* !db_stacktrace_print */
|
||||
|
||||
#define db_stacktrace() db_stacktrace_print(printf);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: db_panic.c,v 1.11 2021/10/06 12:18:20 uwe Exp $ */
|
||||
/* $NetBSD: db_panic.c,v 1.12 2023/11/21 14:35:01 riastradh Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000, 2002, 2006, 2007, 2009, 2013 The NetBSD Foundation, Inc.
|
||||
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_panic.c,v 1.11 2021/10/06 12:18:20 uwe Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_panic.c,v 1.12 2023/11/21 14:35:01 riastradh Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -52,7 +52,9 @@ db_panic(void)
|
|||
intrace = 1;
|
||||
printf("cpu%u: Begin traceback...\n",
|
||||
cpu_index(curcpu()));
|
||||
db_stack_trace_print(
|
||||
db_stack_trace_print_ra(
|
||||
(db_expr_t)(intptr_t)__builtin_return_address(0),
|
||||
true,
|
||||
(db_expr_t)(intptr_t)__builtin_frame_address(0),
|
||||
true, db_panicstackframes, "", printf);
|
||||
printf("cpu%u: End traceback...\n",
|
||||
|
|
Loading…
Reference in New Issue