]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: remove BLOCK_NRANGES macro
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 7 Feb 2022 03:30:06 +0000 (22:30 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Thu, 28 Apr 2022 02:05:03 +0000 (22:05 -0400)
Replace with range for loops.

Change-Id: Icbe04f9b6f9e6ddae2e15b2409c61f7a336bc3e3

gdb/block.h
gdb/blockframe.c
gdb/cli/cli-cmds.c

index daaaecdd501c60faa282e42a528d6391d7e032bd..3782327c155795381bc616cdaafbaca6e377956a 100644 (file)
@@ -215,10 +215,6 @@ struct global_block
   struct compunit_symtab *compunit_symtab;
 };
 
-/* Number of ranges within a block.  */
-
-#define BLOCK_NRANGES(bl)      (bl)->ranges ().size ()
-
 /* Access range array for block BL.  */
 
 #define BLOCK_RANGE(bl)                (bl)->ranges ().data ()
index e91faaa98b1ba79dec27591b7b3c5492c6e3236b..78c9daabf2361e18c771bb5b826f6332ce6e4aac 100644 (file)
@@ -283,19 +283,19 @@ find_pc_partial_function_sym (CORE_ADDR pc,
            }
          else
            {
-             int i;
-             for (i = 0; i < BLOCK_NRANGES (b); i++)
+             bool found = false;
+             for (const blockrange &range : b->ranges ())
                {
-                 if (BLOCK_RANGE (b)[i].start () <= mapped_pc
-                     && mapped_pc < BLOCK_RANGE (b)[i].end ())
+                 if (range.start () <= mapped_pc && mapped_pc < range.end ())
                    {
-                     cache_pc_function_low = BLOCK_RANGE (b)[i].start ();
-                     cache_pc_function_high = BLOCK_RANGE (b)[i].end ();
+                     cache_pc_function_low = range.start ();
+                     cache_pc_function_high = range.end ();
+                     found = true;
                      break;
                    }
                }
              /* Above loop should exit via the break.  */
-             gdb_assert (i < BLOCK_NRANGES (b));
+             gdb_assert (found);
            }
 
 
@@ -394,16 +394,15 @@ 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++)
+      for (const blockrange &range : block->ranges ())
        {
-         if (BLOCK_RANGE (block)[i].start () <= entry_pc
-             && entry_pc < BLOCK_RANGE (block)[i].end ())
+         if (range.start () <= entry_pc && entry_pc < range.end ())
            {
              if (address != nullptr)
-               *address = BLOCK_RANGE (block)[i].start ();
+               *address = range.start ();
 
              if (endaddr != nullptr)
-               *endaddr = BLOCK_RANGE (block)[i].end ();
+               *endaddr = range.end ();
 
              return status;
            }
index f7c556a4e0cf25ded618d72e8590b596093c4b78..7a6a8ea20a15da5da6f82611f995cba421a16b5f 100644 (file)
@@ -1442,10 +1442,11 @@ print_disassembly (struct gdbarch *gdbarch, const char *name,
        }
       else
        {
-         for (int i = 0; i < BLOCK_NRANGES (block); i++)
+         for (const blockrange &range : block->ranges ())
            {
-             CORE_ADDR range_low = BLOCK_RANGE (block)[i].start ();
-             CORE_ADDR range_high = BLOCK_RANGE (block)[i].end ();
+             CORE_ADDR range_low = range.start ();
+             CORE_ADDR range_high = range.end ();
+
              gdb_printf (_("Address range %ps to %ps:\n"),
                          styled_string (address_style.style (),
                                         paddress (gdbarch, range_low)),