gdb: use bool in the solib catchpoint area

Use bool instead of int in struct solib_catchpoint and in init_catchpoint &
related functions.

gdb/ChangeLog:

	* breakpoint.h (init_catchpoint): Change int parameter to bool.
	(add_solib_catchpoint): Likewise.
	* breakpoint.c (struct solib_catchpoint) <is_load>: Change type
	to bool.
	(add_solib_catchpoint): Change int parameter/variable to bool.
	(catch_load_or_unload): Likewise.
	(init_catchpoint): Likewise.
	(create_fork_vfork_event_catchpoint): Likewise.
	(catch_fork_command_1): Likewise.
	(catch_exec_command_1): Likewise.

Change-Id: I1faf4506e9109f3ccdd7229ba766dc7d77aa7aa0
This commit is contained in:
Simon Marchi
2020-09-16 17:26:30 -04:00
parent 4d0bcfcf62
commit b650a28273
3 changed files with 43 additions and 33 deletions

View File

@@ -1,3 +1,16 @@
2020-09-16 Simon Marchi <simon.marchi@efficios.com>
* breakpoint.h (init_catchpoint): Change int parameter to bool.
(add_solib_catchpoint): Likewise.
* breakpoint.c (struct solib_catchpoint) <is_load>: Change type
to bool.
(add_solib_catchpoint): Change int parameter/variable to bool.
(catch_load_or_unload): Likewise.
(init_catchpoint): Likewise.
(create_fork_vfork_event_catchpoint): Likewise.
(catch_fork_command_1): Likewise.
(catch_exec_command_1): Likewise.
2020-09-16 Simon Marchi <simon.marchi@efficios.com> 2020-09-16 Simon Marchi <simon.marchi@efficios.com>
* gdb-gdb.py.in (class StructTypePrettyPrinter) <to_string>: * gdb-gdb.py.in (class StructTypePrettyPrinter) <to_string>:

View File

@@ -7867,7 +7867,7 @@ struct solib_catchpoint : public breakpoint
~solib_catchpoint () override; ~solib_catchpoint () override;
/* True for "catch load", false for "catch unload". */ /* True for "catch load", false for "catch unload". */
unsigned char is_load; bool is_load;
/* Regular expression to match, if any. COMPILED is only valid when /* Regular expression to match, if any. COMPILED is only valid when
REGEX is non-NULL. */ REGEX is non-NULL. */
@@ -8039,15 +8039,10 @@ print_recreate_catch_solib (struct breakpoint *b, struct ui_file *fp)
static struct breakpoint_ops catch_solib_breakpoint_ops; static struct breakpoint_ops catch_solib_breakpoint_ops;
/* Shared helper function (MI and CLI) for creating and installing /* See breakpoint.h. */
a shared object event catchpoint. If IS_LOAD is non-zero then
the events to be caught are load events, otherwise they are
unload events. If IS_TEMP is non-zero the catchpoint is a
temporary one. If ENABLED is non-zero the catchpoint is
created in an enabled state. */
void void
add_solib_catchpoint (const char *arg, int is_load, int is_temp, int enabled) add_solib_catchpoint (const char *arg, bool is_load, bool is_temp, bool enabled)
{ {
struct gdbarch *gdbarch = get_current_arch (); struct gdbarch *gdbarch = get_current_arch ();
@@ -8080,12 +8075,10 @@ static void
catch_load_or_unload (const char *arg, int from_tty, int is_load, catch_load_or_unload (const char *arg, int from_tty, int is_load,
struct cmd_list_element *command) struct cmd_list_element *command)
{ {
int tempflag;
const int enabled = 1; const int enabled = 1;
bool temp = get_cmd_context (command) == CATCH_TEMPORARY;
tempflag = get_cmd_context (command) == CATCH_TEMPORARY; add_solib_catchpoint (arg, is_load, temp, enabled);
add_solib_catchpoint (arg, is_load, tempflag, enabled);
} }
static void static void
@@ -8102,14 +8095,11 @@ catch_unload_command_1 (const char *arg, int from_tty,
catch_load_or_unload (arg, from_tty, 0, command); catch_load_or_unload (arg, from_tty, 0, command);
} }
/* Initialize a new breakpoint of the bp_catchpoint kind. If TEMPFLAG /* See breakpoint.h. */
is non-zero, then make the breakpoint temporary. If COND_STRING is
not NULL, then store it in the breakpoint. OPS, if not NULL, is
the breakpoint_ops structure associated to the catchpoint. */
void void
init_catchpoint (struct breakpoint *b, init_catchpoint (struct breakpoint *b,
struct gdbarch *gdbarch, int tempflag, struct gdbarch *gdbarch, bool temp,
const char *cond_string, const char *cond_string,
const struct breakpoint_ops *ops) const struct breakpoint_ops *ops)
{ {
@@ -8119,7 +8109,7 @@ init_catchpoint (struct breakpoint *b,
init_raw_breakpoint (b, gdbarch, sal, bp_catchpoint, ops); init_raw_breakpoint (b, gdbarch, sal, bp_catchpoint, ops);
b->cond_string = (cond_string == NULL) ? NULL : xstrdup (cond_string); b->cond_string = (cond_string == NULL) ? NULL : xstrdup (cond_string);
b->disposition = tempflag ? disp_del : disp_donttouch; b->disposition = temp ? disp_del : disp_donttouch;
} }
void void
@@ -8139,12 +8129,12 @@ install_breakpoint (int internal, std::unique_ptr<breakpoint> &&arg, int update_
static void static void
create_fork_vfork_event_catchpoint (struct gdbarch *gdbarch, create_fork_vfork_event_catchpoint (struct gdbarch *gdbarch,
int tempflag, const char *cond_string, bool temp, const char *cond_string,
const struct breakpoint_ops *ops) const struct breakpoint_ops *ops)
{ {
std::unique_ptr<fork_catchpoint> c (new fork_catchpoint ()); std::unique_ptr<fork_catchpoint> c (new fork_catchpoint ());
init_catchpoint (c.get (), gdbarch, tempflag, cond_string, ops); init_catchpoint (c.get (), gdbarch, temp, cond_string, ops);
c->forked_inferior_pid = null_ptid; c->forked_inferior_pid = null_ptid;
@@ -11148,10 +11138,9 @@ catch_fork_command_1 (const char *arg, int from_tty,
struct gdbarch *gdbarch = get_current_arch (); struct gdbarch *gdbarch = get_current_arch ();
const char *cond_string = NULL; const char *cond_string = NULL;
catch_fork_kind fork_kind; catch_fork_kind fork_kind;
int tempflag;
fork_kind = (catch_fork_kind) (uintptr_t) get_cmd_context (command); fork_kind = (catch_fork_kind) (uintptr_t) get_cmd_context (command);
tempflag = (fork_kind == catch_fork_temporary bool temp = (fork_kind == catch_fork_temporary
|| fork_kind == catch_vfork_temporary); || fork_kind == catch_vfork_temporary);
if (!arg) if (!arg)
@@ -11174,12 +11163,12 @@ catch_fork_command_1 (const char *arg, int from_tty,
{ {
case catch_fork_temporary: case catch_fork_temporary:
case catch_fork_permanent: case catch_fork_permanent:
create_fork_vfork_event_catchpoint (gdbarch, tempflag, cond_string, create_fork_vfork_event_catchpoint (gdbarch, temp, cond_string,
&catch_fork_breakpoint_ops); &catch_fork_breakpoint_ops);
break; break;
case catch_vfork_temporary: case catch_vfork_temporary:
case catch_vfork_permanent: case catch_vfork_permanent:
create_fork_vfork_event_catchpoint (gdbarch, tempflag, cond_string, create_fork_vfork_event_catchpoint (gdbarch, temp, cond_string,
&catch_vfork_breakpoint_ops); &catch_vfork_breakpoint_ops);
break; break;
default: default:
@@ -11193,10 +11182,8 @@ catch_exec_command_1 (const char *arg, int from_tty,
struct cmd_list_element *command) struct cmd_list_element *command)
{ {
struct gdbarch *gdbarch = get_current_arch (); struct gdbarch *gdbarch = get_current_arch ();
int tempflag;
const char *cond_string = NULL; const char *cond_string = NULL;
bool temp = get_cmd_context (command) == CATCH_TEMPORARY;
tempflag = get_cmd_context (command) == CATCH_TEMPORARY;
if (!arg) if (!arg)
arg = ""; arg = "";
@@ -11213,7 +11200,7 @@ catch_exec_command_1 (const char *arg, int from_tty,
error (_("Junk at end of arguments.")); error (_("Junk at end of arguments."));
std::unique_ptr<exec_catchpoint> c (new exec_catchpoint ()); std::unique_ptr<exec_catchpoint> c (new exec_catchpoint ());
init_catchpoint (c.get (), gdbarch, tempflag, cond_string, init_catchpoint (c.get (), gdbarch, temp, cond_string,
&catch_exec_breakpoint_ops); &catch_exec_breakpoint_ops);
c->exec_pathname = NULL; c->exec_pathname = NULL;

View File

@@ -1333,8 +1333,13 @@ extern void
int enabled, int enabled,
int from_tty); int from_tty);
/* Initialize a new breakpoint of the bp_catchpoint kind. If TEMP
is true, then make the breakpoint temporary. If COND_STRING is
not NULL, then store it in the breakpoint. OPS, if not NULL, is
the breakpoint_ops structure associated to the catchpoint. */
extern void init_catchpoint (struct breakpoint *b, extern void init_catchpoint (struct breakpoint *b,
struct gdbarch *gdbarch, int tempflag, struct gdbarch *gdbarch, bool temp,
const char *cond_string, const char *cond_string,
const struct breakpoint_ops *ops); const struct breakpoint_ops *ops);
@@ -1561,9 +1566,14 @@ extern void disable_breakpoints_in_shlibs (void);
extern bool is_catchpoint (struct breakpoint *b); extern bool is_catchpoint (struct breakpoint *b);
/* Shared helper function (MI and CLI) for creating and installing /* Shared helper function (MI and CLI) for creating and installing
a shared object event catchpoint. */ a shared object event catchpoint. If IS_LOAD is true then
extern void add_solib_catchpoint (const char *arg, int is_load, int is_temp, the events to be caught are load events, otherwise they are
int enabled); unload events. If IS_TEMP is true the catchpoint is a
temporary one. If ENABLED is true the catchpoint is
created in an enabled state. */
extern void add_solib_catchpoint (const char *arg, bool is_load, bool is_temp,
bool enabled);
/* Create and insert a new software single step breakpoint for the /* Create and insert a new software single step breakpoint for the
current thread. May be called multiple times; each time will add a current thread. May be called multiple times; each time will add a