return value_from_longest (type, (LONGEST) SYMBOL_VALUE (var));
case LOC_LABEL:
- return value_from_longest (type, (LONGEST) SYMBOL_VALUE_ADDRESS (var));
+ return value_from_pointer (type, (CORE_ADDR) SYMBOL_VALUE_ADDRESS (var));
default:
return 0;
dummy_frame = xmalloc (sizeof (struct dummy_frame));
dummy_frame->registers = xmalloc (REGISTER_BYTES);
- dummy_frame->pc = read_register (PC_REGNUM);
- dummy_frame->sp = read_register (SP_REGNUM);
+ dummy_frame->pc = read_pc ();
+ dummy_frame->sp = read_sp ();
dummy_frame->top = dummy_frame->sp;
dummy_frame->fp = fp;
read_register_bytes (0, dummy_frame->registers, REGISTER_BYTES);
/* Print the unmangled name if desired. */
/* Print vtable entry - we only get here if we ARE using
-fvtable_thunks. (Otherwise, look under TYPE_CODE_STRUCT.) */
- print_address_demangle (extract_address (valaddr + embedded_offset, TYPE_LENGTH (type)),
- stream, demangle);
+ CORE_ADDR addr
+ = extract_typed_address (valaddr + embedded_offset, type);
+ print_address_demangle (addr, stream, demangle);
break;
}
elttype = check_typedef (TYPE_TARGET_TYPE (type));
}
if (addressprint)
{
+ CORE_ADDR addr
+ = extract_typed_address (valaddr + embedded_offset, type);
fprintf_filtered (stream, "@");
- print_address_numeric
- (extract_address (valaddr + embedded_offset,
- TARGET_PTR_BIT / HOST_CHAR_BIT), 1, stream);
+ print_address_numeric (addr, 1, stream);
if (deref_ref)
fputs_filtered (": ", stream);
}
/* Print the unmangled name if desired. */
/* Print vtable entry - we only get here if NOT using
-fvtable_thunks. (Otherwise, look under TYPE_CODE_PTR.) */
- print_address_demangle (extract_address (
- valaddr + embedded_offset +
- TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8,
- TYPE_LENGTH (TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET))),
- stream, demangle);
+ int offset = (embedded_offset +
+ TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8);
+ struct type *field_type = TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET);
+ CORE_ADDR addr
+ = extract_typed_address (valaddr + offset, field_type);
+
+ print_address_demangle (addr, stream, demangle);
}
else
cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream, format,
/* pai: FIXME 32x64 problem? */
/* Not sure what the best notation is in the case where there is no
baseclass name. */
- v = value_from_longest (lookup_pointer_type (builtin_type_unsigned_long),
+ v = value_from_pointer (lookup_pointer_type (builtin_type_unsigned_long),
*(unsigned long *) (valaddr + offset));
val_print (VALUE_TYPE (v), VALUE_CONTENTS (v), 0, 0,
extern CORE_ADDR extract_address (void *, int);
+extern CORE_ADDR extract_typed_address (void *buf, struct type *type);
+
extern void store_signed_integer (void *, int, LONGEST);
extern void store_unsigned_integer (void *, int, ULONGEST);
extern void store_address (void *, int, LONGEST);
+extern void store_typed_address (void *buf, struct type *type, CORE_ADDR addr);
+
/* Setup definitions for host and target floating point formats. We need to
consider the format for `float', `double', and `long double' for both target
and host. We need to do this so that we know what kind of conversions need
/* Method invocation : stuff "this" as first parameter */
/* pai: this used to have lookup_pointer_type for some reason,
* but temp is already a pointer to the object */
- argvec[1] = value_from_longest (VALUE_TYPE (temp),
- VALUE_ADDRESS (temp) + VALUE_OFFSET (temp));
+ argvec[1]
+ = value_from_pointer (VALUE_TYPE (temp),
+ VALUE_ADDRESS (temp) + VALUE_OFFSET (temp));
/* Name of method from expression */
strcpy (tstr, &exp->elts[pc2 + 2].string);
/* Now, convert these values to an address. */
arg1 = value_cast (lookup_pointer_type (TYPE_DOMAIN_TYPE (type)),
arg1);
- arg3 = value_from_longest (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
+ arg3 = value_from_pointer (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
value_as_long (arg1) + mem_offset);
return value_ind (arg3);
bad_pointer_to_member:
return 0;
}
+
+/* Treat the LEN bytes at ADDR as a target-format address, and return
+ that address. ADDR is a buffer in the GDB process, not in the
+ inferior.
+
+ This function should only be used by target-specific code. It
+ assumes that a pointer has the same representation as that thing's
+ address represented as an integer. Some machines use word
+ addresses, or similarly munged things, for certain types of
+ pointers, so that assumption doesn't hold everywhere.
+
+ Common code should use extract_typed_address instead, or something
+ else based on POINTER_TO_ADDRESS. */
+
CORE_ADDR
extract_address (void *addr, int len)
{
return (CORE_ADDR) extract_unsigned_integer (addr, len);
}
+
+#ifndef POINTER_TO_ADDRESS
+#define POINTER_TO_ADDRESS generic_pointer_to_address
+#endif
+
+/* Treat the bytes at BUF as a pointer of type TYPE, and return the
+ address it represents. */
+CORE_ADDR
+extract_typed_address (void *buf, struct type *type)
+{
+ if (TYPE_CODE (type) != TYPE_CODE_PTR
+ && TYPE_CODE (type) != TYPE_CODE_REF)
+ internal_error ("findvar.c (generic_pointer_to_address): "
+ "type is not a pointer or reference");
+
+ return POINTER_TO_ADDRESS (type, buf);
+}
+
+
void
store_signed_integer (void *addr, int len, LONGEST val)
{
}
}
-/* Store the literal address "val" into
- gdb-local memory pointed to by "addr"
- for "len" bytes. */
+/* Store the address VAL as a LEN-byte value in target byte order at
+ ADDR. ADDR is a buffer in the GDB process, not in the inferior.
+
+ This function should only be used by target-specific code. It
+ assumes that a pointer has the same representation as that thing's
+ address represented as an integer. Some machines use word
+ addresses, or similarly munged things, for certain types of
+ pointers, so that assumption doesn't hold everywhere.
+
+ Common code should use store_typed_address instead, or something else
+ based on ADDRESS_TO_POINTER. */
void
store_address (void *addr, int len, LONGEST val)
{
store_unsigned_integer (addr, len, val);
}
+
+
+#ifndef ADDRESS_TO_POINTER
+#define ADDRESS_TO_POINTER generic_address_to_pointer
+#endif
+
+/* Store the address ADDR as a pointer of type TYPE at BUF, in target
+ form. */
+void
+store_typed_address (void *buf, struct type *type, CORE_ADDR addr)
+{
+ if (TYPE_CODE (type) != TYPE_CODE_PTR
+ && TYPE_CODE (type) != TYPE_CODE_REF)
+ internal_error ("findvar.c (generic_address_to_pointer): "
+ "type is not a pointer or reference");
+
+ ADDRESS_TO_POINTER (type, buf, addr);
+}
+
+
+
\f
/* Extract a floating-point number from a target-order byte-stream at ADDR.
Returns the value as type DOUBLEST.
if (raw_buffer != NULL)
{
/* Put it back in target format. */
- store_address (raw_buffer, REGISTER_RAW_SIZE (regnum), (LONGEST) addr);
+ store_address (raw_buffer, REGISTER_RAW_SIZE (regnum),
+ (LONGEST) addr);
}
if (addrp != NULL)
*addrp = 0;
if (!register_valid[regno])
target_fetch_registers (regno);
- return (CORE_ADDR) extract_address (®isters[REGISTER_BYTE (regno)],
- REGISTER_RAW_SIZE (regno));
+ return ((CORE_ADDR)
+ extract_unsigned_integer (®isters[REGISTER_BYTE (regno)],
+ REGISTER_RAW_SIZE (regno)));
}
CORE_ADDR
{
TARGET_WRITE_FP (val);
}
+
+
+/* Given a pointer of type TYPE in target form in BUF, return the
+ address it represents. */
+CORE_ADDR
+generic_pointer_to_address (struct type *type, char *buf)
+{
+ return extract_address (buf, TYPE_LENGTH (type));
+}
+
+
+/* Given an address, store it as a pointer of type TYPE in target
+ format in BUF. */
+void
+generic_address_to_pointer (struct type *type, char *buf, CORE_ADDR addr)
+{
+ store_address (buf, TYPE_LENGTH (type), addr);
+}
+
\f
/* Will calling read_var_value or locate_var_value on SYM end
up caring what frame it is being evaluated relative to? SYM must
case LOC_LABEL:
/* Put the constant back in target format. */
if (overlay_debugging)
- store_address (VALUE_CONTENTS_RAW (v), len,
- (LONGEST) symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
- SYMBOL_BFD_SECTION (var)));
+ {
+ CORE_ADDR addr
+ = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
+ SYMBOL_BFD_SECTION (var));
+ store_typed_address (VALUE_CONTENTS_RAW (v), type, addr);
+ }
else
- store_address (VALUE_CONTENTS_RAW (v), len,
- (LONGEST) SYMBOL_VALUE_ADDRESS (var));
+ store_typed_address (VALUE_CONTENTS_RAW (v), type,
+ SYMBOL_VALUE_ADDRESS (var));
VALUE_LVAL (v) = not_lval;
return v;
value_ptr val;
addr = VALUE_ADDRESS (lazy_value);
- val = value_from_longest (lookup_pointer_type (type), (LONGEST) addr);
+ val = value_from_pointer (lookup_pointer_type (type), addr);
VALUE_BFD_SECTION (val) = VALUE_BFD_SECTION (lazy_value);
return val;
}
gdbarch_register_convertible_ftype *register_convertible;
gdbarch_register_convert_to_virtual_ftype *register_convert_to_virtual;
gdbarch_register_convert_to_raw_ftype *register_convert_to_raw;
+ gdbarch_pointer_to_address_ftype *pointer_to_address;
+ gdbarch_address_to_pointer_ftype *address_to_pointer;
gdbarch_extract_return_value_ftype *extract_return_value;
gdbarch_push_arguments_ftype *push_arguments;
gdbarch_push_dummy_frame_ftype *push_dummy_frame;
0,
0,
0,
+ 0,
+ 0,
/* startup_gdbarch() */
};
struct gdbarch *current_gdbarch = &startup_gdbarch;
gdbarch->call_dummy_stack_adjust_p = -1;
gdbarch->coerce_float_to_double = default_coerce_float_to_double;
gdbarch->register_convertible = generic_register_convertible_not;
+ gdbarch->pointer_to_address = generic_pointer_to_address;
+ gdbarch->address_to_pointer = generic_address_to_pointer;
gdbarch->breakpoint_from_pc = legacy_breakpoint_from_pc;
gdbarch->memory_insert_breakpoint = default_memory_insert_breakpoint;
gdbarch->memory_remove_breakpoint = default_memory_remove_breakpoint;
/* Skip verify of register_convertible, invalid_p == 0 */
/* Skip verify of register_convert_to_virtual, invalid_p == 0 */
/* Skip verify of register_convert_to_raw, invalid_p == 0 */
+ /* Skip verify of pointer_to_address, invalid_p == 0 */
+ /* Skip verify of address_to_pointer, invalid_p == 0 */
if ((GDB_MULTI_ARCH >= 2)
&& (gdbarch->extract_return_value == 0))
internal_error ("gdbarch: verify_gdbarch: extract_return_value invalid");
"gdbarch_update: REGISTER_CONVERT_TO_RAW = 0x%08lx\n",
(long) current_gdbarch->register_convert_to_raw
/*REGISTER_CONVERT_TO_RAW ()*/);
+ fprintf_unfiltered (gdb_stdlog,
+ "gdbarch_update: POINTER_TO_ADDRESS = 0x%08lx\n",
+ (long) current_gdbarch->pointer_to_address
+ /*POINTER_TO_ADDRESS ()*/);
+ fprintf_unfiltered (gdb_stdlog,
+ "gdbarch_update: ADDRESS_TO_POINTER = 0x%08lx\n",
+ (long) current_gdbarch->address_to_pointer
+ /*ADDRESS_TO_POINTER ()*/);
fprintf_unfiltered (gdb_stdlog,
"gdbarch_update: EXTRACT_RETURN_VALUE = 0x%08lx\n",
(long) current_gdbarch->extract_return_value
gdbarch->register_convert_to_raw = register_convert_to_raw;
}
+CORE_ADDR
+gdbarch_pointer_to_address (struct gdbarch *gdbarch, struct type *type, char *buf)
+{
+ if (gdbarch->pointer_to_address == 0)
+ internal_error ("gdbarch: gdbarch_pointer_to_address invalid");
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_pointer_to_address called\n");
+ return gdbarch->pointer_to_address (type, buf);
+}
+
+void
+set_gdbarch_pointer_to_address (struct gdbarch *gdbarch,
+ gdbarch_pointer_to_address_ftype pointer_to_address)
+{
+ gdbarch->pointer_to_address = pointer_to_address;
+}
+
+void
+gdbarch_address_to_pointer (struct gdbarch *gdbarch, struct type *type, char *buf, CORE_ADDR addr)
+{
+ if (gdbarch->address_to_pointer == 0)
+ internal_error ("gdbarch: gdbarch_address_to_pointer invalid");
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_address_to_pointer called\n");
+ gdbarch->address_to_pointer (type, buf, addr);
+}
+
+void
+set_gdbarch_address_to_pointer (struct gdbarch *gdbarch,
+ gdbarch_address_to_pointer_ftype address_to_pointer)
+{
+ gdbarch->address_to_pointer = address_to_pointer;
+}
+
void
gdbarch_extract_return_value (struct gdbarch *gdbarch, struct type *type, char *regbuf, char *valbuf)
{
return 0;
}
+
/* Disassembler */
/* Pointer to the target-dependent disassembly function. */
#endif
#endif
+typedef CORE_ADDR (gdbarch_pointer_to_address_ftype) (struct type *type, char *buf);
+extern CORE_ADDR gdbarch_pointer_to_address (struct gdbarch *gdbarch, struct type *type, char *buf);
+extern void set_gdbarch_pointer_to_address (struct gdbarch *gdbarch, gdbarch_pointer_to_address_ftype *pointer_to_address);
+#if GDB_MULTI_ARCH
+#if (GDB_MULTI_ARCH > 1) || !defined (POINTER_TO_ADDRESS)
+#define POINTER_TO_ADDRESS(type, buf) (gdbarch_pointer_to_address (current_gdbarch, type, buf))
+#endif
+#endif
+
+typedef void (gdbarch_address_to_pointer_ftype) (struct type *type, char *buf, CORE_ADDR addr);
+extern void gdbarch_address_to_pointer (struct gdbarch *gdbarch, struct type *type, char *buf, CORE_ADDR addr);
+extern void set_gdbarch_address_to_pointer (struct gdbarch *gdbarch, gdbarch_address_to_pointer_ftype *address_to_pointer);
+#if GDB_MULTI_ARCH
+#if (GDB_MULTI_ARCH > 1) || !defined (ADDRESS_TO_POINTER)
+#define ADDRESS_TO_POINTER(type, buf, addr) (gdbarch_address_to_pointer (current_gdbarch, type, buf, addr))
+#endif
+#endif
+
typedef void (gdbarch_extract_return_value_ftype) (struct type *type, char *regbuf, char *valbuf);
extern void gdbarch_extract_return_value (struct gdbarch *gdbarch, struct type *type, char *regbuf, char *valbuf);
extern void set_gdbarch_extract_return_value (struct gdbarch *gdbarch, gdbarch_extract_return_value_ftype *extract_return_value);
f:2:REGISTER_CONVERT_TO_VIRTUAL:void:register_convert_to_virtual:int regnum, struct type *type, char *from, char *to:regnum, type, from, to:::0:0
f:2:REGISTER_CONVERT_TO_RAW:void:register_convert_to_raw:struct type *type, int regnum, char *from, char *to:type, regnum, from, to:::0:0
#
+f:2:POINTER_TO_ADDRESS:CORE_ADDR:pointer_to_address:struct type *type, char *buf:type, buf:::generic_pointer_to_address:0
+f:2:ADDRESS_TO_POINTER:void:address_to_pointer:struct type *type, char *buf, CORE_ADDR addr:type, buf, addr:::generic_address_to_pointer:0
+#
f:2:EXTRACT_RETURN_VALUE:void:extract_return_value:struct type *type, char *regbuf, char *valbuf:type, regbuf, valbuf::0:0
f:1:PUSH_ARGUMENTS:CORE_ADDR:push_arguments:int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr:nargs, args, sp, struct_return, struct_addr::0:0
f:2:PUSH_DUMMY_FRAME:void:push_dummy_frame:void:-:::0
return 0;
}
+
/* Disassembler */
/* Pointer to the target-dependent disassembly function. */
/* now prepare the arguments for the call */
args[0] = value_from_longest (TYPE_FIELD_TYPE (ftype, 0), 12);
- args[1] = value_from_longest (TYPE_FIELD_TYPE (ftype, 1), SYMBOL_VALUE_ADDRESS (msymbol));
- args[2] = value_from_longest (TYPE_FIELD_TYPE (ftype, 2), endo_buff_addr);
+ args[1] = value_from_pointer (TYPE_FIELD_TYPE (ftype, 1), SYMBOL_VALUE_ADDRESS (msymbol));
+ args[2] = value_from_pointer (TYPE_FIELD_TYPE (ftype, 2), endo_buff_addr);
args[3] = value_from_longest (TYPE_FIELD_TYPE (ftype, 3), TYPE_PROCEDURE);
- args[4] = value_from_longest (TYPE_FIELD_TYPE (ftype, 4), value_return_addr);
- args[5] = value_from_longest (TYPE_FIELD_TYPE (ftype, 5), errno_return_addr);
+ args[4] = value_from_pointer (TYPE_FIELD_TYPE (ftype, 4), value_return_addr);
+ args[5] = value_from_pointer (TYPE_FIELD_TYPE (ftype, 5), errno_return_addr);
/* now call the function */
extern void generic_target_write_fp PARAMS ((CORE_ADDR));
+extern CORE_ADDR generic_pointer_to_address (struct type *type, char *buf);
+
+extern void generic_address_to_pointer (struct type *type, char *buf,
+ CORE_ADDR addr);
+
extern void wait_for_inferior PARAMS ((void));
extern void fetch_inferior_event PARAMS ((void *));
/* Make address available to the user as $_. */
set_internalvar (lookup_internalvar ("_"),
- value_from_longest (lookup_pointer_type (builtin_type_void),
- (LONGEST) addr));
+ value_from_pointer (lookup_pointer_type (builtin_type_void),
+ addr));
}
/* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
{
/* Make last address examined available to the user as $_. Use
the correct pointer type. */
+ struct type *pointer_type
+ = lookup_pointer_type (VALUE_TYPE (last_examine_value));
set_internalvar (lookup_internalvar ("_"),
- value_from_longest (
- lookup_pointer_type (VALUE_TYPE (last_examine_value)),
- (LONGEST) last_examine_address));
+ value_from_pointer (pointer_type,
+ last_examine_address));
/* Make contents of last address examined available to the user as $__. */
/* If the last value has not been fetched from memory then don't
traceframe_sal.pc = traceframe_sal.line = 0;
traceframe_sal.symtab = NULL;
set_internalvar (lookup_internalvar ("trace_func"),
- value_from_longest (charstar, (LONGEST) 0));
+ value_from_pointer (charstar, (LONGEST) 0));
set_internalvar (lookup_internalvar ("trace_file"),
- value_from_longest (charstar, (LONGEST) 0));
+ value_from_pointer (charstar, (LONGEST) 0));
set_internalvar (lookup_internalvar ("trace_line"),
- value_from_longest (builtin_type_int, (LONGEST) - 1));
+ value_from_pointer (builtin_type_int, (LONGEST) - 1));
return;
}
if (traceframe_fun == NULL ||
SYMBOL_NAME (traceframe_fun) == NULL)
set_internalvar (lookup_internalvar ("trace_func"),
- value_from_longest (charstar, (LONGEST) 0));
+ value_from_pointer (charstar, (LONGEST) 0));
else
{
len = strlen (SYMBOL_NAME (traceframe_fun));
if (traceframe_sal.symtab == NULL ||
traceframe_sal.symtab->filename == NULL)
set_internalvar (lookup_internalvar ("trace_file"),
- value_from_longest (charstar, (LONGEST) 0));
+ value_from_pointer (charstar, (LONGEST) 0));
else
{
len = strlen (traceframe_sal.symtab->filename);
len = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (valptrtype)));
if (len == 0)
len = 1; /* For (void *) */
- retval = value_from_longest (valptrtype,
- value_as_long (valptr)
+ retval = value_from_pointer (valptrtype,
+ value_as_pointer (valptr)
+ (len * value_as_long (valint)));
VALUE_BFD_SECTION (retval) = VALUE_BFD_SECTION (valptr);
return retval;
{
/* pointer - integer. */
LONGEST sz = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)));
- return value_from_longest
- (VALUE_TYPE (arg1),
- value_as_long (arg1) - (sz * value_as_long (arg2)));
+ return value_from_pointer (VALUE_TYPE (arg1),
+ (value_as_pointer (arg1)
+ - (sz * value_as_long (arg2))));
}
else if (TYPE_CODE (type2) == TYPE_CODE_PTR
&& TYPE_LENGTH (TYPE_TARGET_TYPE (type1))
if (msymbol != NULL)
{
struct type *type;
- LONGEST maddr;
+ CORE_ADDR maddr;
type = lookup_pointer_type (builtin_type_char);
type = lookup_function_type (type);
type = lookup_pointer_type (type);
- maddr = (LONGEST) SYMBOL_VALUE_ADDRESS (msymbol);
- return value_from_longest (type, maddr);
+ maddr = SYMBOL_VALUE_ADDRESS (msymbol);
+ return value_from_pointer (type, maddr);
}
else
{
if (VALUE_LVAL (arg1) != lval_memory)
error ("Attempt to take address of value not located in memory.");
- return value_from_longest (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
- (LONGEST) (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1)));
+ return value_from_pointer (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
+ (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1)));
}
/* Given a value which is a function, return a value which is a pointer
if (VALUE_LVAL (arg1) != lval_memory)
error ("Attempt to take address of value not located in memory.");
- retval = value_from_longest (lookup_pointer_type (VALUE_TYPE (arg1)),
- (LONGEST) (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1)));
+ retval = value_from_pointer (lookup_pointer_type (VALUE_TYPE (arg1)),
+ (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1)));
VALUE_BFD_SECTION (retval) = VALUE_BFD_SECTION (arg1);
return retval;
}
error ("Attempt to take address of value not located in memory.");
/* Get target memory address */
- arg2 = value_from_longest (lookup_pointer_type (VALUE_TYPE (arg1)),
- (LONGEST) (VALUE_ADDRESS (arg1)
- + VALUE_OFFSET (arg1)
- + VALUE_EMBEDDED_OFFSET (arg1)));
+ arg2 = value_from_pointer (lookup_pointer_type (VALUE_TYPE (arg1)),
+ (VALUE_ADDRESS (arg1)
+ + VALUE_OFFSET (arg1)
+ + VALUE_EMBEDDED_OFFSET (arg1)));
/* This may be a pointer to a base subobject; so remember the
full derived object's type ... */
we just pushed. */
/*args[i] = value_from_longest (lookup_pointer_type (value_type),
(LONGEST) addr); */
- args[i] = value_from_longest (lookup_pointer_type (arg_type),
- (LONGEST) addr);
+ args[i] = value_from_pointer (lookup_pointer_type (arg_type),
+ addr);
}
}
}
do { struct type *value_type_arg_tmp = check_typedef (VALUE_TYPE (arg));\
if (TYPE_CODE (value_type_arg_tmp) == TYPE_CODE_REF) \
arg = value_at_lazy (TYPE_TARGET_TYPE (value_type_arg_tmp), \
- unpack_long (VALUE_TYPE (arg), \
- VALUE_CONTENTS (arg)), \
+ unpack_pointer (VALUE_TYPE (arg), \
+ VALUE_CONTENTS (arg)), \
VALUE_BFD_SECTION (arg)); \
} while (0)
extern value_ptr value_from_longest PARAMS ((struct type * type, LONGEST num));
+extern value_ptr value_from_pointer (struct type *type, CORE_ADDR addr);
+
extern value_ptr value_from_double PARAMS ((struct type * type, DOUBLEST num));
extern value_ptr value_from_string PARAMS ((char *string));
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;
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");
whether we want this to be true eventually. */
return unpack_long (type, valaddr);
}
+
\f
/* Get the value of the FIELDN'th field (which must be static) of TYPE. */
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:
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