From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 6A51F385781D; Fri, 29 Apr 2022 22:24:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A51F385781D 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] Merge probe and ordinary breakpoints X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 823b50f3857846fe7cd8fb8831a13797903885b8 X-Git-Newrev: 5d926615e9684d1f9a95801106300ade64548dcc Message-Id: <20220429222406.6A51F385781D@sourceware.org> Date: Fri, 29 Apr 2022 22:24:06 +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:24:06 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D5d926615e968= 4d1f9a95801106300ade64548dcc commit 5d926615e9684d1f9a95801106300ade64548dcc Author: Tom Tromey Date: Sun Jan 16 17:25:52 2022 -0700 Merge probe and ordinary breakpoints =20 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. =20 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 **l= oc); =20 static struct bp_location *allocate_bp_location (struct breakpoint *bpt); =20 +static std::vector 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_locat= ion *bl) bl->target_info.kind =3D breakpoint_kind (bl, &addr); bl->target_info.placed_address =3D addr; =20 + int result; if (bl->loc_type =3D=3D bp_loc_hardware_breakpoint) - return target_insert_hw_breakpoint (bl->gdbarch, &bl->target_info); + result =3D target_insert_hw_breakpoint (bl->gdbarch, &bl->target_info); else - return target_insert_breakpoint (bl->gdbarch, &bl->target_info); + result =3D target_insert_breakpoint (bl->gdbarch, &bl->target_info); + + if (result =3D=3D 0 && bl->probe.prob !=3D 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; } =20 int base_breakpoint::remove_location (struct bp_location *bl, enum remove_bp_reason reason) { + if (bl->probe.prob !=3D nullptr) + { + /* Let's clear the semaphore before removing the location. */ + bl->probe.prob->clear_semaphore (bl->probe.objfile, bl->gdbarch); + } + if (bl->loc_type =3D=3D bp_loc_hardware_breakpoint) return target_remove_hw_breakpoint (bl->gdbarch, &bl->target_info); else @@ -12001,6 +12022,9 @@ std::vector base_breakpoint::decode_location (struct event_location *location, struct program_space *search_pspace) { + if (event_location_type (location) =3D=3D PROBE_LOCATION) + return bkpt_probe_decode_location (this, location, search_pspace); + return decode_location_default (this, location, search_pspace); } =20 @@ -12139,33 +12163,6 @@ longjmp_breakpoint::~longjmp_breakpoint () tp->initiating_frame =3D null_frame_id; } =20 -/* Specific methods for probe breakpoints. */ - -static int -bkpt_probe_insert_location (struct bp_location *bl) -{ - int v =3D bl->owner->insert_location (bl); - - if (v =3D=3D 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 =3D &bkpt_probe_breakpoint_ops; *ops =3D vtable_breakpoint_ops; - ops->insert_location =3D bkpt_probe_insert_location; - ops->remove_location =3D bkpt_probe_remove_location; ops->create_sals_from_location =3D bkpt_probe_create_sals_from_location; - ops->decode_location =3D bkpt_probe_decode_location; =20 /* Probe tracepoints. */ ops =3D &tracepoint_probe_breakpoint_ops;