summaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2022-01-16 16:56:24 -0700
committerTom Tromey <tom@tromey.com>2022-04-29 16:14:30 -0600
commitc01e038bd26d36e56ab290ddf1458d4236b2e4c3 (patch)
tree0be79443651b907556e6bd32bcca16048c17fb48 /gdb
parent6689579725c370e4284f035ea283f2e459653738 (diff)
downloadbinutils-gdb-c01e038bd26d36e56ab290ddf1458d4236b2e4c3.tar.gz
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ada-lang.c4
-rw-r--r--gdb/break-catch-exec.c4
-rw-r--r--gdb/break-catch-fork.c4
-rw-r--r--gdb/break-catch-load.c4
-rw-r--r--gdb/break-catch-sig.c4
-rw-r--r--gdb/break-catch-syscall.c4
-rw-r--r--gdb/break-catch-throw.c4
-rw-r--r--gdb/breakpoint.c31
-rw-r--r--gdb/breakpoint.h5
9 files changed, 45 insertions, 19 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 42f285165e3..69698a1b99a 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -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
diff --git a/gdb/break-catch-exec.c b/gdb/break-catch-exec.c
index 10a578bd277..fa2a4717445 100644
--- a/gdb/break-catch-exec.c
+++ b/gdb/break-catch-exec.c
@@ -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
diff --git a/gdb/break-catch-fork.c b/gdb/break-catch-fork.c
index ca3c44f9381..a5c90e142bd 100644
--- a/gdb/break-catch-fork.c
+++ b/gdb/break-catch-fork.c
@@ -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
diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c
index 393fc61923d..8711c00e45c 100644
--- a/gdb/break-catch-load.c
+++ b/gdb/break-catch-load.c
@@ -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
diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c
index b739ca7dd43..06e521d9bf3 100644
--- a/gdb/break-catch-sig.c
+++ b/gdb/break-catch-sig.c
@@ -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
diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index 515a9577bb1..2b09e64ba60 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -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
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index d98baf47d6d..cec292427d4 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -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. */
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 28c898e7c0c..de1c09e6c44 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -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,
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 8c0c3a3d5b9..455a1b4b5ca 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -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".