public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Enze Li <lienze2010@hotmail.com>
To: lsix@lancelotsix.com
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH RESEND v3] gdb: fix using clear command to delete non-user breakpoints(PR cli/7161)
Date: Thu, 21 Apr 2022 22:29:34 +0800	[thread overview]
Message-ID: <MEAP282MB0293A487453315938FB246E3DDF49@MEAP282MB0293.AUSP282.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <MEAP282MB029316144DF9B9D67E6FBA23DDF09@MEAP282MB0293.AUSP282.PROD.OUTLOOK.COM>

Hi Lancelot,

Thank you for the review.

I'm very sorry for the long wait, I dunno what's going on with my
email.  I didn't receive this email from you and gdb-patches@list until
I happened to see your reply on the gdb-patches web page[1].  I copied
the content from the web page and replied to you here, please see below.

[1] https://sourceware.org/pipermail/gdb-patches/2022-April/187959.html

>Lancelot SIX lsix@lancelotsix.com
>Sun Apr 17 22:29:29 GMT 2022
>
>Hi,
>
>I think Tom already OK-ed this patch, but I have minor comments, if
>you do not mind.
>
>> +
>> +proc get_maint_info_bp { var } {
>> +    global expect_out
>> +    global gdb_prompt
>> +
>> +    gdb_test_multiple "maint info break -1" "find address of
>> internal bp $var" {
>
>In this proc, the `var` param is only used in the messages, not in the
>actual command.  Did you mean "maint info break $var" here?
>

Yes, I didn't notice the problem at the time.

>> +	-re ".*(0x\[0-9a-f\]+).*$gdb_prompt $" {
>> +	    return $expect_out(1,string)
>> +	}
>> +	timeout {
>> +	    perror "couldn't find address of $var"
>> +	    return ""
>> +	}
>> +    }
>> +    return ""
>> +}
>
>> +
>> +standard_testfile .c
>> +
>> +# This testcase just needs a "Hello world" source file, reuse
>> +# gdb.base/main.c instead of adding a new one.
>> +if  { [gdb_compile "${srcdir}/${subdir}/main.c" "${binfile}"
>> executable {debug}] != "" } {
>> +    untested "failed to compile"
>> +    return -1
>> +}
>> +
>> +# Start with a fresh gdb.
>> +clean_restart ${binfile}
>> +
>> +if ![runto_main] then {
>> +    return 0
>> +}
>> +
>> +gdb_test "break main.c:21" \
>> +    ".*Breakpoint.* at .*" \
>> +    "set breakpoint"
>
>If I run this test, I have:
>
>    (gdb) break -qualified main
>    Breakpoint 1 at 0x401020: file .../gdb/testsuite/gdb.base/main.c,
> line 21. (gdb) run 
>    Starting program:
> .../gdb/testsuite/outputs/gdb.base/clear_non_user_bp/clear_non_user_bp
> [Thread debugging using libthread_db enabled] Using host libthread_db
> library ".../lib/libthread_db.so.1".
>
>    Breakpoint 1, main () at .../gdb/testsuite/gdb.base/main.c:21
>    21        return 0;
>    (gdb) break main.c:21
>    Note: breakpoint 1 also set at pc 0x401020.
>    Breakpoint 2 at 0x401020: file .../gdb/testsuite/gdb.base/main.c,
> line 21. (gdb) PASS: gdb.base/clear_non_user_bp.exp: set breakpoint
>
>So you already have a user breakpoint inserted (which also happens to
>be at the same address as the breakpoint you want to insert).  I am
>not sure this adds much to your testcase (but I might be wrong).
>
>Also, I do not know how maintainers feel about this (I am not one), but
>I feel that using gdb.base/main.c which is not directly linked to this
>testcase makes it easy to have main.c accidentally edited with this
>file not being touched.  With a plain line number, we might end up with
>unexpected test changes.  I really do not expect this file to change
>any time soon, but who knows, an update in the license header might
>lead to the line you are looking for not being 21 anymore.
>
>If you really need this breakpoint, I guess I would go for something
>like:
>
>    gdb_break [gdb_get_line_number "return 0;"]
>

I also noticed this "Note" message a few hours ago, and I was thinking
of deleting this piece of code, which is actually possible.

>> +
>> +set bp_addr [get_maint_info_bp "-1"]
>> +
>> +gdb_test "maint info break -1" \
>> +    "-1.*shlib events.*keep y.*$bp_addr.*" \
>> +    "maint info breakpoint -1 error"
>
>The last param is the name of the test, not an error message.  If the
>test was to fail, the output would be:
>
>    FAIL: main info breakpoint -1 error
>
>"FAIL" and "error" would be somewhat redundant.  I would suggest
>dropping the last argument altogether since, if missing, the framework
>uses the 1st parameter (the command) as default value.
>
>Also, I feel that both main
>
>> +
>> +gdb_test "clear *$bp_addr" \
>> +    "No breakpoint at \\*$bp_addr." \
>> +    "clear internal breakpoint error"
>
>Here, I would suggest just dropping the " error" part of the testname.
>"$bp_addr" is likely to change from one configuration to another,
>making diffing .sum files difficult.
>

Thank you so much for providing such detailed instructions and advice,
it was really helpful.  I'll cc you when the next version is ready if
you don't mind.

Thanks again,
Enze




      parent reply	other threads:[~2022-04-21 14:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220314122406.24889-1-lienze2010@hotmail.com>
2022-03-17 14:24 ` [PATCH v2] " Enze Li
2022-03-23 14:25   ` Enze Li
2022-04-14  5:58   ` [PING^2][PATCH " Enze Li
2022-04-15 16:41   ` [PATCH " Tom Tromey
2022-04-16  3:42     ` [PATCH v3] " Enze Li
2022-04-17 21:26       ` Tom Tromey
2022-04-18 16:04       ` Pedro Alves
2022-04-19 14:07         ` Enze Li
2022-04-22 15:01           ` Pedro Alves
2022-04-18 16:12       ` Tom Tromey
2022-04-19  2:10         ` Enze Li
2022-04-19  3:26           ` Tom Tromey
2022-04-18 23:49       ` Simon Marchi
2022-04-19  3:37         ` Simon Marchi
2022-04-19 13:32           ` Enze Li
2022-04-17  7:18     ` [PATCH RESEND " Enze Li
2022-04-17 22:29       ` Lancelot SIX
2022-04-21 14:29       ` Enze Li [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MEAP282MB0293A487453315938FB246E3DDF49@MEAP282MB0293.AUSP282.PROD.OUTLOOK.COM \
    --to=lienze2010@hotmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=lsix@lancelotsix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).