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

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?

> +	-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;"]

> +
> +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.

Best,
Lancelot.

  reply	other threads:[~2022-04-17 22: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 [this message]
2022-04-21 14:29       ` Enze Li

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=20220417222929.mqgof7ygmeafgn52@ubuntu.lan \
    --to=lsix@lancelotsix.com \
    --cc=gdb-patches@sourceware.org \
    --cc=lienze2010@hotmail.com \
    --cc=tom@tromey.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).