static void breakpoints_info (char *, int);
-static void breakpoint_1 (int, int);
+static void watchpoints_info (char *, int);
+
+static int breakpoint_1 (int, int, int (*) (const struct breakpoint *));
static bpstat bpstat_alloc (const struct bp_location *, bpstat);
static void update_global_location_list_nothrow (int);
-static int is_hardware_watchpoint (struct breakpoint *bpt);
+static int is_hardware_watchpoint (const struct breakpoint *bpt);
-static int is_watchpoint (struct breakpoint *bpt);
+static int is_watchpoint (const struct breakpoint *bpt);
static void insert_breakpoint_locations (void);
#define ALL_TRACEPOINTS(B) \
for (B = breakpoint_chain; B; B = B->next) \
- if (tracepoint_type (B))
+ if (is_tracepoint (B))
/* Chains of all breakpoints defined. */
b->hit_count = 0;
}
-/* Encapsulate tests for different types of tracepoints. */
-
-static int
-tracepoint_type (const struct breakpoint *b)
-{
- return (b->type == bp_tracepoint || b->type == bp_fast_tracepoint);
-}
-
/* Allocate a new counted_command_line with reference count of 1.
The new structure owns COMMANDS. */
}
}
+/* Encapsulate tests for different types of tracepoints. */
+
int
-breakpoint_is_tracepoint (const struct breakpoint *b)
+is_tracepoint (const struct breakpoint *b)
{
- switch (b->type)
- {
- case bp_tracepoint:
- case bp_fast_tracepoint:
- return 1;
- default:
- return 0;
-
- }
+ return (b->type == bp_tracepoint || b->type == bp_fast_tracepoint);
}
-
+
/* A helper function that validsates that COMMANDS are valid for a
breakpoint. This function will throw an exception if a problem is
found. */
validate_commands_for_breakpoint (struct breakpoint *b,
struct command_line *commands)
{
- if (breakpoint_is_tracepoint (b))
+ if (is_tracepoint (b))
{
/* We need to verify that each top-level element of commands
is valid for tracepoints, that there's at most one while-stepping
l = read_command_lines (str,
info->from_tty, 1,
- (breakpoint_is_tracepoint (b)
+ (is_tracepoint (b)
? check_tracepoint_command : 0),
b);
/* Return true if BPT is of any hardware watchpoint kind. */
static int
-is_hardware_watchpoint (struct breakpoint *bpt)
+is_hardware_watchpoint (const struct breakpoint *bpt)
{
return (bpt->type == bp_hardware_watchpoint
|| bpt->type == bp_read_watchpoint
software. */
static int
-is_watchpoint (struct breakpoint *bpt)
+is_watchpoint (const struct breakpoint *bpt)
{
return (is_hardware_watchpoint (bpt)
|| bpt->type == bp_watchpoint);
/* Tracepoints are inserted by the target at a time of its choosing,
not by us. */
- if (tracepoint_type (bpt->owner))
+ if (is_tracepoint (bpt->owner))
return 0;
return 1;
/* By definition, the inferior does not report stops at
tracepoints. */
- if (tracepoint_type (b))
+ if (is_tracepoint (b))
return 0;
if (b->type != bp_watchpoint
because the condition is an internal implementation detail
that we do not want to expose to the user. */
annotate_field (7);
- if (tracepoint_type (b))
+ if (is_tracepoint (b))
ui_out_text (uiout, "\ttrace only if ");
else
ui_out_text (uiout, "\tstop only if ");
return (b->type == bp_breakpoint
|| b->type == bp_catchpoint
|| b->type == bp_hardware_breakpoint
- || tracepoint_type (b)
+ || is_tracepoint (b)
|| b->type == bp_watchpoint
|| b->type == bp_read_watchpoint
|| b->type == bp_access_watchpoint
}
/* Print information on user settable breakpoint (watchpoint, etc)
- number BNUM. If BNUM is -1 print all user settable breakpoints.
- If ALLFLAG is non-zero, include non- user settable breakpoints. */
+ number BNUM. If BNUM is -1 print all user-settable breakpoints.
+ If ALLFLAG is non-zero, include non-user-settable breakpoints. If
+ FILTER is non-NULL, call it on each breakpoint and only include the
+ ones for which it returns non-zero. Return the total number of
+ breakpoints listed. */
-static void
-breakpoint_1 (int bnum, int allflag)
+static int
+breakpoint_1 (int bnum, int allflag, int (*filter) (const struct breakpoint *))
{
struct breakpoint *b;
struct bp_location *last_loc = NULL;
if (bnum == -1
|| bnum == b->number)
{
+ /* If we have a filter, only list the breakpoints it accepts. */
+ if (filter && !filter (b))
+ continue;
+
if (allflag || user_settable_breakpoint (b))
{
int addr_bit = breakpoint_address_bits (b);
if (bnum == -1
|| bnum == b->number)
{
+ /* If we have a filter, only list the breakpoints it accepts. */
+ if (filter && !filter (b))
+ continue;
+
/* We only print out user settable breakpoints unless the
allflag is set. */
if (allflag || user_settable_breakpoint (b))
if (nr_printable_breakpoints == 0)
{
- if (bnum == -1)
- ui_out_message (uiout, 0, "No breakpoints or watchpoints.\n");
- else
- ui_out_message (uiout, 0, "No breakpoint or watchpoint number %d.\n",
- bnum);
+ /* If there's a filter, let the caller decide how to report empty list. */
+ if (!filter)
+ {
+ if (bnum == -1)
+ ui_out_message (uiout, 0, "No breakpoints or watchpoints.\n");
+ else
+ ui_out_message (uiout, 0, "No breakpoint or watchpoint number %d.\n",
+ bnum);
+ }
}
else
{
/* FIXME? Should this be moved up so that it is only called when
there have been breakpoints? */
annotate_breakpoints_table_end ();
+
+ return nr_printable_breakpoints;
}
static void
if (bnum_exp)
bnum = parse_and_eval_long (bnum_exp);
- breakpoint_1 (bnum, 0);
+ breakpoint_1 (bnum, 0, NULL);
+}
+
+static void
+watchpoints_info (char *wpnum_exp, int from_tty)
+{
+ int wpnum = -1, num_printed;
+
+ if (wpnum_exp)
+ wpnum = parse_and_eval_long (wpnum_exp);
+
+ num_printed = breakpoint_1 (wpnum, 0, is_watchpoint);
+
+ if (num_printed == 0)
+ {
+ if (wpnum == -1)
+ ui_out_message (uiout, 0, "No watchpoints.\n");
+ else
+ ui_out_message (uiout, 0, "No watchpoint number %d.\n", wpnum);
+ }
}
static void
if (bnum_exp)
bnum = parse_and_eval_long (bnum_exp);
- breakpoint_1 (bnum, 1);
+ breakpoint_1 (bnum, 1, NULL);
}
static int
{
if (loc->owner->type == bp_breakpoint
|| loc->owner->type == bp_hardware_breakpoint
- || tracepoint_type (loc->owner))
+ || is_tracepoint (loc->owner))
{
find_pc_partial_function (loc->address, &(loc->function_name),
NULL, NULL);
if (((b->type == bp_breakpoint)
|| (b->type == bp_jit_event)
|| (b->type == bp_hardware_breakpoint)
- || (tracepoint_type (b)))
+ || (is_tracepoint (b)))
&& loc->pspace == current_program_space
&& !loc->shlib_disabled
#ifdef PC_SOLIB
|| !loc->enabled
|| loc->shlib_disabled
|| !breakpoint_address_is_meaningful (b)
- || tracepoint_type (b))
+ || is_tracepoint (b))
continue;
/* Permanent breakpoint should always be inserted. */
ALL_BREAKPOINTS (b)
if (b->number == bptnum)
{
+ if (is_tracepoint (b))
+ {
+ if (from_tty && count != 0)
+ printf_filtered (_("Ignore count ignored for tracepoint %d."),
+ bptnum);
+ return;
+ }
+
b->ignore_count = count;
if (from_tty)
{
static void
tracepoints_info (char *tpnum_exp, int from_tty)
{
- struct breakpoint *b;
- int tps_to_list = 0;
+ int tpnum = -1, num_printed;
+
+ if (tpnum_exp)
+ tpnum = parse_and_eval_long (tpnum_exp);
- /* In the no-arguments case, say "No tracepoints" if none found. */
- if (tpnum_exp == 0)
+ num_printed = breakpoint_1 (tpnum, 0, is_tracepoint);
+
+ if (num_printed == 0)
{
- ALL_TRACEPOINTS (b)
- {
- if (b->number >= 0)
- {
- tps_to_list = 1;
- break;
- }
- }
- if (!tps_to_list)
- {
- ui_out_message (uiout, 0, "No tracepoints.\n");
- return;
- }
+ if (tpnum == -1)
+ ui_out_message (uiout, 0, "No tracepoints.\n");
+ else
+ ui_out_message (uiout, 0, "No tracepoint number %d.\n", tpnum);
}
-
- /* Otherwise be the same as "info break". */
- breakpoints_info (tpnum_exp, from_tty);
}
/* The 'enable trace' command enables tracepoints.
{
ALL_BREAKPOINTS_SAFE (b, temp)
{
- if (tracepoint_type (b)
+ if (is_tracepoint (b)
&& b->number >= 0)
delete_breakpoint (b);
}
an expression is either read or written."));
set_cmd_completer (c, expression_completer);
- add_info ("watchpoints", breakpoints_info,
- _("Synonym for ``info breakpoints''."));
+ add_info ("watchpoints", watchpoints_info, _("\
+Status of watchpoints, or watchpoint number NUMBER."));
+
/* XXX: cagney/2005-02-23: This should be a boolean, and should