aboutsummaryrefslogtreecommitdiff
path: root/gdb/values.c
diff options
context:
space:
mode:
authorJim Blandy <jimb@codesourcery.com>2000-04-14 18:43:41 +0000
committerJim Blandy <jimb@codesourcery.com>2000-04-14 18:43:41 +0000
commit4478b372e973afcd2253fe4c1ec3f2d083ac3943 (patch)
tree8140dc777f65fea1264b2d52a191ed79b61eb069 /gdb/values.c
parentd84dd0c55ec2daf8bc3430098b22760478b4b68b (diff)
downloadbinutils-4478b372e973afcd2253fe4c1ec3f2d083ac3943.zip
binutils-4478b372e973afcd2253fe4c1ec3f2d083ac3943.tar.gz
binutils-4478b372e973afcd2253fe4c1ec3f2d083ac3943.tar.bz2
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new
functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
Diffstat (limited to 'gdb/values.c')
-rw-r--r--gdb/values.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/gdb/values.c b/gdb/values.c
index 07aff7a..6186b34 100644
--- a/gdb/values.c
+++ b/gdb/values.c
@@ -580,8 +580,9 @@ value_as_double (val)
error ("Invalid floating value found in program.");
return foo;
}
-/* Extract a value as a C pointer.
- Does not deallocate the value. */
+/* Extract a value as a C pointer. Does not deallocate the value.
+ Note that val's type may not actually be a pointer; value_as_long
+ handles all the cases. */
CORE_ADDR
value_as_pointer (val)
value_ptr val;
@@ -649,7 +650,7 @@ unpack_long (type, valaddr)
if (GDB_TARGET_IS_D10V
&& len == 2)
return D10V_MAKE_DADDR (extract_address (valaddr, len));
- return extract_address (valaddr, len);
+ return extract_typed_address (valaddr, type);
case TYPE_CODE_MEMBER:
error ("not implemented: member types in unpack_long");
@@ -731,6 +732,7 @@ unpack_pointer (type, valaddr)
whether we want this to be true eventually. */
return unpack_long (type, valaddr);
}
+
/* Get the value of the FIELDN'th field (which must be static) of TYPE. */
@@ -1420,9 +1422,7 @@ retry:
case TYPE_CODE_REF:
case TYPE_CODE_PTR:
- /* This assumes that all pointers of a given length
- have the same form. */
- store_address (VALUE_CONTENTS_RAW (val), len, (CORE_ADDR) num);
+ store_typed_address (VALUE_CONTENTS_RAW (val), type, (CORE_ADDR) num);
break;
default:
@@ -1431,6 +1431,18 @@ retry:
return val;
}
+
+/* Create a value representing a pointer of type TYPE to the address
+ ADDR. */
+value_ptr
+value_from_pointer (struct type *type, CORE_ADDR addr)
+{
+ value_ptr val = allocate_value (type);
+ store_typed_address (VALUE_CONTENTS_RAW (val), type, addr);
+ return val;
+}
+
+
/* Create a value for a string constant to be stored locally
(not in the inferior's memory space, but in GDB memory).
This is analogous to value_from_longest, which also does not