From nobody Mon Oct 03 16:56:44 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 4Mh6SF0cTMz4dgtw; Mon, 3 Oct 2022 16:56:45 +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 4Mh6SD6zpyz3SCY; Mon, 3 Oct 2022 16:56:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664816205; 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=sG2OrP2MvfsNl3+UD0UrN4qvWVrXCoo5Umhej0fTXBU=; b=jyW/89/msnVbu2x6DfQ/cFG8jgSqQf4+09q61MP+VWs+jKiN2AzRlZwI2iMJHQYI4TvTPi wdC0V5n/Bpiq25sokhqzel+1FBHfvTO1w5fAVhdZRbsyvUPo21PzeAThECZDA2mc0vzejX ISnNfkwePjOBAABTKkZLm2bFVEzwWvXjRqnCK+hZhOCWBYFWVZX+1ILTC8GcfcF2cNoSSp 5qtDew9h+RwePCNIj9wAFkQH9Lk4X9nRx5yFm61+p9ZaOdnMHtUnrrdQsgoYP0HaLX4T7V dyUe/pdvOgS5Jn3roqGRnEEu5BTXOuedkWCtITD9T5s16zXF7EznIwx68ttBkQ== 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 4Mh6SD60CczGs8; Mon, 3 Oct 2022 16:56:44 +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 293GuisH084981; Mon, 3 Oct 2022 16:56:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 293Gui4J084980; Mon, 3 Oct 2022 16:56:44 GMT (envelope-from git) Date: Mon, 3 Oct 2022 16:56:44 GMT Message-Id: <202210031656.293Gui4J084980@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: 754cb545b68b - main - ddb: de-duplicate decode_syscall() 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: 754cb545b68ba0a1643792763d000018ffe2afec Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664816205; 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=sG2OrP2MvfsNl3+UD0UrN4qvWVrXCoo5Umhej0fTXBU=; b=omXnk7WRL1WkQxN5tkVHCPDsueGs5kMHIgk6Tj0fKoLAes38cptAS8QoT3NNlHSflFiLnb ipUm4cDLYIRm9IFQTdM/Du2E4038qNJ5eMmNy03CkJAScqyocx+j1e6j4rA8KiBM0gabxD 90ZK/X+oIDo8KBmVyc86eLXa8lSWU+LtPY9PbP2BxINjGw6KpzbXobU9hWqV8Ip5pn2R2m S10Ij0GqQ9DEinuUn4FyZsfS4YDfvkKJX4mvAKoEhugza+v2HsnHUlHtC+CZ2Z5ehr+qds K8rE1J87e/48pzviDMQVIo/UVSsEguK7D2DFLZ3SOOIqfKrbY55F+Ri0Asrgsw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664816205; a=rsa-sha256; cv=none; b=GCyxPMCoghAU5GrIIBk2OgsBsNv5wXybPUBogavOh7Ej+RozCJGxpDQVlKeQo/amst3FXz KqHXexFBK4rzgvNgnQjqNqSgegnvisGmaIlmPIw5kQD9ULslwRR6tT3UtgXeCubimguDsV 7YqIJpVbTI+pmSZEwmLtWOauNaGzem1e5+6xh3G8nXbzyWrjDPOyLH2cjcUVeFlpWNJe+0 Vv0GuRqp0HeS3xuElb0Q8GZXaadhOnZ2DmYZhyINZSInnLYajtWldLR3ZMrNJD0Ft/jde9 V2hsD3uARQrrmHnRnusCz/ZA4p6TUFkqJaRMcUDYRUBx4AwnJM3nIKEMLSUsIg== 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=754cb545b68ba0a1643792763d000018ffe2afec commit 754cb545b68ba0a1643792763d000018ffe2afec Author: Mitchell Horne AuthorDate: 2022-10-02 22:46:00 +0000 Commit: Mitchell Horne CommitDate: 2022-10-03 16:49:54 +0000 ddb: de-duplicate decode_syscall() Only i386 and amd64 print the decoded syscall name in the backtrace. This de-duplication facilitates further changes and adoption by other platforms. Reviewed by: jrtc27, markj, jhb MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D36565 --- sys/amd64/amd64/db_trace.c | 25 +------------------------ sys/ddb/db_sym.c | 24 +++++++++++++++++++++++- sys/ddb/db_sym.h | 2 ++ sys/i386/i386/db_trace.c | 26 +------------------------- 4 files changed, 27 insertions(+), 50 deletions(-) diff --git a/sys/amd64/amd64/db_trace.c b/sys/amd64/amd64/db_trace.c index 90fcce5732d1..414202ef1008 100644 --- a/sys/amd64/amd64/db_trace.c +++ b/sys/amd64/amd64/db_trace.c @@ -34,7 +34,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -139,28 +138,6 @@ db_print_stack_entry(const char *name, db_addr_t callpc, void *frame) db_printf("\n"); } -static void -decode_syscall(int number, struct thread *td) -{ - struct proc *p; - c_db_sym_t sym; - db_expr_t diff; - sy_call_t *f; - const char *symname; - - db_printf(" (%d", 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); - } - } - db_printf(")"); -} - /* * Figure out the next frame up in the call stack. */ @@ -242,7 +219,7 @@ db_nextframe(struct amd64_frame **fp, db_addr_t *ip, struct thread *td) break; case SYSCALL: db_printf("--- syscall"); - decode_syscall(tf->tf_rax, td); + db_decode_syscall(tf->tf_rax, td); break; case INTERRUPT: db_printf("--- interrupt"); diff --git a/sys/ddb/db_sym.c b/sys/ddb/db_sym.c index 0c3a8963baae..3fdf80a76ae6 100644 --- a/sys/ddb/db_sym.c +++ b/sys/ddb/db_sym.c @@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include @@ -481,3 +481,25 @@ db_sym_numargs(c_db_sym_t sym, int *nargp, char **argnames) { return (X_db_sym_numargs(db_last_symtab, sym, nargp, argnames)); } + +void +db_decode_syscall(int number, struct thread *td) +{ + struct proc *p; + c_db_sym_t sym; + db_expr_t diff; + sy_call_t *f; + const char *symname; + + db_printf(" (%d", 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); + } + } + db_printf(")"); +} diff --git a/sys/ddb/db_sym.h b/sys/ddb/db_sym.h index 1ad35e2b0c85..7ad7fb71f970 100644 --- a/sys/ddb/db_sym.h +++ b/sys/ddb/db_sym.h @@ -105,4 +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); + #endif /* !_DDB_DB_SYM_H_ */ diff --git a/sys/i386/i386/db_trace.c b/sys/i386/i386/db_trace.c index 529b94b76cc4..aee90ee058de 100644 --- a/sys/i386/i386/db_trace.c +++ b/sys/i386/i386/db_trace.c @@ -32,7 +32,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -196,7 +195,6 @@ static void db_nextframe(struct i386_frame **, db_addr_t *, struct thread *); static int db_numargs(struct i386_frame *); static void db_print_stack_entry(const char *, int, char **, int *, db_addr_t, void *); -static void decode_syscall(int, struct thread *); /* * Figure out how many arguments were passed into the frame at "fp". @@ -262,28 +260,6 @@ db_print_stack_entry(name, narg, argnp, argp, callpc, frame) db_printf("\n"); } -static void -decode_syscall(int number, struct thread *td) -{ - struct proc *p; - c_db_sym_t sym; - db_expr_t diff; - sy_call_t *f; - const char *symname; - - db_printf(" (%d", 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); - } - } - db_printf(")"); -} - /* * Figure out the next frame up in the call stack. */ @@ -396,7 +372,7 @@ db_nextframe(struct i386_frame **fp, db_addr_t *ip, struct thread *td) break; case SYSCALL: db_printf("--- syscall"); - decode_syscall(tf->tf_eax, td); + db_decode_syscall(tf->tf_eax, td); break; case INTERRUPT: db_printf("--- interrupt");