Rename to allow_perf_tests
[binutils-gdb.git] / gdb / block.h
index b6b8b86f3333b912af54c79df970f168b7965a2c..379359f07be6376736313e4a3c4852762758fcc3 100644 (file)
@@ -1,6 +1,6 @@
 /* Code dealing with blocks for GDB.
 
-   Copyright (C) 2003-2022 Free Software Foundation, Inc.
+   Copyright (C) 2003-2023 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -157,11 +157,21 @@ struct block
 
   /* Return a view on this block's ranges.  */
   gdb::array_view<blockrange> ranges ()
-  { return gdb::make_array_view (m_ranges->range, m_ranges->nranges); }
+  {
+    if (m_ranges == nullptr)
+      return {};
+    else
+      return gdb::make_array_view (m_ranges->range, m_ranges->nranges);
+  }
 
   /* Const version of the above.  */
   gdb::array_view<const blockrange> ranges () const
-  { return gdb::make_array_view (m_ranges->range, m_ranges->nranges); }
+  {
+    if (m_ranges == nullptr)
+      return {};
+    else
+      return gdb::make_array_view (m_ranges->range, m_ranges->nranges);
+  }
 
   /* Set this block's ranges array.  */
   void set_ranges (blockranges *ranges)
@@ -296,12 +306,24 @@ struct blockvector
   const struct block *static_block () const
   { return this->block (STATIC_BLOCK); }
 
+  /* Return the address -> block map of this blockvector.  */
+  addrmap *map ()
+  { return m_map; }
+
+  /* Const version of the above.  */
+  const addrmap *map () const
+  { return m_map; }
+
+  /* Set this blockvector's address -> block map.  */
+  void set_map (addrmap *map)
+  { m_map = map; }
+
+private:
   /* An address map mapping addresses to blocks in this blockvector.
      This pointer is zero if the blocks' start and end addresses are
      enough.  */
-  struct addrmap *map;
+  struct addrmap *m_map;
 
-private:
   /* Number of blocks in the list.  */
   int m_num_blocks;
 
@@ -309,8 +331,6 @@ private:
   struct block *m_blocks[1];
 };
 
-#define BLOCKVECTOR_MAP(blocklist) ((blocklist)->map)
-
 /* Return the objfile of BLOCK, which must be non-NULL.  */
 
 extern struct objfile *block_objfile (const struct block *block);