aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r--gdb/breakpoint.c205
1 files changed, 87 insertions, 118 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index fc2155a..635cc49 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -185,8 +185,11 @@ commands_command (arg)
if (b->number == bnum)
{
if (input_from_terminal_p ())
- printf ("Type commands for when breakpoint %d is hit, one per line.\n\
+ {
+ printf ("Type commands for when breakpoint %d is hit, one per line.\n\
End with a line saying just \"end\".\n", bnum);
+ fflush (stdout);
+ }
l = read_command_lines ();
free_command_lines (&b->commands);
b->commands = l;
@@ -316,6 +319,16 @@ breakpoint_here_p (pc)
return 0;
}
+/* Evaluate the expression EXP and return 1 if value is zero.
+ This is used inside a catch_errors to evaluate the breakpoint condition. */
+
+int
+breakpoint_cond_eval (exp)
+ struct expression *exp;
+{
+ return value_zerop (evaluate_expression (exp));
+}
+
/* Return 0 if PC is not the address just after a breakpoint,
or -1 if breakpoint says do not stop now,
or -2 if breakpoint says it has deleted itself and don't stop,
@@ -344,7 +357,9 @@ breakpoint_stop_status (pc, frame)
int value_zero;
if (b->cond)
{
- value_zero = value_zerop (evaluate_expression (b->cond));
+ value_zero
+ = catch_errors (breakpoint_cond_eval, b->cond,
+ "Error occurred in testing breakpoint condition.");
free_all_values ();
}
if (b->cond && value_zero)
@@ -607,96 +622,63 @@ set_breakpoint (s, line, tempflag)
}
/* Set a breakpoint according to ARG (function, linenum or *address)
- and make it temporary if TEMPFLAG is nonzero.
-
- LINE_NUM is for C++. */
+ and make it temporary if TEMPFLAG is nonzero. */
static void
-break_command_1 (arg, tempflag, from_tty, line_num)
+break_command_1 (arg, tempflag, from_tty)
char *arg;
- int tempflag, from_tty, line_num;
+ int tempflag, from_tty;
{
- struct symtabs_and_lines sals;
struct symtab_and_line sal;
register struct expression *cond = 0;
register struct breakpoint *b;
- char *save_arg;
- int i;
-
- sals.sals = NULL;
- sals.nelts = 0;
- sal.line = sal.pc = sal.end = 0;
- sal.symtab = 0;
+ sal.pc = 0;
if (arg)
{
- CORE_ADDR pc;
- sals = decode_line_1 (&arg, 1, 0, 0);
+ sal = decode_line_1 (&arg, 1, 0, 0);
- if (! sals.nelts) return;
- save_arg = arg;
- for (i = 0; i < sals.nelts; i++)
+ if (sal.pc == 0 && sal.symtab != 0)
{
- sal = sals.sals[i];
- if (sal.pc == 0 && sal.symtab != 0)
- {
- pc = find_line_pc (sal.symtab, sal.line);
- if (pc == 0)
- error ("No line %d in file \"%s\".",
- sal.line, sal.symtab->filename);
- }
- else pc = sal.pc;
+ sal.pc = find_line_pc (sal.symtab, sal.line);
+ if (sal.pc == 0)
+ error ("No line %d in file \"%s\".",
+ sal.line, sal.symtab->filename);
+ }
- while (*arg)
- {
- if (arg[0] == 'i' && arg[1] == 'f'
- && (arg[2] == ' ' || arg[2] == '\t'))
- cond = (struct expression *) parse_c_1 ((arg += 2, &arg),
- block_for_pc (pc), 0);
- else
- error ("Junk at end of arguments.");
- }
- arg = save_arg;
- sals.sals[i].pc = pc;
+ while (*arg)
+ {
+ if (arg[0] == 'i' && arg[1] == 'f'
+ && (arg[2] == ' ' || arg[2] == '\t'))
+ cond = (struct expression *) parse_c_1 ((arg += 2, &arg),
+ block_for_pc (sal.pc), 0);
+ else
+ error ("Junk at end of arguments.");
}
}
else if (default_breakpoint_valid)
{
- sals.sals = (struct symtab_and_line *) malloc (sizeof (struct symtab_and_line));
sal.pc = default_breakpoint_address;
sal.line = default_breakpoint_line;
sal.symtab = default_breakpoint_symtab;
- sals.sals[0] = sal;
- sals.nelts = 1;
}
else
error ("No default breakpoint address now.");
- for (i = 0; i < sals.nelts; i++)
- {
- sal = sals.sals[i];
- sal.line += line_num; /** C++ **/
- if (line_num != 0)
- { /* get the pc for a particular line */
- sal.pc = find_line_pc (sal.symtab, sal.line);
- }
-
- if (from_tty)
- describe_other_breakpoints (sal.pc);
-
- b = set_raw_breakpoint (sal);
- b->number = ++breakpoint_count;
- b->cond = cond;
- if (tempflag)
- b->enable = temporary;
+ if (from_tty)
+ describe_other_breakpoints (sal.pc);
- printf ("Breakpoint %d at 0x%x", b->number, b->address);
- if (b->symtab)
- printf (": file %s, line %d.", b->symtab->filename, b->line_number);
- printf ("\n");
- }
- free (sals.sals);
+ b = set_raw_breakpoint (sal);
+ b->number = ++breakpoint_count;
+ b->cond = cond;
+ if (tempflag)
+ b->enable = temporary;
+
+ printf ("Breakpoint %d at 0x%x", b->number, b->address);
+ if (b->symtab)
+ printf (": file %s, line %d.", b->symtab->filename, b->line_number);
+ printf ("\n");
}
static void
@@ -704,7 +686,7 @@ break_command (arg, from_tty)
char *arg;
int from_tty;
{
- break_command_1 (arg, 0, from_tty, 0);
+ break_command_1 (arg, 0, from_tty);
}
static void
@@ -712,7 +694,7 @@ tbreak_command (arg, from_tty)
char *arg;
int from_tty;
{
- break_command_1 (arg, 1, from_tty, 0);
+ break_command_1 (arg, 1, from_tty);
}
static void
@@ -721,72 +703,60 @@ clear_command (arg, from_tty)
int from_tty;
{
register struct breakpoint *b, *b1;
- struct symtabs_and_lines sals;
struct symtab_and_line sal;
register struct breakpoint *found;
- int i;
if (arg)
- {
- sals = decode_line_spec (arg, 1);
- }
+ sal = decode_line_spec (arg, 1);
else
{
- sals.sals = (struct symtab_and_line *) malloc (sizeof (struct symtab_and_line));
sal.line = default_breakpoint_line;
sal.symtab = default_breakpoint_symtab;
sal.pc = 0;
if (sal.symtab == 0)
error ("No source file specified.");
-
- sals.sals[0] = sal;
- sals.nelts = 1;
}
- for (i = 0; i < sals.nelts; i++)
+ /* If exact pc given, clear bpts at that pc.
+ But if sal.pc is zero, clear all bpts on specified line. */
+
+ found = (struct breakpoint *) 0;
+ while (breakpoint_chain
+ && (sal.pc ? breakpoint_chain->address == sal.pc
+ : (breakpoint_chain->symtab == sal.symtab
+ && breakpoint_chain->line_number == sal.line)))
{
- /* If exact pc given, clear bpts at that pc.
- But if sal.pc is zero, clear all bpts on specified line. */
- sal = sals.sals[i];
- found = (struct breakpoint *) 0;
- while (breakpoint_chain
- && (sal.pc ? breakpoint_chain->address == sal.pc
- : (breakpoint_chain->symtab == sal.symtab
- && breakpoint_chain->line_number == sal.line)))
- {
- b1 = breakpoint_chain;
- breakpoint_chain = b1->next;
- b1->next = found;
- found = b1;
- }
+ b1 = breakpoint_chain;
+ breakpoint_chain = b1->next;
+ b1->next = found;
+ found = b1;
+ }
- ALL_BREAKPOINTS (b)
- while (b->next
- && (sal.pc ? b->next->address == sal.pc
- : (b->next->symtab == sal.symtab
- && b->next->line_number == sal.line)))
- {
- b1 = b->next;
- b->next = b1->next;
- b1->next = found;
- found = b1;
- }
+ ALL_BREAKPOINTS (b)
+ while (b->next
+ && (sal.pc ? b->next->address == sal.pc
+ : (b->next->symtab == sal.symtab
+ && b->next->line_number == sal.line)))
+ {
+ b1 = b->next;
+ b->next = b1->next;
+ b1->next = found;
+ found = b1;
+ }
- if (found == 0)
- error ("No breakpoint at %s.", arg);
+ if (found == 0)
+ error ("No breakpoint at %s.", arg);
- if (found->next) from_tty = 1; /* Always report if deleted more than one */
- if (from_tty) printf ("Deleted breakpoint%s ", found->next ? "s" : "");
- while (found)
- {
- if (from_tty) printf ("%d ", found->number);
- b1 = found->next;
- delete_breakpoint (found);
- found = b1;
- }
- if (from_tty) putchar ('\n');
+ if (found->next) from_tty = 1; /* Alwats report if deleted more than one */
+ if (from_tty) printf ("Deleted breakpoint%s ", found->next ? "s" : "");
+ while (found)
+ {
+ if (from_tty) printf ("%d ", found->number);
+ b1 = found->next;
+ delete_breakpoint (found);
+ found = b1;
}
- free (sals.sals);
+ if (from_tty) putchar ('\n');
}
/* Delete breakpoint number BNUM if it is a `delete' breakpoint.
@@ -909,13 +879,12 @@ ignore_command (args, from_tty)
char *args;
int from_tty;
{
- register char *p;
+ register char *p = args;
register int num;
if (p == 0)
error_no_arg ("a breakpoint number");
- p = args;
while (*p >= '0' && *p <= '9') p++;
if (*p && *p != ' ' && *p != '\t')
error ("First argument must be a breakpoint number.");