Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Keith Seitz <keiths@redhat.com>,
	GDB Patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH v2.1 2/3] Make "break foo" find "A::foo", A::B::foo", etc. [C++ and wild matching]
Date: Tue, 28 Nov 2017 12:39:00 -0000	[thread overview]
Message-ID: <4a8ceac3-6711-7831-66e1-2fc4e138bf4b@redhat.com> (raw)
In-Reply-To: <43559340-27d5-75b3-7f61-4156eca2c3b7@redhat.com>

On 11/28/2017 02:50 AM, Keith Seitz wrote:
> On 11/27/2017 04:14 PM, Pedro Alves wrote:
>> On 11/28/2017 12:01 AM, Pedro Alves wrote:
>>> On 11/27/2017 05:13 PM, Pedro Alves wrote:
>>>> In v2:
>>>>
>>>>   - Implements Keith's suggestion of making "-qualified" a flag
>>>>     option, instead of being a replacement for "-function".  This
>>>>     means that "break -q filename.cc:function" interprets
>>>>     "filename.cc:function" as a linespec with two components instead
>>>>     of a (bogus) function name.  Basically, this folds in these
>>>>     changes (with some additional cleanup here and there):
>>>>      https://sourceware.org/ml/gdb-patches/2017-11/msg00621.html
>>>>      https://sourceware.org/ml/gdb-patches/2017-11/msg00618.html
>>>
>>> Rereading this, I realized that the "-qualified" options wasn't being saved
>>> by "save breakpoints".  There were a couple problems.  First,
>>> linespec.c:canonicalize_linespec was losing the symbol_name_match_type.
>>> While addressing this, I realized that we don't really need to add
>>> a new field to ls_parser to record the desired symbol_name_match_type,
>>> since we can just use the one in PARSER_EXPLICIT.
>>> The second is that I missed updating the "-qualified" handling in
>>> explicit_to_string_internal to take into account the fact that
>>> "-qualified" now appears with traditional linespecs as well.
> 
> Hahaha. If I had a dime for every time I (almost?) forgot to check
> "save-breakpoints," I'd have a couple of bucks by now...
> 
>>> Below's what I'm folding in to the patch, to address this.  New
>>> testcase included.
>>
>> And here's the resulting patch with that folded in.
>>
> 
> Just one little comment.
> 
>> diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c
>> index 833bdc0..6cb1d71 100644
>> --- a/gdb/mi/mi-cmd-break.c
>> +++ b/gdb/mi/mi-cmd-break.c
>> @@ -337,7 +337,8 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc)
>>      }
>>    else
>>      {
>> -      location = string_to_event_location_basic (&address, current_language);
>> +      location = string_to_event_location_basic (&address, current_language,
>> +						 symbol_name_match_type::WILD);
>>        if (*address)
>>  	error (_("Garbage '%s' at end of location"), address);
>>      }
> 
> At first, the use of ::WILD here seemed odd to me. MI is to be used by user
> interfaces like Eclipse, I wondered why Eclipse would need WILD-card access
> to symbol names.

My rationale here was to make that setting breakpoints via MI (the GUI) and
via CLI (the GDB console) find the same locations, by default.  My thinking is that
setting breakpoints by function name is something that usually frontends don't
do -- they usually set breakpoints by source filename + line number.  But
when setting a breakpoint by function name, in response to the user
typing some function name in some input line widget, it'll be better
to make CLI and the frontend agree on locations.

> 
> But then I remembered that having access to full source code "database" is not
> (or should not) be a requirement for using MI.
> 
> So that leaves me to assume that we intend a follow-on patch to address
> adding a "-qualified"-like flag for MI, too. Not requesting changes. Just
> thinking aloud.

Right, I had this unfinished patchlet here (missing tests, docs, etc...):

MI and --qualified
---

 gdb/mi/mi-cmd-break.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c
index 6cb1d71..75449e8 100644
--- a/gdb/mi/mi-cmd-break.c
+++ b/gdb/mi/mi-cmd-break.c
@@ -189,7 +189,8 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc)
       IGNORE_COUNT_OPT, THREAD_OPT, PENDING_OPT, DISABLE_OPT,
       TRACEPOINT_OPT,
       EXPLICIT_SOURCE_OPT, EXPLICIT_FUNC_OPT,
-      EXPLICIT_LABEL_OPT, EXPLICIT_LINE_OPT
+      EXPLICIT_LABEL_OPT, EXPLICIT_LINE_OPT,
+      QUALIFIED_OPT,
     };
   static const struct mi_opt opts[] =
   {
@@ -205,6 +206,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc)
     {"-function", EXPLICIT_FUNC_OPT, 1},
     {"-label", EXPLICIT_LABEL_OPT, 1},
     {"-line", EXPLICIT_LINE_OPT, 1},
+    {"-qualified", QUALIFIED_OPT, 0},
     { 0, 0, 0 }
   };
 
@@ -263,6 +265,9 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc)
 	  is_explicit = 1;
 	  explicit_loc.line_offset = linespec_parse_line_offset (oarg);
 	  break;
+	case QUALIFIED_OPT:
+	  explicit_loc.func_name_match_type = symbol_name_match_type::FULL;
+	  break;
 	}
     }
 
@@ -337,8 +342,9 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc)
     }
   else
     {
-      location = string_to_event_location_basic (&address, current_language,
-						 symbol_name_match_type::WILD);
+      location
+	= string_to_event_location_basic (&address, current_language,
+					  explicit_loc.func_name_match_type);
       if (*address)
 	error (_("Garbage '%s' at end of location"), address);
     }


which seems to work fine.  We get:

-break-insert --qualified main
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000400501",func="main",file="main.c",fullname="/home/pedro/gdb/tests/main.c",line="5",thread-groups=["i1"],times="0",original-location="-qualified main"}
(gdb) 
-break-insert --qualified --function main
^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000400501",func="main",file="main.c",fullname="/home/pedro/gdb/tests/main.c",line="5",thread-groups=["i1"],times="0",original-location="-qualified -function main"}
(gdb) 

Really not sure it's worth the bother to try to treat single-dash
"-qualified" as part of the linespec, as in:

  "-break-insert LINESPEC" =>
  "-break-insert -qualified function"

(I think we could get that working by using mi_getopt_allow_unknown.)

I assume a frontend would want to wire this up to a toggle checkbox:

 [line widget for function name]  [X] qualified 

> 
> [I would guess the same for the similar python and guile changes.]

*nod*

Here I'm assuming we'll get most of it for free too given Phil's
Python explicit locations work, though I haven't looked much at
it, to be honest.

(My thinking was to focus/settle on the core/CLI bits ignoring
those, and address those after, maybe even after the branch
is cut.)

> 
> Am I in left field?
> 
> That said, LGTM.

Alright, let me know what think of the above.

Thanks,
Pedro Alves


  reply	other threads:[~2017-11-28 12:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-27 17:13 [PATCH v2 0/3] C++ debugging improvements: wild matching and ABI tags Pedro Alves
2017-11-27 17:13 ` [PATCH v2 1/3] Handle custom completion match prefix / LCD Pedro Alves
2017-11-28  1:42   ` Keith Seitz
2017-11-27 17:13 ` [PATCH v2 3/3] Breakpoints in symbols with ABI tags (PR c++/19436) Pedro Alves
2017-11-28  3:47   ` Keith Seitz
2017-11-27 17:14 ` [PATCH v2 2/3] Make "break foo" find "A::foo", A::B::foo", etc. [C++ and wild matching] Pedro Alves
2017-11-27 17:47   ` Eli Zaretskii
2017-11-28  0:01   ` Pedro Alves
2017-11-28  0:14     ` [PATCH v2.1 " Pedro Alves
2017-11-28  2:50       ` Keith Seitz
2017-11-28 12:39         ` Pedro Alves [this message]
2017-11-28 17:35           ` Keith Seitz
2017-11-29 19:52             ` Pedro Alves
2017-11-27 17:33 ` [PATCH v2 0/3] C++ debugging improvements: wild matching and ABI tags Pedro Alves

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=4a8ceac3-6711-7831-66e1-2fc4e138bf4b@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.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