[PATCH] python doc: Rework Breakpoint.__init__ doc

Simon Marchi simon.marchi@ericsson.com
Fri Dec 8 20:47:00 GMT 2017


On 2017-12-08 02:44 PM, Eli Zaretskii wrote:
>> Date: Fri, 08 Dec 2017 12:59:31 -0500
>> From: Simon Marchi <simon.marchi@polymtl.ca>
>> Cc: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
>>
>> We have a cross-reference for break and watch just above, is it 
>> necessary to put them at every reference of those commands?
> 
> No, not if they are close enough to one another.

Ok.

>> Alternatively, instead of adding a "(see Setting Breakpoints)", for 
>> example, is it possible to make the "break" word a link itself to the 
>> documentation of break?
> 
> This doesn't work well in some formats supported by Texinfo, so IMO
> it's best to avoid that.
> 
>> It would work great for 
>> HTML, PDF and info (formats with links), but not so much for plain text 
>> formats.
> 
> Actually, it works well for HTML, less well for Info, and not at all
> for PDF (because there are no hyperlinks in the printed version, only
> "See this and that").

Ok.

>>>> +The optional @var{type} argument denotes the breakpoint to create 
>>>> from the types
>>>> +defined later in this chapter.  This argument can be either
>>>> +@code{gdb.BP_BREAKPOINT} or @code{gdb.BP_WATCHPOINT}; it defaults to
>>>> +@code{gdb.BP_BREAKPOINT}.
>>>
>>> TYPE does not denote the breakpoint, it specifies its type.  So
>>> suggest to reword"
>>>
>>>   The optional @var{type} argument specifies the type of the
>>>   breakpoint to create, as defined below.
>>
>> Done.  I understand that we get rid of the second sentence (This 
>> argument can be either...)?
> 
> Not necessarily, you can keep it if you think it's useful.

Ok, I don't think it's useful to say

 This argument can be either @code{gdb.BP_BREAKPOINT} or @code{gdb.BP_WATCHPOINT}

since there are other acceptable values as well referring to the list below is better.
So I'll remove that, but keep

  It defaults to @code{gdb.BP_BREAKPOINT}.

>>> Btw, didn't you want to describe which combinations of these keywords
>>> are valid?  Or maybe you should add a cross-reference to where that is
>>> described for the CLI commands.
>>
>> The important part is the fact that you can't use "spec" at the same 
>> time as source/line/label/function.  This should now be clear, because 
>> they are defined in the two separate forms of gdb.Breakpoint().
> 
> Hmmm... now I'm confused: "at the same time" and "separate forms"
> sounds like a contradiction to me.

I don't see the contradiction:

  - don't use spec and function/line/label/source at the same time
  - you should choose (exclusively) one form (the one that uses spec) or
    the other (the one that uses function/line/label/source)

>My understanding was that one
> needs to choose which constructor to use: the first or the second, and
> then produce the spec accordingly.  Isn't that so?

What do you mean, "produce the spec accordingly" ?

One indeed has to choose between the two forms.  You can do

  1.1 gdb.Breakpoint("main")
  1.2 gdb.Breakpoint(spec="main")
  1.3 gdb.Breakpoint(spec="-function main")

Those are all equivalent, and use the first form.  spec is parsed as a
CLI-style linespec.  If you want to use the second form, you can do:

  2.1 gdb.Breakpoint(function="main")

The arguments of the second form are all keyword arguments, meaning that the
only way to pass a value to them is by naming them (such as the function= in
example 2.1).

However, showing two different constructors in the documentation is not technically
accurate with how it is implemented in the Python-support code, because it is
not possible to have two constructors with different signatures in Python.
Instead, we have a single constructor with all the parameters of both forms,
and validate that the user didn't mix arguments from both forms.  But I thought
it was a good way of explaining how it was meant to be used.

Simon



More information about the Gdb-patches mailing list