From patchwork Wed Dec 7 09:00:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 61649 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9F1FC3BF90F1 for ; Wed, 7 Dec 2022 09:00:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9F1FC3BF90F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670403648; bh=9d6YYKMrAT949OtRZJCzDbA5NcQwHjl73KRus+wQEjs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=dl3HQSW83F8SFENc3XxizaOmZ5dQ5N40Z00ZUseywJelCXqWf0Mpwo7xfKmJIN4E3 9y2ob2pxF8P44UhJZ0AKkGQgt+hi5SZuSJOBtHjXHqr7EX4QUbppRV6+FOUBKlsSwa oFJIuwIp3ieDl65rr5zyZoXzjNycZgCo35ZPOHSc= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id C31D7395B417 for ; Wed, 7 Dec 2022 09:00:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C31D7395B417 Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id ECC6821CA2 for ; Wed, 7 Dec 2022 09:00:20 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id D45EF134CD for ; Wed, 7 Dec 2022 09:00:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id e2vRMiRWkGNmXQAAGKfGzw (envelope-from ) for ; Wed, 07 Dec 2022 09:00:20 +0000 To: gdb-patches@sourceware.org Subject: [RFC] [gdb/cli] Add maintenance ignore-probes Date: Wed, 7 Dec 2022 10:00:20 +0100 Message-Id: <20221207090020.15890-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" There's a command "disable probes", but SystemTap probes cannot be disabled. Add a command "maintenance ignore-probes" that ignores probes during get_probes, such that we can easily pretend to use a glibc without say, the longjmp probe: ... (gdb) maint ignore-probes libc longjmp$ (gdb) start ^M Temporary breakpoint 1 at 0x4005bb: file longjmp.c, line 46. Starting program: outputs/gdb.base/longjmp/longjmp ^M Ignoring SystemTap probe libc longjmp in /lib64/libc.so.6.^M Ignoring SystemTap probe libc longjmp in /lib64/libc.so.6.^M Ignoring SystemTap probe libc longjmp in /lib64/libc.so.6.^M ^M Breakpoint 1, main () at longjmp.c:46^M 46 volatile int i = 0;^M (gdb) ... Note that as with "disable probes", running "maint ignore-probes" without arguments ignores all probes. PR cli/27159 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27159 --- gdb/probe.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ gdb/probe.h | 5 +++++ gdb/stap-probe.c | 7 +++++++ 3 files changed, 61 insertions(+) base-commit: 58c49b3efef1833762ba4725937f8625058607f4 diff --git a/gdb/probe.c b/gdb/probe.c index ec8845219fa..631f35ecd1f 100644 --- a/gdb/probe.c +++ b/gdb/probe.c @@ -680,6 +680,45 @@ disable_probes_command (const char *arg, int from_tty) } } +static bool ignore_probes_p = false; +static gdb::optional ignore_obj_pat; +static gdb::optional ignore_prov_pat; +static gdb::optional ignore_probe_pat; + +/* See comments in probe.h. */ + +bool ignore_probe (const char *provider, const char *name, + const char *objfile_name) +{ + return (ignore_probes_p + && (!ignore_obj_pat + || ignore_obj_pat->exec (objfile_name, 0, NULL, 0) == 0) + && (!ignore_prov_pat + || ignore_prov_pat->exec (provider, 0, NULL, 0) == 0) + && (!ignore_probe_pat + || ignore_probe_pat->exec (name, 0, NULL, 0) == 0)); +} + +/* Implementation of the `maintenance ignore-probes' command. */ + +static void +ignore_probes_command (const char *arg, int from_tty) +{ + std::string ignore_provider, ignore_probe_name, ignore_objname; + + parse_probe_linespec ((const char *) arg, &ignore_provider, + &ignore_probe_name, &ignore_objname); + + ignore_prov_pat.emplace (ignore_provider.c_str (), REG_NOSUB, + _("Invalid provider regexp")); + ignore_probe_pat.emplace (ignore_probe_name.c_str (), REG_NOSUB, + _("Invalid probe regexp")); + ignore_obj_pat.emplace (ignore_objname.c_str (), REG_NOSUB, + _("Invalid object file regexp")); + + ignore_probes_p = true; +} + /* See comments in probe.h. */ struct value * @@ -931,4 +970,14 @@ If you do not specify any argument then the command will disable\n\ all defined probes."), &disablelist); + add_cmd ("ignore-probes", class_maintenance, ignore_probes_command, _("\ +Ignore probes.\n\ +Usage: ignore probes [PROVIDER [NAME [OBJECT]]]\n\ +Each argument is a regular expression, used to select probes.\n\ +PROVIDER matches probe provider names.\n\ +NAME matches the probe names.\n\ +OBJECT matches the executable or shared library name.\n\ +If you do not specify any argument then the command will ignore\n\ +all defined probes. Only supported for SystemTap probes"), + &maintenancelist); } diff --git a/gdb/probe.h b/gdb/probe.h index 598f43a238e..3637ea9cc10 100644 --- a/gdb/probe.h +++ b/gdb/probe.h @@ -304,4 +304,9 @@ extern struct cmd_list_element **info_probes_cmdlist_get (void); extern struct value *probe_safe_evaluate_at_pc (frame_info_ptr frame, unsigned n); +/* Return true if the PROVIDER/NAME probe from OBJFILE_NAME needs to be + ignored. */ + +bool ignore_probe (const char *provider, const char *name, + const char *objfile_name); #endif /* !defined (PROBE_H) */ diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c index 6f91d87846a..f244d85bb3d 100644 --- a/gdb/stap-probe.c +++ b/gdb/stap-probe.c @@ -1619,6 +1619,13 @@ handle_stap_probe (struct objfile *objfile, struct sdt_note *el, return; } + if (ignore_probe (provider, name, objfile_name (objfile))) + { + gdb_printf (gdb_stdlog, _("Ignoring SystemTap probe %s %s in %s.\n"), + provider, name, objfile_name (objfile)); + return; + } + stap_probe *ret = new stap_probe (std::string (name), std::string (provider), address, gdbarch, sem_addr, probe_args);