/* Everything about breakpoints, for GDB.
- Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994
+ Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995
Free Software Foundation, Inc.
This file is part of GDB.
static void
disable_command PARAMS ((char *, int));
-static void
-disable_breakpoint PARAMS ((struct breakpoint *));
-
static void
enable_command PARAMS ((char *, int));
-static void
-enable_breakpoint PARAMS ((struct breakpoint *));
-
static void
map_breakpoint_numbers PARAMS ((char *, void (*)(struct breakpoint *)));
b? (tmp=b->next, 1): 0; \
b = tmp)
-/* By default no support for hardware watchpoints is assumed. */
+/* Provide defaults for systems that don't support hardware watchpoints. */
+
#ifndef TARGET_CAN_USE_HARDWARE_WATCHPOINT
+
+/* Returns non-zero if we can set a hardware watchpoint of type TYPE. TYPE is
+ one of bp_hardware_watchpoint, bp_read_watchpoint, bp_write_watchpoint, or
+ bp_hardware_breakpoint. CNT is the number of such watchpoints used so far
+ (including this one?). OTHERTYPE is who knows what... */
+
#define TARGET_CAN_USE_HARDWARE_WATCHPOINT(TYPE,CNT,OTHERTYPE) 0
+
+/* Set/clear a hardware watchpoint starting at ADDR, for LEN bytes. TYPE is 1
+ for read and 2 for read/write accesses. Returns 0 for success, non-zero for
+ failure. */
+
#define target_remove_watchpoint(ADDR,LEN,TYPE) -1
#define target_insert_watchpoint(ADDR,LEN,TYPE) -1
#endif
/* Chain of all breakpoints defined. */
-static struct breakpoint *breakpoint_chain;
+struct breakpoint *breakpoint_chain;
/* Number of last breakpoint made. */
if (*arg)
error ("Junk at end of expression");
}
+ breakpoints_changed ();
return;
}
&& ! b->inserted
&& ! b->duplicate)
{
- FRAME saved_frame;
+ struct frame_info *saved_frame;
int saved_level, within_current_scope;
value_ptr mark = value_mark ();
value_ptr v;
within_current_scope = 1;
else
{
- FRAME fr = find_frame_addr_in_frame_chain (b->watchpoint_frame);
- within_current_scope = (fr != NULL);
+ struct frame_info *fi =
+ find_frame_addr_in_frame_chain (b->watchpoint_frame);
+ within_current_scope = (fi != NULL);
if (within_current_scope)
- select_frame (fr, -1);
+ select_frame (fi, -1);
}
if (within_current_scope)
int
frame_in_dummy (frame)
- FRAME frame;
+ struct frame_info *frame;
{
struct breakpoint *b;
{
bpstat bs;
struct cleanup *old_chain;
+ struct command_line *cmd;
executing_breakpoint_commands = 1;
old_chain = make_cleanup (cleanup_executing_breakpoints, 0);
breakpoint_proceeded = 0;
for (; bs != NULL; bs = bs->next)
{
- while (bs->commands)
+ cmd = bs->commands;
+ while (cmd != NULL)
{
- char *line = bs->commands->line;
- bs->commands = bs->commands->next;
- execute_command (line, 0);
- /* If the inferior is proceeded by the command, bomb out now.
- The bpstat chain has been blown away by wait_for_inferior.
- But since execution has stopped again, there is a new bpstat
- to look at, so start over. */
- if (breakpoint_proceeded)
- goto top;
+ execute_control_command (cmd);
+ cmd = cmd->next;
}
+ if (breakpoint_proceeded)
+ /* The inferior is proceeded by the command; bomb out now.
+ The bpstat chain has been blown away by wait_for_inferior.
+ But since execution has stopped again, there is a new bpstat
+ to look at, so start over. */
+ goto top;
+ else
+ bs->commands = NULL;
}
executing_breakpoint_commands = 0;
/* The value has not changed. */
#define WP_VALUE_NOT_CHANGED 3
+#define BP_TEMPFLAG 1
+#define BP_HARDWAREFLAG 2
+
/* Check watchpoint condition. */
static int
{
bpstat bs = (bpstat) p;
struct breakpoint *b;
- FRAME saved_frame, fr;
+ struct frame_info *saved_frame, *fr;
int within_current_scope, saved_level;
- /* 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 = selected_frame_level;
-
b = bs->breakpoint_at;
if (b->exp_valid_block == NULL)
within_current_scope = 1;
else
{
+ /* There is no current frame at this moment. If we're going to have
+ any chance of handling watchpoints on local variables, we'll need
+ the frame chain (so we can determine if we're in scope). */
+ reinit_frame_cache();
fr = find_frame_addr_in_frame_chain (b->watchpoint_frame);
within_current_scope = (fr != NULL);
if (within_current_scope)
bs->old_val = b->val;
b->val = new_val;
/* We will stop here */
- select_frame (saved_frame, saved_level);
return WP_VALUE_CHANGED;
}
else
/* Nothing changed, don't do anything. */
value_free_to_mark (mark);
/* We won't stop here */
- select_frame (saved_frame, saved_level);
return WP_VALUE_NOT_CHANGED;
}
}
delete_breakpoint (b->related_breakpoint);
delete_breakpoint (b);
- select_frame (saved_frame, saved_level);
return WP_DELETED;
}
}
}
/* Get a bpstat associated with having just stopped at address *PC
- and frame address FRAME_ADDRESS. Update *PC to point at the
+ and frame address CORE_ADDRESS. Update *PC to point at the
breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
if this is known to not be a real breakpoint (it could still be a
watchpoint, though). */
*/
bpstat
-bpstat_stop_status (pc, frame_address, not_a_breakpoint)
+bpstat_stop_status (pc, not_a_breakpoint)
CORE_ADDR *pc;
- FRAME_ADDR frame_address;
int not_a_breakpoint;
{
register struct breakpoint *b;
int real_breakpoint = 0;
#endif
/* Root of the chain of bpstat's */
- struct bpstat root_bs[1];
+ struct bpstats root_bs[1];
/* Pointer to the last thing in the chain currently. */
bpstat bs = root_bs;
static char message1[] =
&& b->address != bp_addr)
continue;
+/* If defined, then we need to decr pc by this much after a hardware break-
+ point. Presumably should override DECR_PC_AFTER_BREAK, though it doesn't
+ now... */
+
#ifndef DECR_PC_AFTER_HW_BREAK
#define DECR_PC_AFTER_HW_BREAK 0
#endif
+
if (b->type == bp_hardware_breakpoint
&& b->address != (bp_addr - DECR_PC_AFTER_HW_BREAK))
continue;
real_breakpoint = 1;
#endif
- if (b->frame && b->frame != frame_address)
+ if (b->frame && b->frame != (get_current_frame ())->frame)
bs->stop = 0;
else
{
{
/* FIXME should make an annotation for this */
- printf_filtered ("\tbreakpoint already hit %d times\n",
- b->hit_count);
+ printf_filtered ("\tbreakpoint already hit %d time%s\n",
+ b->hit_count, (b->hit_count == 1 ? "" : "s"));
}
if (b->ignore_count)
while (l)
{
- fputs_filtered ("\t", gdb_stdout);
- fputs_filtered (l->line, gdb_stdout);
- fputs_filtered ("\n", gdb_stdout);
+ print_command_line (l, 4);
l = l->next;
}
}
else
b->source_file = savestring (sal.symtab->filename,
strlen (sal.symtab->filename));
+ b->language = current_language->la_language;
+ b->input_radix = input_radix;
b->thread = -1;
b->line_number = sal.line;
b->enable = enabled;
{
struct minimal_symbol *m;
- m = lookup_minimal_symbol(func_name, (struct objfile *)NULL);
+ m = lookup_minimal_symbol_text (func_name, NULL, (struct objfile *)NULL);
if (m)
sal.pc = SYMBOL_VALUE_ADDRESS (m);
else
void
set_longjmp_resume_breakpoint(pc, frame)
CORE_ADDR pc;
- FRAME frame;
+ struct frame_info *frame;
{
register struct breakpoint *b;
b->address = pc;
b->enable = enabled;
if (frame != NULL)
- b->frame = FRAME_FP(frame);
+ b->frame = frame->frame;
else
b->frame = 0;
check_duplicates (b->address);
struct breakpoint *
set_momentary_breakpoint (sal, frame, type)
struct symtab_and_line sal;
- FRAME frame;
+ struct frame_info *frame;
enum bptype type;
{
register struct breakpoint *b;
b->type = type;
b->enable = enabled;
b->disposition = donttouch;
- b->frame = (frame ? FRAME_FP (frame) : 0);
+ b->frame = (frame ? frame->frame : 0);
return b;
}
int i;
int thread;
- hardwareflag = flag & 2;
- tempflag = flag & 1;
+ hardwareflag = flag & BP_HARDWAREFLAG;
+ tempflag = flag & BP_TEMPFLAG;
sals.sals = NULL;
sals.nelts = 0;
b->cond_string = savestring (cond_start, cond_end - cond_start);
b->enable = enabled;
- b->disposition = tempflag ? delete : donttouch;
+ b->disposition = tempflag ? del : donttouch;
mention (b);
}
}
}
-#define BP_TEMPFLAG 1
-#define BP_HARDWAREFLAG 2
void
break_command (arg, from_tty)
char *arg;
struct expression *exp;
struct block *exp_valid_block;
struct value *val, *mark;
- FRAME frame, prev_frame;
+ struct frame_info *frame, *prev_frame;
char *exp_start = NULL;
char *exp_end = NULL;
char *tok, *end_tok;
if (frame)
{
prev_frame = get_prev_frame (frame);
- b->watchpoint_frame = FRAME_FP (frame);
+ b->watchpoint_frame = frame->frame;
}
else
b->watchpoint_frame = (CORE_ADDR)0;
scope_breakpoint->enable = enabled;
/* Automatically delete the breakpoint when it hits. */
- scope_breakpoint->disposition = delete;
+ scope_breakpoint->disposition = del;
/* Only break in the proper frame (help with recursion). */
scope_breakpoint->frame = prev_frame->frame;
}
\f
-/*
- * Helper routine for the until_command routine in infcmd.c. Here
- * because it uses the mechanisms of breakpoints.
- */
+/* Helper routine for the until_command routine in infcmd.c. Here
+ because it uses the mechanisms of breakpoints. */
+
/* ARGSUSED */
void
until_break_command (arg, from_tty)
{
struct symtabs_and_lines sals;
struct symtab_and_line sal;
- FRAME prev_frame = get_prev_frame (selected_frame);
+ struct frame_info *prev_frame = get_prev_frame (selected_frame);
struct breakpoint *breakpoint;
struct cleanup *old_chain;
if (prev_frame)
{
- struct frame_info *fi;
-
- fi = get_frame_info (prev_frame);
- sal = find_pc_line (fi->pc, 0);
- sal.pc = fi->pc;
+ sal = find_pc_line (prev_frame->pc, 0);
+ sal.pc = prev_frame->pc;
breakpoint = set_momentary_breakpoint (sal, prev_frame, bp_until);
make_cleanup(delete_breakpoint, breakpoint);
}
register struct blockvector *bl;
register struct block *block;
int index, have_default = 0;
- struct frame_info *fi;
CORE_ADDR pc;
struct symtabs_and_lines sals;
struct sal_chain *sal_chain = 0;
if (selected_frame == NULL)
error ("No selected frame.");
block = get_frame_block (selected_frame);
- fi = get_frame_info (selected_frame);
- pc = fi->pc;
+ pc = selected_frame->pc;
sals.nelts = 0;
sals.sals = NULL;
b->type = bp_breakpoint;
b->cond = cond;
b->enable = enabled;
- b->disposition = tempflag ? delete : donttouch;
+ b->disposition = tempflag ? del : donttouch;
mention (b);
}
free ((PTR)sals.sals);
}
+/* Used by the gui, could be made a worker for other things. */
+
+struct breakpoint *
+set_breakpoint_sal (sal)
+struct symtab_and_line sal;
+{
+ struct breakpoint *b;
+ b = set_raw_breakpoint (sal);
+ set_breakpoint_count (breakpoint_count + 1);
+ b->number = breakpoint_count;
+ b->type = bp_breakpoint;
+ b->cond = 0;
+ b->thread = -1;
+ return b;
+}
+
#if 0
/* These aren't used; I don't know what they were for. */
/* Disable breakpoints on all catch clauses described in ARGS. */
bpstat bs;
{
for (; bs; bs = bs->next)
- if (bs->breakpoint_at && bs->breakpoint_at->disposition == delete
+ if (bs->breakpoint_at && bs->breakpoint_at->disposition == del
&& bs->stop)
delete_breakpoint (bs->breakpoint_at);
}
{
/* Ask user only if there are some breakpoints to delete. */
if (!from_tty
- || (breakpoint_chain && query ("Delete all breakpoints? ", 0, 0)))
+ || (breakpoint_chain && query ("Delete all breakpoints? ")))
{
/* No arg; clear all breakpoints. */
while (breakpoint_chain)
save_enable = b->enable;
b->enable = disabled;
+ set_language (b->language);
+ input_radix = b->input_radix;
s = b->addr_string;
sals = decode_line_1 (&s, 1, (struct symtab *)NULL, 0, (char ***)NULL);
for (i = 0; i < sals.nelts; i++)
breakpoint_re_set ()
{
struct breakpoint *b, *temp;
+ enum language save_language;
+ int save_input_radix;
static char message1[] = "Error in re-setting breakpoint %d:\n";
char message[sizeof (message1) + 30 /* slop */];
+ save_language = current_language->la_language;
+ save_input_radix = input_radix;
ALL_BREAKPOINTS_SAFE (b, temp)
{
sprintf (message, message1, b->number); /* Format possible error msg */
catch_errors (breakpoint_re_set_one, (char *) b, message,
RETURN_MASK_ALL);
}
+ set_language (save_language);
+ input_radix = save_input_radix;
create_longjmp_breakpoint("longjmp");
create_longjmp_breakpoint("_longjmp");
}
}
-static void
+void
enable_breakpoint (bpt)
struct breakpoint *bpt;
{
- FRAME save_selected_frame = NULL;
+ struct frame_info *save_selected_frame = NULL;
int save_selected_frame_level = -1;
int target_resources_ok, other_type_used;
struct value *mark;
- if (enable_breakpoint_hook)
- enable_breakpoint_hook (bpt);
-
if (bpt->type == bp_hardware_breakpoint)
{
int i;
{
if (bpt->exp_valid_block != NULL)
{
- FRAME fr = find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
+ struct frame_info *fr =
+ find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
if (fr == NULL)
{
printf_filtered ("\
select_frame (save_selected_frame, save_selected_frame_level);
value_free_to_mark (mark);
}
+
+ if (modify_breakpoint_hook)
+ modify_breakpoint_hook (bpt);
}
/* ARGSUSED */
map_breakpoint_numbers (args, enable_breakpoint);
}
-static void
+void
disable_breakpoint (bpt)
struct breakpoint *bpt;
{
if (bpt->type == bp_watchpoint_scope)
return;
- if (disable_breakpoint_hook)
- disable_breakpoint_hook (bpt);
-
bpt->enable = disabled;
check_duplicates (bpt->address);
+
+ if (modify_breakpoint_hook)
+ modify_breakpoint_hook (bpt);
}
/* ARGSUSED */
enable_once_breakpoint (bpt)
struct breakpoint *bpt;
{
- FRAME save_selected_frame = NULL;
+ struct frame_info *save_selected_frame = NULL;
int save_selected_frame_level = -1;
int target_resources_ok, other_type_used;
struct value *mark;
{
if (bpt->exp_valid_block != NULL)
{
- FRAME fr = find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
+ struct frame_info *fr =
+ find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
if (fr == NULL)
{
printf_filtered ("\
struct breakpoint *bpt;
{
bpt->enable = enabled;
- bpt->disposition = delete;
+ bpt->disposition = del;
check_duplicates (bpt->address);
breakpoints_changed ();
map_breakpoint_numbers (args, enable_delete_breakpoint);
}
\f
-/*
- * Use default_breakpoint_'s, or nothing if they aren't valid.
- */
+/* Use default_breakpoint_'s, or nothing if they aren't valid. */
+
struct symtabs_and_lines
decode_line_spec_1 (string, funfirstline)
char *string;
&deletelist);
add_com ("clear", class_breakpoint, clear_command,
- "Clear breakpoint at specified line or function.\n\
+ concat ("Clear breakpoint at specified line or function.\n\
Argument may be line number, function name, or \"*\" and an address.\n\
If line number is specified, all breakpoints in that line are cleared.\n\
If function is specified, breakpoints at beginning of function are cleared.\n\
-If an address is specified, breakpoints at that address are cleared.\n\n\
-With no argument, clears all breakpoints in the line that the selected frame\n\
+If an address is specified, breakpoints at that address are cleared.\n\n",
+"With no argument, clears all breakpoints in the line that the selected frame\n\
is executing in.\n\
\n\
-See also the \"delete\" command which clears breakpoints by number.");
+See also the \"delete\" command which clears breakpoints by number.", NULL));
add_com ("break", class_breakpoint, break_command,
- "Set breakpoint at specified line or function.\n\
+ concat ("Set breakpoint at specified line or function.\n\
Argument may be line number, function name, or \"*\" and an address.\n\
If line number is specified, break at start of code for that line.\n\
If function is specified, break at start of code for that function.\n\
-If an address is specified, break at that exact address.\n\
-With no arg, uses current execution address of selected stack frame.\n\
+If an address is specified, break at that exact address.\n",
+"With no arg, uses current execution address of selected stack frame.\n\
This is useful for breaking on return to a stack frame.\n\
\n\
Multiple breakpoints at one place are permitted, and useful if conditional.\n\
\n\
-Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
+Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL));
add_com_alias ("b", "break", class_run, 1);
add_com_alias ("br", "break", class_run, 1);
add_com_alias ("bre", "break", class_run, 1);
add_com_alias ("brea", "break", class_run, 1);
add_info ("breakpoints", breakpoints_info,
- "Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
+ concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
The \"Type\" column indicates one of:\n\
\tbreakpoint - normal breakpoint\n\
\twatchpoint - watchpoint\n\
The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
-address and file/line number respectively.\n\n\
-Convenience variable \"$_\" and default examine address for \"x\"\n\
+address and file/line number respectively.\n\n",
+"Convenience variable \"$_\" and default examine address for \"x\"\n\
are set to the address of the last breakpoint listed.\n\n\
Convenience variable \"$bpnum\" contains the number of the last\n\
-breakpoint set.");
+breakpoint set.", NULL));
#if MAINTENANCE_CMDS
add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints,
- "Status of all breakpoints, or breakpoint number NUMBER.\n\
+ concat ("Status of all breakpoints, or breakpoint number NUMBER.\n\
The \"Type\" column indicates one of:\n\
\tbreakpoint - normal breakpoint\n\
\twatchpoint - watchpoint\n\
\tlongjmp - internal breakpoint used to step through longjmp()\n\
\tlongjmp resume - internal breakpoint at the target of longjmp()\n\
\tuntil - internal breakpoint used by the \"until\" command\n\
-\tfinish - internal breakpoint used by the \"finish\" command\n\
-The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
+\tfinish - internal breakpoint used by the \"finish\" command\n",
+"The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
-address and file/line number respectively.\n\n\
-Convenience variable \"$_\" and default examine address for \"x\"\n\
+address and file/line number respectively.\n\n",
+"Convenience variable \"$_\" and default examine address for \"x\"\n\
are set to the address of the last breakpoint listed.\n\n\
Convenience variable \"$bpnum\" contains the number of the last\n\
-breakpoint set.",
+breakpoint set.", NULL),
&maintenanceinfolist);
#endif /* MAINTENANCE_CMDS */
"Synonym for ``info breakpoints''.");
}
-
-/* OK, when we call objfile_relocate, we need to relocate breakpoints
- too. breakpoint_re_set is not a good choice--for example, if
- addr_string contains just a line number without a file name the
- breakpoint might get set in a different file. In general, there is
- no need to go all the way back to the user's string (though this might
- work if some effort were made to canonicalize it), since symtabs and
- everything except addresses are still valid.
-
- Probably the best way to solve this is to have each breakpoint save
- the objfile and the section number that was used to set it (if set
- by "*addr", probably it is best to use find_pc_line to get a symtab
- and use the objfile and block_line_section for that symtab). Then
- objfile_relocate can call fixup_breakpoints with the objfile and
- the new_offsets, and it can relocate only the appropriate breakpoints. */
-
-#ifdef IBM6000_TARGET
-/* But for now, just kludge it based on the concept that before an
- objfile is relocated the breakpoint is below 0x10000000, and afterwards
- it is higher, so that way we only relocate each breakpoint once. */
-
-void
-fixup_breakpoints (low, high, delta)
- CORE_ADDR low;
- CORE_ADDR high;
- CORE_ADDR delta;
-{
- struct breakpoint *b;
-
- ALL_BREAKPOINTS (b)
- {
- if (b->address >= low && b->address <= high)
- b->address += delta;
- }
-}
-#endif