From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 13/31] Introduce read_var_value overload
Date: Sun, 05 Nov 2023 11:11:51 -0700 [thread overview]
Message-ID: <20231105-split-objfile-2023-bound-sym-october-v2-13-dbd2d158bbc3@tromey.com> (raw)
In-Reply-To: <20231105-split-objfile-2023-bound-sym-october-v2-0-dbd2d158bbc3@tromey.com>
This adds an overload of read_var_value that accepts a block_symbol.
The next batch of patches concern rewriting gdb to use this overload,
in the end allowing us to remove a use of value_address.
---
gdb/compile/compile-c-symbols.c | 2 +-
gdb/compile/compile-cplus-symbols.c | 2 +-
gdb/findvar.c | 12 ++++++++++++
gdb/infrun.c | 2 +-
gdb/valops.c | 26 ++++++++++++--------------
gdb/value.h | 3 +++
6 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index 2d49ead249e..40578bf36f4 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -155,7 +155,7 @@ convert_one_symbol (compile_c_instance *context,
sym.symbol->print_name ());
}
- val = read_var_value (sym.symbol, sym.block, frame);
+ val = read_var_value (sym, frame);
if (val->lval () != lval_memory)
error (_("Symbol \"%s\" cannot be used for compilation "
"evaluation as its address has not been found."),
diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c
index dec0260bf7a..1288225f08e 100644
--- a/gdb/compile/compile-cplus-symbols.c
+++ b/gdb/compile/compile-cplus-symbols.c
@@ -151,7 +151,7 @@ convert_one_symbol (compile_cplus_instance *instance,
sym.symbol->print_name ());
}
- val = read_var_value (sym.symbol, sym.block, frame);
+ val = read_var_value (sym, frame);
if (val->lval () != lval_memory)
error (_("Symbol \"%s\" cannot be used for compilation "
"evaluation as its address has not been found."),
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 4e992ecdcc7..909dca65532 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -794,6 +794,18 @@ read_var_value (struct symbol *var, const struct block *var_block,
return lang->read_var_value (var, var_block, frame);
}
+/* Calls VAR's language read_var_value hook with the given arguments. */
+
+struct value *
+read_var_value (block_symbol var, frame_info_ptr frame)
+{
+ const struct language_defn *lang = language_def (var.symbol->language ());
+
+ gdb_assert (lang != NULL);
+
+ return lang->read_var_value (var.symbol, var.block, frame);
+}
+
/* Install default attributes for register values. */
struct value *
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 4fde96800fb..a7cb02c958e 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -8311,7 +8311,7 @@ insert_exception_resume_breakpoint (struct thread_info *tp,
vsym = lookup_symbol_search_name (sym->search_name (),
b, VAR_DOMAIN);
- value = read_var_value (vsym.symbol, vsym.block, frame);
+ value = read_var_value (vsym, frame);
/* If the value was optimized out, revert to the old behavior. */
if (! value->optimized_out ())
{
diff --git a/gdb/valops.c b/gdb/valops.c
index 70851cd40b4..b7ed458a649 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -3711,17 +3711,16 @@ value_struct_elt_for_reference (struct type *domain, int offset,
if (TYPE_FN_FIELD_STATIC_P (f, j))
{
- struct symbol *s =
- lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j),
- 0, VAR_DOMAIN, 0).symbol;
+ block_symbol s = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j),
+ 0, VAR_DOMAIN, 0);
- if (s == NULL)
- return NULL;
+ if (s.symbol == nullptr)
+ return nullptr;
if (want_address)
- return value_addr (read_var_value (s, 0, 0));
+ return value_addr (read_var_value (s, 0));
else
- return read_var_value (s, 0, 0);
+ return read_var_value (s, 0);
}
if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
@@ -3742,14 +3741,13 @@ value_struct_elt_for_reference (struct type *domain, int offset,
}
else
{
- struct symbol *s =
- lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j),
- 0, VAR_DOMAIN, 0).symbol;
+ block_symbol s = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j),
+ 0, VAR_DOMAIN, 0);
- if (s == NULL)
- return NULL;
+ if (s.symbol == nullptr)
+ return nullptr;
- struct value *v = read_var_value (s, 0, 0);
+ struct value *v = read_var_value (s, 0);
if (!want_address)
result = v;
else
@@ -4000,7 +3998,7 @@ value_of_this (const struct language_defn *lang)
error (_("current stack frame does not contain a variable named `%s'"),
lang->name_of_this ());
- return read_var_value (sym.symbol, sym.block, frame);
+ return read_var_value (sym, frame);
}
/* Return the value of the local variable, if one exists. Return NULL
diff --git a/gdb/value.h b/gdb/value.h
index e4912717684..b683cbf5f90 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -1140,6 +1140,9 @@ extern struct value *read_var_value (struct symbol *var,
const struct block *var_block,
frame_info_ptr frame);
+extern struct value *read_var_value (block_symbol var,
+ frame_info_ptr frame);
+
extern struct value *allocate_repeat_value (struct type *type, int count);
extern struct value *value_mark (void);
--
2.41.0
next prev parent reply other threads:[~2023-11-05 18:11 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-05 18:11 [PATCH v2 00/31] Baby step for objfile splitting Tom Tromey
2023-11-05 18:11 ` [PATCH v2 01/31] Introduce block-symbol.h Tom Tromey
2023-11-05 18:11 ` [PATCH v2 02/31] Add block_symbol::address Tom Tromey
2023-11-05 18:11 ` [PATCH v2 03/31] Add bound_symbol Tom Tromey
2023-11-05 18:11 ` [PATCH v2 04/31] Easy conversions to use block_symbol::address Tom Tromey
2023-11-05 18:11 ` [PATCH v2 05/31] Use block_symbol::address in ada-tasks.c Tom Tromey
2023-11-05 18:11 ` [PATCH v2 06/31] Use block_symbol::address in printcmd.c Tom Tromey
2023-11-05 18:11 ` [PATCH v2 07/31] Use bound_symbol::address in tracepoint.c Tom Tromey
2023-11-05 18:11 ` [PATCH v2 08/31] Use block_symbol::address " Tom Tromey
2023-11-05 18:11 ` [PATCH v2 09/31] Use block_symbol::address in ax-gdb.c Tom Tromey
2023-11-05 18:11 ` [PATCH v2 10/31] Use block_symbol::address in linespec.c Tom Tromey
2023-11-05 18:11 ` [PATCH v2 11/31] Use block_symbol::address in ada-lang.c Tom Tromey
2023-11-05 18:11 ` [PATCH v2 12/31] Use bound_symbol::address in symmisc.c Tom Tromey
2023-11-05 18:11 ` Tom Tromey [this message]
2023-11-05 18:11 ` [PATCH v2 14/31] Use read_var_value in gdb/compile Tom Tromey
2023-11-05 18:11 ` [PATCH v2 15/31] Return a block_symbol from find_pc_sect_function Tom Tromey
2023-11-05 18:11 ` [PATCH v2 16/31] Use read_var_value overload in finish_command_fsm Tom Tromey
2023-11-05 18:11 ` [PATCH v2 17/31] Use block_symbol in overload-handling code Tom Tromey
2023-11-05 18:11 ` [PATCH v2 18/31] Change evaluate_var_value to accept a block_symbol Tom Tromey
2023-11-05 18:11 ` [PATCH v2 19/31] Change value_of_variable to take " Tom Tromey
2023-11-05 18:11 ` [PATCH v2 20/31] Return a block_symbol from get_frame_function Tom Tromey
2023-11-05 18:11 ` [PATCH v2 21/31] Use read_var_value overload in return_command Tom Tromey
2023-11-05 18:12 ` [PATCH v2 22/31] Use read_var_value overload in py-finishbreakpoint.c Tom Tromey
2023-11-05 18:12 ` [PATCH v2 23/31] Use read_var_value overload in py-framefilter.c Tom Tromey
2023-11-05 18:12 ` [PATCH v2 24/31] Use read_var_value overload in Guile Tom Tromey
2023-11-05 18:12 ` [PATCH v2 25/31] Use read_var_value in read_frame_arg and read_frame_local Tom Tromey
2023-11-05 18:12 ` [PATCH v2 26/31] Change print_variable_and_value to take a block_symbol Tom Tromey
2023-11-05 18:12 ` [PATCH v2 27/31] Change find_frame_funname to return " Tom Tromey
2023-11-05 18:12 ` [PATCH v2 28/31] Change btrace_function::sym to " Tom Tromey
2023-11-05 18:12 ` [PATCH v2 29/31] Use read_var_value overload in Python Tom Tromey
2023-11-05 18:12 ` [PATCH v2 30/31] Remove the old read_var_value Tom Tromey
2023-11-05 18:12 ` [PATCH v2 31/31] Change language_defn::read_var_value to accept block_symbol Tom Tromey
2023-11-06 15:16 ` [PATCH v2 00/31] Baby step for objfile splitting Andrew Burgess
2023-11-07 3:36 ` Tom Tromey
2023-11-07 11:06 ` Andrew Burgess
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=20231105-split-objfile-2023-bound-sym-october-v2-13-dbd2d158bbc3@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).