/* Everything about breakpoints, for GDB.
Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
- 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software
+ 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
Foundation, Inc.
This file is part of GDB.
#include "gdb.h"
#include "ui-out.h"
#include "cli/cli-script.h"
+#include "gdb_assert.h"
#include "gdb-events.h"
static void ignore_command (char *, int);
-static int breakpoint_re_set_one (PTR);
+static int breakpoint_re_set_one (void *);
static void clear_command (char *, int);
static bpstat bpstat_alloc (struct breakpoint *, bpstat);
-static int breakpoint_cond_eval (PTR);
+static int breakpoint_cond_eval (void *);
-static void cleanup_executing_breakpoints (PTR);
+static void cleanup_executing_breakpoints (void *);
static void commands_command (char *, int);
}
args_for_catchpoint_enable;
-static int watchpoint_check (PTR);
+static int watchpoint_check (void *);
-static int cover_target_enable_exception_callback (PTR);
+static int cover_target_enable_exception_callback (void *);
static void maintenance_info_breakpoints (char *, int);
ALL_BREAKPOINTS_SAFE (b, temp)
{
- if (b->enable_state == bp_permanent)
- /* Permanent breakpoints cannot be inserted or removed. */
+ /* Permanent breakpoints cannot be inserted or removed. Disabled
+ breakpoints should not be inserted. */
+ if (b->enable_state != bp_enabled)
continue;
+
if ((b->type == bp_watchpoint
|| b->type == bp_hardware_watchpoint
|| b->type == bp_read_watchpoint
&& b->type != bp_catch_exec
&& b->type != bp_catch_throw
&& b->type != bp_catch_catch
- && b->enable_state != bp_disabled
- && b->enable_state != bp_shlib_disabled
- && b->enable_state != bp_call_disabled
&& !b->inserted
&& !b->duplicate)
{
return_val = val; /* remember failure */
}
else if (ep_is_exception_catchpoint (b)
- && b->enable_state != bp_disabled
- && b->enable_state != bp_shlib_disabled
- && b->enable_state != bp_call_disabled
&& !b->inserted
&& !b->duplicate)
else if ((b->type == bp_hardware_watchpoint ||
b->type == bp_read_watchpoint ||
b->type == bp_access_watchpoint)
- && b->enable_state == bp_enabled
&& b->disposition != disp_del_at_next_stop
&& !b->inserted
&& !b->duplicate)
/* Save the current frame and level so we can restore it after
evaluating the watchpoint expression on its own frame. */
- saved_frame = selected_frame;
- saved_level = frame_relative_level (selected_frame);
+ saved_frame = deprecated_selected_frame;
+ saved_level = frame_relative_level (deprecated_selected_frame);
/* Determine if the watchpoint is within scope. */
if (b->exp_valid_block == NULL)
}
/* Restore the frame and level. */
- if ((saved_frame != selected_frame) ||
- (saved_level != frame_relative_level (selected_frame)))
+ if ((saved_frame != deprecated_selected_frame) ||
+ (saved_level != frame_relative_level (deprecated_selected_frame)))
select_frame (saved_frame);
if (val)
else if ((b->type == bp_catch_fork
|| b->type == bp_catch_vfork
|| b->type == bp_catch_exec)
- && b->enable_state == bp_enabled
&& !b->inserted
&& !b->duplicate)
{
automagically. Certainly on HP-UX that's true.
Jim Blandy <jimb@redhat.com>: Actually, zero is a perfectly
- valid code address on some platforms (like the mn10200 and
- mn10300 simulators). We shouldn't assign any special
+ valid code address on some platforms (like the OBSOLETE mn10200
+ and mn10300 simulators). We shouldn't assign any special
interpretation to a breakpoint with a zero address. And in
fact, GDB doesn't --- I can't see what that comment above is
talking about. As far as I can tell, setting the address of a
}
/* Return nonzero if FRAME is a dummy frame. We can't use
- PC_IN_CALL_DUMMY because figuring out the saved SP would take too
- much time, at least using get_saved_register on the 68k. This
- means that for this function to work right a port must use the
+ DEPRECATED_PC_IN_CALL_DUMMY because figuring out the saved SP would
+ take too much time, at least using get_saved_register on the 68k.
+ This means that for this function to work right a port must use the
bp_call_dummy breakpoint. */
int
if (!CALL_DUMMY_P)
return 0;
- if (USE_GENERIC_DUMMY_FRAMES)
- return generic_pc_in_call_dummy (frame->pc, frame->frame, frame->frame);
+ /* 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
- && b->frame == frame->frame
+ && 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. */
- && (frame->pc
+ && (get_frame_pc (frame)
>= (b->address
- - SIZEOF_CALL_DUMMY_WORDS / sizeof (LONGEST) * REGISTER_SIZE))
- && frame->pc <= b->address)
+ - SIZEOF_CALL_DUMMY_WORDS / sizeof (LONGEST) * REGISTER_SIZE))
+ && get_frame_pc (frame) <= b->address)
return 1;
}
return 0;
/* Stub for cleaning up our state if we error-out of a breakpoint command */
/* ARGSUSED */
static void
-cleanup_executing_breakpoints (PTR ignore)
+cleanup_executing_breakpoints (void *ignore)
{
executing_breakpoint_commands = 0;
}
static enum print_stop_action
print_it_typical (bpstat bs)
{
- struct cleanup *old_chain;
+ struct cleanup *old_chain, *ui_out_chain;
struct ui_stream *stb;
stb = ui_out_stream_new (uiout);
old_chain = make_cleanup_ui_out_stream_delete (stb);
if (ui_out_is_mi_like_p (uiout))
ui_out_field_string (uiout, "reason", "watchpoint-trigger");
mention (bs->breakpoint_at);
- ui_out_tuple_begin (uiout, "value");
+ ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
ui_out_text (uiout, "\nOld value = ");
value_print (bs->old_val, stb->stream, 0, Val_pretty_default);
ui_out_field_stream (uiout, "old", stb);
ui_out_text (uiout, "\nNew value = ");
value_print (bs->breakpoint_at->val, stb->stream, 0, Val_pretty_default);
ui_out_field_stream (uiout, "new", stb);
- ui_out_tuple_end (uiout);
+ do_cleanups (ui_out_chain);
ui_out_text (uiout, "\n");
value_free (bs->old_val);
bs->old_val = NULL;
if (ui_out_is_mi_like_p (uiout))
ui_out_field_string (uiout, "reason", "read-watchpoint-trigger");
mention (bs->breakpoint_at);
- ui_out_tuple_begin (uiout, "value");
+ ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
ui_out_text (uiout, "\nValue = ");
value_print (bs->breakpoint_at->val, stb->stream, 0, Val_pretty_default);
ui_out_field_stream (uiout, "value", stb);
- ui_out_tuple_end (uiout);
+ do_cleanups (ui_out_chain);
ui_out_text (uiout, "\n");
return PRINT_UNKNOWN;
break;
if (ui_out_is_mi_like_p (uiout))
ui_out_field_string (uiout, "reason", "access-watchpoint-trigger");
mention (bs->breakpoint_at);
- ui_out_tuple_begin (uiout, "value");
+ ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
ui_out_text (uiout, "\nOld value = ");
value_print (bs->old_val, stb->stream, 0, Val_pretty_default);
ui_out_field_stream (uiout, "old", stb);
mention (bs->breakpoint_at);
if (ui_out_is_mi_like_p (uiout))
ui_out_field_string (uiout, "reason", "access-watchpoint-trigger");
- ui_out_tuple_begin (uiout, "value");
+ ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
ui_out_text (uiout, "\nValue = ");
}
value_print (bs->breakpoint_at->val, stb->stream, 0,Val_pretty_default);
ui_out_field_stream (uiout, "new", stb);
- ui_out_tuple_end (uiout);
+ do_cleanups (ui_out_chain);
ui_out_text (uiout, "\n");
return PRINT_UNKNOWN;
break;
make it pass through catch_errors. */
static int
-breakpoint_cond_eval (PTR exp)
+breakpoint_cond_eval (void *exp)
{
struct value *mark = value_mark ();
int i = !value_true (evaluate_expression ((struct expression *) exp));
/* Check watchpoint condition. */
static int
-watchpoint_check (PTR p)
+watchpoint_check (void *p)
{
bpstat bs = (bpstat) p;
struct breakpoint *b;
real_breakpoint = 1;
}
- if (b->frame &&
- b->frame != (get_current_frame ())->frame)
+ if (frame_id_p (b->frame_id)
+ && !frame_id_eq (b->frame_id, get_frame_id (get_current_frame ())))
bs->stop = 0;
else
{
char wrap_indent[80];
struct ui_stream *stb = ui_out_stream_new (uiout);
struct cleanup *old_chain = make_cleanup_ui_out_stream_delete (stb);
+ struct cleanup *bkpt_chain;
annotate_record ();
- ui_out_tuple_begin (uiout, "bkpt");
+ bkpt_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "bkpt");
/* 1 */
annotate_field (0);
ui_out_text (uiout, "\n");
- if (b->frame)
+ if (frame_id_p (b->frame_id))
{
annotate_field (6);
ui_out_text (uiout, "\tstop only in stack frame at ");
- ui_out_field_core_addr (uiout, "frame", b->frame);
+ /* FIXME: cagney/2002-12-01: Shouldn't be poeking around inside
+ the frame ID. */
+ ui_out_field_core_addr (uiout, "frame", b->frame_id.base);
ui_out_text (uiout, "\n");
}
if ((l = b->commands))
{
+ struct cleanup *script_chain;
+
annotate_field (9);
- ui_out_tuple_begin (uiout, "script");
+ script_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "script");
print_command_lines (uiout, l, 4);
- ui_out_tuple_end (uiout);
+ do_cleanups (script_chain);
}
- ui_out_tuple_end (uiout);
+ do_cleanups (bkpt_chain);
do_cleanups (old_chain);
}
register struct breakpoint *b;
CORE_ADDR last_addr = (CORE_ADDR) -1;
int nr_printable_breakpoints;
+ struct cleanup *bkpttbl_chain;
/* Compute the number of rows in the table. */
nr_printable_breakpoints = 0;
}
if (addressprint)
- ui_out_table_begin (uiout, 6, nr_printable_breakpoints, "BreakpointTable");
+ bkpttbl_chain
+ = make_cleanup_ui_out_table_begin_end (uiout, 6, nr_printable_breakpoints,
+ "BreakpointTable");
else
- ui_out_table_begin (uiout, 5, nr_printable_breakpoints, "BreakpointTable");
+ bkpttbl_chain
+ = make_cleanup_ui_out_table_begin_end (uiout, 5, nr_printable_breakpoints,
+ "BreakpointTable");
if (nr_printable_breakpoints > 0)
annotate_breakpoints_headers ();
print_one_breakpoint (b, &last_addr);
}
- ui_out_table_end (uiout);
+ do_cleanups (bkpttbl_chain);
if (nr_printable_breakpoints == 0)
{
b->silent = 0;
b->ignore_count = 0;
b->commands = NULL;
- b->frame = 0;
+ b->frame_id = null_frame_id;
b->dll_pathname = NULL;
b->triggered_dll_pathname = NULL;
b->forked_inferior_pid = 0;
create_thread_event_breakpoint (CORE_ADDR address)
{
struct breakpoint *b;
- char addr_string[80]; /* Surely an addr can't be longer than that. */
b = create_internal_breakpoint (address, bp_thread_event);
b->enable_state = bp_enabled;
/* addr_string has to be used or breakpoint_re_set will delete me. */
- sprintf (addr_string, "*0x%s", paddr (b->address));
- b->addr_string = xstrdup (addr_string);
+ xasprintf (&b->addr_string, "*0x%s", paddr (b->address));
return b;
}
that gets deleted automatically... */
void
-set_longjmp_resume_breakpoint (CORE_ADDR pc, struct frame_info *frame)
+set_longjmp_resume_breakpoint (CORE_ADDR pc, struct frame_id frame_id)
{
register struct breakpoint *b;
{
b->address = pc;
b->enable_state = bp_enabled;
- if (frame != NULL)
- b->frame = frame->frame;
- else
- b->frame = 0;
+ b->frame_id = frame_id;
check_duplicates (b);
return;
}
Restrict it to frame FRAME if FRAME is nonzero. */
struct breakpoint *
-set_momentary_breakpoint (struct symtab_and_line sal, struct frame_info *frame,
+set_momentary_breakpoint (struct symtab_and_line sal, struct frame_id frame_id,
enum bptype type)
{
register struct breakpoint *b;
b = set_raw_breakpoint (sal, type);
b->enable_state = bp_enabled;
b->disposition = disp_donttouch;
- b->frame = (frame ? frame->frame : 0);
+ b->frame_id = frame_id;
/* If we're debugging a multi-threaded program, then we
want momentary breakpoints to be active in only a
mention (struct breakpoint *b)
{
int say_where = 0;
- struct cleanup *old_chain;
+ struct cleanup *old_chain, *ui_out_chain;
struct ui_stream *stb;
stb = ui_out_stream_new (uiout);
break;
case bp_watchpoint:
ui_out_text (uiout, "Watchpoint ");
- ui_out_tuple_begin (uiout, "wpt");
+ ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "wpt");
ui_out_field_int (uiout, "number", b->number);
ui_out_text (uiout, ": ");
print_expression (b->exp, stb->stream);
ui_out_field_stream (uiout, "exp", stb);
- ui_out_tuple_end (uiout);
+ do_cleanups (ui_out_chain);
break;
case bp_hardware_watchpoint:
ui_out_text (uiout, "Hardware watchpoint ");
- ui_out_tuple_begin (uiout, "wpt");
+ ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "wpt");
ui_out_field_int (uiout, "number", b->number);
ui_out_text (uiout, ": ");
print_expression (b->exp, stb->stream);
ui_out_field_stream (uiout, "exp", stb);
- ui_out_tuple_end (uiout);
+ do_cleanups (ui_out_chain);
break;
case bp_read_watchpoint:
ui_out_text (uiout, "Hardware read watchpoint ");
- ui_out_tuple_begin (uiout, "hw-rwpt");
+ ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-rwpt");
ui_out_field_int (uiout, "number", b->number);
ui_out_text (uiout, ": ");
print_expression (b->exp, stb->stream);
ui_out_field_stream (uiout, "exp", stb);
- ui_out_tuple_end (uiout);
+ do_cleanups (ui_out_chain);
break;
case bp_access_watchpoint:
ui_out_text (uiout, "Hardware access (read/write) watchpoint ");
- ui_out_tuple_begin (uiout, "hw-awpt");
+ ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-awpt");
ui_out_field_int (uiout, "number", b->number);
ui_out_text (uiout, ": ");
print_expression (b->exp, stb->stream);
ui_out_field_stream (uiout, "exp", stb);
- ui_out_tuple_end (uiout);
+ do_cleanups (ui_out_chain);
break;
case bp_breakpoint:
if (ui_out_is_mi_like_p (uiout))
b->number = breakpoint_count;
b->cond = cond[i];
b->thread = thread;
- b->addr_string = addr_string[i];
+ if (addr_string[i])
+ b->addr_string = addr_string[i];
+ else
+ /* addr_string has to be used or breakpoint_re_set will delete
+ me. */
+ xasprintf (&b->addr_string, "*0x%s", paddr (b->address));
b->cond_string = cond_string[i];
b->ignore_count = ignore_count;
b->enable_state = bp_enabled;
if (default_breakpoint_valid)
{
- if (selected_frame)
+ if (deprecated_selected_frame)
{
- selected_pc = selected_frame->pc;
+ selected_pc = get_frame_pc (deprecated_selected_frame);
if (arg)
if_arg = 1;
}
frame = parse_frame_specification (level_arg);
if (frame)
- selected_pc = frame->pc;
+ selected_pc = get_frame_pc (frame);
else
selected_pc = 0;
}
{
if (default_breakpoint_valid)
{
- if (selected_frame)
+ if (deprecated_selected_frame)
{
addr_string = (char *) xmalloc (15);
- sprintf (addr_string, "*0x%s", paddr_nz (selected_frame->pc));
+ sprintf (addr_string, "*0x%s",
+ paddr_nz (get_frame_pc (deprecated_selected_frame)));
if (arg)
if_arg = 1;
}
if (frame)
{
prev_frame = get_prev_frame (frame);
- get_frame_id (frame, &b->watchpoint_frame);
+ b->watchpoint_frame = get_frame_id (frame);
}
else
{
scope_breakpoint->disposition = disp_del;
/* Only break in the proper frame (help with recursion). */
- scope_breakpoint->frame = prev_frame->frame;
+ scope_breakpoint->frame_id = get_frame_id (prev_frame);
/* Set the address at which we will stop. */
scope_breakpoint->address = get_frame_pc (prev_frame);
/* ARGSUSED */
void
-until_break_command (char *arg, int from_tty)
+until_break_command (char *arg, int from_tty, int anywhere)
{
struct symtabs_and_lines sals;
struct symtab_and_line sal;
- struct frame_info *prev_frame = get_prev_frame (selected_frame);
+ struct frame_info *prev_frame = get_prev_frame (deprecated_selected_frame);
struct breakpoint *breakpoint;
struct cleanup *old_chain;
struct continuation_arg *arg1;
resolve_sal_pc (&sal);
- breakpoint = set_momentary_breakpoint (sal, selected_frame, bp_until);
+ if (anywhere)
+ /* If the user told us to continue until a specified location,
+ we don't specify a frame at which we need to stop. */
+ breakpoint = set_momentary_breakpoint (sal, null_frame_id, bp_until);
+ else
+ /* Otherwise, specify the current frame, because we want to stop only
+ at the very same frame. */
+ breakpoint = set_momentary_breakpoint (sal,
+ get_frame_id (deprecated_selected_frame),
+ bp_until);
if (!event_loop_p || !target_can_async_p ())
old_chain = make_cleanup_delete_breakpoint (breakpoint);
add_continuation (until_break_command_continuation, arg1);
}
- /* Keep within the current frame */
-
+ /* Keep within the current frame, or in frames called by the current
+ one. */
if (prev_frame)
{
- sal = find_pc_line (prev_frame->pc, 0);
- sal.pc = prev_frame->pc;
- breakpoint = set_momentary_breakpoint (sal, prev_frame, bp_until);
+ sal = find_pc_line (get_frame_pc (prev_frame), 0);
+ sal.pc = get_frame_pc (prev_frame);
+ breakpoint = set_momentary_breakpoint (sal, get_frame_id (prev_frame),
+ bp_until);
if (!event_loop_p || !target_can_async_p ())
make_cleanup_delete_breakpoint (breakpoint);
else
if (!event_loop_p || !target_can_async_p ())
do_cleanups (old_chain);
}
-\f
+
#if 0
/* These aren't used; I don't konw what they were for. */
/* Set a breakpoint at the catch clause for NAME. */
/* Not sure whether an error message is always the correct response,
but it's better than a core dump. */
- if (selected_frame == NULL)
+ if (deprecated_selected_frame == NULL)
error ("No selected frame.");
- block = get_frame_block (selected_frame, 0);
- pc = selected_frame->pc;
+ block = get_frame_block (deprecated_selected_frame, 0);
+ pc = get_frame_pc (deprecated_selected_frame);
sals.nelts = 0;
sals.sals = NULL;
inside a catch_errors */
static int
-cover_target_enable_exception_callback (PTR arg)
+cover_target_enable_exception_callback (void *arg)
{
args_for_catchpoint_enable *args = arg;
struct symtab_and_line *sal;
Unused in this case. */
static int
-breakpoint_re_set_one (PTR bint)
+breakpoint_re_set_one (void *bint)
{
/* get past catch_errs */
struct breakpoint *b = (struct breakpoint *) bint;
value_free (b->val);
b->val = evaluate_expression (b->exp);
release_value (b->val);
- if (VALUE_LAZY (b->val))
+ if (VALUE_LAZY (b->val) && b->enable_state == bp_enabled)
value_fetch_lazy (b->val);
if (b->cond_string != NULL)
return;
}
- save_selected_frame = selected_frame;
- save_selected_frame_level = frame_relative_level (selected_frame);
+ save_selected_frame = deprecated_selected_frame;
+ save_selected_frame_level = frame_relative_level (deprecated_selected_frame);
select_frame (fr);
}