From nobody Sun Nov 06 14:55:37 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 4N4y8n3Z0Jz4hMp4; Sun, 6 Nov 2022 14:55:37 +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 4N4y8n32BTz3VZ1; Sun, 6 Nov 2022 14:55:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667746537; 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=kHRqrlynWT7SD6/r8ZP0Q98fApsfrAviBOJs0DALxBM=; b=iz9YRMRnBKLFjJQrcwNGphjsg9LlF4sP9dcDe6G5fjql7/wOapZF1PBwqzaYCkFVxeDHXe 7lIgBDZqWMukcImgT3LKEfQ5wrVu5P/nVeCXwvtuSZ4FbHzVQH/sDQP7/j6Su2zzlUvE4p cXgbQMOPK/VlpW+1wQluFcTfURuuwGE3fXILrpyyMM5B68Gu9q+cht5/B5XmWqs84V7ZdC tHAHh1L0ryfFNSvbUAhqsKyEJJCKZEf5cePRI+81fTmtn+kKaGDK+jQsdDSezSgbZZIzcB DllF8rpMLDBSntZG7Pj9Vgyf2FItm8YY/J0fzHSMJBwuvrGJJIvV8+egwx1L0Q== 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 4N4y8n25qJzPqJ; Sun, 6 Nov 2022 14:55:37 +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 2A6EtbrQ025603; Sun, 6 Nov 2022 14:55:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2A6Etbdp025602; Sun, 6 Nov 2022 14:55:37 GMT (envelope-from git) Date: Sun, 6 Nov 2022 14:55:37 GMT Message-Id: <202211061455.2A6Etbdp025602@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: a4dd26ead25d - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: a4dd26ead25db6d5aa07938ccb83413172c9cf2b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667746537; 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=kHRqrlynWT7SD6/r8ZP0Q98fApsfrAviBOJs0DALxBM=; b=lc4WLaxbYB5VPG2d1Vzvzd80wyVEmaxG8nyqtd1xvswuG+NwcjzWvThUHPfP02O1kabur1 gw8yr7soSK7BwPDFEbf3Lmz6NCgSH7X6LaFEZZWqhW7iUppWdUNaOFgs6s4OfOn4hbunpk wO0nP2VuGvJTmc7t84Jtw0UxgpV7so1lQKTaLDqNdhuYqmybsPp00HMCUoEXQPdr5eGnrm sRois3AaM9RZXlxQczkoVyIOXLC7jG3zVCuPYHvwZcM4WeeqxZNFeioW11/KIPn/sotRiE B7Z8WcVDW6nLRoONNIAxXdan0cIj3Fofk7ussn/5S9eyzuMnU0L6QXdpJvEpLA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1667746537; a=rsa-sha256; cv=none; b=JK3wO5tYD6K76BiEyn+X/quxX2t38uHR84WIHlaYr0IosVQKi3mgDBXa9F+JS770XA0XDm TbC0WBJHJ/B9hBPlVZ0fJeV+coHXt81dzgV4HffzpUFVq7i5V4qG6uo7ozKERAaAz6/ep5 FTiHTsP0blIfMqAtnZiVOr2mvJOQfQBe5ato98IckqRn8gJn+KNSIrurYL4Vrc2SrFarIB MlkrWFuKT1qTG0DPs2W1COHVsurGXuhW4enkV2TKmu+3O6uBNbu/nMNLZnVX4YbGj07YcV L8cTdL7DAi/7lJNmIR0y0cEJVg0TDapKDQ4SJyAy8eJkY3/XFXXytvI3qisgKg== 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=a4dd26ead25db6d5aa07938ccb83413172c9cf2b commit a4dd26ead25db6d5aa07938ccb83413172c9cf2b Author: Mitchell Horne AuthorDate: 2022-10-02 22:46:00 +0000 Commit: Mitchell Horne CommitDate: 2022-11-06 14:54:46 +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 (cherry picked from commit 754cb545b68ba0a1643792763d000018ffe2afec) (cherry picked from commit 6f8a182b15c4c14cfb9462b806a928ddaf47c87e) (cherry picked from commit 89e5ef8917af900558c2d275f5d5c4c703520ead) (cherry picked from commit 85b715baae22ca12f2d24e1b2980f3d5b32937b8) --- sys/amd64/amd64/db_trace.c | 26 +------------------------- sys/ddb/db_sym.c | 26 +++++++++++++++++++++++++- sys/ddb/db_sym.h | 2 ++ sys/i386/i386/db_trace.c | 26 +------------------------- 4 files changed, 29 insertions(+), 51 deletions(-) diff --git a/sys/amd64/amd64/db_trace.c b/sys/amd64/amd64/db_trace.c index 037cae200e2e..1eae53f3d06d 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 @@ -126,7 +125,6 @@ db_frame(struct db_variable *vp, db_expr_t *valuep, int op) static void db_nextframe(struct amd64_frame **, db_addr_t *, struct thread *); static void db_print_stack_entry(const char *, db_addr_t, void *); -static void decode_syscall(int, struct thread *); static void db_print_stack_entry(const char *name, db_addr_t callpc, void *frame) @@ -139,28 +137,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 +218,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..43a0b5447479 100644 --- a/sys/ddb/db_sym.c +++ b/sys/ddb/db_sym.c @@ -36,9 +36,11 @@ __FBSDID("$FreeBSD$"); #include "opt_kstack_pages.h" #include +#include #include +#include #include -#include +#include #include @@ -481,3 +483,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");