From: Doug Evans <xdje42@gmail.com>
To: Keith Seitz <keiths@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v6 2/9] Explicit locations: introduce new struct event_locations-based API
Date: Tue, 11 Aug 2015 21:49:00 -0000 [thread overview]
Message-ID: <m37fp1a43l.fsf@sspiff.org> (raw)
In-Reply-To: <1439325925-4652-1-git-send-email-keiths@redhat.com> (Keith Seitz's message of "Tue, 11 Aug 2015 13:45:25 -0700")
Keith Seitz <keiths@redhat.com> writes:
> Doug Evans <dje@google.com> writes:
>
>> As for reposting, in this particular case (2/9) I suppose you should,
>> but only for informational sake. No need for waiting for another review.
>
> For the record, this is the version I plan to commit/push. The only change
> is the removal of event_location_to_string_cosnt, which was not being used
> anymore.
>
> gdb/ChangeLog:
>
> * Makefile.in (SFILES): Add location.c.
> (HFILES_NO_SRCDIR): Add location.h.
> (COMMON_OBS): Add location.o.
> * linespec.c (linespec_lex_to_end): New function.
> * linespec.h (linespec_lex_to_end): Declare.
> * location.c: New file.
> * location.h: New file.
Alas the removal of event_location_to_string_const isn't quite right.
> +/* See description in location.h. */
> +
> +const char *
> +event_location_to_string (struct event_location *location)
> +{
> + char *result = NULL;
> +
> + if (EL_STRING (location) != NULL)
> + return xstrdup (EL_STRING (location));
> +
> + switch (EL_TYPE (location))
> + {
> + case LINESPEC_LOCATION:
> + if (EL_LINESPEC (location) != NULL)
> + result = xstrdup (EL_LINESPEC (location));
> + break;
> +
> + default:
> + gdb_assert_not_reached ("unknown event location type");
> + }
> +
> + return result;
> +}
The caching done by the previous version is lost:
+/* See description in location.h. */
+
+const char *
+event_location_to_string (struct event_location *location)
+{
+ /* Cache a copy of the string representation. */
+ if (EL_STRING (location) == NULL)
+ EL_STRING (location) = event_location_to_string_const (location);
+
+ return EL_STRING (location);
+}
The result is still owned by the location so we don't want to return
an xstrdup'd copy.
How about:
const char *
event_location_to_string (const struct event_location *location)
{
if (EL_STRING (location) == NULL)
{
switch (EL_TYPE (location))
{
case LINESPEC_LOCATION:
if (EL_LINESPEC (location) != NULL)
EL_STRING (location) = xstrdup (EL_LINESPEC (location));
break;
default:
gdb_assert_not_reached ("unknown event location type");
}
}
return EL_STRING (location);
}
next prev parent reply other threads:[~2015-08-11 21:49 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-05 23:28 [PATCH v6 0/9] Series short description Keith Seitz
2015-08-05 23:29 ` [PATCH v6 3/9] Explicit locations: use new location API Keith Seitz
2015-08-10 18:02 ` Doug Evans
2015-08-05 23:29 ` [PATCH v6 1/9] Explicit locations: rename "address string"/"addr_string" to "location" Keith Seitz
2015-08-10 16:43 ` Doug Evans
2015-08-05 23:29 ` [PATCH v6 2/9] Explicit locations: introduce new struct event_location-based API Keith Seitz
2015-08-10 17:34 ` Doug Evans
2015-08-10 18:05 ` Keith Seitz
2015-08-10 19:59 ` Doug Evans
2015-08-11 20:45 ` [PATCH v6 2/9] Explicit locations: introduce new struct event_locations-based API Keith Seitz
2015-08-11 21:49 ` Doug Evans [this message]
2015-08-05 23:30 ` [PATCH v6 4/9] Explicit locations: introduce address locations Keith Seitz
2015-08-10 18:04 ` Doug Evans
2015-12-14 7:11 ` Joel Brobecker
2015-12-14 20:56 ` Keith Seitz
2015-12-15 13:40 ` Joel Brobecker
2016-01-17 15:32 ` [RFA] Fix regression introduced in "break *<EXPR>" by explicit location patches (was: "Re: [PATCH v6 4/9] Explicit locations: introduce address locations") Joel Brobecker
2016-01-18 21:29 ` [RFA] Fix regression introduced in "break *<EXPR>" by explicit location patches Keith Seitz
2016-01-21 10:33 ` Joel Brobecker
2015-08-05 23:30 ` [PATCH v6 5/9] Explicit locations: introduce probe locations Keith Seitz
2015-08-10 18:06 ` Doug Evans
2015-08-05 23:32 ` [PATCH v6 6/9] Explicit locations: introduce explicit locations Keith Seitz
2015-08-10 18:09 ` Doug Evans
2015-08-05 23:33 ` [PATCH v6 7/9] Explicit locations: add UI features for CLI Keith Seitz
2015-08-10 19:42 ` Doug Evans
2015-08-11 20:45 ` Keith Seitz
2015-08-11 21:50 ` Doug Evans
2015-08-17 16:41 ` Yao Qi
2015-08-17 17:19 ` Keith Seitz
2015-08-05 23:33 ` [PATCH v6 8/9] Explicit locations: MI support for explicit locations Keith Seitz
2015-08-10 19:43 ` Doug Evans
2015-08-05 23:34 ` [PATCH v6 9/9] Explicit locations: documentation updates Keith Seitz
2015-08-10 19:45 ` Doug Evans
2015-08-10 19:54 ` [PATCH v6 0/9] Series short description Doug Evans
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=m37fp1a43l.fsf@sspiff.org \
--to=xdje42@gmail.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