public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>,
	Bruno Larsen <blarsen@redhat.com>
Subject: [PATCH v2 12/13] gdb: make frame_info_ptr grab frame level and id on construction
Date: Tue, 13 Dec 2022 22:34:40 -0500	[thread overview]
Message-ID: <20221214033441.499512-13-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20221214033441.499512-1-simon.marchi@polymtl.ca>

From: Simon Marchi <simon.marchi@efficios.com>

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 <blarsen@redhat.com>
---
 gdb/frame.c                              | 19 +++++++++++--------
 gdb/frame.h                              |  9 +--------
 gdb/infcmd.c                             |  1 -
 gdb/mi/mi-cmd-stack.c                    |  1 -
 gdb/stack.c                              | 10 ----------
 gdb/unittests/frame_info_ptr-selftests.c |  2 --
 6 files changed, 12 insertions(+), 30 deletions(-)

diff --git a/gdb/frame.c b/gdb/frame.c
index 873c3912e076..4755c8e9aa7f 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -3208,14 +3208,18 @@ intrusive_list<frame_info_ptr> 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_ptr == nullptr)
+    return;
+
+  m_cached_level = ptr->level;
 
-  if (m_cached_level != 0
-      || (m_ptr != nullptr && m_ptr->this_id.value.user_created_p))
-    m_cached_id = get_frame_id (*this);
+  if (m_cached_level != 0 || m_ptr->this_id.value.user_created_p)
+    m_cached_id = m_ptr->this_id.value;
 }
 
 /* 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), indicating
-     prepare_reinflate was called.  */
+  /* Ensure we have a valid frame level (sentinel frame or above).  */
   gdb_assert (m_cached_level >= -1);
 
   if (m_ptr != nullptr)
diff --git a/gdb/frame.h b/gdb/frame.h
index 88af96f0c619..f8ca57815bf6 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -206,11 +206,7 @@ class frame_info_ptr : public intrusive_list_node<frame_info_ptr>
 {
 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 ()
@@ -310,9 +306,6 @@ class frame_info_ptr : public intrusive_list_node<frame_info_ptr>
     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
diff --git a/gdb/unittests/frame_info_ptr-selftests.c b/gdb/unittests/frame_info_ptr-selftests.c
index edf1b9fa0bb7..47306113c7aa 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));
 
-  frame.prepare_reinflate ();
   reinit_frame_cache ();
   frame.reinflate ();
 
@@ -61,7 +60,6 @@ test_user_created_frame ()
   /* Pass the frame to a callee, which calls reinit_frame_cache.  This lets us
      validate that the reinflation in both the callee and caller restore the
      same frame_info object.  */
-  frame.prepare_reinflate ();
   frame_info_ptr callees_frame_info = user_created_frame_callee (frame);
   frame.reinflate ();
 
-- 
2.38.1


  parent reply	other threads:[~2022-12-14  3:46 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-14  3:34 [PATCH v2 00/13] Make frame_info_ptr automatic Simon Marchi
2022-12-14  3:34 ` [PATCH v2 01/13] gdb: move type_map_instance to compile/compile.c Simon Marchi
2022-12-14  3:34 ` [PATCH v2 02/13] gdb: move compile_instance to compile/compile.h Simon Marchi
2022-12-14  3:34 ` [PATCH v2 03/13] gdb: remove language.h include from frame.h Simon Marchi
2022-12-14  3:34 ` [PATCH v2 04/13] gdb: move sect_offset and cu_offset to dwarf2/types.h Simon Marchi
2022-12-14  3:34 ` [PATCH v2 05/13] gdb: move call site types to call-site.h Simon Marchi
2022-12-14  3:34 ` [PATCH v2 06/13] gdb: move frame_info_ptr to frame.{c,h} Simon Marchi
2022-12-20 17:01   ` Bruno Larsen
2023-01-03 18:59     ` Simon Marchi
2022-12-14  3:34 ` [PATCH v2 07/13] gdb: add frame_id::user_created_p Simon Marchi
2022-12-14  3:34 ` [PATCH v2 08/13] gdb: add user-created frames to stash Simon Marchi
2022-12-14  3:34 ` [PATCH v2 09/13] gdb: add create_new_frame(frame_id) overload Simon Marchi
2022-12-14  3:34 ` [PATCH v2 10/13] gdb: make it possible to restore selected user-created frames Simon Marchi
2022-12-14  3:34 ` [PATCH v2 11/13] gdb: make user-created frames reinflatable Simon Marchi
2023-01-23 12:57   ` Tom de Vries
2023-01-23 14:34     ` Luis Machado
2023-01-24  3:55       ` Simon Marchi
2023-01-24  8:22         ` Luis Machado
2023-01-25  3:45           ` Simon Marchi
2023-01-30  8:49             ` Luis Machado
2023-01-30 16:20               ` Simon Marchi
2022-12-14  3:34 ` Simon Marchi [this message]
2022-12-14  3:34 ` [PATCH v2 13/13] gdb: make frame_info_ptr auto-reinflatable Simon Marchi
2022-12-20 16:57 ` [PATCH v2 00/13] Make frame_info_ptr automatic Bruno Larsen
2023-01-03 19:00   ` Simon Marchi
2023-01-03 19:09 ` Simon Marchi
2023-01-18 18:10 ` Tom Tromey
2023-01-19  3:40   ` Simon Marchi

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=20221214033441.499512-13-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=blarsen@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    /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: link
Be 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).