Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 May 2020 20:58:28 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r360926 - stable/12/sys/riscv/riscv
Message-ID:  <202005112058.04BKwSWk022705@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Mon May 11 20:58:27 2020
New Revision: 360926
URL: https://svnweb.freebsd.org/changeset/base/360926

Log:
  MFC 357632: 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.

Modified:
  stable/12/sys/riscv/riscv/db_trace.c
  stable/12/sys/riscv/riscv/machdep.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/riscv/riscv/db_trace.c
==============================================================================
--- stable/12/sys/riscv/riscv/db_trace.c	Mon May 11 20:55:04 2020	(r360925)
+++ stable/12/sys/riscv/riscv/db_trace.c	Mon May 11 20:58:27 2020	(r360926)
@@ -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: stable/12/sys/riscv/riscv/machdep.c
==============================================================================
--- stable/12/sys/riscv/riscv/machdep.c	Mon May 11 20:55:04 2020	(r360925)
+++ stable/12/sys/riscv/riscv/machdep.c	Mon May 11 20:58:27 2020	(r360926)
@@ -568,7 +568,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?202005112058.04BKwSWk022705>