[19/30] Return a block_symbol from get_frame_function

Message ID 20231029-split-objfile-2023-bound-sym-october-v1-19-612531df2734@tromey.com
State New
Headers
Series Baby step for objfile splitting |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Tom Tromey Oct. 29, 2023, 11:23 p.m. UTC
  This changes get_frame_function to return a block_symbol, allowing
updates in other places.  Like some earlier patches, this change is
the direction the code should go anyway -- the return value will
eventually carry an objfile along with it.
---
 gdb/blockframe.c   | 6 +++---
 gdb/breakpoint.c   | 2 +-
 gdb/findvar.c      | 2 +-
 gdb/frame.c        | 2 +-
 gdb/frame.h        | 3 ++-
 gdb/infcmd.c       | 4 ++--
 gdb/infrun.c       | 4 ++--
 gdb/inline-frame.c | 2 +-
 gdb/skip.c         | 2 +-
 gdb/stack.c        | 8 ++++----
 10 files changed, 18 insertions(+), 17 deletions(-)
  

Patch

diff --git a/gdb/blockframe.c b/gdb/blockframe.c
index 981094803ed..3977ecd6229 100644
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -114,18 +114,18 @@  get_pc_function_start (CORE_ADDR pc)
 
 /* Return the symbol for the function executing in frame FRAME.  */
 
-struct symbol *
+block_symbol
 get_frame_function (frame_info_ptr frame)
 {
   const struct block *bl = get_frame_block (frame, 0);
 
   if (bl == NULL)
-    return NULL;
+    return {};
 
   while (bl->function () == NULL && bl->superblock () != NULL)
     bl = bl->superblock ();
 
-  return bl->function ();
+  return { bl->function (), bl };
 }
 
 
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 60ba22c3257..311d21f02c5 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -5287,7 +5287,7 @@  watchpoint_check (bpstat *bs)
 	{
 	  struct symbol *function;
 
-	  function = get_frame_function (fr);
+	  function = get_frame_function (fr).symbol;
 	  if (function == NULL
 	      || !function->value_block ()->contains (b->exp_valid_block))
 	    within_current_scope = false;
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 909dca65532..f3be783ec24 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -408,7 +408,7 @@  follow_static_link (frame_info_ptr frame,
      in.  */
   for (; frame != NULL; frame = get_prev_frame (frame))
     {
-      struct symbol *framefunc = get_frame_function (frame);
+      struct symbol *framefunc = get_frame_function (frame).symbol;
 
       /* Stacks can be quite deep: give the user a chance to stop this.  */
       QUIT;
diff --git a/gdb/frame.c b/gdb/frame.c
index 7077016ccba..315b94e4447 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -2833,7 +2833,7 @@  find_frame_sal (frame_info_ptr frame)
 	 function, which can not be inferred from get_frame_pc.  */
       next_frame = get_next_frame (frame);
       if (next_frame)
-	sym = get_frame_function (next_frame);
+	sym = get_frame_function (next_frame).symbol;
       else
 	sym = inline_skipped_symbol (inferior_thread ());
 
diff --git a/gdb/frame.h b/gdb/frame.h
index 1d7422cac32..0f1640c4a68 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -69,6 +69,7 @@ 
 
    */
 
+#include "block-symbol.h"
 #include "cli/cli-option.h"
 #include "frame-id.h"
 #include "gdbsupport/common-debug.h"
@@ -856,7 +857,7 @@  extern const struct block *get_frame_block (frame_info_ptr,
 
 extern const struct block *get_selected_block (CORE_ADDR *addr_in_block);
 
-extern struct symbol *get_frame_function (frame_info_ptr);
+extern block_symbol get_frame_function (frame_info_ptr);
 
 extern CORE_ADDR get_pc_function_start (CORE_ADDR);
 
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 03e54438686..2e9d913c41c 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -957,7 +957,7 @@  prepare_one_step (thread_info *tp, struct step_command_fsm *sm)
 
 	      frame = get_current_frame ();
 	      sal = find_frame_sal (frame);
-	      sym = get_frame_function (frame);
+	      sym = get_frame_function (frame).symbol;
 
 	      if (sym != nullptr)
 		fn = sym->print_name ();
@@ -1085,7 +1085,7 @@  jump_command (const char *arg, int from_tty)
   resolve_sal_pc (&sal);	/* May error out.  */
 
   /* See if we are trying to jump to another function.  */
-  fn = get_frame_function (get_current_frame ());
+  fn = get_frame_function (get_current_frame ()).symbol;
   sfn = find_pc_sect_containing_function (sal.pc,
 					  find_pc_mapped_section (sal.pc));
   if (fn != nullptr && sfn != fn)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 2a004690e67..3c85cb5f481 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -4846,7 +4846,7 @@  inline_frame_is_marked_for_skip (bool prev_frame, struct thread_info *tp)
 	break;
 
       sal = find_frame_sal (frame);
-      sym = get_frame_function (frame);
+      sym = get_frame_function (frame).symbol;
 
       if (sym != nullptr)
 	fn = sym->print_name ();
@@ -8390,7 +8390,7 @@  check_exception_resume (struct execution_control_state *ecs,
       return;
     }
 
-  func = get_frame_function (frame);
+  func = get_frame_function (frame).symbol;
   if (!func)
     return;
 
diff --git a/gdb/inline-frame.c b/gdb/inline-frame.c
index 80765d5cca5..48ada3597bf 100644
--- a/gdb/inline-frame.c
+++ b/gdb/inline-frame.c
@@ -179,7 +179,7 @@  inline_frame_this_id (frame_info_ptr this_frame,
      which generates DW_AT_entry_pc for inlined functions when
      possible.  If this attribute is available, we should use it
      in the frame ID (and eventually, to set breakpoints).  */
-  func = get_frame_function (this_frame);
+  func = get_frame_function (this_frame).symbol;
   gdb_assert (func != NULL);
   (*this_id).code_addr = func->value_block ()->entry_pc ();
   (*this_id).artificial_depth++;
diff --git a/gdb/skip.c b/gdb/skip.c
index 28902a6d326..a11a35314e3 100644
--- a/gdb/skip.c
+++ b/gdb/skip.c
@@ -205,7 +205,7 @@  skip_function_command (const char *arg, int from_tty)
   if (arg == NULL)
     {
       frame_info_ptr fi = get_selected_frame (_("No default function now."));
-      struct symbol *sym = get_frame_function (fi);
+      struct symbol *sym = get_frame_function (fi).symbol;
       const char *name = NULL;
 
       if (sym != NULL)
diff --git a/gdb/stack.c b/gdb/stack.c
index 0b35d62f82f..52448ff98a5 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -1266,7 +1266,7 @@  find_frame_funname (frame_info_ptr frame, enum language *funlang,
   if (funcp)
     *funcp = NULL;
 
-  func = get_frame_function (frame);
+  func = get_frame_function (frame).symbol;
   if (func)
     {
       const char *print_name = func->print_name ();
@@ -1498,7 +1498,7 @@  info_frame_command_core (frame_info_ptr fi, bool selected_frame_p)
     pc_regname = "pc";
 
   frame_pc_p = get_frame_pc_if_available (fi, &frame_pc);
-  func = get_frame_function (fi);
+  func = get_frame_function (fi).symbol;
   symtab_and_line sal = find_frame_sal (fi);
   s = sal.symtab;
   gdb::unique_xmalloc_ptr<char> func_only;
@@ -2514,7 +2514,7 @@  print_frame_arg_vars (frame_info_ptr frame,
       return;
     }
 
-  func = get_frame_function (frame);
+  func = get_frame_function (frame).symbol;
   if (func == NULL)
     {
       if (!quiet)
@@ -2699,7 +2699,7 @@  return_command (const char *retval_exp, int from_tty)
   std::string query_prefix;
 
   thisframe = get_selected_frame ("No selected frame.");
-  thisfun = get_frame_function (thisframe);
+  thisfun = get_frame_function (thisframe).symbol;
   gdbarch = get_frame_arch (thisframe);
 
   if (get_frame_type (get_current_frame ()) == INLINE_FRAME)