Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Feb 2020 18:04:45 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r357632 - head/sys/riscv/riscv
Message-ID:  <202002061804.016I4jtJ089635@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002061804.016I4jtJ089635>