public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Convert break-catch-exec to vtable ops Date: Fri, 29 Apr 2022 22:22:35 +0000 (GMT) [thread overview] Message-ID: <20220429222235.26F303857806@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=021443b5f3d73a4e148afabc06a0b8dcec54734a commit 021443b5f3d73a4e148afabc06a0b8dcec54734a Author: Tom Tromey <tom@tromey.com> Date: Fri Jan 14 18:56:19 2022 -0700 Convert break-catch-exec to vtable ops 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 @@ 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<char> exec_pathname; }; -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 ()); } -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 ()); } -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 = (struct exec_catchpoint *) bl->owner; - if (ws.kind () != TARGET_WAITKIND_EXECD) return 0; - c->exec_pathname = make_unique_xstrdup (ws.execd_pathname ()); + exec_pathname = make_unique_xstrdup (ws.execd_pathname ()); return 1; } -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 = current_uiout; - struct breakpoint *b = bs->breakpoint_at; - struct exec_catchpoint *c = (struct exec_catchpoint *) b; - annotate_catchpoint (b->number); + annotate_catchpoint (number); maybe_print_thread_hit_breakpoint (uiout); - if (b->disposition == disp_del) + if (disposition == 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 ("), "); return PRINT_SRC_AND_LOC; } -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 = (struct exec_catchpoint *) b; struct value_print_options opts; struct ui_out *uiout = current_uiout; @@ -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 != NULL) + if (exec_pathname != NULL) { uiout->text (", program \""); - uiout->field_string ("what", c->exec_pathname.get ()); + uiout->field_string ("what", exec_pathname.get ()); uiout->text ("\" "); } @@ -123,24 +132,21 @@ print_one_catch_exec (struct breakpoint *b, struct bp_location **last_loc) return true; } -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); } -/* Implement the "print_recreate" breakpoint_ops method for exec - catchpoints. */ +/* Implement the "print_recreate" method for exec catchpoints. */ -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); } -static struct breakpoint_ops catch_exec_breakpoint_ops; - /* This function attempts to parse an optional "if <cond>" clause from the arg string. If one is not found, it returns NULL. @@ -199,37 +205,16 @@ catch_exec_command_1 (const char *arg, int from_tty, std::unique_ptr<exec_catchpoint> c (new exec_catchpoint ()); init_catchpoint (c.get (), gdbarch, temp, cond_string, - &catch_exec_breakpoint_ops); + &vtable_breakpoint_ops); c->exec_pathname.reset (); install_breakpoint (0, std::move (c), 1); } -static void -initialize_ops () -{ - struct breakpoint_ops *ops; - - initialize_breakpoint_ops (); - - /* Exec catchpoints. */ - ops = &catch_exec_breakpoint_ops; - *ops = base_breakpoint_ops; - ops->insert_location = insert_catch_exec; - ops->remove_location = remove_catch_exec; - ops->breakpoint_hit = breakpoint_hit_catch_exec; - ops->print_it = print_it_catch_exec; - ops->print_one = print_one_catch_exec; - ops->print_mention = print_mention_catch_exec; - ops->print_recreate = 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,
reply other threads:[~2022-04-29 22:22 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220429222235.26F303857806@sourceware.org \ --to=tromey@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).