Author: jhb
Date: Thu Feb  6 18:04:45 2020
New Revision: 357632
URL: https://svnweb.freebsd.org/changeset/base/357632

Log:
  Use the context created in makectx() for stack traces.
  
  Always use the kdb_thr_ctx() for db_trace_thread() as on other
  architectures.  Initialize pcb_ra to be the sepc from the saved
  trapframe rather than the saved ra to avoid skipping a frame.
  
  Reviewed by:  mhorne, br
  MFC after:    1 week
  Sponsored by: DARPA
  Differential Revision:        https://reviews.freebsd.org/D23513

Modified:
  head/sys/riscv/riscv/db_trace.c
  head/sys/riscv/riscv/machdep.c

Modified: head/sys/riscv/riscv/db_trace.c
==============================================================================
--- head/sys/riscv/riscv/db_trace.c     Thu Feb  6 18:04:15 2020        
(r357631)
+++ head/sys/riscv/riscv/db_trace.c     Thu Feb  6 18:04:45 2020        
(r357632)
@@ -130,15 +130,12 @@ db_trace_thread(struct thread *thr, int count)
        struct unwind_state frame;
        struct pcb *ctx;
 
-       if (thr != curthread) {
-               ctx = kdb_thr_ctx(thr);
+       ctx = kdb_thr_ctx(thr);
 
-               frame.sp = (uint64_t)ctx->pcb_sp;
-               frame.fp = (uint64_t)ctx->pcb_s[0];
-               frame.pc = (uint64_t)ctx->pcb_ra;
-               db_stack_trace_cmd(&frame);
-       } else
-               db_trace_self();
+       frame.sp = (uint64_t)ctx->pcb_sp;
+       frame.fp = (uint64_t)ctx->pcb_s[0];
+       frame.pc = (uint64_t)ctx->pcb_ra;
+       db_stack_trace_cmd(&frame);
        return (0);
 }
 

Modified: head/sys/riscv/riscv/machdep.c
==============================================================================
--- head/sys/riscv/riscv/machdep.c      Thu Feb  6 18:04:15 2020        
(r357631)
+++ head/sys/riscv/riscv/machdep.c      Thu Feb  6 18:04:45 2020        
(r357632)
@@ -571,7 +571,7 @@ makectx(struct trapframe *tf, struct pcb *pcb)
 
        memcpy(pcb->pcb_s, tf->tf_s, sizeof(tf->tf_s));
 
-       pcb->pcb_ra = tf->tf_ra;
+       pcb->pcb_ra = tf->tf_sepc;
        pcb->pcb_sp = tf->tf_sp;
        pcb->pcb_gp = tf->tf_gp;
        pcb->pcb_tp = tf->tf_tp;
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to