summaryrefslogtreecommitdiff
path: root/gdb/location.c
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2015-08-11 17:09:35 -0700
committerKeith Seitz <keiths@redhat.com>2015-08-11 17:09:35 -0700
commit5b56227bdc000d129d393772f1e4544b5ea0fd46 (patch)
treefdc2dc4b0a2d0a2581a066d9e87f802504728536 /gdb/location.c
parenta06efdd6effd149a1d392df8d62824e44872003a (diff)
downloadbinutils-gdb-5b56227bdc000d129d393772f1e4544b5ea0fd46.tar.gz
Explicit locations: introduce probe locations
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.
Diffstat (limited to 'gdb/location.c')
-rw-r--r--gdb/location.c56
1 files changed, 54 insertions, 2 deletions
diff --git a/gdb/location.c b/gdb/location.c
index eea88fa9e21..fd35c48541a 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");
}
@@ -213,6 +246,10 @@ event_location_to_string (struct event_location *location)
core_addr_to_string (EL_ADDRESS (location)));
break;
+ case PROBE_LOCATION:
+ EL_STRING (location) = xstrdup (EL_PROBE (location));
+ break;
+
default:
gdb_assert_not_reached ("unknown event location type");
}
@@ -242,8 +279,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;
@@ -263,6 +312,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");
}