From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 26F303857806; Fri, 29 Apr 2022 22:22:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26F303857806 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] Convert break-catch-exec to vtable ops X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 3aca48d3b44720aaa23fe969f8b460aad2034aea X-Git-Newrev: 021443b5f3d73a4e148afabc06a0b8dcec54734a Message-Id: <20220429222235.26F303857806@sourceware.org> Date: Fri, 29 Apr 2022 22:22:35 +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, 29 Apr 2022 22:22:35 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D021443b5f3d7= 3a4e148afabc06a0b8dcec54734a commit 021443b5f3d73a4e148afabc06a0b8dcec54734a Author: Tom Tromey Date: Fri Jan 14 18:56:19 2022 -0700 Convert break-catch-exec to vtable ops =20 This converts break-catch-exec.c to use vtable_breakpoint_ops. Diff: --- gdb/break-catch-exec.c | 99 +++++++++++++++++++++-------------------------= ---- 1 file changed, 42 insertions(+), 57 deletions(-) diff --git a/gdb/break-catch-exec.c b/gdb/break-catch-exec.c index fa2a4717445..9d84fed273b 100644 --- a/gdb/break-catch-exec.c +++ b/gdb/break-catch-exec.c @@ -36,68 +36,77 @@ =20 struct exec_catchpoint : public breakpoint { + int insert_location (struct bp_location *) override; + int remove_location (struct bp_location *, + enum remove_bp_reason reason) override; + int breakpoint_hit (const struct bp_location *bl, + const address_space *aspace, + CORE_ADDR bp_addr, + const target_waitstatus &ws) override; + enum print_stop_action print_it (struct bpstat *bs) override; + bool print_one (struct bp_location **) override; + void print_mention () override; + void print_recreate (struct ui_file *fp) override; + /* Filename of a program whose exec triggered this catchpoint. This field is only valid immediately after this catchpoint has triggered. */ gdb::unique_xmalloc_ptr exec_pathname; }; =20 -static int -insert_catch_exec (struct bp_location *bl) +int +exec_catchpoint::insert_location (struct bp_location *bl) { return target_insert_exec_catchpoint (inferior_ptid.pid ()); } =20 -static int -remove_catch_exec (struct bp_location *bl, enum remove_bp_reason reason) +int +exec_catchpoint::remove_location (struct bp_location *bl, + enum remove_bp_reason reason) { return target_remove_exec_catchpoint (inferior_ptid.pid ()); } =20 -static int -breakpoint_hit_catch_exec (const struct bp_location *bl, - const address_space *aspace, CORE_ADDR bp_addr, - const target_waitstatus &ws) +int +exec_catchpoint::breakpoint_hit (const struct bp_location *bl, + const address_space *aspace, + CORE_ADDR bp_addr, + const target_waitstatus &ws) { - struct exec_catchpoint *c =3D (struct exec_catchpoint *) bl->owner; - if (ws.kind () !=3D TARGET_WAITKIND_EXECD) return 0; =20 - c->exec_pathname =3D make_unique_xstrdup (ws.execd_pathname ()); + exec_pathname =3D make_unique_xstrdup (ws.execd_pathname ()); return 1; } =20 -static enum print_stop_action -print_it_catch_exec (bpstat *bs) +enum print_stop_action +exec_catchpoint::print_it (bpstat *bs) { struct ui_out *uiout =3D current_uiout; - struct breakpoint *b =3D bs->breakpoint_at; - struct exec_catchpoint *c =3D (struct exec_catchpoint *) b; =20 - annotate_catchpoint (b->number); + annotate_catchpoint (number); maybe_print_thread_hit_breakpoint (uiout); - if (b->disposition =3D=3D disp_del) + if (disposition =3D=3D disp_del) uiout->text ("Temporary catchpoint "); else uiout->text ("Catchpoint "); if (uiout->is_mi_like_p ()) { uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_EXEC)= ); - uiout->field_string ("disp", bpdisp_text (b->disposition)); + uiout->field_string ("disp", bpdisp_text (disposition)); } - uiout->field_signed ("bkptno", b->number); + uiout->field_signed ("bkptno", number); uiout->text (" (exec'd "); - uiout->field_string ("new-exec", c->exec_pathname.get ()); + uiout->field_string ("new-exec", exec_pathname.get ()); uiout->text ("), "); =20 return PRINT_SRC_AND_LOC; } =20 -static bool -print_one_catch_exec (struct breakpoint *b, struct bp_location **last_loc) +bool +exec_catchpoint::print_one (struct bp_location **last_loc) { - struct exec_catchpoint *c =3D (struct exec_catchpoint *) b; struct value_print_options opts; struct ui_out *uiout =3D current_uiout; =20 @@ -110,10 +119,10 @@ print_one_catch_exec (struct breakpoint *b, struct bp= _location **last_loc) uiout->field_skip ("addr"); annotate_field (5); uiout->text ("exec"); - if (c->exec_pathname !=3D NULL) + if (exec_pathname !=3D NULL) { uiout->text (", program \""); - uiout->field_string ("what", c->exec_pathname.get ()); + uiout->field_string ("what", exec_pathname.get ()); uiout->text ("\" "); } =20 @@ -123,24 +132,21 @@ print_one_catch_exec (struct breakpoint *b, struct bp= _location **last_loc) return true; } =20 -static void -print_mention_catch_exec (struct breakpoint *b) +void +exec_catchpoint::print_mention () { - gdb_printf (_("Catchpoint %d (exec)"), b->number); + gdb_printf (_("Catchpoint %d (exec)"), number); } =20 -/* Implement the "print_recreate" breakpoint_ops method for exec - catchpoints. */ +/* Implement the "print_recreate" method for exec catchpoints. */ =20 -static void -print_recreate_catch_exec (struct breakpoint *b, struct ui_file *fp) +void +exec_catchpoint::print_recreate (struct ui_file *fp) { gdb_printf (fp, "catch exec"); - print_recreate_thread (b, fp); + print_recreate_thread (this, fp); } =20 -static struct breakpoint_ops catch_exec_breakpoint_ops; - /* This function attempts to parse an optional "if " clause from the arg string. If one is not found, it returns NULL. =20 @@ -199,37 +205,16 @@ catch_exec_command_1 (const char *arg, int from_tty, =20 std::unique_ptr c (new exec_catchpoint ()); init_catchpoint (c.get (), gdbarch, temp, cond_string, - &catch_exec_breakpoint_ops); + &vtable_breakpoint_ops); c->exec_pathname.reset (); =20 install_breakpoint (0, std::move (c), 1); } =20 -static void -initialize_ops () -{ - struct breakpoint_ops *ops; - - initialize_breakpoint_ops (); - - /* Exec catchpoints. */ - ops =3D &catch_exec_breakpoint_ops; - *ops =3D base_breakpoint_ops; - ops->insert_location =3D insert_catch_exec; - ops->remove_location =3D remove_catch_exec; - ops->breakpoint_hit =3D breakpoint_hit_catch_exec; - ops->print_it =3D print_it_catch_exec; - ops->print_one =3D print_one_catch_exec; - ops->print_mention =3D print_mention_catch_exec; - ops->print_recreate =3D print_recreate_catch_exec; -} - void _initialize_break_catch_exec (); void _initialize_break_catch_exec () { - initialize_ops (); - add_catch_command ("exec", _("Catch calls to exec."), catch_exec_command_1, NULL,