static void breakpoint_adjustment_warning (CORE_ADDR, CORE_ADDR, int, int);
-static CORE_ADDR adjust_breakpoint_address (CORE_ADDR bpaddr);
+static CORE_ADDR adjust_breakpoint_address (CORE_ADDR bpaddr,
+ enum bptype bptype);
static void describe_other_breakpoints (CORE_ADDR, asection *);
if such is available. */
static int can_use_hw_watchpoints;
+/* If AUTO_BOOLEAN_FALSE, gdb will not attempt to create pending breakpoints.
+ If AUTO_BOOLEAN_TRUE, gdb will automatically create pending breakpoints
+ for unrecognized breakpoint locations.
+ If AUTO_BOOLEAN_AUTO, gdb will query when breakpoints are unrecognized. */
+static enum auto_boolean pending_break_support;
+
void _initialize_breakpoint (void);
extern int addressprint; /* Print machine addresses? */
/* Pointer to current exception event record */
static struct exception_event_record *current_exception_event;
-/* Indicator of whether exception catchpoints should be nuked
- between runs of a program */
-int exception_catchpoints_are_fragile = 0;
+/* Indicator of whether exception catchpoints should be nuked between
+ runs of a program. */
+int deprecated_exception_catchpoints_are_fragile = 0;
/* Indicator of when exception catchpoints set-up should be
- reinitialized -- e.g. when program is re-run */
-int exception_support_initialized = 0;
+ reinitialized -- e.g. when program is re-run. */
+int deprecated_exception_support_initialized = 0;
/* This function returns a pointer to the string representation of the
pathname of the dynamically-linked library that has just been
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.
must watch. As soon as a many-to-one mapping is available I'll
convert this. */
- struct frame_info *saved_frame;
- int saved_level, within_current_scope;
+ int within_current_scope;
struct value *mark = value_mark ();
struct value *v;
+ struct frame_id saved_frame_id;
- /* Save the current frame and level so we can restore it after
+ /* Save the current frame's ID so we can restore it after
evaluating the watchpoint expression on its own frame. */
/* FIXME drow/2003-09-09: It would be nice if evaluate_expression
took a frame parameter, so that we didn't have to change the
selected frame. */
- saved_frame = deprecated_selected_frame;
- saved_level = frame_relative_level (deprecated_selected_frame);
+ saved_frame_id = get_frame_id (deprecated_selected_frame);
/* Determine if the watchpoint is within scope. */
if (bpt->owner->exp_valid_block == NULL)
if (within_current_scope)
{
+ free_valchain (bpt);
+
/* Evaluate the expression and cut the chain of values
produced off from the value chain.
bpt->owner->disposition = disp_del_at_next_stop;
}
- /* Restore the frame and level. */
- if (saved_frame != deprecated_selected_frame
- || saved_level != frame_relative_level (deprecated_selected_frame))
- select_frame (saved_frame);
+ /* Restore the selected frame. */
+ select_frame (frame_find_by_id (saved_frame_id));
return val;
}
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 ||
default:
/* Likewise for exception catchpoints in dynamic-linked
executables where required */
- if (ep_is_exception_catchpoint (b) &&
- exception_catchpoints_are_fragile)
+ if (ep_is_exception_catchpoint (b)
+ && deprecated_exception_catchpoints_are_fragile)
{
warning_needed = 1;
delete_breakpoint (b);
}
}
- if (exception_catchpoints_are_fragile)
- exception_support_initialized = 0;
+ if (deprecated_exception_catchpoints_are_fragile)
+ deprecated_exception_support_initialized = 0;
/* Don't issue the warning unless it's really needed... */
if (warning_needed && (context != inf_exited))
return 0;
}
-/* Return nonzero if FRAME is a dummy frame. We can't use
- DEPRECATED_PC_IN_CALL_DUMMY because figuring out the saved SP would
- take too much time, at least using frame_register() on the 68k.
- This means that for this function to work right a port must use the
- bp_call_dummy breakpoint. */
-
-int
-deprecated_frame_in_dummy (struct frame_info *frame)
-{
- struct breakpoint *b;
-
- /* This function is used by two files: get_frame_type(), after first
- checking that !DEPRECATED_USE_GENERIC_DUMMY_FRAMES; and
- sparc-tdep.c, which doesn't yet use generic dummy frames anyway. */
- gdb_assert (!DEPRECATED_USE_GENERIC_DUMMY_FRAMES);
-
- ALL_BREAKPOINTS (b)
- {
- if (b->type == bp_call_dummy
- && frame_id_eq (b->frame_id, get_frame_id (frame))
- /* We need to check the PC as well as the frame on the sparc,
- for signals.exp in the testsuite. */
- && (get_frame_pc (frame)
- >= (b->loc->address
- - DEPRECATED_SIZEOF_CALL_DUMMY_WORDS / sizeof (LONGEST) * DEPRECATED_REGISTER_SIZE))
- && get_frame_pc (frame) <= b->loc->address)
- return 1;
- }
- return 0;
-}
-
/* breakpoint_thread_match (PC, PTID) returns true if the breakpoint at
PC is valid for process/thread PTID. */
}
/* Get a bpstat associated with having just stopped at address
- BP_ADDR. */
+ BP_ADDR in thread PTID. STOPPED_BY_WATCHPOINT is 1 if the
+ target thinks we stopped due to a hardware watchpoint, 0 if we
+ know we did not trigger a hardware watchpoint, and -1 if we do not know. */
/* Determine whether we stopped at a breakpoint, etc, or whether we
don't understand this stop. Result is a chain of bpstat's such that:
commands, FIXME??? fields. */
bpstat
-bpstat_stop_status (CORE_ADDR bp_addr, ptid_t ptid)
+bpstat_stop_status (CORE_ADDR bp_addr, ptid_t ptid, int stopped_by_watchpoint)
{
struct breakpoint *b, *temp;
/* True if we've hit a breakpoint (as opposed to a watchpoint). */
continue;
}
+ /* Continuable 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_hardware_watchpoint
+ || b->type == bp_read_watchpoint
+ || b->type == bp_access_watchpoint)
+ && !stopped_by_watchpoint)
+ continue;
+
if (b->type == bp_hardware_breakpoint)
{
if (b->loc->address != bp_addr)
/* step_resume entries: a step resume breakpoint overrides another
breakpoint of signal handling (see comment in wait_for_inferior
- at first PC_IN_SIGTRAMP where we set the step_resume breakpoint). */
+ at where we set the step_resume breakpoint). */
/* We handle the through_sigtramp_breakpoint the same way; having both
one of those and a step_resume_breakpoint is probably very rare (?). */
{
annotate_field (4);
if (b->pending)
- {
- ui_out_field_string (uiout, "addr", "<PENDING>");
- if (TARGET_ADDR_BIT <= 32)
- ui_out_spaces (uiout, 2);
- else
- ui_out_spaces (uiout, 8);
- }
+ ui_out_field_string (uiout, "addr", "<PENDING>");
else
ui_out_field_core_addr (uiout, "addr", b->loc->address);
}
this function is simply the identity function. */
static CORE_ADDR
-adjust_breakpoint_address (CORE_ADDR bpaddr)
+adjust_breakpoint_address (CORE_ADDR bpaddr, enum bptype bptype)
{
if (!gdbarch_adjust_breakpoint_address_p (current_gdbarch))
{
/* Very few targets need any kind of breakpoint adjustment. */
return bpaddr;
}
+ else if (bptype == bp_watchpoint
+ || bptype == bp_hardware_watchpoint
+ || bptype == bp_read_watchpoint
+ || bptype == bp_access_watchpoint
+ || bptype == bp_catch_fork
+ || bptype == bp_catch_vfork
+ || bptype == bp_catch_exec)
+ {
+ /* Watchpoints and the various bp_catch_* eventpoints should not
+ have their addresses modified. */
+ return bpaddr;
+ }
else
{
CORE_ADDR adjusted_bpaddr;
memset (b, 0, sizeof (*b));
b->loc = allocate_bp_location (b, bptype);
b->loc->requested_address = sal.pc;
- b->loc->address = adjust_breakpoint_address (b->loc->requested_address);
+ b->loc->address = adjust_breakpoint_address (b->loc->requested_address,
+ bptype);
if (sal.symtab == NULL)
b->source_file = NULL;
else
b->enable_state = bp_enabled;
/* addr_string has to be used or breakpoint_re_set will delete me. */
- xasprintf (&b->addr_string, "*0x%s", paddr (b->loc->address));
+ b->addr_string = xstrprintf ("*0x%s", paddr (b->loc->address));
return b;
}
if (b->type == bp_longjmp_resume)
{
b->loc->requested_address = pc;
- b->loc->address = adjust_breakpoint_address (b->loc->requested_address);
+ b->loc->address = adjust_breakpoint_address (b->loc->requested_address,
+ b->type);
b->enable_state = bp_enabled;
b->frame_id = frame_id;
check_duplicates (b);
stb = ui_out_stream_new (uiout);
old_chain = make_cleanup_ui_out_stream_delete (stb);
- /* FIXME: This is misplaced; mention() is called by things (like hitting a
- watchpoint) other than breakpoint creation. It should be possible to
- clean this up and at the same time replace the random calls to
- breakpoint_changed with this hook, as has already been done for
- delete_breakpoint_hook and so on. */
- if (create_breakpoint_hook)
- create_breakpoint_hook (b);
+ /* FIXME: This is misplaced; mention() is called by things (like
+ hitting a watchpoint) other than breakpoint creation. It should
+ be possible to clean this up and at the same time replace the
+ random calls to breakpoint_changed with this hook, as has already
+ been done for deprecated_delete_breakpoint_hook and so on. */
+ if (deprecated_create_breakpoint_hook)
+ deprecated_create_breakpoint_hook (b);
breakpoint_create_event (b->number);
if (b->ops != NULL && b->ops->print_mention != NULL)
else
/* addr_string has to be used or breakpoint_re_set will delete
me. */
- xasprintf (&b->addr_string, "*0x%s", paddr (b->loc->address));
+ b->addr_string = xstrprintf ("*0x%s", paddr (b->loc->address));
b->cond_string = cond_string[i];
b->ignore_count = ignore_count;
b->enable_state = bp_enabled;
be copied too. */
if (pending_bp->commands)
b->commands = copy_command_lines (pending_bp->commands);
+
+ /* We have to copy over the ignore_count and thread as well. */
+ b->ignore_count = pending_bp->ignore_count;
+ b->thread = pending_bp->thread;
}
mention (b);
}
Give the target a chance to bless sals.sals[i].pc before we
try to make a breakpoint for it. */
- if (PC_REQUIRES_RUN_BEFORE_USE (sals->sals[i].pc))
+#ifdef DEPRECATED_PC_REQUIRES_RUN_BEFORE_USE
+ if (DEPRECATED_PC_REQUIRES_RUN_BEFORE_USE (sals->sals[i].pc))
{
if (address == NULL)
error ("Cannot break without a running program.");
error ("Cannot break on %s without a running program.",
address);
}
+#endif
}
}
error_output_message (NULL, err_msg);
xfree (err_msg);
- if (!query ("Make breakpoint pending on future shared library load? "))
+
+ /* If pending breakpoint support is turned off, throw error. */
+
+ if (pending_break_support == AUTO_BOOLEAN_FALSE)
+ throw_exception (RETURN_ERROR);
+
+ /* If pending breakpoint support is auto query and the user selects
+ no, then simply return the error code. */
+ if (pending_break_support == AUTO_BOOLEAN_AUTO &&
+ !nquery ("Make breakpoint pending on future shared library load? "))
return rc;
+
+ /* At this point, either the user was queried about setting a
+ pending breakpoint and selected yes, or pending breakpoint
+ behavior is on and thus a pending breakpoint is defaulted
+ on behalf of the user. */
copy_arg = xstrdup (addr_start);
addr_string = ©_arg;
sals.nelts = 1;
scope_breakpoint->loc->requested_address
= get_frame_pc (prev_frame);
scope_breakpoint->loc->address
- = adjust_breakpoint_address (scope_breakpoint->loc->requested_address);
+ = adjust_breakpoint_address (scope_breakpoint->loc->requested_address,
+ scope_breakpoint->type);
/* The scope breakpoint is related to the watchpoint. We
will need to act on them together. */
in hardware. If the watchpoint can not be handled
in hardware return zero. */
-#if !defined(TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT)
-#define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(BYTE_SIZE) \
- ((BYTE_SIZE) <= (DEPRECATED_REGISTER_SIZE))
-#endif
-
#if !defined(TARGET_REGION_OK_FOR_HW_WATCHPOINT)
#define TARGET_REGION_OK_FOR_HW_WATCHPOINT(ADDR,LEN) \
(TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(LEN))
if (bpt->type == bp_none)
return;
- if (delete_breakpoint_hook)
- delete_breakpoint_hook (bpt);
+ if (deprecated_delete_breakpoint_hook)
+ deprecated_delete_breakpoint_hook (bpt);
breakpoint_delete_event (bpt->number);
if (bpt->loc->inserted)
remove_breakpoint (bpt->loc, mark_inserted);
+ free_valchain (bpt->loc);
+
if (breakpoint_chain == bpt)
breakpoint_chain = bpt->next;
b->line_number = sals.sals[i].line;
b->loc->requested_address = sals.sals[i].pc;
b->loc->address
- = adjust_breakpoint_address (b->loc->requested_address);
+ = adjust_breakpoint_address (b->loc->requested_address,
+ b->type);
/* Used to check for duplicates here, but that can
cause trouble, as it doesn't check for disabled
check_duplicates (bpt);
- if (modify_breakpoint_hook)
- modify_breakpoint_hook (bpt);
+ if (deprecated_modify_breakpoint_hook)
+ deprecated_modify_breakpoint_hook (bpt);
breakpoint_modify_event (bpt->number);
}
static void
do_enable_breakpoint (struct breakpoint *bpt, enum bpdisp disposition)
{
- struct frame_info *save_selected_frame = NULL;
- int save_selected_frame_level = -1;
int target_resources_ok, other_type_used;
struct value *mark;
bpt->type == bp_read_watchpoint ||
bpt->type == bp_access_watchpoint)
{
+ struct frame_id saved_frame_id;
+
+ saved_frame_id = get_frame_id (get_selected_frame ());
if (bpt->exp_valid_block != NULL)
{
struct frame_info *fr =
bpt->enable_state = bp_disabled;
return;
}
-
- save_selected_frame = deprecated_selected_frame;
- save_selected_frame_level = frame_relative_level (deprecated_selected_frame);
select_frame (fr);
}
}
}
- if (save_selected_frame_level >= 0)
- select_frame (save_selected_frame);
+ select_frame (frame_find_by_id (saved_frame_id));
value_free_to_mark (mark);
}
}
- if (modify_breakpoint_hook)
- modify_breakpoint_hook (bpt);
+ if (deprecated_modify_breakpoint_hook)
+ deprecated_modify_breakpoint_hook (bpt);
breakpoint_modify_event (bpt->number);
}
map_breakpoint_numbers (args, enable_delete_breakpoint);
}
\f
+static void
+set_breakpoint_cmd (char *args, int from_tty)
+{
+}
+
+static void
+show_breakpoint_cmd (char *args, int from_tty)
+{
+}
+
/* Use default_breakpoint_'s, or nothing if they aren't valid. */
struct symtabs_and_lines
void
_initialize_breakpoint (void)
{
+ static struct cmd_list_element *breakpoint_set_cmdlist;
+ static struct cmd_list_element *breakpoint_show_cmdlist;
struct cmd_list_element *c;
breakpoint_chain = 0;
add_show_from_set (c, &showlist);
can_use_hw_watchpoints = 1;
+
+ add_prefix_cmd ("breakpoint", class_maintenance, set_breakpoint_cmd, "\
+Breakpoint specific settings\n\
+Configure various breakpoint-specific variables such as\n\
+pending breakpoint behavior",
+ &breakpoint_set_cmdlist, "set breakpoint ",
+ 0/*allow-unknown*/, &setlist);
+ add_prefix_cmd ("breakpoint", class_maintenance, show_breakpoint_cmd, "\
+Breakpoint specific settings\n\
+Configure various breakpoint-specific variables such as\n\
+pending breakpoint behavior",
+ &breakpoint_show_cmdlist, "show breakpoint ",
+ 0/*allow-unknown*/, &showlist);
+
+ add_setshow_auto_boolean_cmd ("pending", no_class, &pending_break_support, "\
+Set debugger's behavior regarding pending breakpoints.\n\
+If on, an unrecognized breakpoint location will cause gdb to create a\n\
+pending breakpoint. If off, an unrecognized breakpoint location results in\n\
+an error. If auto, an unrecognized breakpoint location results in a\n\
+user-query to see if a pending breakpoint should be created.","\
+Show debugger's behavior regarding pending breakpoints.\n\
+If on, an unrecognized breakpoint location will cause gdb to create a\n\
+pending breakpoint. If off, an unrecognized breakpoint location results in\n\
+an error. If auto, an unrecognized breakpoint location results in a\n\
+user-query to see if a pending breakpoint should be created.",
+ NULL, NULL,
+ &breakpoint_set_cmdlist,
+ &breakpoint_show_cmdlist);
+
+ pending_break_support = AUTO_BOOLEAN_AUTO;
}