From: Simon Marchi <simon.marchi@ericsson.com>
To: Phil Muldoon <pmuldoon@redhat.com>,
Keith Seitz <keiths@redhat.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [python] Allow explicit locations in breakpoints.
Date: Mon, 16 Oct 2017 18:23:00 -0000 [thread overview]
Message-ID: <4768c7ad-cc3d-5702-fa93-40e9760d4ee8@ericsson.com> (raw)
In-Reply-To: <58311250-9ab1-39d1-99b6-07478bc8c2ab@redhat.com>
On 2017-08-23 02:30 PM, Phil Muldoon wrote:
> On 23/08/17 18:51, Keith Seitz wrote:
>> On 08/23/2017 06:58 AM, Phil Muldoon wrote:
>>
>>> diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
>>> index 6156eb6179..8431bed939 100644
>>> --- a/gdb/python/py-breakpoint.c
>>> +++ b/gdb/python/py-breakpoint.c
>>> @@ -681,7 +681,7 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
>>> case bp_breakpoint:
>>> {
>>> event_location_up location
>>> - = string_to_event_location_basic (©, current_language);
>>> + = string_to_event_location (©, current_language);
>>> create_breakpoint (python_gdbarch,
>>> location.get (), NULL, -1, NULL,
>>> 0,
>>
>> This binds python interfaces to the CLI, and I don't think we want
>> that. I would have expected (perhaps naively) to see explicit
>> locations supported using a more natural python convention, such as
>> using PyArg_ParseTupleAndKeywords.
>
> My original implementation was that. I had function="foo" etc as
> parameters to the constructor. The problem is with the -line
> parameters and relative parameters. So line=+3 won't work in the
> Python parameter sense. So it would have to be line="+3" in the
> constructor. If keywords are all strings, I'm not sure I see the point
> of parsing them as keywords when you can just specify the whole string
> (i.e. gdb.Breakpoint("-source=foo.c -line=28"). This is what we do,
> more less, with the current constructor: IE
>
> foo = gdb.Breakpoint("bar.c:23")
> or
> foo = gdb.Breakpoint("functionName").
>
> So this patch allows the addition of explicit location parsing in much
> the same vein as we handle regular breakpoints. (That is, with a
> CLI-like interface). The gdb.Breakpoint class, for better or for
> worse, is based pretty much on the interface to create_breakpoint. I'm
> not adverse to implementing keywords; it's a little extra string
> wrangling, but I'm not clear on the benefit? The gdb.Breakpoint class
> has always handed over the interpretation of breakpoints to GDB using
> the CLI like syntax. I can see why MI separates it out, and I take
> your point well, in a machine context.
I think for Python it would make sense to support the two paradigms. If you
are writing a Python command that ends up installing a breakpoint, it would
be nice if you could directly pass what you received to the gdb.Breakpoint
constructor and have it parse it (including explicit locations). For example,
(gdb) special-break -file foo.c -line 17
But it would also be nice to have a keywords based API, for when the line/file/function
information is already split. It would avoid having to build an explicit linespec
string just to have GDB parse it after.
In terms of API, I think the "spec" argument could be mutually exclusive with
the function/file/line/etc keywork arguments, which would be added. An error
would be thrown if you try to use both ways at the same time.
About the line="+3" issue, because this is Python, the line keyword could
probably accept integers and strings. And if it's a string, there could
be some validation on the format.
Simon
next prev parent reply other threads:[~2017-10-16 18:23 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-23 13:59 Phil Muldoon
2017-08-23 17:51 ` Keith Seitz
2017-08-23 18:31 ` Phil Muldoon
2017-10-16 18:23 ` Simon Marchi [this message]
2017-10-16 18:33 ` Simon Marchi
2017-10-16 20:24 ` Phil Muldoon
2017-10-16 21:26 ` Simon Marchi
2017-10-16 22:01 ` Phil Muldoon
2017-10-16 22:26 ` Simon Marchi
2017-11-17 11:02 ` Phil Muldoon
2017-11-17 13:31 ` Eli Zaretskii
2017-11-17 14:02 ` Phil Muldoon
2017-11-23 22:17 ` Simon Marchi
2017-11-24 14:07 ` Phil Muldoon
2017-12-07 10:02 ` Phil Muldoon
2017-12-07 12:16 ` Phil Muldoon
2017-12-07 14:54 ` Simon Marchi
2017-12-07 15:12 ` Phil Muldoon
2017-12-07 16:41 ` Simon Marchi
2017-12-08 13:50 ` Eli Zaretskii
2017-09-12 10:03 ` Phil Muldoon
2017-10-02 15:18 ` Phil Muldoon
2017-10-16 11:14 ` Phil Muldoon
2017-10-16 18:31 ` Simon Marchi
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=4768c7ad-cc3d-5702-fa93-40e9760d4ee8@ericsson.com \
--to=simon.marchi@ericsson.com \
--cc=gdb-patches@sourceware.org \
--cc=keiths@redhat.com \
--cc=pmuldoon@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).