public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "naaaag at gmail dot com" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug breakpoints/7143] Watchpoint does not trigger when first set Date: Fri, 09 Jan 2009 16:48:00 -0000 [thread overview] Message-ID: <20090109164850.10611.qmail@sourceware.org> (raw) In-Reply-To: <20010311215800.7143.chastain@redhat.com> ------- Additional Comments From naaaag at gmail dot com 2009-01-09 16:48 ------- Well formed problem. Relevant snippets from this test case : int i = 0; int main () { i = 1; i = 2; i = 3; return 0; } (gdb) break main Breakpoint 1 at 0x80483c3: file x2.c, line 5. (gdb) run Starting program: /gehman/home/chastain/tmp/x2 Breakpoint 1, main () at x2.c:5 5 i = 1; (gdb) watch i Hardware watchpoint 2: i (gdb) next 6 i = 2; (gdb) next Hardware watchpoint 2: i Old value = 0 New value = 2 main () at x2.c:7 7 i = 3; Change from 0->1 is not 'watched'. Breakpoint will be hit , before executing the instruction. Whereas Watchpoint will be hit , after executing the instruction. In the first 'next' after 'watch' , breakpoints are not enabled , as current pc is still pointing to breakpoint 1 ( 'main' ). infrun.c : 791 if (oneproc) 792 /* We will get a trace trap after one instruction. 793 Continue it automatically and insert breakpoints then. */ 794 stepping_over_breakpoint = 1; 795 else 796 insert_breakpoints (); Here the watchpoints can be enabled even for single stepping. Following can be done : 1. in breakpoint.c, rename insert_watchpoints to a local function (static function ) and add a boolean parameter , say watchpoint only. -> And skip non-watchpoint bpts if watchpoint_only=TRUE. 2. Create insert_watchpoints , which calls insert_watchpoints_local with FALSE. 3. Introduce a new function insert_watchpoints , which calls insert_watchpoints_local with TRUE. 4. In infrun.c:proceed , if ( single stepping ) call insert_watchpoints. With a modified gdb : Breakpoint 1, main () at x2.c:5 5 i = 1; (top-gdb) watch i Hardware watchpoint 2: i (top-gdb) next During symbol reading, incomplete CFI data; unspecified registers (e.g., rax) at 0x4004ac. Hardware watchpoint 2: i Old value = 0 New value = 1 main () at x2.c:6 6 i = 2; (top-gdb) next Hardware watchpoint 2: i Old value = 1 New value = 2 main () at x2.c:7 7 i = 3; (top-gdb) next Hardware watchpoint 2: i Old value = 2 New value = 3 main () at x2.c:8 ------------------------------------------------------------------------------- Following are the code changes : ( apologize , I am still a newbie to the gdb dev processes . Will try improve the same :-) ). breakpoint.h : @@ -717,6 +717,8 @@ extern void set_breakpoint (char *addres extern void insert_breakpoints (void); +extern void insert_watchpoints (void); + extern int remove_breakpoints (void); breakpoint.c : @@ -210,6 +210,8 @@ unlink_locations_from_global_list (struc static int is_hardware_watchpoint (struct breakpoint *bpt); +static void insert_breakpoints_local (int watchpoint_only); + /* Prototypes for exported functions. */ /* If FALSE, gdb will not use hardware support for watchpoints, even @@ -1220,6 +1222,18 @@ Note: automatically using hardware break void insert_breakpoints (void) { + insert_breakpoints_local(FALSE); +} + +void +insert_watchpoints (void) +{ + insert_breakpoints_local(TRUE); +} + +static void +insert_breakpoints_local (int watchpoint_only) +{ struct breakpoint *bpt; struct bp_location *b, *temp; int error = 0; @@ -1244,6 +1258,9 @@ insert_breakpoints (void) if (!breakpoint_enabled (b->owner)) continue; + if (watchpoint_only && !is_hardware_watchpoint(b->owner)) + continue; + /* There is no point inserting thread-specific breakpoints if the thread no longer exists. */ if (b->owner->thread != -1 @@ -1707,6 +1724,14 @@ breakpoint_here_p (CORE_ADDR pc) ALL_BP_LOCATIONS (bpt) { + struct breakpoint *b=bpt->owner; + + if (bpt->loc_type == bp_loc_hardware_breakpoint && + (b->type == bp_hardware_watchpoint || + b->type == bp_read_watchpoint || + b->type == bp_access_watchpoint)) + continue; + if (bpt->loc_type != bp_loc_software_breakpoint && bpt->loc_type != bp_loc_hardware_breakpoint) continue; infrun.c : @@ -789,9 +789,13 @@ proceed (CORE_ADDR addr, enum target_sig oneproc = 1; if (oneproc) + { /* We will get a trace trap after one instruction. - Continue it automatically and insert breakpoints then. */ + Continue it automatically and insert breakpoints then. But + watchpoints are different as they needs to be enabled now. */ stepping_over_breakpoint = 1; + insert_watchpoints (); + } else insert_breakpoints (); -- http://sourceware.org/bugzilla/show_bug.cgi?id=7143 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
next parent reply other threads:[~2009-01-09 16:48 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <20010311215800.7143.chastain@redhat.com> 2009-01-09 16:48 ` naaaag at gmail dot com [this message] [not found] <bug-7143-4717@http.sourceware.org/bugzilla/> 2012-01-25 16:29 ` tromey at redhat dot com 2012-01-25 16:34 ` tromey at redhat dot com 2012-01-25 16:58 ` palves at redhat dot com 2012-03-30 13:46 ` eager at eagercon dot com 2012-09-25 21:09 ` palves at redhat dot com 2014-02-24 17:23 ` palves at redhat dot com 2014-03-20 13:49 ` cvs-commit at gcc dot gnu.org 2014-03-20 13:53 ` palves at redhat dot com 2014-05-20 18:02 ` cvs-commit at gcc dot gnu.org 2014-05-29 13:28 ` brobecker at gnat dot com 2014-05-29 15:01 ` palves at redhat dot com 2014-05-29 15:02 ` palves at redhat dot com 2014-05-29 17:47 ` brobecker at adacore dot com 2014-05-29 18:04 ` palves at redhat dot com 2014-05-29 18:35 ` brobecker at adacore dot com 2014-05-29 22:22 ` palves at redhat dot com 2014-05-30 16:09 ` palves at redhat dot com 2014-05-30 16:21 ` brobecker at adacore dot com 2014-08-19 17:19 ` cvs-commit at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20090109164850.10611.qmail@sourceware.org \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).