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/testsuite | |
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/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/testsuite/gdb.guile/scm-breakpoint.c | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.guile/scm-breakpoint.exp | 23 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-breakpoint.c | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-breakpoint.exp | 20 |
5 files changed, 66 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 123344f..c14c341 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,12 @@ +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. + 2019-12-09 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdb.cp/rvalue-ref-overload.cc (g): New function that takes diff --git a/gdb/testsuite/gdb.guile/scm-breakpoint.c b/gdb/testsuite/gdb.guile/scm-breakpoint.c index 16700416..ed7dbdb 100644 --- a/gdb/testsuite/gdb.guile/scm-breakpoint.c +++ b/gdb/testsuite/gdb.guile/scm-breakpoint.c @@ -15,6 +15,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifdef USE_PROBES +#include <sys/sdt.h> +#endif + int result = 0; int multiply (int i) @@ -38,6 +42,9 @@ int main (int argc, char *argv[]) { result += multiply (foo); /* Break at multiply. */ result += add (bar); /* Break at add. */ +#ifdef USE_PROBES + DTRACE_PROBE1 (test, result_updated, result); +#endif } return 0; /* Break at end. */ diff --git a/gdb/testsuite/gdb.guile/scm-breakpoint.exp b/gdb/testsuite/gdb.guile/scm-breakpoint.exp index 47bc80c..183ad16 100644 --- a/gdb/testsuite/gdb.guile/scm-breakpoint.exp +++ b/gdb/testsuite/gdb.guile/scm-breakpoint.exp @@ -499,6 +499,28 @@ proc test_bkpt_address {} { ".*Breakpoint ($decimal)+ at .*$srcfile, line ($decimal)+\." } +proc test_bkpt_probe {} { + global decimal hex testfile srcfile + + if { [prepare_for_testing "failed to prepare" ${testfile}-probes \ + ${srcfile} {additional_flags=-DUSE_PROBES}] } { + return -1 + } + + if ![gdb_guile_runto_main] then { + return + } + + gdb_scm_test_silent_cmd \ + "guile (define bp1 (make-breakpoint \"-probe test:result_updated\"))" \ + "create probe breakpoint" + + gdb_test \ + "guile (register-breakpoint! bp1)" \ + "Breakpoint $decimal at $hex" \ + "register probe breakpoint" +} + test_bkpt_basic test_bkpt_deletion test_bkpt_cond_and_cmds @@ -508,3 +530,4 @@ test_bkpt_internal test_bkpt_eval_funcs test_bkpt_registration test_bkpt_address +test_bkpt_probe diff --git a/gdb/testsuite/gdb.python/py-breakpoint.c b/gdb/testsuite/gdb.python/py-breakpoint.c index d102a5f..12adc99 100644 --- a/gdb/testsuite/gdb.python/py-breakpoint.c +++ b/gdb/testsuite/gdb.python/py-breakpoint.c @@ -15,6 +15,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifdef USE_PROBES +#include <sys/sdt.h> +#endif + int result = 0; namespace foo_ns @@ -46,6 +50,9 @@ int main (int argc, char *argv[]) { result += multiply (foo); /* Break at multiply. */ result += add (bar); /* Break at add. */ +#ifdef USE_PROBES + DTRACE_PROBE1 (test, result_updated, result); +#endif } return 0; /* Break at end. */ diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp index 625977c..95f2b29 100644 --- a/gdb/testsuite/gdb.python/py-breakpoint.exp +++ b/gdb/testsuite/gdb.python/py-breakpoint.exp @@ -695,6 +695,25 @@ proc_with_prefix test_bkpt_qualified {} { "-q in spec string and qualified false" } +proc_with_prefix test_bkpt_probe {} { + global decimal hex testfile srcfile + + if { [prepare_for_testing "failed to prepare" ${testfile}-probes \ + ${srcfile} {debug c++ additional_flags=-DUSE_PROBES}] } { + return -1 + } + + if ![runto_main] then { + fail "cannot run to main." + return 0 + } + + gdb_test \ + "python gdb.Breakpoint(\"-probe test:result_updated\")" \ + "Breakpoint $decimal at $hex" \ + "-probe in spec string" +} + test_bkpt_basic test_bkpt_deletion test_bkpt_cond_and_cmds @@ -708,3 +727,4 @@ test_bkpt_pending test_bkpt_events test_bkpt_explicit_loc test_bkpt_qualified +test_bkpt_probe |