From nobody Fri Oct 28 21:33:53 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MzbQT592Wz4fwms; Fri, 28 Oct 2022 21:33:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MzbQT4gt2z3HX7; Fri, 28 Oct 2022 21:33:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666992833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iuYaP9CO/d/Jbj0yHD4hJF08twn8YIONsMR9qN1fTcQ=; b=wrnWQ4qXNRtMEg/k9UjIy1z18h9O+q2Pf+IZF8ULDuOOXpblrdWZcgvd6EUw+7zoiO+5Sv wbmLONMhNNs7isSp4omY9I9A0vVcQE5EJuJNS5JK0yoUUCzcU2M5/tI8fz+SCPeRnzBdLD oHfXrfV1wl53nY2vsAkZledBNSgBcv0KmF2B7XB28fX09FjNXE83HZggJhpzt/9+ScLEV7 DcRqloMxedd0ByUVUDhpQi/jDFHTlCDmDp+dmtGqShcfpYKpbVR3k/EMSkl1JZ88YzMhpF O9zBVWagubMo+ve+G+0WLArVp1BDnpsoegKr9Ifqr95P4ZWgQvmMPJhz5T/uiA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MzbQT3Q2Lzslg; Fri, 28 Oct 2022 21:33:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29SLXrwc064193; Fri, 28 Oct 2022 21:33:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29SLXr0x064192; Fri, 28 Oct 2022 21:33:53 GMT (envelope-from git) Date: Fri, 28 Oct 2022 21:33:53 GMT Message-Id: <202210282133.29SLXr0x064192@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: aba921bd9e18 - main - ddb: print the actual syscall name List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: aba921bd9e1869dae9ae4cc6e0c048f997401034 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666992833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iuYaP9CO/d/Jbj0yHD4hJF08twn8YIONsMR9qN1fTcQ=; b=wUamlCu0PU8PZz9x5K2Uy0DTmBO+SNZA8RXXfFWVG7+g4pWjKKLJYV0vwKg3zQe1A5CC2e pJZq6z6RxiDtffrZZa9aX2c1apmcwvXdV2s7RPButfOYJqxzSuDEKTVkrqgvy7S80aGAsi G2HrqiSYXW5Iw7wCu0ICJY0zF1Dx/ihZUyP2CdLHRf+Y+FOgapDuyN4sioqr5Tj6xpigFp /N69nNrDFSCrhkZUVxXWF6ZNdSzh/F+15tzMjOYcQ82vEM7rUCn2wzncXaLEuM8X7M+sGO 4cVYIGDWbmroiITSGTFYeMst7VllWSExvX4ZUDWj9cIv6i/FS/753B+Rm1bzhw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666992833; a=rsa-sha256; cv=none; b=i3S3uu5m0bDanGTR9Og4tuOzs38fa9cwMKRPbrgnU1SSniv2N7w1Tc6i7omA9q7w180iTC bek6MI/URGkhRc1TPD0+3JwV6DXFZm8Bh2kVVZm6Frf0XZ09FuSgVTOPPAByPyhHPJQ9NT 5y1VdOjGgZ9sGud1vrrj4wGTtzm8/f4eDtAggYIGfOGrI0pRWWamHBaJQtRL1Ca2QCFNg9 KaNpgL0vJafVqNLJ0o+6Wrl2JnnsYC3MMkjZhMyv4Q7YHOyonvFHZtMUxENhG5rC5yIAPP fDMcxXX7lje17sM+HEmN1DcrBcb8Iz9u2rvdqepuukrBgJuMARIzmNyC7T3wXg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=aba921bd9e1869dae9ae4cc6e0c048f997401034 commit aba921bd9e1869dae9ae4cc6e0c048f997401034 Author: Mitchell Horne AuthorDate: 2022-10-28 21:20:05 +0000 Commit: Mitchell Horne CommitDate: 2022-10-28 21:21:08 +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 --- 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 217988ced7ac..c38f4f6a4860 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",