gdb: include gdbsupport/buildargv.h in ser-mingw.c
[binutils-gdb.git] / gdb / blockframe.c
index 09c3eed48db9d4d638befa8b39f84ed690ad10c7..88595d4fcb0b31cc097321d2fab16564618fa834 100644 (file)
@@ -1,7 +1,7 @@
 /* Get info from stack frames; convert between frames, blocks,
    functions and pc values.
 
-   Copyright (C) 1986-2020 Free Software Foundation, Inc.
+   Copyright (C) 1986-2022 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -191,7 +191,7 @@ find_pc_sect_containing_function (CORE_ADDR pc, struct obj_section *section)
 
 static CORE_ADDR cache_pc_function_low = 0;
 static CORE_ADDR cache_pc_function_high = 0;
-static const char *cache_pc_function_name = 0;
+static const general_symbol_info *cache_pc_function_sym = nullptr;
 static struct obj_section *cache_pc_function_section = NULL;
 static const struct block *cache_pc_function_block = nullptr;
 
@@ -202,7 +202,7 @@ clear_pc_function_cache (void)
 {
   cache_pc_function_low = 0;
   cache_pc_function_high = 0;
-  cache_pc_function_name = (char *) 0;
+  cache_pc_function_sym = nullptr;
   cache_pc_function_section = NULL;
   cache_pc_function_block = nullptr;
 }
@@ -210,8 +210,10 @@ clear_pc_function_cache (void)
 /* See symtab.h.  */
 
 bool
-find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address,
-                         CORE_ADDR *endaddr, const struct block **block)
+find_pc_partial_function_sym (CORE_ADDR pc,
+                             const struct general_symbol_info **sym,
+                             CORE_ADDR *address, CORE_ADDR *endaddr,
+                             const struct block **block)
 {
   struct obj_section *section;
   struct symbol *f;
@@ -257,7 +259,7 @@ find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address,
        {
          const struct block *b = SYMBOL_BLOCK_VALUE (f);
 
-         cache_pc_function_name = f->linkage_name ();
+         cache_pc_function_sym = f;
          cache_pc_function_section = section;
          cache_pc_function_block = b;
 
@@ -283,7 +285,7 @@ find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address,
            {
              int i;
              for (i = 0; i < BLOCK_NRANGES (b); i++)
-               {
+               {
                  if (BLOCK_RANGE_START (b, i) <= mapped_pc
                      && mapped_pc < BLOCK_RANGE_END (b, i))
                    {
@@ -313,8 +315,8 @@ find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address,
   if (msymbol.minsym == NULL)
     {
       /* No available symbol.  */
-      if (name != NULL)
-       *name = 0;
+      if (sym != nullptr)
+       *sym = 0;
       if (address != NULL)
        *address = 0;
       if (endaddr != NULL)
@@ -325,7 +327,7 @@ find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address,
     }
 
   cache_pc_function_low = BMSYMBOL_VALUE_ADDRESS (msymbol);
-  cache_pc_function_name = msymbol.minsym->linkage_name ();
+  cache_pc_function_sym = msymbol.minsym;
   cache_pc_function_section = section;
   cache_pc_function_high = minimal_symbol_upper_bound (msymbol);
   cache_pc_function_block = nullptr;
@@ -340,8 +342,8 @@ find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address,
        *address = cache_pc_function_low;
     }
 
-  if (name)
-    *name = cache_pc_function_name;
+  if (sym != nullptr)
+    *sym = cache_pc_function_sym;
 
   if (endaddr)
     {
@@ -365,6 +367,20 @@ find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address,
   return true;
 }
 
+/* See symtab.h.  */
+
+bool
+find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address,
+                         CORE_ADDR *endaddr, const struct block **block)
+{
+  const general_symbol_info *gsi;
+  bool r = find_pc_partial_function_sym (pc, &gsi, address, endaddr, block);
+  if (name != nullptr)
+    *name = r ? gsi->linkage_name () : nullptr;
+  return r;
+}
+
+
 /* See symtab.h.  */
 
 bool
@@ -379,24 +395,24 @@ find_function_entry_range_from_pc (CORE_ADDR pc, const char **name,
       CORE_ADDR entry_pc = BLOCK_ENTRY_PC (block);
 
       for (int i = 0; i < BLOCK_NRANGES (block); i++)
-        {
+       {
          if (BLOCK_RANGE_START (block, i) <= entry_pc
              && entry_pc < BLOCK_RANGE_END (block, i))
            {
              if (address != nullptr)
-               *address = BLOCK_RANGE_START (block, i);
+               *address = BLOCK_RANGE_START (block, i);
 
              if (endaddr != nullptr)
-               *endaddr = BLOCK_RANGE_END (block, i);
+               *endaddr = BLOCK_RANGE_END (block, i);
 
              return status;
            }
        }
 
       /* It's an internal error if we exit the above loop without finding
-         the range.  */
+        the range.  */
       internal_error (__FILE__, __LINE__,
-                      _("Entry block not found in find_function_entry_range_from_pc"));
+                     _("Entry block not found in find_function_entry_range_from_pc"));
     }
 
   return status;
@@ -429,11 +445,11 @@ find_gnu_ifunc_target_type (CORE_ADDR resolver_funaddr)
 
       /* If we found a pointer to function, then the resolved type
         is the type of the pointed-to function.  */
-      if (TYPE_CODE (resolver_ret_type) == TYPE_CODE_PTR)
+      if (resolver_ret_type->code () == TYPE_CODE_PTR)
        {
          struct type *resolved_type
            = TYPE_TARGET_TYPE (resolver_ret_type);
-         if (TYPE_CODE (check_typedef (resolved_type)) == TYPE_CODE_FUNC)
+         if (check_typedef (resolved_type)->code () == TYPE_CODE_FUNC)
            return resolved_type;
        }
     }
@@ -448,14 +464,10 @@ find_gnu_ifunc_target_type (CORE_ADDR resolver_funaddr)
 struct frame_info *
 block_innermost_frame (const struct block *block)
 {
-  struct frame_info *frame;
-
   if (block == NULL)
     return NULL;
 
-  frame = get_selected_frame_if_set ();
-  if (frame == NULL)
-    frame = get_current_frame ();
+  frame_info *frame = get_selected_frame ();
   while (frame != NULL)
     {
       const struct block *frame_block = get_frame_block (frame, NULL);