aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.guile
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2021-05-05 16:52:29 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2021-05-06 10:44:29 +0100
commit0618ecf6eb99dce0278102a88f622f28e3ecd837 (patch)
tree50fd21fbd4a963082ad8c833f4fb1978ff37f650 /gdb/testsuite/gdb.guile
parenta7ed4ea6af8a333fccf1760cf38bf7d3634afd59 (diff)
downloadgdb-0618ecf6eb99dce0278102a88f622f28e3ecd837.zip
gdb-0618ecf6eb99dce0278102a88f622f28e3ecd837.tar.gz
gdb-0618ecf6eb99dce0278102a88f622f28e3ecd837.tar.bz2
gdb/guile: don't try to print location for watchpoints
Currently, using the guile API, if a user tries to print a breakpoint object that represents a watchpoint, then GDB will crash. For example: (gdb) guile (use-modules (gdb)) (gdb) guile (define wp1 (make-breakpoint "some_variable" #:type BP_WATCHPOINT #:wp-class WP_WRITE)) (gdb) guile (register-breakpoint! wp1) (gdb) guile (display wp1) (newline) Aborted (core dumped) This turns out to be because GDB calls event_location_to_string on the breakpoints location, and watchpoint breakpoints don't have a location. This commit resolves the crash by just skipping the printing of the location if the breakpoint doesn't have one. Potentially, we could improve on this by printing details about what the watchpoint is watching, however, I'm considering this a possible future enhancement, this commit focuses just on having GDB not crash. gdb/ChangeLog: * guile/scm-breakpoint.c (bpscm_print_breakpoint_smob): Only print breakpoint locations when the breakpoint actually has a location. gdb/testsuite/ChangeLog: * gdb.guile/scm-breakpoint.exp (test_watchpoints): Print the watchpoint object before and after registering it with GDB.
Diffstat (limited to 'gdb/testsuite/gdb.guile')
-rw-r--r--gdb/testsuite/gdb.guile/scm-breakpoint.exp5
1 files changed, 5 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.guile/scm-breakpoint.exp b/gdb/testsuite/gdb.guile/scm-breakpoint.exp
index 9d27173..5605894 100644
--- a/gdb/testsuite/gdb.guile/scm-breakpoint.exp
+++ b/gdb/testsuite/gdb.guile/scm-breakpoint.exp
@@ -248,8 +248,13 @@ proc_with_prefix test_watchpoints { } {
gdb_scm_test_silent_cmd "guile (define wp1 (make-breakpoint \"result\" #:type BP_WATCHPOINT #:wp-class WP_WRITE))" \
"create watchpoint"
+ gdb_test "guile (display wp1) (newline)" "#<gdb:breakpoint #-1>" \
+ "print watchpoint before registering"
gdb_scm_test_silent_cmd "guile (register-breakpoint! wp1)" \
"register wp1"
+ gdb_test "guile (display wp1) (newline)" \
+ "#<gdb:breakpoint #${decimal} BP_(?:HARDWARE_)?WATCHPOINT enabled noisy hit:0 ignore:0>" \
+ "print watchpoint after registering"
gdb_test "continue" \
".*\[Ww\]atchpoint.*result.*Old value = 0.*New value = 25.*main.*" \
"test watchpoint write"