This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Teach "info breakpoints" to show the address of a -location watchpoint
- From: Patrick Palka <patrick at parcs dot ath dot cx>
- To: gdb-patches at sourceware dot org
- Cc: Patrick Palka <patrick at parcs dot ath dot cx>
- Date: Sat, 26 Mar 2016 13:34:43 -0400
- Subject: [PATCH] Teach "info breakpoints" to show the address of a -location watchpoint
- Authentication-results: sourceware.org; auth=none
Currently the "info breakpoints" command leaves empty the Address column
corresponding to a -location watchpoint, even though there is an address
internally tied to this watchpoint. Instead of printing nothing, this
patch makes the type and the computed address of the -location
watchpoint get printed. Conviently the exp_string_reparse already has a
pretty-printed string that contains this information.
The new output of "info breakpoints" looks something like:
Num Type Disp Enb Address What
2 hw watchpoint keep y (tree_code *) 0x00007ffff7ff4990 -location decl.base.code
Tested on x86_64-pc-linux-gnu.
gdb/ChangeLog:
* breakpoint.c (print_one_breakpoint): Print the type and address
of a -location watchpoint in the "addr" column.
gdb/testsuite/ChangeLog:
* gdb.base/watchpoint.exp (test_watch_location): Test that
"info breakpoints" shows the address of the -location
watchpoint.
---
gdb/breakpoint.c | 14 ++++++++++----
gdb/testsuite/gdb.base/watchpoint.exp | 5 +++++
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index f99a7ab..37c9882 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -6399,11 +6399,17 @@ print_one_breakpoint_location (struct breakpoint *b,
{
struct watchpoint *w = (struct watchpoint *) b;
- /* Field 4, the address, is omitted (which makes the columns
- not line up too nicely with the headers, but the effect
- is relatively readable). */
if (opts.addressprint)
- ui_out_field_skip (uiout, "addr");
+ {
+ /* For a -location watchpoint, we print its type and address. */
+ if (startswith (w->exp_string, "-location "))
+ {
+ gdb_assert (startswith (w->exp_string_reparse, "* "));
+ ui_out_field_string (uiout, "addr", w->exp_string_reparse + 2);
+ }
+ else
+ ui_out_field_skip (uiout, "addr");
+ }
annotate_field (5);
ui_out_field_string (uiout, "what", w->exp_string);
}
diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp
index e4eab3d..79772e8 100644
--- a/gdb/testsuite/gdb.base/watchpoint.exp
+++ b/gdb/testsuite/gdb.base/watchpoint.exp
@@ -595,6 +595,7 @@ proc test_disable_enable_software_watchpoint {} {
proc test_watch_location {} {
global gdb_prompt
+ global hex
gdb_breakpoint [gdb_get_line_number "func5 breakpoint here"]
gdb_continue_to_breakpoint "func5 breakpoint here"
@@ -616,6 +617,10 @@ proc test_watch_location {} {
"Continuing.*\[Ww\]atchpoint .*: .*New value = 27.*" \
"continue with watch -location"
+ gdb_test "info breakpoints \$bpnum" \
+ "watchpoint +keep +y +\\(int \\*\\) +$hex +-location \\*x\r\n.*" \
+ "info breakpoints shows address of watchpoint"
+
gdb_test_no_output "delete \$bpnum" "delete watch -location"
}
--
2.8.0.rc3.27.gade0865