diff options
-rw-r--r-- | gdb/value.c | 13 | ||||
-rw-r--r-- | gdb/value.h | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/gdb/value.c b/gdb/value.c index 080af48..a57a832 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1703,7 +1703,7 @@ value_release_to_mark (const struct value *mark) but it's a different block of storage. */ struct value * -value_copy (struct value *arg) +value_copy (const value *arg) { struct type *encl_type = value_enclosing_type (arg); struct value *val; @@ -1713,7 +1713,7 @@ value_copy (struct value *arg) else val = allocate_value (encl_type); val->type = arg->type; - VALUE_LVAL (val) = VALUE_LVAL (arg); + VALUE_LVAL (val) = arg->lval; val->location = arg->location; val->offset = arg->offset; val->bitpos = arg->bitpos; @@ -1727,8 +1727,13 @@ value_copy (struct value *arg) val->initialized = arg->initialized; if (!value_lazy (val)) - copy (value_contents_all_raw (arg), - value_contents_all_raw (val)); + { + gdb_assert (arg->contents != nullptr); + ULONGEST length = TYPE_LENGTH (value_enclosing_type (arg)); + const auto &arg_view + = gdb::make_array_view (arg->contents.get (), length); + copy (arg_view, value_contents_all_raw (val)); + } val->unavailable = arg->unavailable; val->optimized_out = arg->optimized_out; diff --git a/gdb/value.h b/gdb/value.h index f7b2902..4cd2044 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -1127,7 +1127,7 @@ extern void preserve_values (struct objfile *); /* From values.c */ -extern struct value *value_copy (struct value *); +extern struct value *value_copy (const value *); extern struct value *value_non_lval (struct value *); |