public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Pedro Alves <palves@redhat.com>
Cc: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] python: Add qualified parameter to gdb.Breakpoint
Date: Fri, 08 Dec 2017 18:42:00 -0000	[thread overview]
Message-ID: <7f59352579a659f3ee96f6a9e5404f9b@polymtl.ca> (raw)
In-Reply-To: <18e86b00-7659-e57f-e650-fae62ebf1d2c@redhat.com>

On 2017-12-08 07:05, Pedro Alves wrote:
> That was fast.  :-)  Thanks!
> 
> See comments about the docs below.
> 
> The code looks fine to me, except a formatting nit.
> 
>> --- a/gdb/doc/python.texi
>> +++ b/gdb/doc/python.texi
>> @@ -4885,7 +4885,7 @@ create both breakpoints and watchpoints.  The 
>> second accepts separate Python
>>  arguments similar to @ref{Explicit Locations} and can only be used to 
>> create
>>  breakpoints.
>> 
>> -@defun Breakpoint.__init__ (spec @r{[}, type @r{][}, wp_class @r{][}, 
>> internal @r{][}, temporary @r{]})
>> +@defun Breakpoint.__init__ (spec @r{[}, type @r{][}, wp_class @r{][}, 
>> internal @r{][}, temporary @r{][}, qualified @r{]})
>>  Create a new breakpoint according to @var{spec}, which is a string 
>> naming the
>>  location of a breakpoint, or an expression that defines a watchpoint. 
>> The
>>  contents can be any location recognized by the @code{break} command 
>> or, in the
>> @@ -4909,14 +4909,20 @@ The optional @var{temporary} argument makes 
>> the breakpoint a temporary
>>  breakpoint.  Temporary breakpoints are deleted after they have been 
>> hit.  Any
>>  further access to the Python breakpoint after it has been hit will 
>> result in a
>>  runtime error (as that breakpoint has now been automatically 
>> deleted).
>> +
>> +The optional @var{qualified} argument is a boolean that allows 
>> restricting the
>> +breakpoint to free-functions.
> 
> "free-functions" is incorrect.  With:
> 
>   struct A { void func (); }                  // #1
>   namespace B { struct A { void func (); } }  // #2
> 
> "b -q A::func()" only matches #1 while
> "b A::func()" matches both #1 and #2.
> 
> and A::func() above is not a free function.
> 
> Here's what we say for -qualified in the explicit locations part of the
> manual:
> 
> ~~~
> @item -qualified
> 
> This flag makes @value{GDBN} interpret a function name specified with
> @kbd{-function} as a complete fully-qualified name.
> 
> For example, assuming a C@t{++} program with symbols named
> @code{A::B::func} and @code{B::func}, the @w{@kbd{break -qualified
> -function B::func}} command sets a breakpoint on @code{B::func}, only.
> 
> (Note: the @kbd{-qualified} option can precede a linespec as well
> (@pxref{Linespec Locations}), so the particular example above could be
> simplified as @w{@kbd{break -qualified B::func}}.)
> ~~~
> 
> There's similar text in the linespecs part of the manual and also
> in "help break".  See:
>   $ git show a20714ff39f6 -- doc/gdb.texinfo NEWS break.c
> 
> So we either need to clarify that in the Python bits too,
> or some do some xref'ing.

Agreed, I didn't like that wording either.  I had only found the 
Linespec Locations page, which doesn't specifically say "fully-qualified 
name", but mentions free-function (though it's in an example, not a 
formal definition).  How is this?

The optional @var{qualified} argument is a boolean that allows 
interpreting
the function passed in @code{spec} as a fully-qualified name.  It is 
equivalent
to @code{break}'s @code{-qualified} flag (@pxref{Linespec Locations} and
@ref{Explicit Locations}).

>  It is equivalent to @code{break}'s
>> +@code{-qualified} flag (@pxref{Linespec Locations}).
>> +
>>  @end defun
>> 
>> -@defun Breakpoint.__init__ (@r{[} source @r{][}, function @r{][}, 
>> label @r{][}, line @r{]}, @r{][} internal @r{][}, temporary @r{][})
>> +@defun Breakpoint.__init__ (@r{[} source @r{][}, function @r{][}, 
>> label @r{][}, line @r{]}, @r{][} internal @r{][}, temporary  @r{][}, 
>> qualified @r{]})
>>  Create a new explicit location breakpoint (@pxref{Explicit 
>> Locations})
>>  according to the specifications contained in the key words 
>> @var{source},
>>  @var{function}, @var{label} and @var{line}.
> 
> Should @var{qualified} be added to this list too?

It is mentioned in the paragraph below.

> (BTW, noticed a typo in this paragraph:
> 
>   "create a new a explicit location"
> 
> the second "a" is spurious.)

That text changed based on Eli's comments, but thanks anyway.

>> 
>> -@var{internal} and @var{temporary} have the same usage as explained 
>> previously.
>> +@var{internal}, @var{temporary} and @var{qualified} have the same 
>> usage as
>> +explained previously.
>>  @end defun
>> 
>>  The available types are represented by constants defined in the 
>> @code{gdb}
> 
>> @@ -759,6 +761,9 @@ bppy_init (PyObject *self, PyObject *args, 
>> PyObject *kwargs)
>>  	case bp_breakpoint:
>>  	  {
>>  	    event_location_up location;
>> +	    symbol_name_match_type func_name_match_type
>> +	      = qualified ? symbol_name_match_type::FULL
>> +		  : symbol_name_match_type::WILD;
> 
> Should wrap the multi-line expression in ()s:
> 
>   symbol_name_match_type func_name_match_type
>     = (qualified ? symbol_name_match_type::FULL
>        : symbol_name_match_type::WILD);
> 
> Though I prefer breaking ternary operators like this:
> 
>   symbol_name_match_type func_name_match_type
>     = (qualified
>        ? symbol_name_match_type::FULL
>        : symbol_name_match_type::WILD);
> 
> because it makes it look more obviously like
> 
>  if COND
>    THEN
>    ELSE

Done.

Thanks,

Simon

  reply	other threads:[~2017-12-08 18:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-07 22:34 Simon Marchi
2017-12-08 12:05 ` Pedro Alves
2017-12-08 18:42   ` Simon Marchi [this message]
2017-12-13 13:17     ` Pedro Alves
2017-12-13 16:45       ` Simon Marchi
2017-12-08 14:15 ` Eli Zaretskii
2017-12-08 18:27   ` Simon Marchi
2017-12-08 19:47     ` Eli Zaretskii

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=7f59352579a659f3ee96f6a9e5404f9b@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=simon.marchi@ericsson.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).