Message ID | 20221019033925.86910-1-rkovhaev@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> 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 887003858C2F for <patchwork@sourceware.org>; Wed, 19 Oct 2022 03:49:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 887003858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666151353; bh=9hCt5hlqJVDwm31zsEBMgrJPJglJCJVqNSEbhoI7g80=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=MMD44+UxU5qXNRm7GOaCQG9ZXxDUKAUrA5PcBnlUAKZe8nFcQHZr3SwjoGCHIVnTp wkaXPEYBDbKrnpSTvgfHuTOJ20nQ9nE+4dhZSMv7EfCHNgL66glvtFANx9RQ1EdzKk sM6vbRvOBvgf/h75z4VRKo53/LjxiRMo55+PZjDs= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id 9C2EC3858D32 for <gdb-patches@sourceware.org>; Wed, 19 Oct 2022 03:48:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9C2EC3858D32 Received: by mail-pg1-x535.google.com with SMTP id l6so15108241pgu.7 for <gdb-patches@sourceware.org>; Tue, 18 Oct 2022 20:48:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9hCt5hlqJVDwm31zsEBMgrJPJglJCJVqNSEbhoI7g80=; b=ztwkyTQnOADUTV9T5FBzFFRh7LNmGx/63dm0SAxwGyKQ4uvj/I5oNHpbEispyouNii dt/1P/khidK23p9eAltgV0pGLiRFn2hjHYGaKJo51dPPdQeQ2lhHkGWf36DQcj0zO/ff 1sNj5r4Pg5AjpR3CX1vkSfZf1OUTGHT/9W9L9EJVMf7uSxu95VolPQbraBHh4cZMTZCW ggIpnFDn+xiEaDATxyLKFMVYPAp2cZVXjilsQlagoceXaP2ioRK5RobOSSsGK600lq+E fXCcAYWXsodcFIhZgO96zelhvNqkRYeItyIGxGpNSntLQt8KNH2yHri4ees3QMy4jyy+ EHOA== X-Gm-Message-State: ACrzQf2q4/tLDrOJB3RQ0tfGXKoaf/UBWX74n3JFX7IK/8yE4TvqIDwa JHij2H/rqQCIFpV5xUcB/xMRhobdKB4= X-Google-Smtp-Source: AMsMyM5IFdm+8d87pQICe2X1vWB+vhe714v2l3qupUgCIfQk/lmy52ZFaE4y60TJcmwgMnfRijhjMQ== X-Received: by 2002:a62:31c7:0:b0:561:86fb:27e9 with SMTP id x190-20020a6231c7000000b0056186fb27e9mr6398731pfx.63.1666151327648; Tue, 18 Oct 2022 20:48:47 -0700 (PDT) Received: from nuc10.. ([104.36.148.254]) by smtp.gmail.com with ESMTPSA id a10-20020aa78e8a000000b0056316f0b7f8sm10103909pfr.33.2022.10.18.20.48.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 20:48:47 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [RFC PATCH] gdb: add command to clear value history Date: Tue, 18 Oct 2022 20:39:28 -0700 Message-Id: <20221019033925.86910-1-rkovhaev@gmail.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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 <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Rustam Kovhaev via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Rustam Kovhaev <rkovhaev@gmail.com> Cc: rkovhaev@gmail.com Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
[RFC] gdb: add command to clear value history
|
|
Commit Message
Rustam Kovhaev
Oct. 19, 2022, 3:39 a.m. UTC
Hello,
While debugging an application I wanted to clear the value history and I
could not find an option to do it.
I might be the only one who gets lost in the value history and I am not
sure if anyone else needs it, but I thought it would be nice to have it.
And I hope this does not break anything.
Please let me know what you think. Thanks!
Let's have the functionality to clear the value history.
Introduce 'set values clear' command to clear the value history.
Signed-off-by: Rustam Kovhaev <rkovhaev@gmail.com>
---
gdb/value.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
Comments
On 19/10/2022 05:39, Rustam Kovhaev via Gdb-patches wrote: > Hello, Hi Rustam! Thanks for this patch! I am indifferent to the new command, as I never needed it but I can't see it impacting anything else, so I'm fine with it being added. However, the command "clear" already exists. It clears all breakpoints. You could either add "values" as a subcommand to the existing command, by having it added around gdb/breakpoint.c:14434, but doing so might change how the bare "clear" command works (I'm not sure here), or add something like "values clear" instead, which I think it's a bit too big. This specific point I'll defer to other maintainers on helping you. I also noticed a few specific things that I'll explain inline. > While debugging an application I wanted to clear the value history and I > could not find an option to do it. > I might be the only one who gets lost in the value history and I am not > sure if anyone else needs it, but I thought it would be nice to have it. > And I hope this does not break anything. > Please let me know what you think. Thanks! > > Let's have the functionality to clear the value history. > Introduce 'set values clear' command to clear the value history. GDB tends to prefer a more objective commit message style, even if it comes from a personal need. Your message is fine for the RFC but it needs to be iterated for it to go in. See commits e4014689b9a1b9aa0dde8f8a358401774566fe8b and 70175292616118bad315296ba6180f375326bb6c for some exaples. > > Signed-off-by: Rustam Kovhaev <rkovhaev@gmail.com> We don't really use Signed-off-by tags in GDB. > --- > gdb/value.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/gdb/value.c b/gdb/value.c > index 605e52dee82..726b5ef9084 100644 > --- a/gdb/value.c > +++ b/gdb/value.c > @@ -1971,6 +1971,15 @@ show_values (const char *num_exp, int from_tty) > if (from_tty && num_exp) > set_repeat_arguments ("+"); > } > + > +static struct cmd_list_element *setvallist; > + > +static void > +clear_values (const char *ignore, int from_tty) > +{ > + value_history.clear (); > +} > + > > enum internalvar_kind > { > @@ -4343,6 +4352,13 @@ Convenience functions are defined via the Python API." > Elements of value history around item number IDX (or last ten)."), > &showlist); > > + add_cmd("clear", no_class, clear_values, _("\ > +Clear value history."), &setvallist); You forgot to add a space before ( here. > + > + add_basic_prefix_cmd ("values", class_support, _("\ > +Generic command for setting value history parameters"), > + &setvallist, 0, &setlist); > + Since you are using &setvallist and &setlist here, your command ends up being "set values clear" instead of "clear values". You probably want to use &cmdlist instead. > add_com ("init-if-undefined", class_vars, init_if_undefined_command, _("\ > Initialize a convenience variable if necessary.\n\ > init-if-undefined VARIABLE = EXPRESSION\n\ It would be good if you added a test for this command. I think it would go well in gdb.base/printcmd.exp, adding some extra lines like gdb_test_no_output "clear values" "test clearing values" gdb_test "print 1" ".1 = 1" "test that values were cleared" With all this being said, I like the direction of your patch, I hope to see it going upstream soon :-) Cheers, Bruno
>>>>> "Rustam" == Rustam Kovhaev via Gdb-patches <gdb-patches@sourceware.org> writes:
Rustam> While debugging an application I wanted to clear the value history and I
Rustam> could not find an option to do it.
Rustam> I might be the only one who gets lost in the value history and I am not
Rustam> sure if anyone else needs it, but I thought it would be nice to have it.
Rustam> And I hope this does not break anything.
Rustam> Please let me know what you think. Thanks!
Thanks for the patch.
In addition to what Bruno said, a new feature should have a
documentation patch and also a note in NEWS.
Rustam> +static void
Rustam> +clear_values (const char *ignore, int from_tty)
Rustam> +{
Rustam> + value_history.clear ();
This is indented too much.
Tom
On Thu, Oct 20, 2022 at 12:44:38PM -0600, Tom Tromey wrote: > > Thanks for the patch. > > In addition to what Bruno said, a new feature should have a > documentation patch and also a note in NEWS. > Hi Bruno, Tom, Thanks for the review and the comments. I will send a proper patch.
diff --git a/gdb/value.c b/gdb/value.c index 605e52dee82..726b5ef9084 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1971,6 +1971,15 @@ show_values (const char *num_exp, int from_tty) if (from_tty && num_exp) set_repeat_arguments ("+"); } + +static struct cmd_list_element *setvallist; + +static void +clear_values (const char *ignore, int from_tty) +{ + value_history.clear (); +} + enum internalvar_kind { @@ -4343,6 +4352,13 @@ Convenience functions are defined via the Python API." Elements of value history around item number IDX (or last ten)."), &showlist); + add_cmd("clear", no_class, clear_values, _("\ +Clear value history."), &setvallist); + + add_basic_prefix_cmd ("values", class_support, _("\ +Generic command for setting value history parameters"), + &setvallist, 0, &setlist); + add_com ("init-if-undefined", class_vars, init_if_undefined_command, _("\ Initialize a convenience variable if necessary.\n\ init-if-undefined VARIABLE = EXPRESSION\n\