[commit] Make value_contents_*_raw a function

Andrew Cagney
2005-02-02T00:22:19Z

[-- Attachment #1: Type: text/plain, Size: 23 bytes --]

FYI,
committed,
Andrew

[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 26730 bytes --]

2005-02-01 Andrew Cagney <cagney@gnu.org>

* value.c (value_contents_all_raw)
(value_contents_raw): New functions.
* value.h (VALUE_CONTENTS_ALL_RAW, VALUE_CONTENTS_RAW): Delete.
(value_contents_raw, value_contents_all_raw): Declare functions.
(VALUE_CONTENTS, VALUE_CONTENTS_ALL): Update.
* std-regs.c, valarith.c, valops.c, eval.c: Update.
* tracepoint.c, findvar.c: Update.

Index: ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.68
diff -p -u -r1.68 ada-lang.c
--- ada-lang.c 29 Jan 2005 01:59:29 -0000 1.68
+++ ada-lang.c 1 Feb 2005 23:51:32 -0000
@@ -422,7 +422,7 @@ value_from_contents_and_address (struct
if (valaddr == NULL)
VALUE_LAZY (v) = 1;
else
- memcpy (VALUE_CONTENTS_RAW (v), valaddr, TYPE_LENGTH (type));
+ memcpy (value_contents_raw (v), valaddr, TYPE_LENGTH (type));
VALUE_ADDRESS (v) = address;
if (address != 0)
VALUE_LVAL (v) = lval_memory;
@@ -455,7 +455,7 @@ coerce_unspec_val_to_type (struct value
|| TYPE_LENGTH (type) > TYPE_LENGTH (value_type (val)))
VALUE_LAZY (result) = 1;
else
- memcpy (VALUE_CONTENTS_RAW (result), VALUE_CONTENTS (val),
+ memcpy (value_contents_raw (result), VALUE_CONTENTS (val),
TYPE_LENGTH (type));
return result;
}
@@ -2038,7 +2038,7 @@ ada_value_assign (struct value *toval, s
len);

val = value_copy (toval);
- memcpy (VALUE_CONTENTS_RAW (val), VALUE_CONTENTS (fromval),
+ memcpy (value_contents_raw (val), VALUE_CONTENTS (fromval),
TYPE_LENGTH (type));
val->type = type;

@@ -3503,7 +3503,7 @@ ensure_lval (struct value *val, CORE_ADD
*sp = gdbarch_frame_align (current_gdbarch, *sp);
}

- write_memory (VALUE_ADDRESS (val), VALUE_CONTENTS_RAW (val), len);
+ write_memory (VALUE_ADDRESS (val), value_contents_raw (val), len);
}

return val;
@@ -3542,7 +3542,7 @@ convert_actual (struct value *actual, st
struct value *val;
actual_type = ada_check_typedef (value_type (actual));
val = allocate_value (actual_type);
- memcpy ((char *) VALUE_CONTENTS_RAW (val),
+ memcpy ((char *) value_contents_raw (val),
(char *) VALUE_CONTENTS (actual),
TYPE_LENGTH (actual_type));
actual = ensure_lval (val, sp);
@@ -7103,7 +7103,7 @@ ada_value_binop (struct value *arg1, str
}

val = allocate_value (type1);
- store_unsigned_integer (VALUE_CONTENTS_RAW (val),
+ store_unsigned_integer (value_contents_raw (val),
TYPE_LENGTH (value_type (val)), v);
return val;
}
Index: eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.46
diff -p -u -r1.46 eval.c
--- eval.c 12 Nov 2004 21:45:06 -0000 1.46
+++ eval.c 1 Feb 2005 23:51:32 -0000
@@ -1,8 +1,8 @@
/* Evaluate expressions for GDB.

Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
- 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
- Foundation, Inc.
+ 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005 Free
+ Software Foundation, Inc.

This file is part of GDB.

@@ -360,7 +360,7 @@ init_array_element (struct value *array,
error ("tuple range index out of range");
for (index = low; index <= high; index++)
{
- memcpy (VALUE_CONTENTS_RAW (array)
+ memcpy (value_contents_raw (array)
+ (index - low_bound) * element_size,
VALUE_CONTENTS (element), element_size);
}
@@ -370,7 +370,7 @@ init_array_element (struct value *array,
index = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
if (index < low_bound || index > high_bound)
error ("tuple index out of range");
- memcpy (VALUE_CONTENTS_RAW (array) + (index - low_bound) * element_size,
+ memcpy (value_contents_raw (array) + (index - low_bound) * element_size,
VALUE_CONTENTS (element), element_size);
}
return index;
@@ -500,7 +500,7 @@ evaluate_subexp_standard (struct type *e
&& TYPE_CODE (type) == TYPE_CODE_STRUCT)
{
struct value *rec = allocate_value (expect_type);
- memset (VALUE_CONTENTS_RAW (rec), '\0', TYPE_LENGTH (type));
+ memset (value_contents_raw (rec), '\0', TYPE_LENGTH (type));
return evaluate_struct_tuple (rec, exp, pos, noside, nargs);
}

@@ -518,7 +518,7 @@ evaluate_subexp_standard (struct type *e
high_bound = (TYPE_LENGTH (type) / element_size) - 1;
}
index = low_bound;
- memset (VALUE_CONTENTS_RAW (array), 0, TYPE_LENGTH (expect_type));
+ memset (value_contents_raw (array), 0, TYPE_LENGTH (expect_type));
for (tem = nargs; --nargs >= 0;)
{
struct value *element;
@@ -544,7 +544,7 @@ evaluate_subexp_standard (struct type *e
if (index > high_bound)
/* to avoid memory corruption */
error ("Too many array elements");
- memcpy (VALUE_CONTENTS_RAW (array)
+ memcpy (value_contents_raw (array)
+ (index - low_bound) * element_size,
VALUE_CONTENTS (element),
element_size);
@@ -558,7 +558,7 @@ evaluate_subexp_standard (struct type *e
&& TYPE_CODE (type) == TYPE_CODE_SET)
{
struct value *set = allocate_value (expect_type);
- char *valaddr = VALUE_CONTENTS_RAW (set);
+ char *valaddr = value_contents_raw (set);
struct type *element_type = TYPE_INDEX_TYPE (type);
struct type *check_type = element_type;
LONGEST low_bound, high_bound;
Index: findvar.c
===================================================================
RCS file: /cvs/src/src/gdb/findvar.c,v
retrieving revision 1.82
diff -p -u -r1.82 findvar.c
--- findvar.c 15 Nov 2004 22:17:59 -0000 1.82
+++ findvar.c 1 Feb 2005 23:51:32 -0000
@@ -1,8 +1,8 @@
/* Find a variable's value in memory, for GDB, the GNU debugger.

Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
- 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004 Free Software
- Foundation, Inc.
+ 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free
+ Software Foundation, Inc.

This file is part of GDB.

@@ -282,7 +282,7 @@ value_of_register (int regnum, struct fr

reg_val = allocate_value (register_type (current_gdbarch, regnum));

- memcpy (VALUE_CONTENTS_RAW (reg_val), raw_buffer,
+ memcpy (value_contents_raw (reg_val), raw_buffer,
register_size (current_gdbarch, regnum));
VALUE_LVAL (reg_val) = lval;
VALUE_ADDRESS (reg_val) = addr;
@@ -400,7 +400,7 @@ read_var_value (struct symbol *var, stru
{
case LOC_CONST:
/* Put the constant back in target format. */
- store_signed_integer (VALUE_CONTENTS_RAW (v), len,
+ store_signed_integer (value_contents_raw (v), len,
(LONGEST) SYMBOL_VALUE (var));
VALUE_LVAL (v) = not_lval;
return v;
@@ -412,10 +412,10 @@ read_var_value (struct symbol *var, stru
CORE_ADDR addr
= symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
SYMBOL_BFD_SECTION (var));
- store_typed_address (VALUE_CONTENTS_RAW (v), type, addr);
+ store_typed_address (value_contents_raw (v), type, addr);
}
else
- store_typed_address (VALUE_CONTENTS_RAW (v), type,
+ store_typed_address (value_contents_raw (v), type,
SYMBOL_VALUE_ADDRESS (var));
VALUE_LVAL (v) = not_lval;
return v;
@@ -424,7 +424,7 @@ read_var_value (struct symbol *var, stru
{
char *bytes_addr;
bytes_addr = SYMBOL_VALUE_BYTES (var);
- memcpy (VALUE_CONTENTS_RAW (v), bytes_addr, len);
+ memcpy (value_contents_raw (v), bytes_addr, len);
VALUE_LVAL (v) = not_lval;
return v;
}
@@ -634,7 +634,7 @@ value_from_register (struct type *type,
the corresponding [integer] type (see Alpha). The assumption
is that REGISTER_TO_VALUE populates the entire value
including the location. */
- REGISTER_TO_VALUE (frame, regnum, type, VALUE_CONTENTS_RAW (v));
+ REGISTER_TO_VALUE (frame, regnum, type, value_contents_raw (v));
VALUE_LVAL (v) = lval_register;
VALUE_FRAME_ID (v) = get_frame_id (frame);
VALUE_REGNUM (v) = regnum;
@@ -713,7 +713,7 @@ value_from_register (struct type *type,
v->offset = register_size (current_gdbarch, regnum) - len;
else
v->offset = 0;
- memcpy (VALUE_CONTENTS_RAW (v), value_bytes + value_offset (v), len);
+ memcpy (value_contents_raw (v), value_bytes + value_offset (v), len);
}
return v;
}
Index: infcall.c
===================================================================
RCS file: /cvs/src/src/gdb/infcall.c,v
retrieving revision 1.60
diff -p -u -r1.60 infcall.c
--- infcall.c 12 Nov 2004 21:45:06 -0000 1.60
+++ infcall.c 1 Feb 2005 23:51:33 -0000
@@ -1,7 +1,7 @@
/* Perform an inferior function call, for GDB, the GNU debugger.

Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
- 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.

This file is part of GDB.
@@ -861,7 +861,7 @@ the function call).", name);
NULL, NULL, NULL)
== RETURN_VALUE_REGISTER_CONVENTION);
gdbarch_return_value (current_gdbarch, values_type, retbuf,
- VALUE_CONTENTS_RAW (retval) /*read*/,
+ value_contents_raw (retval) /*read*/,
NULL /*write*/);
}
do_cleanups (retbuf_cleanup);
Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.126
diff -p -u -r1.126 infcmd.c
--- infcmd.c 17 Jan 2005 16:47:55 -0000 1.126
+++ infcmd.c 1 Feb 2005 23:51:33 -0000
@@ -1,6 +1,7 @@
/* Memory-access and commands for "inferior" process, for GDB.
- Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
- 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+
+ Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
+ 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.

This file is part of GDB.
@@ -1098,7 +1099,7 @@ print_return_value (int struct_return, s
value = allocate_value (value_type);
CHECK_TYPEDEF (value_type);
gdbarch_return_value (current_gdbarch, value_type, stop_registers,
- VALUE_CONTENTS_RAW (value), NULL);
+ value_contents_raw (value), NULL);
break;
case RETURN_VALUE_STRUCT_CONVENTION:
value = NULL;
Index: std-regs.c
===================================================================
RCS file: /cvs/src/src/gdb/std-regs.c,v
retrieving revision 1.11
diff -p -u -r1.11 std-regs.c
--- std-regs.c 12 Nov 2004 21:45:07 -0000 1.11
+++ std-regs.c 1 Feb 2005 23:51:33 -0000
@@ -1,6 +1,6 @@
/* Builtin frame register, for GDB, the GNU debugger.

- Copyright 2002 Free Software Foundation, Inc.
+ Copyright 2002, 2005 Free Software Foundation, Inc.

Contributed by Red Hat.

@@ -60,7 +60,7 @@ value_of_builtin_frame_reg (struct frame
build_builtin_type_frame_reg ();
val = allocate_value (builtin_type_frame_reg);
VALUE_LVAL (val) = not_lval;
- buf = VALUE_CONTENTS_RAW (val);
+ buf = value_contents_raw (val);
memset (buf, TYPE_LENGTH (value_type (val)), 0);
/* frame.base. */
if (frame != NULL)
@@ -85,7 +85,7 @@ value_of_builtin_frame_fp_reg (struct fr
else
{
struct value *val = allocate_value (builtin_type_void_data_ptr);
- char *buf = VALUE_CONTENTS_RAW (val);
+ char *buf = value_contents_raw (val);
if (frame == NULL)
memset (buf, TYPE_LENGTH (value_type (val)), 0);
else
@@ -103,7 +103,7 @@ value_of_builtin_frame_pc_reg (struct fr
else
{
struct value *val = allocate_value (builtin_type_void_data_ptr);
- char *buf = VALUE_CONTENTS_RAW (val);
+ char *buf = value_contents_raw (val);
if (frame == NULL)
memset (buf, TYPE_LENGTH (value_type (val)), 0);
else
Index: tracepoint.c
===================================================================
RCS file: /cvs/src/src/gdb/tracepoint.c,v
retrieving revision 1.67
diff -p -u -r1.67 tracepoint.c
--- tracepoint.c 14 Jan 2005 03:59:19 -0000 1.67
+++ tracepoint.c 1 Feb 2005 23:51:33 -0000
@@ -1,7 +1,7 @@
/* Tracing functionality for remote targets in custom GDB protocol

- Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
- Free Software Foundation, Inc.
+ Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free
+ Software Foundation, Inc.

This file is part of GDB.

@@ -297,7 +297,7 @@ set_traceframe_context (CORE_ADDR trace_
builtin_type_char, func_range);
func_val = allocate_value (func_string);
func_val->type = func_string;
- memcpy (VALUE_CONTENTS_RAW (func_val),
+ memcpy (value_contents_raw (func_val),
DEPRECATED_SYMBOL_NAME (traceframe_fun),
len);
func_val->modifiable = 0;
@@ -319,7 +319,7 @@ set_traceframe_context (CORE_ADDR trace_
builtin_type_char, file_range);
file_val = allocate_value (file_string);
file_val->type = file_string;
- memcpy (VALUE_CONTENTS_RAW (file_val),
+ memcpy (value_contents_raw (file_val),
traceframe_sal.symtab->filename,
len);
file_val->modifiable = 0;
Index: valarith.c
===================================================================
RCS file: /cvs/src/src/gdb/valarith.c,v
retrieving revision 1.31
diff -p -u -r1.31 valarith.c
--- valarith.c 28 Jan 2005 16:45:15 -0000 1.31
+++ valarith.c 1 Feb 2005 23:51:33 -0000
@@ -1,8 +1,8 @@
/* Perform arithmetic and other operations on values, for GDB.

Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
- 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
- Foundation, Inc.
+ 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free
+ Software Foundation, Inc.

This file is part of GDB.

@@ -806,7 +806,7 @@ value_binop (struct value *arg1, struct
else
val = allocate_value (builtin_type_double);

- store_typed_floating (VALUE_CONTENTS_RAW (val), value_type (val), v);
+ store_typed_floating (value_contents_raw (val), value_type (val), v);
}
else if (TYPE_CODE (type1) == TYPE_CODE_BOOL
&&
@@ -843,7 +843,7 @@ value_binop (struct value *arg1, struct
}

val = allocate_value (type1);
- store_signed_integer (VALUE_CONTENTS_RAW (val),
+ store_signed_integer (value_contents_raw (val),
TYPE_LENGTH (type1),
v);
}
@@ -1015,7 +1015,7 @@ value_binop (struct value *arg1, struct
(result_len > TARGET_LONG_BIT / HOST_CHAR_BIT
? builtin_type_unsigned_long_long
: builtin_type_unsigned_long);
- store_unsigned_integer (VALUE_CONTENTS_RAW (val),
+ store_unsigned_integer (value_contents_raw (val),
TYPE_LENGTH (value_type (val)),
v);
}
@@ -1139,7 +1139,7 @@ value_binop (struct value *arg1, struct
(result_len > TARGET_LONG_BIT / HOST_CHAR_BIT
? builtin_type_long_long
: builtin_type_long);
- store_signed_integer (VALUE_CONTENTS_RAW (val),
+ store_signed_integer (value_contents_raw (val),
TYPE_LENGTH (value_type (val)),
v);
}
Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.140
diff -p -u -r1.140 valops.c
--- valops.c 28 Jan 2005 16:45:15 -0000 1.140
+++ valops.c 1 Feb 2005 23:51:33 -0000
@@ -1,6 +1,7 @@
/* Perform non-arithmetic operations on values, for GDB.
+
Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
- 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.

This file is part of GDB.
@@ -457,7 +458,7 @@ value_at (struct type *type, CORE_ADDR a

val = allocate_value (type);

- read_memory (addr, VALUE_CONTENTS_ALL_RAW (val), TYPE_LENGTH (type));
+ read_memory (addr, value_contents_all_raw (val), TYPE_LENGTH (type));

VALUE_LVAL (val) = lval_memory;
VALUE_ADDRESS (val) = addr;
@@ -504,7 +505,7 @@ value_fetch_lazy (struct value *val)

struct type *type = value_type (val);
if (length)
- read_memory (addr, VALUE_CONTENTS_ALL_RAW (val), length);
+ read_memory (addr, value_contents_all_raw (val), length);

VALUE_LAZY (val) = 0;
return 0;
@@ -728,7 +729,7 @@ value_assign (struct value *toval, struc
}

val = value_copy (toval);
- memcpy (VALUE_CONTENTS_RAW (val), VALUE_CONTENTS (fromval),
+ memcpy (value_contents_raw (val), VALUE_CONTENTS (fromval),
TYPE_LENGTH (type));
val->type = type;
val = value_change_enclosing_type (val, VALUE_ENCLOSING_TYPE (fromval));
@@ -753,7 +754,7 @@ value_repeat (struct value *arg1, int co
val = allocate_repeat_value (VALUE_ENCLOSING_TYPE (arg1), count);

read_memory (VALUE_ADDRESS (arg1) + value_offset (arg1),
- VALUE_CONTENTS_ALL_RAW (val),
+ value_contents_all_raw (val),
TYPE_LENGTH (VALUE_ENCLOSING_TYPE (val)));
VALUE_LVAL (val) = lval_memory;
VALUE_ADDRESS (val) = VALUE_ADDRESS (arg1) + value_offset (arg1);
@@ -1021,7 +1022,7 @@ value_array (int lowbound, int highbound
val = allocate_value (arraytype);
for (idx = 0; idx < nelem; idx++)
{
- memcpy (VALUE_CONTENTS_ALL_RAW (val) + (idx * typelength),
+ memcpy (value_contents_all_raw (val) + (idx * typelength),
VALUE_CONTENTS_ALL (elemvec[idx]),
typelength);
}
@@ -1069,7 +1070,7 @@ value_string (char *ptr, int len)
if (current_language->c_style_arrays == 0)
{
val = allocate_value (stringtype);
- memcpy (VALUE_CONTENTS_RAW (val), ptr, len);
+ memcpy (value_contents_raw (val), ptr, len);
return val;
}

@@ -1093,7 +1094,7 @@ value_bitstring (char *ptr, int len)
struct type *type = create_set_type ((struct type *) NULL, domain_type);
TYPE_CODE (type) = TYPE_CODE_BITSTRING;
val = allocate_value (type);
- memcpy (VALUE_CONTENTS_RAW (val), ptr, TYPE_LENGTH (type));
+ memcpy (value_contents_raw (val), ptr, TYPE_LENGTH (type));
return val;
}
\f
@@ -1297,7 +1298,7 @@ search_struct_field (char *name, struct
CORE_ADDR base_addr;

base_addr = VALUE_ADDRESS (arg1) + value_offset (arg1) + boffset;
- if (target_read_memory (base_addr, VALUE_CONTENTS_RAW (v2),
+ if (target_read_memory (base_addr, value_contents_raw (v2),
TYPE_LENGTH (basetype)) != 0)
error ("virtual baseclass botch");
VALUE_LVAL (v2) = lval_memory;
@@ -1312,8 +1313,8 @@ search_struct_field (char *name, struct
if (VALUE_LAZY (arg1))
VALUE_LAZY (v2) = 1;
else
- memcpy (VALUE_CONTENTS_RAW (v2),
- VALUE_CONTENTS_RAW (arg1) + boffset,
+ memcpy (value_contents_raw (v2),
+ value_contents_raw (arg1) + boffset,
TYPE_LENGTH (basetype));
}

@@ -2744,7 +2745,7 @@ value_slice (struct value *array, int lo
int j = i % TARGET_CHAR_BIT;
if (BITS_BIG_ENDIAN)
j = TARGET_CHAR_BIT - 1 - j;
- VALUE_CONTENTS_RAW (slice)[i / TARGET_CHAR_BIT] |= (1 << j);
+ value_contents_raw (slice)[i / TARGET_CHAR_BIT] |= (1 << j);
}
}
/* We should set the address, bitssize, and bitspos, so the clice
@@ -2792,9 +2793,9 @@ value_literal_complex (struct value *arg
arg1 = value_cast (real_type, arg1);
arg2 = value_cast (real_type, arg2);

- memcpy (VALUE_CONTENTS_RAW (val),
+ memcpy (value_contents_raw (val),
VALUE_CONTENTS (arg1), TYPE_LENGTH (real_type));
- memcpy (VALUE_CONTENTS_RAW (val) + TYPE_LENGTH (real_type),
+ memcpy (value_contents_raw (val) + TYPE_LENGTH (real_type),
VALUE_CONTENTS (arg2), TYPE_LENGTH (real_type));
return val;
}
@@ -2811,9 +2812,9 @@ cast_into_complex (struct type *type, st
struct value *re_val = allocate_value (val_real_type);
struct value *im_val = allocate_value (val_real_type);

- memcpy (VALUE_CONTENTS_RAW (re_val),
+ memcpy (value_contents_raw (re_val),
VALUE_CONTENTS (val), TYPE_LENGTH (val_real_type));
- memcpy (VALUE_CONTENTS_RAW (im_val),
+ memcpy (value_contents_raw (im_val),
VALUE_CONTENTS (val) + TYPE_LENGTH (val_real_type),
TYPE_LENGTH (val_real_type));

Index: value.c
===================================================================
RCS file: /cvs/src/src/gdb/value.c,v
retrieving revision 1.6
diff -p -u -r1.6 value.c
--- value.c 27 Jan 2005 21:00:59 -0000 1.6
+++ value.c 1 Feb 2005 23:51:33 -0000
@@ -1,8 +1,8 @@
/* Low level packing and unpacking of values for GDB, the GNU Debugger.

Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
- 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003 Free Software
- Foundation, Inc.
+ 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005 Free
+ Software Foundation, Inc.

This file is part of GDB.

@@ -147,6 +147,19 @@ value_bitsize (struct value *value)
return value->bitsize;
}

+bfd_byte *
+value_contents_raw (struct value *value)
+{
+ return value->aligner.contents + value->embedded_offset;
+}
+
+bfd_byte *
+value_contents_all_raw (struct value *value)
+{
+ return value->aligner.contents;
+}
+
+\f
/* Return a mark in the value chain. All values allocated after the
mark is obtained (except for those released) are subject to being freed
if a subsequent value_free_to_mark is passed the mark. */
@@ -256,7 +269,7 @@ value_copy (struct value *arg)
val->modifiable = arg->modifiable;
if (!VALUE_LAZY (val))
{
- memcpy (VALUE_CONTENTS_ALL_RAW (val), VALUE_CONTENTS_ALL_RAW (arg),
+ memcpy (value_contents_all_raw (val), value_contents_all_raw (arg),
TYPE_LENGTH (VALUE_ENCLOSING_TYPE (arg)));

}
@@ -938,7 +951,7 @@ value_primitive_field (struct value *arg
if (VALUE_LAZY (arg1))
VALUE_LAZY (v) = 1;
else
- memcpy (VALUE_CONTENTS_ALL_RAW (v), VALUE_CONTENTS_ALL_RAW (arg1),
+ memcpy (value_contents_all_raw (v), value_contents_all_raw (arg1),
TYPE_LENGTH (VALUE_ENCLOSING_TYPE (arg1)));
v->offset = value_offset (arg1);
VALUE_EMBEDDED_OFFSET (v)
@@ -954,8 +967,8 @@ value_primitive_field (struct value *arg
if (VALUE_LAZY (arg1))
VALUE_LAZY (v) = 1;
else
- memcpy (VALUE_CONTENTS_RAW (v),
- VALUE_CONTENTS_RAW (arg1) + offset,
+ memcpy (value_contents_raw (v),
+ value_contents_raw (arg1) + offset,
TYPE_LENGTH (type));
v->offset = (value_offset (arg1) + offset
+ VALUE_EMBEDDED_OFFSET (arg1));
@@ -1154,12 +1167,12 @@ retry:
case TYPE_CODE_ENUM:
case TYPE_CODE_BOOL:
case TYPE_CODE_RANGE:
- store_signed_integer (VALUE_CONTENTS_RAW (val), len, num);
+ store_signed_integer (value_contents_raw (val), len, num);
break;

case TYPE_CODE_REF:
case TYPE_CODE_PTR:
- store_typed_address (VALUE_CONTENTS_RAW (val), type, (CORE_ADDR) num);
+ store_typed_address (value_contents_raw (val), type, (CORE_ADDR) num);
break;

default:
@@ -1175,7 +1188,7 @@ struct value *
value_from_pointer (struct type *type, CORE_ADDR addr)
{
struct value *val = allocate_value (type);
- store_typed_address (VALUE_CONTENTS_RAW (val), type, addr);
+ store_typed_address (value_contents_raw (val), type, addr);
return val;
}

@@ -1204,7 +1217,7 @@ value_from_string (char *ptr)
string_char_type,
rangetype);
val = allocate_value (stringtype);
- memcpy (VALUE_CONTENTS_RAW (val), ptr, len);
+ memcpy (value_contents_raw (val), ptr, len);
return val;
}

@@ -1218,7 +1231,7 @@ value_from_double (struct type *type, DO

if (code == TYPE_CODE_FLT)
{
- store_typed_floating (VALUE_CONTENTS_RAW (val), base_type, num);
+ store_typed_floating (value_contents_raw (val), base_type, num);
}
else
error ("Unexpected type encountered for floating constant.");
Index: value.h
===================================================================
RCS file: /cvs/src/src/gdb/value.h,v
retrieving revision 1.65
diff -p -u -r1.65 value.h
--- value.h 29 Jan 2005 01:59:31 -0000 1.65
+++ value.h 1 Feb 2005 23:51:33 -0000
@@ -181,12 +181,12 @@ extern int value_offset (struct value *)
#define VALUE_ENCLOSING_TYPE(val) (val)->enclosing_type
#define VALUE_LAZY(val) (val)->lazy

-/* VALUE_CONTENTS and VALUE_CONTENTS_RAW both return the address of
+/* VALUE_CONTENTS and value_contents_raw() both return the address of
the gdb buffer used to hold a copy of the contents of the lval.
VALUE_CONTENTS is used when the contents of the buffer are needed
-- it uses value_fetch_lazy() to load the buffer from the process
being debugged if it hasn't already been loaded.
- VALUE_CONTENTS_RAW is used when data is being stored into the
+ value_contents_raw() is used when data is being stored into the
buffer, or when it is certain that the contents of the buffer are
valid.

@@ -194,18 +194,18 @@ extern int value_offset (struct value *)
get to the real subobject, if the value happens to represent
something embedded in a larger run-time object. */

-#define VALUE_CONTENTS_RAW(val) \
- ((val)->aligner.contents + (val)->embedded_offset)
+extern bfd_byte *value_contents_raw (struct value *);
#define VALUE_CONTENTS(val) \
- ((void)(VALUE_LAZY(val) && value_fetch_lazy(val)), VALUE_CONTENTS_RAW(val))
+ ((void)(VALUE_LAZY(val) && value_fetch_lazy(val)), \
+ (val)->aligner.contents)

/* The ALL variants of the above two macros do not adjust the returned
pointer by the embedded_offset value. */

-#define VALUE_CONTENTS_ALL_RAW(val) ((char *) (val)->aligner.contents)
+extern bfd_byte *value_contents_all_raw (struct value *);
#define VALUE_CONTENTS_ALL(val) \
((void) (VALUE_LAZY(val) && value_fetch_lazy(val)), \
- VALUE_CONTENTS_ALL_RAW(val))
+ (val)->aligner.contents)

extern int value_fetch_lazy (struct value *val);

Index: varobj.c
===================================================================
RCS file: /cvs/src/src/gdb/varobj.c,v
retrieving revision 1.44
diff -p -u -r1.44 varobj.c
--- varobj.c 14 Jan 2005 18:17:18 -0000 1.44
+++ varobj.c 1 Feb 2005 23:51:35 -0000
@@ -2095,7 +2095,7 @@ c_value_of_variable (struct varobj *var)
if (VALUE_LAZY (var->value))
gdb_value_fetch_lazy (var->value);
val_print (value_type (var->value),
- VALUE_CONTENTS_RAW (var->value), 0,
+ value_contents_raw (var->value), 0,
VALUE_ADDRESS (var->value), stb,
format_code[(int) var->format], 1, 0, 0);
thevalue = ui_file_xstrdup (stb, &dummy);