summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2022-08-10 12:05:52 -0700
committerJohn Baldwin <jhb@FreeBSD.org>2022-09-01 16:47:42 -0700
commitcabfc6253d9d61d97cd3c6b0c4cae949dd36187b (patch)
treeb8c94ed9a1e226ab57f9b37f0c9fe717ad4af40f
parenta4f89e9870e5ed92527bb6879187c5cc28e98001 (diff)
downloadbinutils-gdb-cabfc6253d9d61d97cd3c6b0c4cae949dd36187b.tar.gz
Read memory capabilities atomically.
When resolving a lazy memory capability value, use target_read_capability to read the entire capability directly rather than only using it to read the tag. Also, just use target_read_capability directly without requiring a gdbarch wrapper method.
-rw-r--r--gdb/value.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/gdb/value.c b/gdb/value.c
index 1dad82823c4..1c0b8d5e4dd 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -3960,16 +3960,25 @@ value_fetch_lazy_memory (struct value *val)
CORE_ADDR addr = value_address (val);
struct type *type = check_typedef (value_enclosing_type (val));
+ if (TYPE_CAPABILITY (type))
+ {
+ gdb::byte_vector cap = target_read_capability (addr);
+ if (cap.size () == TYPE_LENGTH (type) + 1)
+ {
+ memcpy (value_contents_all_raw (val).data (), cap.data () + 1,
+ TYPE_LENGTH (type));
+ set_value_tag (val, cap[0] != 0);
+ return;
+ }
+ }
+
if (TYPE_LENGTH (type))
read_value_memory (val, 0, value_stack (val),
addr, value_contents_all_raw (val).data (),
type_length_units (type));
if (TYPE_CAPABILITY (type))
- {
- bool tag = gdbarch_get_cap_tag_from_address (get_value_arch (val), addr);
- set_value_tag (val, tag);
- }
+ set_value_tag (val, false);
}
/* Helper for value_fetch_lazy when the value is in a register. */