From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id D954D385828A; Sun, 14 Aug 2022 13:47:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D954D385828A 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] Change location_spec_to_sals to a method X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: b3d5660a7adf2e1e3846976ff4346c6a9b323978 X-Git-Newrev: 2c9a6d728e3ab63d8338b5e1f831d2c1eead8d67 Message-Id: <20220814134759.D954D385828A@sourceware.org> Date: Sun, 14 Aug 2022 13:47:59 +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: Sun, 14 Aug 2022 13:48:00 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D2c9a6d728e3a= b63d8338b5e1f831d2c1eead8d67 commit 2c9a6d728e3ab63d8338b5e1f831d2c1eead8d67 Author: Tom Tromey Date: Sat May 21 10:00:00 2022 -0600 Change location_spec_to_sals to a method =20 location_spec_to_sals is only ever called for code breakpoints, so make it a protected method there. Diff: --- gdb/breakpoint.c | 62 +++++++++++++++++++++++++++++-----------------------= ---- gdb/breakpoint.h | 8 ++++++++ 2 files changed, 40 insertions(+), 30 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 35701930cac..b24fbd1fe36 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -12636,9 +12636,10 @@ update_breakpoint_locations (code_breakpoint *b, /* Find the SaL locations corresponding to the given LOCSPEC. On return, FOUND will be 1 if any SaL was found, zero otherwise. */ =20 -static std::vector -location_spec_to_sals (struct breakpoint *b, location_spec *locspec, - struct program_space *search_pspace, int *found) +std::vector +code_breakpoint::location_spec_to_sals (location_spec *locspec, + struct program_space *search_pspace, + int *found) { struct gdb_exception exception; =20 @@ -12646,7 +12647,7 @@ location_spec_to_sals (struct breakpoint *b, locati= on_spec *locspec, =20 try { - sals =3D b->decode_location_spec (locspec, search_pspace); + sals =3D decode_location_spec (locspec, search_pspace); } catch (gdb_exception_error &e) { @@ -12660,13 +12661,13 @@ location_spec_to_sals (struct breakpoint *b, loca= tion_spec *locspec, breakpoint being disabled, and don't want to see more errors. */ if (e.error =3D=3D NOT_FOUND_ERROR - && (b->condition_not_parsed - || (b->loc !=3D NULL + && (condition_not_parsed + || (loc !=3D NULL && search_pspace !=3D NULL - && b->loc->pspace !=3D search_pspace) - || (b->loc && b->loc->shlib_disabled) - || (b->loc && b->loc->pspace->executing_startup) - || b->enable_state =3D=3D bp_disabled)) + && loc->pspace !=3D search_pspace) + || (loc && loc->shlib_disabled) + || (loc && loc->pspace->executing_startup) + || enable_state =3D=3D bp_disabled)) not_found_and_ok =3D 1; =20 if (!not_found_and_ok) @@ -12677,7 +12678,7 @@ location_spec_to_sals (struct breakpoint *b, locati= on_spec *locspec, have separate 'warning emitted' flag. Since this happens only when a binary has changed, I don't know which approach is better. */ - b->enable_state =3D bp_disabled; + enable_state =3D bp_disabled; throw; } =20 @@ -12688,26 +12689,26 @@ location_spec_to_sals (struct breakpoint *b, loca= tion_spec *locspec, { for (auto &sal : sals) resolve_sal_pc (&sal); - if (b->condition_not_parsed && b->extra_string !=3D NULL) + if (condition_not_parsed && extra_string !=3D NULL) { - gdb::unique_xmalloc_ptr cond_string, extra_string; - int thread, task; + gdb::unique_xmalloc_ptr local_cond, local_extra; + int local_thread, local_task; =20 - find_condition_and_thread_for_sals (sals, b->extra_string.get (), - &cond_string, &thread, - &task, &extra_string); - gdb_assert (b->cond_string =3D=3D NULL); - if (cond_string) - b->cond_string =3D std::move (cond_string); - b->thread =3D thread; - b->task =3D task; - if (extra_string) - b->extra_string =3D std::move (extra_string); - b->condition_not_parsed =3D 0; + find_condition_and_thread_for_sals (sals, extra_string.get (), + &local_cond, &local_thread, + &local_task, &local_extra); + gdb_assert (cond_string =3D=3D nullptr); + if (local_cond !=3D nullptr) + cond_string =3D std::move (local_cond); + thread =3D local_thread; + task =3D local_task; + if (local_extra !=3D nullptr) + extra_string =3D std::move (local_extra); + condition_not_parsed =3D 0; } =20 - if (b->type =3D=3D bp_static_tracepoint) - sals[0] =3D update_static_tracepoint (b, sals[0]); + if (type =3D=3D bp_static_tracepoint) + sals[0] =3D update_static_tracepoint (this, sals[0]); =20 *found =3D 1; } @@ -12728,15 +12729,16 @@ code_breakpoint::re_set_default () std::vector expanded, expanded_end; =20 int found; - std::vector sals - =3D location_spec_to_sals (this, locspec.get (), filter_pspace, &found= ); + std::vector sals =3D location_spec_to_sals (locspec.get= (), + filter_pspace, + &found); if (found) expanded =3D std::move (sals); =20 if (locspec_range_end !=3D nullptr) { std::vector sals_end - =3D location_spec_to_sals (this, locspec_range_end.get (), + =3D location_spec_to_sals (locspec_range_end.get (), filter_pspace, &found); if (found) expanded_end =3D std::move (sals_end); diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 5316d193cc5..e919fe6f0d2 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -891,6 +891,14 @@ protected: =20 /* Helper method that does the basic work of re_set. */ void re_set_default (); + + /* Find the SaL locations corresponding to the given LOCATION. + On return, FOUND will be 1 if any SaL was found, zero otherwise. */ + + std::vector location_spec_to_sals + (location_spec *locspec, + struct program_space *search_pspace, + int *found); }; =20 /* An instance of this type is used to represent a watchpoint,