aboutsummaryrefslogtreecommitdiff
path: root/gdb/break-catch-load.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2022-04-30 14:19:44 -0600
committerTom Tromey <tom@tromey.com>2022-05-06 12:03:34 -0600
commit4874f776caf053b708d7f76d6b72a8846f2ca219 (patch)
treeaf1722119097e09f8eb439f01c90e59b5b929922 /gdb/break-catch-load.c
parentec798154804ede0a7a3a9bcd3d8d08cd0499897b (diff)
downloadbinutils-4874f776caf053b708d7f76d6b72a8846f2ca219.zip
binutils-4874f776caf053b708d7f76d6b72a8846f2ca219.tar.gz
binutils-4874f776caf053b708d7f76d6b72a8846f2ca219.tar.bz2
Add constructor to solib_catchpoint
This adds a constructor to solib_catchpoint and simplifies the caller.
Diffstat (limited to 'gdb/break-catch-load.c')
-rw-r--r--gdb/break-catch-load.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c
index 99aa185ad..3e3bed2 100644
--- a/gdb/break-catch-load.c
+++ b/gdb/break-catch-load.c
@@ -35,6 +35,15 @@
struct solib_catchpoint : public breakpoint
{
+ solib_catchpoint (bool is_load_, const char *arg)
+ : is_load (is_load_),
+ regex (arg == nullptr ? nullptr : make_unique_xstrdup (arg)),
+ compiled (arg == nullptr
+ ? nullptr
+ : new compiled_regex (arg, REG_NOSUB, _("Invalid regexp")))
+ {
+ }
+
int insert_location (struct bp_location *) override;
int remove_location (struct bp_location *,
enum remove_bp_reason reason) override;
@@ -216,17 +225,11 @@ add_solib_catchpoint (const char *arg, bool is_load, bool is_temp, bool enabled)
if (!arg)
arg = "";
arg = skip_spaces (arg);
+ if (*arg == '\0')
+ arg = nullptr;
- std::unique_ptr<solib_catchpoint> c (new solib_catchpoint ());
-
- if (*arg != '\0')
- {
- c->compiled.reset (new compiled_regex (arg, REG_NOSUB,
- _("Invalid regexp")));
- c->regex = make_unique_xstrdup (arg);
- }
+ std::unique_ptr<solib_catchpoint> c (new solib_catchpoint (is_load, arg));
- c->is_load = is_load;
init_catchpoint (c.get (), gdbarch, is_temp, NULL);
c->enable_state = enabled ? bp_enabled : bp_disabled;