From 7270d8f229f13ef08e41cc754a94dff18a6ada53 Mon Sep 17 00:00:00 2001 From: Orjan Friberg Date: Mon, 26 Apr 2004 09:02:41 +0000 Subject: [PATCH] 2004-04-26 Orjan Friberg From Paul Koning : * breakpoint.c (free_valchain): New function. (insert_bp_location, delete_breakpoint): Use free_valchain. (remove_breakpoint): Do not remove the valchain. (bpstat_stop_status): If not stopped by watchpoint, skip watchpoints when generating stop status list. * infrun.c (handle_inferior_event): Make stepped_after_stopped_by_watchpoint a global variable. * remote.c (remote_stopped_data_address): Return watch data address rather than zero if stepped_after_stopped_by_watchpoint is set. --- gdb/ChangeLog | 14 ++++++++++++++ gdb/breakpoint.c | 41 +++++++++++++++++++++++++++++------------ gdb/infrun.c | 3 ++- gdb/remote.c | 5 ++++- 4 files changed, 49 insertions(+), 14 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index af8808b..ccc04d2 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,17 @@ +2004-04-26 Orjan Friberg + + From Paul Koning : + * breakpoint.c (free_valchain): New function. + (insert_bp_location, delete_breakpoint): Use free_valchain. + (remove_breakpoint): Do not remove the valchain. + (bpstat_stop_status): If not stopped by watchpoint, skip + watchpoints when generating stop status list. + * infrun.c (handle_inferior_event): Make + stepped_after_stopped_by_watchpoint a global variable. + * remote.c (remote_stopped_data_address): Return watch data + address rather than zero if stepped_after_stopped_by_watchpoint is + set. + 2004-04-25 Michael Chastain Fix PR gdb/1626. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index c38720a..95b0814 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -746,6 +746,23 @@ insert_catchpoint (struct ui_out *uo, void *args) return 0; } +/* Helper routine: free the value chain for a breakpoint (watchpoint). */ + +static void free_valchain (struct bp_location *b) +{ + struct value *v; + struct value *n; + + /* Free the saved value chain. We will construct a new one + the next time the watchpoint is inserted. */ + for (v = b->owner->val_chain; v; v = n) + { + n = v->next; + value_free (v); + } + b->owner->val_chain = NULL; +} + /* Insert a low-level "breakpoint" of some type. BPT is the breakpoint. Any error messages are printed to TMP_ERROR_STREAM; and DISABLED_BREAKS, PROCESS_WARNING, and HW_BREAKPOINT_ERROR are used to report problems. @@ -920,6 +937,8 @@ insert_bp_location (struct bp_location *bpt, if (within_current_scope) { + free_valchain (bpt); + /* Evaluate the expression and cut the chain of values produced off from the value chain. @@ -1505,15 +1524,6 @@ remove_breakpoint (struct bp_location *b, insertion_state_t is) if ((is == mark_uninserted) && (b->inserted)) warning ("Could not remove hardware watchpoint %d.", b->owner->number); - - /* Free the saved value chain. We will construct a new one - the next time the watchpoint is inserted. */ - for (v = b->owner->val_chain; v; v = n) - { - n = v->next; - value_free (v); - } - b->owner->val_chain = NULL; } else if ((b->owner->type == bp_catch_fork || b->owner->type == bp_catch_vfork || @@ -2616,10 +2626,15 @@ bpstat_stop_status (CORE_ADDR bp_addr, ptid_t ptid) if (!breakpoint_enabled (b) && b->enable_state != bp_permanent) continue; + /* Hardware watchpoints are treated as non-existent if the reason we + stopped wasn't a hardware watchpoint (we didn't stop on some data + address). Otherwise gdb won't stop on a break instruction in the code + (not from a breakpoint) when a hardware watchpoint has been defined. */ if (b->type != bp_watchpoint - && b->type != bp_hardware_watchpoint - && b->type != bp_read_watchpoint - && b->type != bp_access_watchpoint + && !((b->type == bp_hardware_watchpoint + || b->type == bp_read_watchpoint + || b->type == bp_access_watchpoint) + && target_stopped_data_address () != 0) && b->type != bp_hardware_breakpoint && b->type != bp_catch_fork && b->type != bp_catch_vfork @@ -6881,6 +6896,8 @@ delete_breakpoint (struct breakpoint *bpt) if (bpt->loc->inserted) remove_breakpoint (bpt->loc, mark_inserted); + free_valchain (bpt->loc); + if (breakpoint_chain == bpt) breakpoint_chain = bpt->next; diff --git a/gdb/infrun.c b/gdb/infrun.c index 0b4f05a..f546602 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1356,6 +1356,8 @@ adjust_pc_after_break (struct execution_control_state *ecs) by an event from the inferior, figure out what it means and take appropriate action. */ +int stepped_after_stopped_by_watchpoint; + void handle_inferior_event (struct execution_control_state *ecs) { @@ -1364,7 +1366,6 @@ handle_inferior_event (struct execution_control_state *ecs) isn't used, then you're wrong! The macro STOPPED_BY_WATCHPOINT, defined in the file "config/pa/nm-hppah.h", accesses the variable indirectly. Mutter something rude about the HP merge. */ - int stepped_after_stopped_by_watchpoint; int sw_single_step_trap_p = 0; /* Cache the last pid/waitstatus. */ diff --git a/gdb/remote.c b/gdb/remote.c index 1e173d2..384f011 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -4640,10 +4640,13 @@ remote_stopped_by_watchpoint (void) return remote_stopped_by_watchpoint_p; } +extern int stepped_after_stopped_by_watchpoint; + static CORE_ADDR remote_stopped_data_address (void) { - if (remote_stopped_by_watchpoint ()) + if (remote_stopped_by_watchpoint () + || stepped_after_stopped_by_watchpoint) return remote_watch_data_address; return (CORE_ADDR)0; } -- 2.7.4