From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 0100B3857373; Fri, 6 May 2022 18:10:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0100B3857373 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Add constructor to solib_catchpoint X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: ec798154804ede0a7a3a9bcd3d8d08cd0499897b X-Git-Newrev: 4874f776caf053b708d7f76d6b72a8846f2ca219 Message-Id: <20220506181052.0100B3857373@sourceware.org> Date: Fri, 6 May 2022 18:10:52 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 May 2022 18:10:52 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D4874f776caf0= 53b708d7f76d6b72a8846f2ca219 commit 4874f776caf053b708d7f76d6b72a8846f2ca219 Author: Tom Tromey Date: Sat Apr 30 14:19:44 2022 -0600 Add constructor to solib_catchpoint =20 This adds a constructor to solib_catchpoint and simplifies the caller. Diff: --- gdb/break-catch-load.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c index 99aa185ad85..3e3bed2f861 100644 --- a/gdb/break-catch-load.c +++ b/gdb/break-catch-load.c @@ -35,6 +35,15 @@ =20 struct solib_catchpoint : public breakpoint { + solib_catchpoint (bool is_load_, const char *arg) + : is_load (is_load_), + regex (arg =3D=3D nullptr ? nullptr : make_unique_xstrdup (arg)), + compiled (arg =3D=3D 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 =3D ""; arg =3D skip_spaces (arg); + if (*arg =3D=3D '\0') + arg =3D nullptr; =20 - std::unique_ptr c (new solib_catchpoint ()); - - if (*arg !=3D '\0') - { - c->compiled.reset (new compiled_regex (arg, REG_NOSUB, - _("Invalid regexp"))); - c->regex =3D make_unique_xstrdup (arg); - } + std::unique_ptr c (new solib_catchpoint (is_load, arg)= ); =20 - c->is_load =3D is_load; init_catchpoint (c.get (), gdbarch, is_temp, NULL); =20 c->enable_state =3D enabled ? bp_enabled : bp_disabled;