git: 4ad3f9dbe8cf - stable/14 - riscv: Don't print zero offsets for register addresses

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 11 Oct 2023 15:44:28 UTC
The branch stable/14 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=4ad3f9dbe8cf6c6c9bb3dafad8d076814c3a440c

commit 4ad3f9dbe8cf6c6c9bb3dafad8d076814c3a440c
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-09-05 16:12:27 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-10-11 15:10:32 +0000

    riscv: Don't print zero offsets for register addresses
    
    This matches the behavior of db_printsym.
    
    Reviewed by:    mhorne, markj
    Sponsored by:   DARPA
    Differential Revision:  https://reviews.freebsd.org/D41702
    
    (cherry picked from commit ba675bb94870fcb1a07018920433e9468003364c)
---
 sys/riscv/riscv/trap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sys/riscv/riscv/trap.c b/sys/riscv/riscv/trap.c
index e681058800f6..123163ecfc10 100644
--- a/sys/riscv/riscv/trap.c
+++ b/sys/riscv/riscv/trap.c
@@ -149,7 +149,10 @@ print_with_symbol(const char *name, uint64_t value)
 		sym = db_search_symbol(value, DB_STGY_ANY, &offset);
 		if (sym != C_DB_SYM_NULL) {
 			db_symbol_values(sym, &sym_name, &sym_value);
-			printf(" (%s + 0x%lx)", sym_name, offset);
+			if (offset != 0)
+				printf(" (%s + 0x%lx)", sym_name, offset);
+			else
+				printf(" (%s)", sym_name);
 		}
 	}
 #endif