Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@polymtl.ca>, gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: Re: [PATCH] Use -qualified flag when setting temporary breakpoint in start command
Date: Tue, 09 Apr 2019 15:27:00 -0000	[thread overview]
Message-ID: <cdd9058b-e6d4-e2f1-4a1e-399571e0d2d8@redhat.com> (raw)
In-Reply-To: <20190409025557.28846-1-simon.marchi@polymtl.ca>

On 4/9/19 3:55 AM, Simon Marchi wrote:
> From: Simon Marchi <simon.marchi@efficios.com>
> 
> When using the "start" command, GDB puts a temporary breakpoint on the
> "main" symbol (we literally invoke the tbreak command).  However, since
> it does wild matching by default, it also puts a breakpoint on any C++
> method or "main" function in a namespace.  For example, when debugging
> GDB, it creates a total of 24 locations:
> 
>   (gdb) start
>   Temporary breakpoint 1 at 0x198c1e9: main. (24 locations)
> 
> as there are a bunch of methods called main in the selftests, such as
> 
>   selftests::string_view::capacity_1::main()
> 
> If such method was called in the constructor of a global object, or a
> function marked with the attribute "constructor", then we would stop at
> the wrong place.  Also, this causes a few extra symtabs (those that
> contain the "wrong" mains) to be expanded for nothing.
> 
> The dummiest, most straightforward solution is to add -qualified when
> invoking tbreak.  With this patch, "start" creates a single-location
> breakpoint, as expected.
> 

That seems fine.

> I changed the start.exp test to use a C++ test file, which contains two
> main functions.  The test now verifies that the output of "start" is the
> output we get when we set a single-location breakpoint.

I'm mildly concerned that this drops testing with C, though.  Given
that "start" is a basic command, and that C++ symbol/name matching
differs from C, and considering that some targets don't even
support C++ (considering extended-remote too), I'd think it to
be prudent to test both C and C++.  I wouldn't say it's a big
deal, but, the .exp file is small, so it shouldn't be much of
a maintenance burden to copy & adjust it as a separate .exp
file, IMHO.

> 
> gdb/ChangeLog:
> 
> 	* infcmd.c (run_command_1): Pass -qualified to tbreak when usind
> 	the "start" command.
> 
> gdb/testsuite/ChangeLog:
> 
> 	* gdb.base/start.exp: Change test file to start.cpp.  Enhance
> 	regexp to match output of single-location breakpoint.
> 	* gdb.base/start.cpp: New file.

Nit: all other C++ source files in the testsuite use .cc extension.

> +namespace foo
> +{
> +
> +int main ()
> +{
> +  return 1;
> +}
> +
> +} /* namespace foo */
> +
> +int main()

Watch out for GNU formatting.

Thanks,
Pedro Alves


  reply	other threads:[~2019-04-09 15:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-09  2:56 Simon Marchi
2019-04-09 15:27 ` Pedro Alves [this message]
2019-04-09 16:19   ` Simon Marchi
2019-04-09 16:30     ` Pedro Alves
2019-04-09 16:37       ` Simon Marchi
2019-04-09 18:09 ` André Pönitz
2019-04-09 22:02   ` [PP?] " Simon Marchi
2019-04-10 18:22     ` André Pönitz
2019-04-25 14:10 ` Tom Tromey
     [not found]   ` <96f5e735-0cdd-8bcb-58cf-e3986a5e3d5d@efficios.com>
2019-04-25 15:52     ` Tom Tromey

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=cdd9058b-e6d4-e2f1-4a1e-399571e0d2d8@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    --cc=simon.marchi@polymtl.ca \
    /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