From 8bea4e01db202d301348221cff486a4fe78e86a1 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Fri, 31 Jul 2009 14:31:16 +0000 Subject: * breakpoint.h (enum enable_state): Add bp_startup_disabled. (disable_breakpoints_before_startup): Add prototype. (enable_breakpoints_after_startup): Likewise. * breakpoint.c (executing_startup): New static variable. (describe_other_breakpoints): Handle bp_startup_disabled. (check_duplicates_for): Likewise. (disable_breakpoints_before_startup): New function. (enable_breakpoints_after_startup): New function. (create_breakpoint): Mark new breakpoints as bp_startup_disabled if executing_startup flag is true. (break_command_really): Likewise. (breakpoint_re_set_one): Skip bp_startup_disabled breakpoints. --- gdb/breakpoint.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) (limited to 'gdb/breakpoint.c') diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 3a18c8f..3e324c2 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -319,6 +319,9 @@ static int executing_breakpoint_commands; /* Are overlay event breakpoints enabled? */ static int overlay_events_enabled; +/* Are we executing startup code? */ +static int executing_startup; + /* Walk the following statement or block through all breakpoints. ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current breakpoint. */ @@ -4140,7 +4143,8 @@ describe_other_breakpoints (struct gdbarch *gdbarch, CORE_ADDR pc, printf_filtered (" (thread %d)", b->thread); printf_filtered ("%s%s ", ((b->enable_state == bp_disabled - || b->enable_state == bp_call_disabled) + || b->enable_state == bp_call_disabled + || b->enable_state == bp_startup_disabled) ? " (disabled)" : b->enable_state == bp_permanent ? " (permanent)" @@ -4211,6 +4215,7 @@ check_duplicates_for (CORE_ADDR address, struct obj_section *section) ALL_BP_LOCATIONS (b) if (b->owner->enable_state != bp_disabled && b->owner->enable_state != bp_call_disabled + && b->owner->enable_state != bp_startup_disabled && b->enabled && !b->shlib_disabled && b->address == address /* address / overlay match */ @@ -4247,6 +4252,7 @@ check_duplicates_for (CORE_ADDR address, struct obj_section *section) if (b->owner->enable_state != bp_permanent && b->owner->enable_state != bp_disabled && b->owner->enable_state != bp_call_disabled + && b->owner->enable_state != bp_startup_disabled && b->enabled && !b->shlib_disabled && b->address == address /* address / overlay match */ && (!overlay_debugging || b->section == section) @@ -5095,6 +5101,52 @@ enable_watchpoints_after_interactive_call_stop (void) } } +void +disable_breakpoints_before_startup (void) +{ + struct breakpoint *b; + int found = 0; + + ALL_BREAKPOINTS (b) + { + if ((b->type == bp_breakpoint + || b->type == bp_hardware_breakpoint) + && breakpoint_enabled (b)) + { + b->enable_state = bp_startup_disabled; + found = 1; + } + } + + if (found) + update_global_location_list (0); + + executing_startup = 1; +} + +void +enable_breakpoints_after_startup (void) +{ + struct breakpoint *b; + int found = 0; + + executing_startup = 0; + + ALL_BREAKPOINTS (b) + { + if ((b->type == bp_breakpoint + || b->type == bp_hardware_breakpoint) + && b->enable_state == bp_startup_disabled) + { + b->enable_state = bp_enabled; + found = 1; + } + } + + if (found) + breakpoint_re_set (); +} + /* Set a breakpoint that will evaporate an end of command at address specified by SAL. @@ -5438,6 +5490,11 @@ create_breakpoint (struct gdbarch *gdbarch, b->enable_state = enabled ? bp_enabled : bp_disabled; b->disposition = disposition; + if (enabled && executing_startup + && (b->type == bp_breakpoint + || b->type == bp_hardware_breakpoint)) + b->enable_state = bp_startup_disabled; + loc = b->loc; } else @@ -5993,6 +6050,11 @@ break_command_really (struct gdbarch *gdbarch, b->ops = ops; b->enable_state = enabled ? bp_enabled : bp_disabled; + if (enabled && executing_startup + && (b->type == bp_breakpoint + || b->type == bp_hardware_breakpoint)) + b->enable_state = bp_startup_disabled; + mention (b); } @@ -7792,6 +7854,10 @@ breakpoint_re_set_one (void *bint) case bp_breakpoint: case bp_hardware_breakpoint: case bp_tracepoint: + /* Do not attempt to re-set breakpoints disabled during startup. */ + if (b->enable_state == bp_startup_disabled) + return 0; + if (b->addr_string == NULL) { /* Anything without a string can't be re-set. */ -- cgit v1.1