This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 5/9] Explicit locations v2 - Add probe locations
- From: Doug Evans <dje at google dot com>
- To: Keith Seitz <keiths at redhat dot com>
- Cc: "gdb-patches at sourceware dot org ml" <gdb-patches at sourceware dot org>
- Date: Sat, 2 Aug 2014 17:22:31 -0700
- Subject: Re: [RFA 5/9] Explicit locations v2 - Add probe locations
- Authentication-results: sourceware.org; auth=none
- References: <536BC69E dot 9060008 at redhat dot com> <5388CB91 dot 4030802 at redhat dot com> <21469 dot 30354 dot 662367 dot 622712 at ruffy dot mtv dot corp dot google dot com>
On Sat, Aug 2, 2014 at 4:38 PM, Doug Evans <dje@google.com> wrote:
> [...]
> > diff --git a/gdb/probe.c b/gdb/probe.c
> > index c7597d9..2ff5d86 100644
> > --- a/gdb/probe.c
> > +++ b/gdb/probe.c
> > @@ -58,7 +58,8 @@ parse_probes (struct event_location *location,
> > result.sals = NULL;
> > result.nelts = 0;
> >
> > - arg_start = EVENT_LOCATION_LINESPEC (location);
> > + gdb_assert (EVENT_LOCATION_TYPE (location) == PROBE_LOCATION);
> > + arg_start = EVENT_LOCATION_PROBE (location);
> >
> > cs = arg_start;
> > probe_ops = probe_linespec_to_ops (&cs);
> > @@ -173,12 +174,12 @@ parse_probes (struct event_location *location,
> > {
> > canonical->special_display = 1;
> > canonical->pre_expanded = 1;
> > - canonical->location = new_linespec_location (NULL);
> > - EVENT_LOCATION_LINESPEC (canonical->location)
> > + canonical->location = new_probe_location (NULL);
> > + EVENT_LOCATION_PROBE (canonical->location)
> > = savestring (arg_start, arg_end - arg_start);
>
> I see why you pass NULL to new_probe_location and then set EVENT_LOCATION_PROBE
> afterwards (otherwise two copies of the string would be malloc'd, and you'd
> need to deal with freeing one of them). One could add a version of
> new_probe_location that took a char* and a length, but that seems excessive.
> Another place where c++ would allow cleaner code.
OTOH, is that, or any other variation, excessive?
It's preferable to not have users of object foo know how to physically
construct a foo.
/just a thought for discussion's sake - I wouldn't change the patch if
this is but one of many similar instances, unless it makes sense to
change all of them.