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] Merge probe and ordinary breakpoints Date: Fri, 29 Apr 2022 22:24:06 +0000 (GMT) [thread overview] Message-ID: <20220429222406.6A51F385781D@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5d926615e9684d1f9a95801106300ade64548dcc commit 5d926615e9684d1f9a95801106300ade64548dcc Author: Tom Tromey <tom@tromey.com> Date: Sun Jan 16 17:25:52 2022 -0700 Merge probe and ordinary breakpoints Right now, probe breakpoints are handled by a separate ops object. However, they differ only in a small way from ordinary breakpoints, and furthermore can be distinguished by their "probe" object. This patch merges the two cases. This avoids having to introduce a new bp_ constant (which can be quite subtle to do correctly) and a new subclass. Diff: --- gdb/breakpoint.c | 58 +++++++++++++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 67b9313ad83..c7fa53c53e2 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -177,6 +177,11 @@ static void decref_bp_location (struct bp_location **loc); static struct bp_location *allocate_bp_location (struct breakpoint *bpt); +static std::vector<symtab_and_line> bkpt_probe_decode_location + (struct breakpoint *b, + struct event_location *location, + struct program_space *search_pspace); + /* update_global_location_list's modes of operation wrt to whether to insert locations now. */ enum ugll_insert_mode @@ -11845,16 +11850,32 @@ base_breakpoint::insert_location (struct bp_location *bl) bl->target_info.kind = breakpoint_kind (bl, &addr); bl->target_info.placed_address = addr; + int result; if (bl->loc_type == bp_loc_hardware_breakpoint) - return target_insert_hw_breakpoint (bl->gdbarch, &bl->target_info); + result = target_insert_hw_breakpoint (bl->gdbarch, &bl->target_info); else - return target_insert_breakpoint (bl->gdbarch, &bl->target_info); + result = target_insert_breakpoint (bl->gdbarch, &bl->target_info); + + if (result == 0 && bl->probe.prob != nullptr) + { + /* The insertion was successful, now let's set the probe's semaphore + if needed. */ + bl->probe.prob->set_semaphore (bl->probe.objfile, bl->gdbarch); + } + + return result; } int base_breakpoint::remove_location (struct bp_location *bl, enum remove_bp_reason reason) { + if (bl->probe.prob != nullptr) + { + /* Let's clear the semaphore before removing the location. */ + bl->probe.prob->clear_semaphore (bl->probe.objfile, bl->gdbarch); + } + if (bl->loc_type == bp_loc_hardware_breakpoint) return target_remove_hw_breakpoint (bl->gdbarch, &bl->target_info); else @@ -12001,6 +12022,9 @@ std::vector<symtab_and_line> base_breakpoint::decode_location (struct event_location *location, struct program_space *search_pspace) { + if (event_location_type (location) == PROBE_LOCATION) + return bkpt_probe_decode_location (this, location, search_pspace); + return decode_location_default (this, location, search_pspace); } @@ -12139,33 +12163,6 @@ longjmp_breakpoint::~longjmp_breakpoint () tp->initiating_frame = null_frame_id; } -/* Specific methods for probe breakpoints. */ - -static int -bkpt_probe_insert_location (struct bp_location *bl) -{ - int v = bl->owner->insert_location (bl); - - if (v == 0) - { - /* The insertion was successful, now let's set the probe's semaphore - if needed. */ - bl->probe.prob->set_semaphore (bl->probe.objfile, bl->gdbarch); - } - - return v; -} - -static int -bkpt_probe_remove_location (struct bp_location *bl, - enum remove_bp_reason reason) -{ - /* Let's clear the semaphore before removing the location. */ - bl->probe.prob->clear_semaphore (bl->probe.objfile, bl->gdbarch); - - return bl->owner->remove_location (bl, reason); -} - static void bkpt_probe_create_sals_from_location (struct event_location *location, struct linespec_result *canonical, @@ -14579,10 +14576,7 @@ initialize_breakpoint_ops (void) /* Probe breakpoints. */ ops = &bkpt_probe_breakpoint_ops; *ops = vtable_breakpoint_ops; - ops->insert_location = bkpt_probe_insert_location; - ops->remove_location = bkpt_probe_remove_location; ops->create_sals_from_location = bkpt_probe_create_sals_from_location; - ops->decode_location = bkpt_probe_decode_location; /* Probe tracepoints. */ ops = &tracepoint_probe_breakpoint_ops;
reply other threads:[~2022-04-29 22:24 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=20220429222406.6A51F385781D@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).