public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Keith Seitz <keiths@redhat.com>
Cc: "gdb-patches@sourceware.org ml" <gdb-patches@sourceware.org>
Subject: Re: [RFA 4/9] Explicit locations v2 - Add address locations
Date: Sun, 08 Jun 2014 21:58:00 -0000	[thread overview]
Message-ID: <CADPb22S5sRGR49Lbt8o+-SsMzh5ESV7pnqWW-HNCbPDA89mGqA@mail.gmail.com> (raw)
In-Reply-To: <5388CB81.4030409@redhat.com>

On Fri, May 30, 2014 at 11:18 AM, Keith Seitz <keiths@redhat.com> wrote:
> This is an update of this patch based on changes from reviews of previous
> patches.
>
> Keith
>
> Changes since last version:
>   - remove SAVE_SPEC stuff
>   - canonicalize_linespec: remove expression stuff
>   - ditto convert_linespec_to_sals
>   - event_location_to_string_const: compute return value
>     (aka remove SAVE_SPEC)
>   - new_address_location
>
> ChangeLog
> 2014-05-29  Keith Seitz  <keiths@redhat.com>
>
>
>         * breakpoint.c (create_thread_event_breakpoint): Convert
>         linespec to address location.
>         (init_breakpoint_sal): Likewise.
>         * linespec.c (canonicalize_linespec): Do not handle address
>         locations here.
>
>         (convert_address_location_to_sals): New function; contents moved
>         from ...
>         (convert_linespc_to_sals): ... here.
>         (parse_linespec): Remove address locations from linespec grammar.
>
>         Remove handling of address locations.
>         (event_location_to_sals): Handle ADDRESS_LOCATION.
>
>         (linespec_expression_to_pc): Export.
>         * linespec.h (linespec_expression_to_pc): Add declaration.
>         * location.c (copy_event_location): Handle address locations.
>         (delete_event_location): Likewise.
>         (event_location_to_string): Likewise.
>         (string_to_event_location): Likewise.
>         (event_location_empty_p): Likewise.
>         * location.h (enum event_location_type): Add EVENT_LOCATION_ADDRESS.
>         (struct event_location.u) <address>: New member.
>         (ADDRESS_LOCATION): Define accessor macro.
>
>         * python/py-finishbreakpoint.c (bpfinishpy_init): Remove local
>         variable `finish_pc'.
>         Convert linespec to address location.
>         * spu-tdep.c (spu_catch_start): Convert linespec to address
>         location.
>

Hi.
I've given the series another read through.
Not as detailed a read through as I want to, but that'll have to wait for a bit.

I do have one comment that I thought I'd forward on now though ...

Maybe I'm asking for too much in a C-based world,
but IWBN if code like this was done differently.
It's not a blocker, but I would like your thoughts.

@@ -291,10 +290,8 @@ bpfinishpy_init (PyObject *self, PyObject *args,
PyObject *kwargs)
       struct event_location location;

       /* Set a breakpoint on the return address.  */
-      initialize_event_location (&location, LINESPEC_LOCATION);
-      finish_pc = get_frame_pc (prev_frame);
-      xsnprintf (small_buf, sizeof (small_buf), "*%s", hex_string (finish_pc));
-      EVENT_LOCATION_LINESPEC (&location) = small_buf;
+      initialize_event_location (&location, ADDRESS_LOCATION);
+      EVENT_LOCATION_ADDRESS (&location) = get_frame_pc (prev_frame);
       create_breakpoint (python_gdbarch,
                          &location, NULL, thread, NULL,
                          0

[apologies if there's a cut-n-paste error there - I hope that comes through ok]

There's still too much implementation detail exposed here for my
taste, but this is C so we have to compromise.  In this case,
bpfinishpy_init has to take on the responsibility of knowing what
needs to be done to properly initialize an ADDRESS_LOCATION - we can't
call a constructor because the object is on the stack.
I think there are a few cases in the patch set like this, so IWBN, if
possible, to do something better here.

I can think of two solutions.  Maybe there's another even better one.

1) Have a "placement new"-like constructor akin to the existing
new_foo_location constructors we have that takes a pointer to the
object to initialize.
2) Always use the existing new_foo_location constructors and free the
object when done.

Thoughts?

  reply	other threads:[~2014-06-08 21:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-08 18:01 Keith Seitz
2014-05-30 18:18 ` Keith Seitz
2014-06-08 21:58   ` Doug Evans [this message]
2014-06-09 18:12     ` Keith Seitz
2014-08-02 19:16       ` Doug Evans
2014-09-03 19:32       ` Keith Seitz

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=CADPb22S5sRGR49Lbt8o+-SsMzh5ESV7pnqWW-HNCbPDA89mGqA@mail.gmail.com \
    --to=dje@google.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).