From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id A893B3858C50; Fri, 20 Jan 2023 19:53:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A893B3858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674244387; bh=bjXm2kodE8M3v2l99aDgg/g6qG2PQWX8IjpNTrqf2SA=; h=From:To:Subject:Date:From; b=QRloy6/+rZFqZzJJyV99cBElO0AG/ugb8d5LUx28UbL737NlWW8ohiSi3CxIOf48W YTIEA/4XX5Gv32/EKmNS3nBFHZzTpwdDlYV40i9mJm3/SHeLn5kQB9aGZX41EfbXh0 r+ZDgOGSnt72mwqjnOAedDGWNHbqCdRLiyGmZdUg= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: make frame_info_ptr grab frame level and id on construction X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: 836a8d3710462596bb4184617999a9507adc3629 X-Git-Newrev: 93e39555dd0fcd222ce68fc7162f511056361bc7 Message-Id: <20230120195307.A893B3858C50@sourceware.org> Date: Fri, 20 Jan 2023 19:53:07 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D93e39555dd0f= cd222ce68fc7162f511056361bc7 commit 93e39555dd0fcd222ce68fc7162f511056361bc7 Author: Simon Marchi Date: Tue Dec 13 22:34:40 2022 -0500 gdb: make frame_info_ptr grab frame level and id on construction =20 This is the first step of making frame_info_ptr automatic. Remove the frame_info_ptr::prepare_reinflate method, move that code to the constructor. =20 Change-Id: I85cdae3ab1c043c70e2702e7fb38e9a4a8a675d8 Reviewed-By: Bruno Larsen Diff: --- gdb/frame.c | 19 +++++++++++-------- gdb/frame.h | 9 +-------- gdb/infcall.c | 1 - gdb/infcmd.c | 1 - gdb/mi/mi-cmd-stack.c | 1 - gdb/stack.c | 10 ---------- gdb/unittests/frame_info_ptr-selftests.c | 2 -- 7 files changed, 12 insertions(+), 31 deletions(-) diff --git a/gdb/frame.c b/gdb/frame.c index 2d2af874d6a..c4b0f0166d6 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -3208,14 +3208,18 @@ intrusive_list frame_info_ptr::fram= e_list; =20 /* See frame-info-ptr.h. */ =20 -void -frame_info_ptr::prepare_reinflate () +frame_info_ptr::frame_info_ptr (struct frame_info *ptr) + : m_ptr (ptr) { - m_cached_level =3D frame_relative_level (*this); + frame_list.push_back (*this); + + if (m_ptr =3D=3D nullptr) + return; + + m_cached_level =3D ptr->level; =20 - if (m_cached_level !=3D 0 - || (m_ptr !=3D nullptr && m_ptr->this_id.value.user_created_p)) - m_cached_id =3D get_frame_id (*this); + if (m_cached_level !=3D 0 || m_ptr->this_id.value.user_created_p) + m_cached_id =3D m_ptr->this_id.value; } =20 /* See frame-info-ptr.h. */ @@ -3223,8 +3227,7 @@ frame_info_ptr::prepare_reinflate () void frame_info_ptr::reinflate () { - /* Ensure we have a valid frame level (sentinel frame or above), indicat= ing - prepare_reinflate was called. */ + /* Ensure we have a valid frame level (sentinel frame or above). */ gdb_assert (m_cached_level >=3D -1); =20 if (m_ptr !=3D nullptr) diff --git a/gdb/frame.h b/gdb/frame.h index 74524ec41f4..105b9fb92a8 100644 --- a/gdb/frame.h +++ b/gdb/frame.h @@ -206,11 +206,7 @@ class frame_info_ptr : public intrusive_list_node { public: /* Create a frame_info_ptr from a raw pointer. */ - explicit frame_info_ptr (struct frame_info *ptr) - : m_ptr (ptr) - { - frame_list.push_back (*this); - } + explicit frame_info_ptr (struct frame_info *ptr); =20 /* Create a null frame_info_ptr. */ frame_info_ptr () @@ -310,9 +306,6 @@ public: m_ptr =3D nullptr; } =20 - /* Cache the frame_id that the pointer will use to reinflate. */ - void prepare_reinflate (); - /* Use the cached frame_id to reinflate the pointer. */ void reinflate (); =20 diff --git a/gdb/infcall.c b/gdb/infcall.c index e09904f9a35..a60cca47c33 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -842,7 +842,6 @@ call_function_by_hand_dummy (struct value *function, bool stack_temporaries =3D thread_stack_temporaries_enabled_p (call_thre= ad.get ()); =20 frame =3D get_current_frame (); - frame.prepare_reinflate (); gdbarch =3D get_frame_arch (frame); =20 if (!gdbarch_push_dummy_call_p (gdbarch)) diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 7d5ec77ff57..15dca8c4604 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1834,7 +1834,6 @@ finish_command (const char *arg, int from_tty) frame =3D get_prev_frame (get_selected_frame (_("No selected frame."))); if (frame =3D=3D 0) error (_("\"finish\" not meaningful in the outermost frame.")); - frame.prepare_reinflate (); =20 clear_proceed_status (0); =20 diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 21bcf73ed24..9582fa24507 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -176,7 +176,6 @@ mi_cmd_stack_list_frames (const char *command, char **a= rgv, int argc) i++, fi =3D get_prev_frame (fi)) { QUIT; - fi.prepare_reinflate (); /* Print the location and the address always, even for level 0. If args is 0, don't print the arguments. */ print_frame_info (user_frame_print_options, diff --git a/gdb/stack.c b/gdb/stack.c index 0fd797836dc..4250383d9eb 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -362,7 +362,6 @@ print_stack_frame (frame_info_ptr frame, int print_leve= l, if (current_uiout->is_mi_like_p ()) print_what =3D LOC_AND_ADDRESS; =20 - frame.prepare_reinflate (); try { print_frame_info (user_frame_print_options, @@ -744,11 +743,6 @@ print_frame_args (const frame_print_options &fp_opts, =3D (print_names && fp_opts.print_frame_arguments !=3D print_frame_arguments_none); =20 - /* If one of the arguments has a pretty printer that calls a - function of the inferior to print it, the pointer must be - reinflatable. */ - frame.prepare_reinflate (); - /* Temporarily change the selected frame to the given FRAME. This allows routines that rely on the selected frame instead of being given a frame as parameter to use the correct frame. */ @@ -1047,8 +1041,6 @@ print_frame_info (const frame_print_options &fp_opts, int location_print; struct ui_out *uiout =3D current_uiout; =20 - frame.prepare_reinflate (); - if (!current_uiout->is_mi_like_p () && fp_opts.print_frame_info !=3D print_frame_info_auto) { @@ -1682,7 +1674,6 @@ info_frame_command_core (frame_info_ptr fi, bool sele= cted_frame_p) gdb_printf (" %d args: ", numargs); } =20 - fi.prepare_reinflate (); print_frame_args (user_frame_print_options, func, fi, numargs, gdb_stdout); fi.reinflate (); @@ -2075,7 +2066,6 @@ backtrace_command_1 (const frame_print_options &fp_op= ts, for (fi =3D trailing; fi && count--; fi =3D get_prev_frame (fi)) { QUIT; - fi.prepare_reinflate (); =20 /* Don't use print_stack_frame; if an error() occurs it probably means further attempts to backtrace would fail (on the other diff --git a/gdb/unittests/frame_info_ptr-selftests.c b/gdb/unittests/frame= _info_ptr-selftests.c index edf1b9fa0bb..47306113c7a 100644 --- a/gdb/unittests/frame_info_ptr-selftests.c +++ b/gdb/unittests/frame_info_ptr-selftests.c @@ -40,7 +40,6 @@ user_created_frame_callee (frame_info_ptr frame) { validate_user_created_frame (get_frame_id (frame)); =20 - frame.prepare_reinflate (); reinit_frame_cache (); frame.reinflate (); =20 @@ -61,7 +60,6 @@ test_user_created_frame () /* Pass the frame to a callee, which calls reinit_frame_cache. This let= s us validate that the reinflation in both the callee and caller restore t= he same frame_info object. */ - frame.prepare_reinflate (); frame_info_ptr callees_frame_info =3D user_created_frame_callee (frame); frame.reinflate ();