From nobody Sun Nov 06 14:55:41 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 4N4y8t0wnRz4hMjp; Sun, 6 Nov 2022 14:55:42 +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 4N4y8s6spQz3Vp5; Sun, 6 Nov 2022 14:55:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667746542; 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=DfFjibHbUoUW70ZjYRmH6RpZTeWRefvwXFyNPVz8TrU=; b=gmT55o/U04OZs2Voolbg6a0LQhdkdy6jBkExq849ef+GXiZqtCRSEQwZo9IInP2Zuclm8h sAAYetjmUIELMhqfautLICUs3EBgVRy/fhTwQUqZVe2q7deqKSWlV0/gBl5wG1tKQfAGrz Mf6ApiwWj8L5NCSEYH2eo0AkGSnPwLZuyaRyk9HbOF6VPBBIbHc4k343La6z6WkysUYrOJ hdZGTQIqzBisDSPBjSwnUXi877YyIVrJRy7mfa3Adrn6ocJmgStRxJOZPW6M7XxlhFwmb6 m7s/sp/GYTwfRLrBQ6QFSqG/fsgoPUmoVDEDZS/NLl5nA7S5c+0kABXNF3Q5fQ== 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 4N4y8s5ybBzPsK; Sun, 6 Nov 2022 14:55:41 +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 2A6EtfFq025708; Sun, 6 Nov 2022 14:55:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2A6EtfJq025707; Sun, 6 Nov 2022 14:55:41 GMT (envelope-from git) Date: Sun, 6 Nov 2022 14:55:41 GMT Message-Id: <202211061455.2A6EtfJq025707@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 3e00f4ab107d - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 3e00f4ab107d68d5f7782c8bdeeead41cb06b38b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667746542; 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=DfFjibHbUoUW70ZjYRmH6RpZTeWRefvwXFyNPVz8TrU=; b=VGGAEOHv3B54AH6mfdD+FXBKbsqkDLzG3g8osbWtOb2vsXcniM4d0Qp1QW0Q4O/wn6HEC5 URMKWfJtcGkJKKp/dsF1fGbSrxyPowNPhaLpC5ndUh8E4lS4uKOTJEHvRy5KYXEXZ90caw bBr2+Y4voxfNaKehNaDSb1aD06gvZ1KCjUsmiWOH/uBuYF6GgVBICORmbLrCTyRAzin54x pPLz9SV8ReWX8hSNk89UsY7Xi+oh2UhiaHez3ij3UVlSDJ8UVus+n8QWzVf1Hxv8239Zmt D21T+gAY3wfRc8ViSW589//dRYkQn0sXh0poyJinxOetKEKjw6P8qoRKuD040A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1667746542; a=rsa-sha256; cv=none; b=wsYUs+d0aO+THQ6cpeaKsHRJ3vMTID2nBY1oPAFGSBQFLeJwvQx8rLDH1S5W5yMWXAHGkj +Jn0qZKW93yWcR9gxV/0q/hXFwEepQDFYioc8lNEGSLI3Aoqpz7NGjaOvrMRh4px2TKSEm abirA1m0LFm5jnV/3NSHIKq0VPeoc6NjLFGw1cPmCoMNgPFmYAtnK1g9vIesoC3eW4ysT7 Sk1w1IyhTpHtUesV+cBUCw+VBYvwS8FYUnSl9P8Q9Grw/XbMNcPsuDvIJEEGebResjY1z2 aq/5ISS9yvC0DO5CNegT+GwYNicwKC8EG0VBayBCHPGYeW6ksT1eSHtpP+wO9A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=3e00f4ab107d68d5f7782c8bdeeead41cb06b38b commit 3e00f4ab107d68d5f7782c8bdeeead41cb06b38b Author: Mitchell Horne AuthorDate: 2022-10-28 21:20:05 +0000 Commit: Mitchell Horne 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",