diff options
author | George Barrett <bob@bob131.so> | 2019-12-10 08:28:39 +1100 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2019-12-09 16:51:33 -0500 |
commit | bac7c5cf92e85195de99077b4147358bb372e87a (patch) | |
tree | 7d1b2ecbcf4d6acc9111d682c3e20bce1f4ccd2c /gdb/breakpoint.c | |
parent | 330f1d3825daa0d9e8d6c54f4fcf6fa5800e5664 (diff) | |
download | gdb-bac7c5cf92e85195de99077b4147358bb372e87a.zip gdb-bac7c5cf92e85195de99077b4147358bb372e87a.tar.gz gdb-bac7c5cf92e85195de99077b4147358bb372e87a.tar.bz2 |
Fix scripted probe breakpoints
The documentation for make-breakpoint from the Guile API and the `spec'
variant of the gdb.Breakpoint constructor from the Python API state that
the format acceptable for location strings is the same as that accepted
by the break command. However, using the -probe qualifier at the
beginning of the location string causes a GDB internal error as it
attempts to decode a probe location in the wrong code path. Without this
functionality, there doesn't appear to be another way to set breakpoints
on probe points from Python or Guile scripts.
This patch introduces a new helper function that returns a
breakpoint_ops instance appropriate for a parsed location and updates
the Guile and Python bindings to use said function, rather than the
current hard-coded use of bkpt_breakpoint_ops. Since this logic is
duplicated in the handling of the `break' and `trace' commands, those
are also updated to call into the new helper function.
gdb/ChangeLog:
2019-12-10 George Barrett <bob@bob131.so>
Fix scripted probe breakpoints.
* breakpoint.c (tracepoint_probe_breakpoint_ops): Move
declaration forward.
(breakpoint_ops_for_event_location_type)
(breakpoint_ops_for_event_location): Add function definitions.
(break_command_1, trace_command): Use
breakpoint_ops_for_event_location.
* breakpoint.h (breakpoint_ops_for_event_location): Add function
declarations.
* guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Use
breakpoint_ops_for_event_location.
* python/py-breakpoint.c (bppy_init): Use
breakpoint_ops_for_event_location.
gdb/testsuite/ChangeLog:
2019-12-10 George Barrett <bob@bob131.so>
Test scripted probe breakpoints.
* gdb.guile/scm-breakpoint.c (main): Add probe point.
* gdb.python/py-breakpoint.c (main): Likewise.
* gdb.guile/scm-breakpoint.exp (test_bkpt_probe): Add probe
specifier test.
* gdb.python/py-breakpoint.exp (test_bkpt_probe): Likewise.
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r-- | gdb/breakpoint.c | 62 |
1 files changed, 43 insertions, 19 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 583f46d..904abda 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -246,6 +246,9 @@ struct breakpoint_ops bkpt_breakpoint_ops; /* Breakpoints set on probes. */ static struct breakpoint_ops bkpt_probe_breakpoint_ops; +/* Tracepoints set on probes. */ +static struct breakpoint_ops tracepoint_probe_breakpoint_ops; + /* Dynamic printf class type. */ struct breakpoint_ops dprintf_breakpoint_ops; @@ -9163,6 +9166,41 @@ decode_static_tracepoint_spec (const char **arg_p) return sals; } +/* Returns the breakpoint ops appropriate for use with with LOCATION_TYPE and + according to IS_TRACEPOINT. */ + +static const struct breakpoint_ops * +breakpoint_ops_for_event_location_type (enum event_location_type location_type, + bool is_tracepoint) +{ + if (is_tracepoint) + { + if (location_type == PROBE_LOCATION) + return &tracepoint_probe_breakpoint_ops; + else + return &tracepoint_breakpoint_ops; + } + else + { + if (location_type == PROBE_LOCATION) + return &bkpt_probe_breakpoint_ops; + else + return &bkpt_breakpoint_ops; + } +} + +/* See breakpoint.h. */ + +const struct breakpoint_ops * +breakpoint_ops_for_event_location (const struct event_location *location, + bool is_tracepoint) +{ + if (location != nullptr) + return breakpoint_ops_for_event_location_type + (event_location_type (location), is_tracepoint); + return is_tracepoint ? &tracepoint_breakpoint_ops : &bkpt_breakpoint_ops; +} + /* See breakpoint.h. */ int @@ -9344,16 +9382,10 @@ break_command_1 (const char *arg, int flag, int from_tty) enum bptype type_wanted = (flag & BP_HARDWAREFLAG ? bp_hardware_breakpoint : bp_breakpoint); - struct breakpoint_ops *ops; event_location_up location = string_to_event_location (&arg, current_language); - - /* Matching breakpoints on probes. */ - if (location != NULL - && event_location_type (location.get ()) == PROBE_LOCATION) - ops = &bkpt_probe_breakpoint_ops; - else - ops = &bkpt_breakpoint_ops; + const struct breakpoint_ops *ops = breakpoint_ops_for_event_location + (location.get (), false /* is_tracepoint */); create_breakpoint (get_current_arch (), location.get (), @@ -12802,8 +12834,7 @@ tracepoint_decode_location (struct breakpoint *b, struct breakpoint_ops tracepoint_breakpoint_ops; -/* The breakpoint_ops structure to be use on tracepoints placed in a - static probe. */ +/* Virtual table for tracepoints on static probes. */ static void tracepoint_probe_create_sals_from_location @@ -12824,8 +12855,6 @@ tracepoint_probe_decode_location (struct breakpoint *b, return bkpt_probe_decode_location (b, location, search_pspace); } -static struct breakpoint_ops tracepoint_probe_breakpoint_ops; - /* Dprintf breakpoint_ops methods. */ static void @@ -14467,15 +14496,10 @@ set_tracepoint_count (int num) static void trace_command (const char *arg, int from_tty) { - struct breakpoint_ops *ops; - event_location_up location = string_to_event_location (&arg, current_language); - if (location != NULL - && event_location_type (location.get ()) == PROBE_LOCATION) - ops = &tracepoint_probe_breakpoint_ops; - else - ops = &tracepoint_breakpoint_ops; + const struct breakpoint_ops *ops = breakpoint_ops_for_event_location + (location.get (), true /* is_tracepoint */); create_breakpoint (get_current_arch (), location.get (), |