public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Introduce value_at_non_lval
@ 2023-01-03 16:44 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2023-01-03 16:44 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7f22044a6b7ce968aacd8b26f608370940ec158d
commit 7f22044a6b7ce968aacd8b26f608370940ec158d
Author: Tom Tromey <tromey@adacore.com>
Date: Fri Sep 9 12:50:33 2022 -0600
Introduce value_at_non_lval
In some cases, while a value might be read from memory, gdb should not
record the value as being equivalent to that memory.
In Ada, the inferior call code will call ada_convert_actual -- and
here, if the argument is already in memory, that address will simply
be reused. However, for a call like "f(g())", the result of "g" might
be on the stack and thus overwritten by the call to "f".
This patch introduces a new function that is like value_at but that
ensures that the result is non-lvalue.
Diff:
---
gdb/valops.c | 10 ++++++++++
gdb/value.h | 4 ++++
2 files changed, 14 insertions(+)
diff --git a/gdb/valops.c b/gdb/valops.c
index 5b817179df7..c5b16f8d400 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1019,6 +1019,16 @@ value_at (struct type *type, CORE_ADDR addr)
return get_value_at (type, addr, 0);
}
+/* See value.h. */
+
+struct value *
+value_at_non_lval (struct type *type, CORE_ADDR addr)
+{
+ struct value *result = value_at (type, addr);
+ VALUE_LVAL (result) = not_lval;
+ return result;
+}
+
/* Return a lazy value with type TYPE located at ADDR (cf. value_at).
The type of the created value may differ from the passed type TYPE.
Make sure to retrieve the returned values's new type after this call
diff --git a/gdb/value.h b/gdb/value.h
index 089af59fbd8..1e80b74b41f 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -711,6 +711,10 @@ extern struct value *value_from_component_bitsize (struct value *whole,
extern struct value *value_at (struct type *type, CORE_ADDR addr);
extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr);
+/* Like value_at, but ensures that the result is marked not_lval.
+ This can be important if the memory is "volatile". */
+extern struct value *value_at_non_lval (struct type *type, CORE_ADDR addr);
+
extern struct value *value_from_contents_and_address_unresolved
(struct type *, const gdb_byte *, CORE_ADDR);
extern struct value *value_from_contents_and_address (struct type *,
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-03 16:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-03 16:44 [binutils-gdb] Introduce value_at_non_lval Tom Tromey
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).