From patchwork Sat Mar 26 17:34:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 11527 Received: (qmail 31177 invoked by alias); 26 Mar 2016 17:35:04 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 31160 invoked by uid 89); 26 Mar 2016 17:35:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=watchpointexp, watchpoint.exp, UD:watchpoint.exp, tied X-HELO: mail-qk0-f181.google.com Received: from mail-qk0-f181.google.com (HELO mail-qk0-f181.google.com) (209.85.220.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sat, 26 Mar 2016 17:34:53 +0000 Received: by mail-qk0-f181.google.com with SMTP id x64so22159579qkd.1 for ; Sat, 26 Mar 2016 10:34:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+3Cuy4dA6f8tBYh4NZP8sx3B9XoxxDGO9eO9V+hqE74=; b=WeEAjG5KRKQo8E+wJNwne6V6a9bFTVCVhE3k3/0JE0niYgdkRhUcxSJ9KCz7Y7/l86 5dGciZMxR6GrIv6PdMmW7hkEZQf88LNjcX15il6UkiVmdcQlvxBt5tFZNJ0xPITlfDP0 3/KyF7JF77uThBZOwKn3ng9rpqIVzizB1LhV9pJZqQW4INlOO7RJNdRT4d+Efwgc/NOm 0dsvy8eEkeCg9poeAcJ051U/KpfLS2cYDTF1XKLzJpjg5tH2Us6ilFyzlE7xHH+39/f8 tWJGo6ZsptOftopXdJ2U+ZQfnni4eQaEL3+gSVuevlT33Otr1jM9PUtqZgdP5Y4l6cHy WO1w== X-Gm-Message-State: AD7BkJLYLwM1LCaQcQVJeK/93lT5H8Dc9TSf05RECOptG86E4xjPq0R38yBMlVL9zAOSIQ== X-Received: by 10.55.192.14 with SMTP id o14mr4566585qki.31.1459013691421; Sat, 26 Mar 2016 10:34:51 -0700 (PDT) Received: from localhost.localdomain (ool-4353abbc.dyn.optonline.net. [67.83.171.188]) by smtp.gmail.com with ESMTPSA id n83sm7985365qhn.46.2016.03.26.10.34.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 26 Mar 2016 10:34:50 -0700 (PDT) From: Patrick Palka To: gdb-patches@sourceware.org Cc: Patrick Palka Subject: [PATCH] Teach "info breakpoints" to show the address of a -location watchpoint Date: Sat, 26 Mar 2016 13:34:43 -0400 Message-Id: <1459013683-30018-1-git-send-email-patrick@parcs.ath.cx> 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" }