Return bool from breakpoint_ops::print_one

This changes breakpoint_ops::print_one to return bool, and updates all
the implementations and the caller.  The caller is changed so that a
NULL check is no longer needed -- something that will be impossible
with a real method.
This commit is contained in:
Tom Tromey 2022-01-16 16:56:24 -07:00
parent 6689579725
commit c01e038bd2
9 changed files with 45 additions and 19 deletions

View file

@ -12380,7 +12380,7 @@ print_it_exception (bpstat *bs)
/* Implement the PRINT_ONE method in the breakpoint_ops structure
for all exception catchpoint kinds. */
static void
static bool
print_one_exception (struct breakpoint *b, struct bp_location **last_loc)
{
struct ui_out *uiout = current_uiout;
@ -12431,6 +12431,8 @@ print_one_exception (struct breakpoint *b, struct bp_location **last_loc)
internal_error (__FILE__, __LINE__, _("unexpected catchpoint type"));
break;
}
return true;
}
/* Implement the PRINT_MENTION method in the breakpoint_ops structure

View file

@ -94,7 +94,7 @@ print_it_catch_exec (bpstat *bs)
return PRINT_SRC_AND_LOC;
}
static void
static bool
print_one_catch_exec (struct breakpoint *b, struct bp_location **last_loc)
{
struct exec_catchpoint *c = (struct exec_catchpoint *) b;
@ -119,6 +119,8 @@ print_one_catch_exec (struct breakpoint *b, struct bp_location **last_loc)
if (uiout->is_mi_like_p ())
uiout->field_string ("catch-type", "exec");
return true;
}
static void

View file

@ -127,7 +127,7 @@ print_it_catch_fork (bpstat *bs)
/* Implement the "print_one" breakpoint_ops method for fork
catchpoints. */
static void
static bool
print_one_catch_fork (struct breakpoint *b, struct bp_location **last_loc)
{
struct fork_catchpoint *c = (struct fork_catchpoint *) b;
@ -153,6 +153,8 @@ print_one_catch_fork (struct breakpoint *b, struct bp_location **last_loc)
if (uiout->is_mi_like_p ())
uiout->field_string ("catch-type", name);
return true;
}
/* Implement the "print_mention" breakpoint_ops method for fork

View file

@ -137,7 +137,7 @@ print_it_catch_solib (bpstat *bs)
return PRINT_SRC_AND_LOC;
}
static void
static bool
print_one_catch_solib (struct breakpoint *b, struct bp_location **locs)
{
struct solib_catchpoint *self = (struct solib_catchpoint *) b;
@ -176,6 +176,8 @@ print_one_catch_solib (struct breakpoint *b, struct bp_location **locs)
if (uiout->is_mi_like_p ())
uiout->field_string ("catch-type", self->is_load ? "load" : "unload");
return true;
}
static void

View file

@ -201,7 +201,7 @@ signal_catchpoint_print_it (bpstat *bs)
/* Implement the "print_one" breakpoint_ops method for signal
catchpoints. */
static void
static bool
signal_catchpoint_print_one (struct breakpoint *b,
struct bp_location **last_loc)
{
@ -248,6 +248,8 @@ signal_catchpoint_print_one (struct breakpoint *b,
if (uiout->is_mi_like_p ())
uiout->field_string ("catch-type", "signal");
return true;
}
/* Implement the "print_mention" breakpoint_ops method for signal

View file

@ -226,7 +226,7 @@ print_it_catch_syscall (bpstat *bs)
/* Implement the "print_one" breakpoint_ops method for syscall
catchpoints. */
static void
static bool
print_one_catch_syscall (struct breakpoint *b,
struct bp_location **last_loc)
{
@ -275,6 +275,8 @@ print_one_catch_syscall (struct breakpoint *b,
if (uiout->is_mi_like_p ())
uiout->field_string ("catch-type", "syscall");
return true;
}
/* Implement the "print_mention" breakpoint_ops method for syscall

View file

@ -253,7 +253,7 @@ print_it_exception_catchpoint (bpstat *bs)
return PRINT_SRC_AND_LOC;
}
static void
static bool
print_one_exception_catchpoint (struct breakpoint *b,
struct bp_location **last_loc)
{
@ -287,6 +287,8 @@ print_one_exception_catchpoint (struct breakpoint *b,
uiout->field_string ("catch-type", "catch");
break;
}
return true;
}
/* Implement the 'print_one_detail' method. */

View file

@ -6058,9 +6058,10 @@ output_thread_groups (struct ui_out *uiout,
instead of going via breakpoint_ops::print_one. This makes "maint
info breakpoints" show the software breakpoint locations of
catchpoints, which are considered internal implementation
detail. */
detail. Returns true if RAW_LOC is false and if the breakpoint's
print_one method did something; false otherwise. */
static void
static bool
print_one_breakpoint_location (struct breakpoint *b,
struct bp_location *loc,
int loc_number,
@ -6124,8 +6125,9 @@ print_one_breakpoint_location (struct breakpoint *b,
uiout->field_fmt ("enabled", "%c", bpenables[(int) b->enable_state]);
/* 5 and 6 */
if (!raw_loc && b->ops != NULL && b->ops->print_one != NULL)
b->ops->print_one (b, last_loc);
bool result = false;
if (!raw_loc && b->ops != NULL && b->ops->print_one (b, last_loc))
result = true;
else
{
if (is_watchpoint (b))
@ -6372,6 +6374,8 @@ print_one_breakpoint_location (struct breakpoint *b,
uiout->field_string ("original-location",
event_location_to_string (b->location.get ()));
}
return result;
}
/* See breakpoint.h. */
@ -6389,7 +6393,8 @@ print_one_breakpoint (struct breakpoint *b,
|| fix_multi_location_breakpoint_output_globally);
gdb::optional<ui_out_emit_tuple> bkpt_tuple_emitter (gdb::in_place, uiout, "bkpt");
print_one_breakpoint_location (b, NULL, 0, last_loc, allflag, false);
bool printed = print_one_breakpoint_location (b, NULL, 0, last_loc,
allflag, false);
/* The mi2 broken format: the main breakpoint tuple ends here, the locations
are outside. */
@ -6399,9 +6404,7 @@ print_one_breakpoint (struct breakpoint *b,
/* If this breakpoint has custom print function,
it's already printed. Otherwise, print individual
locations, if any. */
if (b->ops == NULL
|| b->ops->print_one == NULL
|| allflag)
if (!printed || allflag)
{
/* If breakpoint has a single location that is disabled, we
print it as if it had several locations, since otherwise it's
@ -9174,7 +9177,7 @@ print_it_ranged_breakpoint (bpstat *bs)
/* Implement the "print_one" breakpoint_ops method for
ranged breakpoints. */
static void
static bool
print_one_ranged_breakpoint (struct breakpoint *b,
struct bp_location **last_loc)
{
@ -9194,6 +9197,8 @@ print_one_ranged_breakpoint (struct breakpoint *b,
annotate_field (5);
print_breakpoint_location (b, bl);
*last_loc = bl;
return true;
}
/* Implement the "print_one_detail" breakpoint_ops method for
@ -11549,6 +11554,12 @@ base_breakpoint_print_it (bpstat *bs)
internal_error_pure_virtual_called ();
}
static bool
base_breakpoint_print_one (struct breakpoint *, struct bp_location **)
{
return false;
}
static void
base_breakpoint_print_one_detail (const struct breakpoint *self,
struct ui_out *uiout)
@ -11628,7 +11639,7 @@ struct breakpoint_ops base_breakpoint_ops =
base_breakpoint_resources_needed,
base_breakpoint_works_in_software_mode,
base_breakpoint_print_it,
NULL,
base_breakpoint_print_one,
base_breakpoint_print_one_detail,
base_breakpoint_print_mention,
base_breakpoint_print_recreate,

View file

@ -608,8 +608,9 @@ struct breakpoint_ops
enum print_stop_action (*print_it) (struct bpstat *bs);
/* Display information about this breakpoint, for "info
breakpoints". */
void (*print_one) (struct breakpoint *, struct bp_location **);
breakpoints". Returns false if this method should use the
default behavior. */
bool (*print_one) (struct breakpoint *, struct bp_location **);
/* Display extra information about this breakpoint, below the normal
breakpoint description in "info breakpoints".