From patchwork Fri Dec 2 18:00:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 61379 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BECBC3858413 for ; Fri, 2 Dec 2022 18:10:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BECBC3858413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670004603; bh=B1UGdTEvYiujwTewYkS0xIuaLxvamU1UayPJVBiBnPE=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=pvRvkLI5TyVxkzbvLzpRd4MmQXDQRAxl60/9D6OLS9QIz0i1StFytS0yqEN4ki6fn JnzvzmsepNIQPWyT8F5K2b+dAPJksscgvM6aUIAIdJLXMhaZdET62eLuB7Y+S9DlMb 77fYjHKbT1/ohV48aGScRfrM+wEG8iXSkRDreYBQ= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 5D83F3858C50 for ; Fri, 2 Dec 2022 18:09:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5D83F3858C50 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 2B2I9Ut2028480 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 2 Dec 2022 13:09:35 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 2B2I9Ut2028480 Received: from simark.localdomain (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 32D571E129; Fri, 2 Dec 2022 13:00:55 -0500 (EST) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 5/6] gdb: make frame_info_ptr grab frame level and id on construction Date: Fri, 2 Dec 2022 13:00:51 -0500 Message-Id: <20221202180052.212745-6-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221202180052.212745-1-simon.marchi@polymtl.ca> References: <20221202180052.212745-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 2 Dec 2022 18:09:30 +0000 X-Spam-Status: No, score=-3189.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" 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. Change-Id: I85cdae3ab1c043c70e2702e7fb38e9a4a8a675d8 Reviewed-By: Bruno Larsen --- gdb/frame-info.c | 18 +++++++++++------- gdb/frame-info.h | 9 +-------- gdb/infcmd.c | 1 - gdb/mi/mi-cmd-stack.c | 1 - gdb/stack.c | 10 ---------- 5 files changed, 12 insertions(+), 27 deletions(-) diff --git a/gdb/frame-info.c b/gdb/frame-info.c index d61fb7ed0e95..8ab5f54f8202 100644 --- a/gdb/frame-info.c +++ b/gdb/frame-info.c @@ -31,14 +31,19 @@ intrusive_list frame_info_ptr::frame_list; /* See frame-info-ptr.h. */ -void -frame_info_ptr::prepare_reinflate () +frame_info_ptr::frame_info_ptr (struct frame_info *ptr) + : m_ptr (ptr) { - m_cached_level = frame_relative_level (*this); + frame_list.push_back (*this); - if (m_cached_level != 0 - || (m_ptr != nullptr && frame_is_user_created (m_ptr))) - m_cached_id = get_frame_id (*this); + if (m_ptr != nullptr) + { + m_cached_level = frame_relative_level (m_ptr); + + if (m_cached_level != 0 + || (m_ptr != nullptr && frame_is_user_created (m_ptr))) + m_cached_id = get_frame_id (m_ptr); + } } /* See frame-info-ptr.h. */ @@ -91,7 +96,6 @@ test_user_created_frame () SELF_CHECK (id.code_addr_p); SELF_CHECK (id.code_addr == 0x5678); - frame.prepare_reinflate (); reinit_frame_cache (); frame.reinflate (); diff --git a/gdb/frame-info.h b/gdb/frame-info.h index 8f01ee007914..224a553ac040 100644 --- a/gdb/frame-info.h +++ b/gdb/frame-info.h @@ -38,11 +38,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); /* Create a null frame_info_ptr. */ frame_info_ptr () @@ -142,9 +138,6 @@ class frame_info_ptr : public intrusive_list_node m_ptr = nullptr; } - /* 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 (); diff --git a/gdb/infcmd.c b/gdb/infcmd.c index a27d3577b3aa..ee3d97b585dd 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1837,7 +1837,6 @@ finish_command (const char *arg, int from_tty) frame = get_prev_frame (get_selected_frame (_("No selected frame."))); if (frame == 0) error (_("\"finish\" not meaningful in the outermost frame.")); - frame.prepare_reinflate (); clear_proceed_status (0); diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index f0af7c9a0143..186d53156730 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 **argv, int argc) i++, fi = 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 4ad51c2eb50e..126ce0b8cc2a 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -362,7 +362,6 @@ print_stack_frame (frame_info_ptr frame, int print_level, if (current_uiout->is_mi_like_p ()) print_what = LOC_AND_ADDRESS; - frame.prepare_reinflate (); try { print_frame_info (user_frame_print_options, @@ -744,11 +743,6 @@ print_frame_args (const frame_print_options &fp_opts, = (print_names && fp_opts.print_frame_arguments != print_frame_arguments_none); - /* 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 = current_uiout; - frame.prepare_reinflate (); - if (!current_uiout->is_mi_like_p () && fp_opts.print_frame_info != print_frame_info_auto) { @@ -1682,7 +1674,6 @@ info_frame_command_core (frame_info_ptr fi, bool selected_frame_p) gdb_printf (" %d args: ", numargs); } - 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_opts, for (fi = trailing; fi && count--; fi = get_prev_frame (fi)) { QUIT; - fi.prepare_reinflate (); /* Don't use print_stack_frame; if an error() occurs it probably means further attempts to backtrace would fail (on the other