static struct bp_location *
allocate_bp_location (struct breakpoint *bpt, enum bptype bp_type);
-static void update_global_location_list (void);
+static void update_global_location_list (int);
-static void update_global_location_list_nothrow (void);
+static void update_global_location_list_nothrow (int);
static int is_hardware_watchpoint (struct breakpoint *bpt);
if (is_hardware_watchpoint (bpt))
update_watchpoint (bpt, 0 /* don't reparse. */);
- update_global_location_list ();
+ update_global_location_list (1);
if (!always_inserted_mode && target_has_execution)
/* update_global_location_list does not insert breakpoints
struct breakpoint *b;
struct breakpoint *temp;
struct bp_location *bploc;
- struct cleanup *cleanup;
/* We're about to delete breakpoints from GDB's lists. If the
INSERTED flag is true, GDB will try to lift the breakpoints by
ALL_BP_LOCATIONS (bploc)
gdb_assert (!bploc->inserted);
- /* The binary we used to debug is now gone, and we're updating
- breakpoints for the new binary. Until we're done, we should not
- try to insert breakpoints. */
- cleanup = make_cleanup_restore_integer (&always_inserted_mode);
- always_inserted_mode = 0;
-
ALL_BREAKPOINTS_SAFE (b, temp)
{
/* Solib breakpoints must be explicitly reset after an exec(). */
}
/* FIXME what about longjmp breakpoints? Re-create them here? */
create_overlay_event_breakpoint ("_ovly_debug_event");
- do_cleanups (cleanup);
}
int
if (b->disposition == disp_disable)
{
b->enable_state = bp_disabled;
- update_global_location_list ();
+ update_global_location_list (0);
}
if (b->silent)
bs->print = 0;
if ((m = lookup_minimal_symbol_text (func_name, NULL)) == NULL)
return;
set_momentary_breakpoint_at_pc (SYMBOL_VALUE_ADDRESS (m), bp_longjmp);
- update_global_location_list ();
+ update_global_location_list (1);
}
/* Call this routine when stepping and nexting to enable a breakpoint
b->enable_state = bp_disabled;
overlay_events_enabled = 0;
}
- update_global_location_list ();
+ update_global_location_list (1);
}
void
if (b->type == bp_overlay_event)
{
b->enable_state = bp_enabled;
- update_global_location_list ();
+ update_global_location_list (1);
overlay_events_enabled = 1;
}
}
if (b->type == bp_overlay_event)
{
b->enable_state = bp_disabled;
- update_global_location_list ();
+ update_global_location_list (0);
overlay_events_enabled = 0;
}
}
/* addr_string has to be used or breakpoint_re_set will delete me. */
b->addr_string = xstrprintf ("*0x%s", paddr (b->loc->address));
- update_global_location_list_nothrow ();
+ update_global_location_list_nothrow (1);
return b;
}
struct breakpoint *b;
b = create_internal_breakpoint (address, bp_shlib_event);
- update_global_location_list_nothrow ();
+ update_global_location_list_nothrow (1);
return b;
}
b->enable_state = bp_enabled;
b->disposition = tempflag ? disp_del : disp_donttouch;
b->forked_inferior_pid = 0;
- update_global_location_list ();
+ update_global_location_list (1);
mention (b);
b->addr_string = NULL;
b->enable_state = bp_enabled;
b->disposition = tempflag ? disp_del : disp_donttouch;
- update_global_location_list ();
+ update_global_location_list (1);
mention (b);
}
&& breakpoint_enabled (b))
{
b->enable_state = bp_call_disabled;
- update_global_location_list ();
+ update_global_location_list (0);
}
}
}
&& (b->enable_state == bp_call_disabled))
{
b->enable_state = bp_enabled;
- update_global_location_list ();
+ update_global_location_list (1);
}
}
}
if (in_thread_list (inferior_ptid))
b->thread = pid_to_thread_id (inferior_ptid);
- update_global_location_list_nothrow ();
+ update_global_location_list_nothrow (1);
return b;
}
thread, ignore_count, ops, from_tty);
}
- update_global_location_list ();
+ update_global_location_list (1);
}
/* Parse ARG which is assumed to be a SAL specification possibly
b->condition_not_parsed = 1;
b->ops = ops;
- update_global_location_list ();
+ update_global_location_list (1);
mention (b);
}
value_free_to_mark (mark);
mention (b);
- update_global_location_list ();
+ update_global_location_list (1);
}
/* Return count of locations need to be watched and can be handled
b->ops = ops;
mention (b);
- update_global_location_list ();
+ update_global_location_list (1);
}
/* Implement the "catch exception" command. */
}
}
+/* If SHOULD_INSERT is true, do not insert any breakpoint locations
+ into the inferior, only remove already-inserted locations that no
+ longer should be inserted. Functions that delete a breakpoint or
+ breakpoints should pass false, so that deleting a breakpoint
+ doesn't have the side effect of inserting the locations of other
+ breakpoints that are marked not-inserted, but should_be_inserted
+ returns true on them.
+
+ This behaviour is useful is situations close to tear-down -- e.g.,
+ after an exec, while the target still has execution, but breakpoint
+ shadows of the previous executable image should *NOT* be restored
+ to the new image; or before detaching, where the target still has
+ execution and wants to delete breakpoints from GDB's lists, and all
+ breakpoints had already been removed from the inferior. */
+
static void
-update_global_location_list (void)
+update_global_location_list (int should_insert)
{
struct breakpoint *b;
struct bp_location **next = &bp_location_chain;
check_duplicates (b);
}
- if (always_inserted_mode && target_has_execution)
+ if (always_inserted_mode && should_insert && target_has_execution)
insert_breakpoint_locations ();
}
}
static void
-update_global_location_list_nothrow (void)
+update_global_location_list_nothrow (int inserting)
{
struct gdb_exception e;
TRY_CATCH (e, RETURN_MASK_ERROR)
- update_global_location_list ();
+ update_global_location_list (inserting);
}
/* Delete a breakpoint and clean up all traces of it in the data
looks at location's owner. It might be better
design to have location completely self-contained,
but it's not the case now. */
- update_global_location_list ();
+ update_global_location_list (0);
/* On the chance that someone will soon try again to delete this same
}
}
- update_global_location_list ();
+ update_global_location_list (1);
}
bpt->enable_state = bp_disabled;
- update_global_location_list ();
+ update_global_location_list (0);
if (deprecated_modify_breakpoint_hook)
deprecated_modify_breakpoint_hook (bpt);
struct bp_location *loc = find_location_by_number (args);
if (loc)
loc->enabled = 0;
- update_global_location_list ();
+ update_global_location_list (0);
}
else
map_breakpoint_numbers (args, disable_breakpoint);
if (bpt->enable_state != bp_permanent)
bpt->enable_state = bp_enabled;
bpt->disposition = disposition;
- update_global_location_list ();
+ update_global_location_list (1);
breakpoints_changed ();
if (deprecated_modify_breakpoint_hook)
struct bp_location *loc = find_location_by_number (args);
if (loc)
loc->enabled = 1;
- update_global_location_list ();
+ update_global_location_list (1);
}
else
map_breakpoint_numbers (args, enable_breakpoint);