From: Keith Seitz <keiths@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v6 5/9] Explicit locations: introduce probe locations
Date: Wed, 05 Aug 2015 23:30:00 -0000 [thread overview]
Message-ID: <20150805233007.21646.43939.stgit@valrhona.uglyboxes.com> (raw)
In-Reply-To: <20150805232802.21646.88440.stgit@valrhona.uglyboxes.com>
* This patch has previously been approved. *
This patch adds support for probe locations and converts existing
probe linespec locations to the new location type.
gdb/ChangeLog:
* break-catch-throw.c (re_set_exception_catchpoint): Convert
linespec for stap probe to probe location.
* breakpoint.c (create_longjmp_master_breakpoint)
(create_exception_master_breakpoint): Likewise.
(break_command_1): Remove local variable `arg_cp'.
Check location type to set appropriate breakpoint ops methods.
(trace_command): Likewise.
* linespec.c (event_location_to_sals): Assert on probe locations.
* location.c (EL_PROBE): Add macro definition.
(new_probe_location, get_probe_location): New functions.
(copy_event_location, delete_event_location, event_location_to_string)
(string_to_event_location, event_location_empty_p): Handle probe
locations.
* location.h (enum event_location_type): Add PROBE_LOCATION.
(new_probe_location, get_probe_location): Declare.
* probe.c (parse_probes): Assert that LOCATION is a probe location.
Convert linespec into probe location.
---
gdb/break-catch-throw.c | 5 ++--
gdb/breakpoint.c | 18 +++++++--------
gdb/linespec.c | 5 ++++
gdb/location.c | 56 +++++++++++++++++++++++++++++++++++++++++++++--
gdb/location.h | 17 +++++++++++++-
gdb/probe.c | 5 +++-
6 files changed, 88 insertions(+), 18 deletions(-)
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 9449aa5..07a8f05 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -216,9 +216,8 @@ re_set_exception_catchpoint (struct breakpoint *self)
/* We first try to use the probe interface. */
TRY
{
- char *spec = ASTRDUP (exception_functions[kind].probe);
-
- location = new_linespec_location (&spec);
+ location
+ = new_probe_location (exception_functions[kind].probe);
cleanup = make_cleanup_delete_event_location (location);
sals = parse_probes (location, NULL);
do_cleanups (cleanup);
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 06af762..f272576 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -3508,7 +3508,6 @@ create_longjmp_master_breakpoint (void)
int i;
struct probe *probe;
struct gdbarch *gdbarch = get_objfile_arch (objfile);
- char *p;
for (i = 0;
VEC_iterate (probe_p,
@@ -3523,8 +3522,8 @@ create_longjmp_master_breakpoint (void)
objfile),
bp_longjmp_master,
&internal_breakpoint_ops);
- p = ASTRDUP ("-probe-stap libc:longjmp");
- b->location = new_linespec_location (&p);
+ b->location
+ = new_probe_location ("-probe-stap libc:longjmp");
b->enable_state = bp_disabled;
}
@@ -3686,15 +3685,14 @@ create_exception_master_breakpoint (void)
++i)
{
struct breakpoint *b;
- char *p;
b = create_internal_breakpoint (gdbarch,
get_probe_address (probe,
objfile),
bp_exception_master,
&internal_breakpoint_ops);
- p = ASTRDUP ("-probe-stap libgcc:unwind");
- b->location = new_linespec_location (&p);
+ b->location
+ = new_probe_location ("-probe-stap libgcc:unwind");
b->enable_state = bp_disabled;
}
@@ -9841,7 +9839,6 @@ break_command_1 (char *arg, int flag, int from_tty)
? bp_hardware_breakpoint
: bp_breakpoint);
struct breakpoint_ops *ops;
- const char *arg_cp = arg;
struct event_location *location;
struct cleanup *cleanup;
@@ -9849,7 +9846,8 @@ break_command_1 (char *arg, int flag, int from_tty)
cleanup = make_cleanup_delete_event_location (location);
/* Matching breakpoints on probes. */
- if (arg_cp != NULL && probe_linespec_to_ops (&arg_cp) != NULL)
+ if (location != NULL
+ && event_location_type (location) == PROBE_LOCATION)
ops = &bkpt_probe_breakpoint_ops;
else
ops = &bkpt_breakpoint_ops;
@@ -14974,11 +14972,11 @@ trace_command (char *arg, int from_tty)
struct breakpoint_ops *ops;
struct event_location *location;
struct cleanup *back_to;
- const char *arg_cp = arg;
location = string_to_event_location (&arg, current_language);
back_to = make_cleanup_delete_event_location (location);
- if (arg_cp != NULL && probe_linespec_to_ops (&arg_cp) != NULL)
+ if (location != NULL
+ && event_location_type (location) == PROBE_LOCATION)
ops = &tracepoint_probe_breakpoint_ops;
else
ops = &tracepoint_breakpoint_ops;
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 65c55df..8a7640b 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -2479,6 +2479,11 @@ event_location_to_sals (linespec_parser *parser,
get_address_location (location));
break;
+ case PROBE_LOCATION:
+ /* Probes are handled by their own decoders. */
+ gdb_assert_not_reached ("attempt to decode probe location");
+ break;
+
default:
gdb_assert_not_reached ("unhandled event location type");
}
diff --git a/gdb/location.c b/gdb/location.c
index c1f4e19..6059679 100644
--- a/gdb/location.c
+++ b/gdb/location.c
@@ -45,6 +45,7 @@ struct event_location
probes. */
char *addr_string;
#define EL_LINESPEC(PTR) ((PTR)->u.addr_string)
+#define EL_PROBE(PTR) ((PTR)->u.addr_string)
/* An address in the inferior. */
CORE_ADDR address;
@@ -121,6 +122,29 @@ get_address_location (const struct event_location *location)
/* See description in location.h. */
struct event_location *
+new_probe_location (const char *probe)
+{
+ struct event_location *location;
+
+ location = XCNEW (struct event_location);
+ EL_TYPE (location) = PROBE_LOCATION;
+ if (probe != NULL)
+ EL_PROBE (location) = xstrdup (probe);
+ return location;
+}
+
+/* See description in location.h. */
+
+const char *
+get_probe_location (const struct event_location *location)
+{
+ gdb_assert (EL_TYPE (location) == PROBE_LOCATION);
+ return EL_PROBE (location);
+}
+
+/* See description in location.h. */
+
+struct event_location *
copy_event_location (const struct event_location *src)
{
struct event_location *dst;
@@ -141,6 +165,11 @@ copy_event_location (const struct event_location *src)
EL_ADDRESS (dst) = EL_ADDRESS (src);
break;
+ case PROBE_LOCATION:
+ if (EL_PROBE (src) != NULL)
+ EL_PROBE (dst) = xstrdup (EL_PROBE (src));
+ break;
+
default:
gdb_assert_not_reached ("unknown event location type");
}
@@ -185,6 +214,10 @@ delete_event_location (struct event_location *location)
/* Nothing to do. */
break;
+ case PROBE_LOCATION:
+ xfree (EL_PROBE (location));
+ break;
+
default:
gdb_assert_not_reached ("unknown event location type");
}
@@ -216,6 +249,10 @@ event_location_to_string_const (const struct event_location *location)
core_addr_to_string (EL_ADDRESS (location)));
break;
+ case PROBE_LOCATION:
+ result = xstrdup (EL_PROBE (location));
+ break;
+
default:
gdb_assert_not_reached ("unknown event location type");
}
@@ -256,8 +293,20 @@ string_to_event_location (char **stringp,
}
else
{
- /* Everything else is a linespec. */
- location = new_linespec_location (stringp);
+ const char *cs;
+
+ /* Next, try the input as a probe spec. */
+ cs = *stringp;
+ if (cs != NULL && probe_linespec_to_ops (&cs) != NULL)
+ {
+ location = new_probe_location (*stringp);
+ *stringp += strlen (*stringp);
+ }
+ else
+ {
+ /* Everything else is a linespec. */
+ location = new_linespec_location (stringp);
+ }
}
return location;
@@ -277,6 +326,9 @@ event_location_empty_p (const struct event_location *location)
case ADDRESS_LOCATION:
return 0;
+ case PROBE_LOCATION:
+ return EL_PROBE (location) == NULL;
+
default:
gdb_assert_not_reached ("unknown event location type");
}
diff --git a/gdb/location.h b/gdb/location.h
index 5fd1dca..5511cad 100644
--- a/gdb/location.h
+++ b/gdb/location.h
@@ -31,7 +31,10 @@ enum event_location_type
LINESPEC_LOCATION,
/* An address in the inferior. */
- ADDRESS_LOCATION
+ ADDRESS_LOCATION,
+
+ /* A probe location. */
+ PROBE_LOCATION
};
/* Return the type of the given event location. */
@@ -79,6 +82,18 @@ extern struct event_location *
extern CORE_ADDR
get_address_location (const struct event_location *location);
+/* Create a new probe location. The return result is malloc'd
+ and should be freed with delete_event_location. */
+
+extern struct event_location *
+ new_probe_location (const char *probe);
+
+/* Return the probe location (a string) of the given event_location
+ (which must be of type PROBE_LOCATION). */
+
+extern const char *
+ get_probe_location (const struct event_location *location);
+
/* Free an event location and any associated data. */
extern void delete_event_location (struct event_location *location);
diff --git a/gdb/probe.c b/gdb/probe.c
index 8366220..a3cfefe 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -59,7 +59,8 @@ parse_probes (const struct event_location *location,
result.sals = NULL;
result.nelts = 0;
- arg_start = get_linespec_location (location);
+ gdb_assert (event_location_type (location) == PROBE_LOCATION);
+ arg_start = get_probe_location (location);
cs = arg_start;
probe_ops = probe_linespec_to_ops (&cs);
@@ -178,7 +179,7 @@ parse_probes (const struct event_location *location,
make_cleanup (xfree, canon);
canonical->special_display = 1;
canonical->pre_expanded = 1;
- canonical->location = new_linespec_location (&canon);
+ canonical->location = new_probe_location (canon);
}
do_cleanups (cleanup);
next prev parent reply other threads:[~2015-08-05 23:30 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 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
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 3/9] Explicit locations: use new location API Keith Seitz
2015-08-10 18:02 ` Doug Evans
2015-08-05 23:30 ` Keith Seitz [this message]
2015-08-10 18:06 ` [PATCH v6 5/9] Explicit locations: introduce probe locations Doug Evans
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: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 8/9] Explicit locations: MI support for " Keith Seitz
2015-08-10 19:43 ` 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: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=20150805233007.21646.43939.stgit@valrhona.uglyboxes.com \
--to=keiths@redhat.com \
--cc=gdb-patches@sourceware.org \
/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