RISC-V: Handle vector type alignment.
[external/binutils.git] / gdb / blockframe.c
index 6dc736e..f6dd861 100644 (file)
@@ -96,7 +96,7 @@ get_pc_function_start (CORE_ADDR pc)
       if (symbol)
        {
          bl = SYMBOL_BLOCK_VALUE (symbol);
-         return BLOCK_START (bl);
+         return BLOCK_ENTRY_PC (bl);
        }
     }
 
@@ -377,12 +377,49 @@ find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address,
 
 /* See symtab.h.  */
 
+bool
+find_function_entry_range_from_pc (CORE_ADDR pc, const char **name,
+                                  CORE_ADDR *address, CORE_ADDR *endaddr)
+{
+  const struct block *block;
+  bool status = find_pc_partial_function (pc, name, address, endaddr, &block);
+
+  if (status && block != nullptr && !BLOCK_CONTIGUOUS_P (block))
+    {
+      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);
+
+             if (endaddr != nullptr)
+               *endaddr = BLOCK_RANGE_END (block, i);
+
+             return status;
+           }
+       }
+
+      /* It's an internal error if we exit the above loop without finding
+         the range.  */
+      internal_error (__FILE__, __LINE__,
+                      _("Entry block not found in find_function_entry_range_from_pc"));
+    }
+
+  return status;
+}
+
+/* See symtab.h.  */
+
 struct type *
 find_function_type (CORE_ADDR pc)
 {
   struct symbol *sym = find_pc_function (pc);
 
-  if (sym != NULL && BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) == pc)
+  if (sym != NULL && BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym)) == pc)
     return SYMBOL_TYPE (sym);
 
   return NULL;