[02/30] Add block_symbol::address

Message ID 20231029-split-objfile-2023-bound-sym-october-v1-2-612531df2734@tromey.com
State New
Headers
Series Baby step for objfile splitting |

Commit Message

Tom Tromey Oct. 29, 2023, 11:23 p.m. UTC
  This adds a new block_symbol::address method.  The long-term goal here
is to change most existing calls to symbol::value_address to call
block_symbol::address instead.

Then, at some future date, we can add an objfile to block_symbol and
change this method to relocate the address when called -- making a
symbol independent of the objfile, as we've already done for minimal
symbols and partial symbols.
---
 gdb/block-symbol.h | 2 ++
 gdb/symtab.h       | 6 ++++++
 2 files changed, 8 insertions(+)
  

Patch

diff --git a/gdb/block-symbol.h b/gdb/block-symbol.h
index 35bc40c1986..f7087cf9943 100644
--- a/gdb/block-symbol.h
+++ b/gdb/block-symbol.h
@@ -34,6 +34,8 @@  struct block_symbol
   /* If SYMBOL is not NULL, then this is the block in which the symbol is
      defined.  */
   const struct block *block;
+
+  CORE_ADDR address () const;
 };
 
 #endif /* GDB_BLOCK_SYMBOL_H */
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 0b3ca3964b6..93cc1f11d08 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1522,6 +1522,12 @@  struct symbol : public general_symbol_info, public allocate_on_obstack
  CORE_ADDR get_maybe_copied_address () const;
 };
 
+inline CORE_ADDR
+block_symbol::address () const
+{
+  return symbol->value_address ();
+}
+
 /* Note: There is no accessor macro for symbol.owner because it is
    "private".  */