This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] remove some subtleties in find_block_in_blockvector


Hi.

This patch removes a subtlety in the handling of blocks.

The first two blocks are special.
Block 0 == GLOBAL_BLOCK, block 1 == STATIC_BLOCK.

The code in block.c:find_block_in_blockvector ignores this fact making the
code less clear than it could be.

Regression tested on amd64-linux.

Ok to commit?

2012-06-04  Doug Evans  <dje@google.com>

	* block.c (find_block_in_blockvector): Make explicit the fact that we
	ignore GLOBAL_BLOCK.

Index: block.c
===================================================================
RCS file: /cvs/src/src/gdb/block.c,v
retrieving revision 1.31
diff -u -p -r1.31 block.c
--- block.c	18 May 2012 14:26:25 -0000	1.31
+++ block.c	4 Jun 2012 23:50:34 -0000
@@ -118,8 +118,13 @@ find_block_in_blockvector (struct blockv
     return addrmap_find (BLOCKVECTOR_MAP (bl), pc);
 
   /* Otherwise, use binary search to find the last block that starts
-     before PC.  */
-  bot = 0;
+     before PC.
+     Note: GLOBAL_BLOCK is block 0, STATIC_BLOCK is block 1.
+     They both have the same START,END values.
+     Historically this code would choose STATIC_BLOCK over GLOBAL_BLOCK but the
+     fact that this choice was made was subtle, now we make it explicit.  */
+  gdb_assert (BLOCKVECTOR_NBLOCKS (bl) >= 2);
+  bot = STATIC_BLOCK;
   top = BLOCKVECTOR_NBLOCKS (bl);
 
   while (top - bot > 1)
@@ -134,7 +139,7 @@ find_block_in_blockvector (struct blockv
 
   /* Now search backward for a block that ends after PC.  */
 
-  while (bot >= 0)
+  while (bot >= STATIC_BLOCK)
     {
       b = BLOCKVECTOR_BLOCK (bl, bot);
       if (BLOCK_END (b) > pc)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]