git: 3e00f4ab107d - stable/13 - ddb: print the actual syscall name
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 06 Nov 2022 14:55:41 UTC
The branch stable/13 has been updated by mhorne:
URL: https://cgit.FreeBSD.org/src/commit/?id=3e00f4ab107d68d5f7782c8bdeeead41cb06b38b
commit 3e00f4ab107d68d5f7782c8bdeeead41cb06b38b
Author: Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2022-10-28 21:20:05 +0000
Commit: Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2022-11-06 14:54:46 +0000
ddb: print the actual syscall name
Some architectures will pretty-print a system call trap in the
backtrace. Rather than printing the symbol, use the syscallname()
function to pull the string from the sv_syscallnames array corresponding
to the process. This simplifies the function somewhat.
Mostly, this will result in dropping the "sys" prefix, e.g. "sys_exit"
will now be printed simply as "exit".
Make two minor tweaks to the function signature: use a u_int for the
syscall number since this is a more correct type (see the 'code' member
of struct syscall_args), and make the thread pointer the first argument.
The latter is more natural and conventional.
Suggested by: jrtc27
Reviewed by: jrtc27, markj, jhb
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37200
(cherry picked from commit aba921bd9e1869dae9ae4cc6e0c048f997401034)
---
sys/amd64/amd64/db_trace.c | 2 +-
sys/ddb/db_sym.c | 18 +++++-------------
sys/ddb/db_sym.h | 2 +-
sys/i386/i386/db_trace.c | 2 +-
sys/riscv/riscv/db_trace.c | 2 +-
5 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/sys/amd64/amd64/db_trace.c b/sys/amd64/amd64/db_trace.c
index 1eae53f3d06d..ebda172994be 100644
--- a/sys/amd64/amd64/db_trace.c
+++ b/sys/amd64/amd64/db_trace.c
@@ -218,7 +218,7 @@ db_nextframe(struct amd64_frame **fp, db_addr_t *ip, struct thread *td)
break;
case SYSCALL:
db_printf("--- syscall");
- db_decode_syscall(tf->tf_rax, td);
+ db_decode_syscall(td, tf->tf_rax);
break;
case INTERRUPT:
db_printf("--- interrupt");
diff --git a/sys/ddb/db_sym.c b/sys/ddb/db_sym.c
index 43a0b5447479..19aba9f7abb2 100644
--- a/sys/ddb/db_sym.c
+++ b/sys/ddb/db_sym.c
@@ -485,23 +485,15 @@ db_sym_numargs(c_db_sym_t sym, int *nargp, char **argnames)
}
void
-db_decode_syscall(int number, struct thread *td)
+db_decode_syscall(struct thread *td, u_int number)
{
struct proc *p;
- c_db_sym_t sym;
- db_expr_t diff;
- sy_call_t *f;
- const char *symname;
- db_printf(" (%d", number);
+ db_printf(" (%u", number);
p = (td != NULL) ? td->td_proc : NULL;
- if (p != NULL && 0 <= number && number < p->p_sysent->sv_size) {
- f = p->p_sysent->sv_table[number].sy_call;
- sym = db_search_symbol((db_addr_t)f, DB_STGY_ANY, &diff);
- if (sym != DB_SYM_NULL && diff == 0) {
- db_symbol_values(sym, &symname, NULL);
- db_printf(", %s, %s", p->p_sysent->sv_name, symname);
- }
+ if (p != NULL) {
+ db_printf(", %s, %s", p->p_sysent->sv_name,
+ syscallname(p, number));
}
db_printf(")");
}
diff --git a/sys/ddb/db_sym.h b/sys/ddb/db_sym.h
index 7ad7fb71f970..76dd0a5837de 100644
--- a/sys/ddb/db_sym.h
+++ b/sys/ddb/db_sym.h
@@ -105,6 +105,6 @@ bool X_db_sym_numargs(db_symtab_t *, c_db_sym_t, int *, char **);
void X_db_symbol_values(db_symtab_t *symtab, c_db_sym_t sym,
const char **namep, db_expr_t *valuep);
-void db_decode_syscall(int number, struct thread *td);
+void db_decode_syscall(struct thread *td, u_int number);
#endif /* !_DDB_DB_SYM_H_ */
diff --git a/sys/i386/i386/db_trace.c b/sys/i386/i386/db_trace.c
index aee90ee058de..47057906fa58 100644
--- a/sys/i386/i386/db_trace.c
+++ b/sys/i386/i386/db_trace.c
@@ -372,7 +372,7 @@ db_nextframe(struct i386_frame **fp, db_addr_t *ip, struct thread *td)
break;
case SYSCALL:
db_printf("--- syscall");
- db_decode_syscall(tf->tf_eax, td);
+ db_decode_syscall(td, tf->tf_eax);
break;
case INTERRUPT:
db_printf("--- interrupt");
diff --git a/sys/riscv/riscv/db_trace.c b/sys/riscv/riscv/db_trace.c
index ef8698917021..295d8631ab2e 100644
--- a/sys/riscv/riscv/db_trace.c
+++ b/sys/riscv/riscv/db_trace.c
@@ -97,7 +97,7 @@ db_stack_trace_cmd(struct thread *td, struct unwind_state *frame)
tf->tf_scause & SCAUSE_CODE);
} else if (tf->tf_scause == SCAUSE_ECALL_USER) {
db_printf("--- syscall");
- db_decode_syscall(td->td_sa.code, td);
+ db_decode_syscall(td, td->td_sa.code);
db_printf("\n");
} else {
db_printf("--- exception %ld, tval = %#lx\n",