Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH] Make BLOCK_START and BLOCK_END into rvalues
Date: Sat, 16 May 2020 09:10:21 -0600	[thread overview]
Message-ID: <20200516151021.7080-1-tom@tromey.com> (raw)

This changes the BLOCK_START and BLOCK_END macros to expand to
rvalues, and then updates some code to assign to these fields
directly.

I considered adding setters here, but that seemed a bit needless,
given that these are "open" structures.  However, I can do that if
it's preferable.  Note that when the time comes to remove the
BLOCK_START and BLOCK_END macros, I think they will be replaced with
methods, because that will make it simpler to achieve objfile
independence for blocks.

This patch is one of a set of small cleanups related to
objfile-splitting that I've had kicking around for years.  I figured I
should start putting them in piecemeal rather than wait for the whole
series to be finished, as that seems very difficult.

gdb/ChangeLog
2020-05-16  Tom Tromey  <tom@tromey.com>

	* mips-tdep.c (mips_make_symbol_special): Update.
	* objfiles.c (objfile_relocate1): Update.
	* mdebugread.c (parse_symbol, mdebug_expand_psymtab)
	(sort_blocks): Update.
	* jit.c (finalize_symtab): Update.
	* buildsym.c (buildsym_compunit::finish_block_internal): Update.
	* block.h (BLOCK_START, BLOCK_END): Expand to rvalue.
---
 gdb/ChangeLog    | 10 ++++++++++
 gdb/block.h      |  4 ++--
 gdb/buildsym.c   | 10 +++++-----
 gdb/jit.c        |  8 ++++----
 gdb/mdebugread.c | 28 ++++++++++++++--------------
 gdb/mips-tdep.c  |  2 +-
 gdb/objfiles.c   |  4 ++--
 7 files changed, 38 insertions(+), 28 deletions(-)

diff --git a/gdb/block.h b/gdb/block.h
index 50ab049f8e6..395f72d1bc9 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -139,8 +139,8 @@ struct global_block
   struct compunit_symtab *compunit_symtab;
 };
 
-#define BLOCK_START(bl)		(bl)->startaddr
-#define BLOCK_END(bl)		(bl)->endaddr
+#define BLOCK_START(bl)		(((bl)->startaddr) + 0)
+#define BLOCK_END(bl)		(((bl)->endaddr) + 0)
 #define BLOCK_FUNCTION(bl)	(bl)->function
 #define BLOCK_SUPERBLOCK(bl)	(bl)->superblock
 #define BLOCK_MULTIDICT(bl)	(bl)->multidict
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index b9bcc33080a..b13857b0dda 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -242,8 +242,8 @@ buildsym_compunit::finish_block_internal
 	}
     }
 
-  BLOCK_START (block) = start;
-  BLOCK_END (block) = end;
+  block->startaddr = start = start;
+  block->endaddr = end;
 
   /* Put the block in as the value of the symbol that names it.  */
 
@@ -329,7 +329,7 @@ buildsym_compunit::finish_block_internal
 		     paddress (gdbarch, BLOCK_START (block)));
 	}
       /* Better than nothing.  */
-      BLOCK_END (block) = BLOCK_START (block);
+      block->endaddr = BLOCK_START (block);
     }
 
   /* Install this block as the superblock of all blocks made since the
@@ -368,9 +368,9 @@ buildsym_compunit::finish_block_internal
 			     paddress (gdbarch, BLOCK_END (block)));
 		}
 	      if (BLOCK_START (pblock->block) < BLOCK_START (block))
-		BLOCK_START (pblock->block) = BLOCK_START (block);
+		pblock->block->startaddr = BLOCK_START (block);
 	      if (BLOCK_END (pblock->block) > BLOCK_END (block))
-		BLOCK_END (pblock->block) = BLOCK_END (block);
+		pblock->block->endaddr = BLOCK_END (block);
 	    }
 	  BLOCK_SUPERBLOCK (pblock->block) = block;
 	}
diff --git a/gdb/jit.c b/gdb/jit.c
index 1b5ef46469e..c099d23e5e2 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -664,8 +664,8 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
       BLOCK_MULTIDICT (new_block)
 	= mdict_create_linear (&objfile->objfile_obstack, NULL);
       /* The address range.  */
-      BLOCK_START (new_block) = (CORE_ADDR) gdb_block_iter.begin;
-      BLOCK_END (new_block) = (CORE_ADDR) gdb_block_iter.end;
+      new_block->startaddr = (CORE_ADDR) gdb_block_iter.begin;
+      new_block->endaddr = (CORE_ADDR) gdb_block_iter.end;
 
       /* The name.  */
       SYMBOL_DOMAIN (block_name) = VAR_DOMAIN;
@@ -704,8 +704,8 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
       BLOCK_SUPERBLOCK (new_block) = block_iter;
       block_iter = new_block;
 
-      BLOCK_START (new_block) = (CORE_ADDR) begin;
-      BLOCK_END (new_block) = (CORE_ADDR) end;
+      new_block->startaddr = (CORE_ADDR) begin;
+      new_block->endaddr = (CORE_ADDR) end;
 
       BLOCKVECTOR_BLOCK (bv, i) = new_block;
 
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index ba53512636e..2a3f9492897 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -792,7 +792,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
       b = new_block (FUNCTION_BLOCK, s->language ());
       SYMBOL_BLOCK_VALUE (s) = b;
       BLOCK_FUNCTION (b) = s;
-      BLOCK_START (b) = BLOCK_END (b) = sh->value;
+      b->startaddr = b->endaddr = sh->value;
       BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
       add_block (b, top_stack->cur_st);
 
@@ -1121,7 +1121,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 
       top_stack->blocktype = stBlock;
       b = new_block (NON_FUNCTION_BLOCK, psymtab_language);
-      BLOCK_START (b) = sh->value + top_stack->procadr;
+      b->startaddr = sh->value + top_stack->procadr;
       BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
       top_stack->cur_block = b;
       add_block (b, top_stack->cur_st);
@@ -1145,7 +1145,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 	  struct type *ftype = top_stack->cur_type;
 	  int i;
 
-	  BLOCK_END (top_stack->cur_block) += sh->value;	/* size */
+	  top_stack->cur_block->endaddr += sh->value;	/* size */
 
 	  /* Make up special symbol to contain procedure specific info.  */
 	  s = new_symbol (MDEBUG_EFI_SYMBOL_NAME);
@@ -1169,8 +1169,8 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 		  && BLOCK_START (b_bad) == top_stack->procadr
 		  && BLOCK_END (b_bad) == top_stack->procadr)
 		{
-		  BLOCK_START (b_bad) = BLOCK_START (cblock);
-		  BLOCK_END (b_bad) = BLOCK_END (cblock);
+		  b_bad->startaddr = BLOCK_START (cblock);
+		  b_bad->endaddr = BLOCK_END (cblock);
 		}
 	    }
 
@@ -1211,7 +1211,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 	  /* End of (code) block.  The value of the symbol is the
 	     displacement from the procedure`s start address of the
 	     end of this block.  */
-	  BLOCK_END (top_stack->cur_block) = sh->value + top_stack->procadr;
+	  top_stack->cur_block->endaddr = sh->value + top_stack->procadr;
 	}
       else if (sh->sc == scText && top_stack->blocktype == stNil)
 	{
@@ -4081,8 +4081,8 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
       top_stack->cur_st = COMPUNIT_FILETABS (cust);
       top_stack->cur_block
 	= BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK);
-      BLOCK_START (top_stack->cur_block) = pst->text_low (objfile);
-      BLOCK_END (top_stack->cur_block) = 0;
+      top_stack->cur_block->startaddr = pst->text_low (objfile);
+      top_stack->cur_block->endaddr = 0;
       top_stack->blocktype = stFile;
       top_stack->cur_type = 0;
       top_stack->procadr = 0;
@@ -4555,9 +4555,9 @@ sort_blocks (struct symtab *s)
     {
       /* Cosmetic */
       if (BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) == 0)
-	BLOCK_START (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) = 0;
+	BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)->startaddr = 0;
       if (BLOCK_END (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) == 0)
-	BLOCK_START (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) = 0;
+	BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)->endaddr = 0;
       return;
     }
   /*
@@ -4578,15 +4578,15 @@ sort_blocks (struct symtab *s)
     for (i = FIRST_LOCAL_BLOCK; i < j; i++)
       if (high < BLOCK_END (BLOCKVECTOR_BLOCK (bv, i)))
 	high = BLOCK_END (BLOCKVECTOR_BLOCK (bv, i));
-    BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) = high;
+    BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)->endaddr = high;
   }
 
-  BLOCK_START (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) =
+  BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)->startaddr =
     BLOCK_START (BLOCKVECTOR_BLOCK (bv, FIRST_LOCAL_BLOCK));
 
-  BLOCK_START (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) =
+  BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)->startaddr =
     BLOCK_START (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK));
-  BLOCK_END (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) =
+  BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)->endaddr =
     BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK));
 }
 \f
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index df59f416b8e..399b5c0c8d7 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -473,7 +473,7 @@ mips_make_symbol_special (struct symbol *sym, struct objfile *objfile)
       msym = lookup_minimal_symbol_by_pc (compact_block_start);
       if (msym.minsym && !msymbol_is_mips (msym.minsym))
 	{
-	  BLOCK_START (block) = compact_block_start;
+	  block->startaddr = compact_block_start;
 	}
     }
 }
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 3aa7973e0d5..a1c6a44145a 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -690,8 +690,8 @@ objfile_relocate1 (struct objfile *objfile,
 	    struct mdict_iterator miter;
 
 	    b = BLOCKVECTOR_BLOCK (bv, i);
-	    BLOCK_START (b) += delta[block_line_section];
-	    BLOCK_END (b) += delta[block_line_section];
+	    b->startaddr += delta[block_line_section];
+	    b->endaddr += delta[block_line_section];
 
 	    if (BLOCK_RANGES (b) != nullptr)
 	      for (int j = 0; j < BLOCK_NRANGES (b); j++)
-- 
2.17.2



             reply	other threads:[~2020-05-16 15:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-16 15:10 Tom Tromey [this message]
2020-05-16 16:15 ` Simon Marchi
2020-05-17 14:05   ` Tom Tromey
2020-05-17 14:40     ` Simon Marchi
2020-05-16 16:36 ` Christian Biesinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200516151021.7080-1-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox