Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107655041
D28026.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D28026.diff
View Options
diff --git a/sys/arm64/arm64/db_trace.c b/sys/arm64/arm64/db_trace.c
--- a/sys/arm64/arm64/db_trace.c
+++ b/sys/arm64/arm64/db_trace.c
@@ -42,6 +42,13 @@
#include <machine/armreg.h>
#include <machine/debug_monitor.h>
#include <machine/stack.h>
+#include <machine/vmparam.h>
+
+#define FRAME_NORMAL 0
+#define FRAME_SYNC 1
+#define FRAME_IRQ 2
+#define FRAME_SERROR 3
+#define FRAME_UNHANDLED 4
void
db_md_list_watchpoints()
@@ -71,14 +78,10 @@
const char *name;
db_expr_t value;
db_expr_t offset;
+ int frame_type;
while (1) {
- uintptr_t pc = frame->pc;
-
- if (!unwind_frame(td, frame))
- break;
-
- sym = db_search_symbol(pc, DB_STGY_ANY, &offset);
+ sym = db_search_symbol(frame->pc, DB_STGY_ANY, &offset);
if (sym == C_DB_SYM_NULL) {
value = 0;
name = "(null)";
@@ -89,12 +92,61 @@
db_printsym(frame->pc, DB_STGY_PROC);
db_printf("\n");
- db_printf("\t pc = 0x%016lx lr = 0x%016lx\n", pc,
- frame->pc);
- db_printf("\t sp = 0x%016lx fp = 0x%016lx\n", frame->sp,
- frame->fp);
- /* TODO: Show some more registers */
- db_printf("\n");
+ if (strcmp(name, "handle_el0_sync") == 0 ||
+ strcmp(name, "handle_el1h_sync") == 0)
+ frame_type = FRAME_SYNC;
+ else if (strcmp(name, "handle_el0_irq") == 0 ||
+ strcmp(name, "handle_el1h_irq") == 0)
+ frame_type = FRAME_IRQ;
+ else if (strcmp(name, "handle_serror") == 0)
+ frame_type = FRAME_SERROR;
+ else if (strcmp(name, "handle_empty_exception") == 0)
+ frame_type = FRAME_UNHANDLED;
+ else
+ frame_type = FRAME_NORMAL;
+
+ if (frame_type != FRAME_NORMAL) {
+ struct trapframe *tf;
+
+ tf = (struct trapframe *)(uintptr_t)frame->fp - 1;
+ if (!kstack_contains(td, (vm_offset_t)tf,
+ sizeof(*tf))) {
+ db_printf("--- invalid trapframe %p\n", tf);
+ break;
+ }
+
+ switch (frame_type) {
+ case FRAME_SYNC:
+ db_printf("--- exception, esr %#x\n",
+ tf->tf_esr);
+ break;
+ case FRAME_IRQ:
+ db_printf("--- interrupt\n");
+ break;
+ case FRAME_SERROR:
+ db_printf("--- system error, esr %#x\n",
+ tf->tf_esr);
+ break;
+ case FRAME_UNHANDLED:
+ db_printf("--- unhandled exception, esr %#x\n",
+ tf->tf_esr);
+ break;
+ default:
+ __assert_unreachable();
+ break;
+ }
+
+ frame->fp = tf->tf_x[29];
+ frame->pc = tf->tf_elr;
+ if (!INKERNEL(frame->fp))
+ break;
+ } else {
+ if (strcmp(name, "fork_trampoline") == 0)
+ break;
+
+ if (!unwind_frame(td, frame))
+ break;
+ }
}
}
@@ -107,7 +159,6 @@
if (thr != curthread) {
ctx = kdb_thr_ctx(thr);
- frame.sp = (uintptr_t)ctx->pcb_sp;
frame.fp = (uintptr_t)ctx->pcb_x[29];
frame.pc = (uintptr_t)ctx->pcb_lr;
db_stack_trace_cmd(thr, &frame);
@@ -120,11 +171,7 @@
db_trace_self(void)
{
struct unwind_state frame;
- uintptr_t sp;
-
- __asm __volatile("mov %0, sp" : "=&r" (sp));
- frame.sp = sp;
frame.fp = (uintptr_t)__builtin_frame_address(0);
frame.pc = (uintptr_t)db_trace_self;
db_stack_trace_cmd(curthread, &frame);
diff --git a/sys/arm64/arm64/exception.S b/sys/arm64/arm64/exception.S
--- a/sys/arm64/arm64/exception.S
+++ b/sys/arm64/arm64/exception.S
@@ -38,8 +38,7 @@
mov x18, sp
sub sp, sp, #128
.endif
- sub sp, sp, #(TF_SIZE + 16)
- stp x29, lr, [sp, #(TF_SIZE)]
+ sub sp, sp, #(TF_SIZE)
stp x28, x29, [sp, #(TF_X + 28 * 8)]
stp x26, x27, [sp, #(TF_X + 26 * 8)]
stp x24, x25, [sp, #(TF_X + 24 * 8)]
@@ -132,7 +131,7 @@
ldr x29, [sp, #(TF_X + 29 * 8)]
.endif
.if \el == 0
- add sp, sp, #(TF_SIZE + 16)
+ add sp, sp, #(TF_SIZE)
.else
mov sp, x18
mrs x18, tpidr_el1
diff --git a/sys/arm64/arm64/stack_machdep.c b/sys/arm64/arm64/stack_machdep.c
--- a/sys/arm64/arm64/stack_machdep.c
+++ b/sys/arm64/arm64/stack_machdep.c
@@ -69,7 +69,6 @@
if (TD_IS_RUNNING(td))
return (EOPNOTSUPP);
- frame.sp = td->td_pcb->pcb_sp;
frame.fp = td->td_pcb->pcb_x[29];
frame.pc = td->td_pcb->pcb_lr;
@@ -81,11 +80,7 @@
stack_save(struct stack *st)
{
struct unwind_state frame;
- uintptr_t sp;
- __asm __volatile("mov %0, sp" : "=&r" (sp));
-
- frame.sp = sp;
frame.fp = (uintptr_t)__builtin_frame_address(0);
frame.pc = (uintptr_t)stack_save;
diff --git a/sys/arm64/arm64/unwind.c b/sys/arm64/arm64/unwind.c
--- a/sys/arm64/arm64/unwind.c
+++ b/sys/arm64/arm64/unwind.c
@@ -45,7 +45,6 @@
if (!kstack_contains(td, fp, sizeof(uintptr_t) * 2))
return (false);
- frame->sp = fp + sizeof(uintptr_t) * 2;
/* FP to previous frame (X29) */
frame->fp = ((uintptr_t *)fp)[0];
/* LR (X30) */
diff --git a/sys/arm64/include/csan.h b/sys/arm64/include/csan.h
--- a/sys/arm64/include/csan.h
+++ b/sys/arm64/include/csan.h
@@ -76,12 +76,8 @@
const char *symname;
#endif
struct unwind_state frame;
- uintptr_t sp;
int nsym;
- __asm __volatile("mov %0, sp" : "=&r" (sp));
-
- frame.sp = sp;
frame.fp = (uintptr_t)__builtin_frame_address(0);
frame.pc = (uintptr_t)kcsan_md_unwind;
nsym = 0;
diff --git a/sys/arm64/include/stack.h b/sys/arm64/include/stack.h
--- a/sys/arm64/include/stack.h
+++ b/sys/arm64/include/stack.h
@@ -34,7 +34,6 @@
struct unwind_state {
uintptr_t fp;
- uintptr_t sp;
uintptr_t pc;
};
diff --git a/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c b/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c
--- a/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c
+++ b/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c
@@ -70,7 +70,6 @@
{
struct unwind_state state;
int scp_offset;
- register_t sp;
int depth;
depth = 0;
@@ -81,10 +80,7 @@
aframes++;
- __asm __volatile("mov %0, sp" : "=&r" (sp));
-
state.fp = (uintptr_t)__builtin_frame_address(0);
- state.sp = sp;
state.pc = (uintptr_t)dtrace_getpcstack;
while (depth < pcstack_limit) {
@@ -179,7 +175,7 @@
{
proc_t *p = curproc;
struct trapframe *tf;
- uintptr_t pc, sp, fp;
+ uintptr_t pc, fp;
volatile uint16_t *flags =
(volatile uint16_t *)&cpu_core[curcpu].cpuc_dtrace_flags;
int n;
@@ -203,7 +199,6 @@
return;
pc = tf->tf_elr;
- sp = tf->tf_sp;
fp = tf->tf_x[29];
if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_ENTRY)) {
@@ -267,17 +262,13 @@
{
struct unwind_state state;
int scp_offset;
- register_t sp;
int depth;
bool done;
depth = 1;
done = false;
- __asm __volatile("mov %0, sp" : "=&r" (sp));
-
state.fp = (uintptr_t)__builtin_frame_address(0);
- state.sp = sp;
state.pc = (uintptr_t)dtrace_getstackdepth;
do {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 18, 5:58 AM (16 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15851088
Default Alt Text
D28026.diff (6 KB)
Attached To
Mode
D28026: arm64: Improve DDB backtrace support
Attached
Detach File
Event Timeline
Log In to Comment