aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Kingdon <jkingdon@engr.sgi.com>1994-03-01 02:20:39 +0000
committerJim Kingdon <jkingdon@engr.sgi.com>1994-03-01 02:20:39 +0000
commit30974778c12e8c276c54d7b84471fa2c3c1cd9e3 (patch)
tree99247aea561fb348c0d1d928495608ddd3cc2b91
parent2fa73738cf209d54339b057f5e0fcdd879ba2ba4 (diff)
downloadgdb-30974778c12e8c276c54d7b84471fa2c3c1cd9e3.zip
gdb-30974778c12e8c276c54d7b84471fa2c3c1cd9e3.tar.gz
gdb-30974778c12e8c276c54d7b84471fa2c3c1cd9e3.tar.bz2
* value.h (struct value): Add modifiable field.
* values.c (allocate_value, record_latest_value, value_copy): Set it. (record_latest_value): Don't mess with VALUE_LVAL of value. * valops.c (value_assign): Check it. Reword existing error message on not_lval.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/valops.c6
-rw-r--r--gdb/value.h36
-rw-r--r--gdb/values.c7
4 files changed, 38 insertions, 17 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c6e5b11..2d2b7bd 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
Mon Feb 28 12:40:46 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
+ * value.h (struct value): Add modifiable field.
+ * values.c (allocate_value, record_latest_value, value_copy): Set it.
+ (record_latest_value): Don't mess with VALUE_LVAL of value.
+ * valops.c (value_assign): Check it. Reword existing error
+ message on not_lval.
+
* mips-tdep.c (mips_step_skips_delay), config/mips/tm-mips.h
(STEP_SKIPS_DELAY): Added.
* infrun.c (proceed) [STEP_SKIPS_DELAY]: Check for a breakpoint in
diff --git a/gdb/valops.c b/gdb/valops.c
index 8a7b8d8..24f2c78 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -289,6 +289,9 @@ value_assign (toval, fromval)
char raw_buffer[MAX_REGISTER_RAW_SIZE];
int use_buffer = 0;
+ if (!toval->modifiable)
+ error ("Left operand of assignment is not a modifiable lvalue.");
+
COERCE_ARRAY (fromval);
COERCE_REF (toval);
@@ -488,7 +491,7 @@ Can't handle bitfield which doesn't fit in a single register.");
default:
- error ("Left side of = operation is not an lvalue.");
+ error ("Left operand of assignment is not an lvalue.");
}
/* Return a value just like TOVAL except with the contents of FROMVAL
@@ -1101,6 +1104,7 @@ call_function_by_hand (function, nargs, args)
char format[80];
sprintf (format, "at %s", local_hex_format ());
name = alloca (80);
+ /* FIXME-32x64: assumes funaddr fits in a long. */
sprintf (name, format, (unsigned long) funaddr);
}
diff --git a/gdb/value.h b/gdb/value.h
index dbc0f86..87ead1b 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -1,5 +1,5 @@
/* Definitions for values of C expressions, for GDB.
- Copyright 1986, 1987, 1989, 1992 Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1989, 1992, 1993, 1994 Free Software Foundation, Inc.
This file is part of GDB.
@@ -47,6 +47,8 @@ struct value
/* Type of value; either not an lval, or one of the various
different possible kinds of lval. */
enum lval_type lval;
+ /* Is it modifiable? Only relevant if lval != not_lval. */
+ int modifiable;
/* Location of value (if lval). */
union
{
@@ -102,9 +104,7 @@ struct value
union {
long contents[1];
double force_double_align;
-#ifdef CC_HAS_LONG_LONG
- long long force_longlong_align;
-#endif
+ LONGEST force_longlong_align;
} aligner;
};
@@ -200,7 +200,7 @@ struct fn_field;
#endif
extern void
-print_address_demangle PARAMS ((CORE_ADDR, FILE *, int));
+print_address_demangle PARAMS ((CORE_ADDR, GDB_FILE *, int));
extern LONGEST
value_as_long PARAMS ((value val));
@@ -238,6 +238,8 @@ extern value value_of_variable PARAMS ((struct symbol *var, struct block *b));
extern value value_of_register PARAMS ((int regnum));
+extern int symbol_read_needs_frame PARAMS ((struct symbol *));
+
/* FIXME: Assumes equivalence of "struct frame_info *" and "FRAME" */
extern value read_var_value PARAMS ((struct symbol *var,
struct frame_info *frame));
@@ -310,6 +312,10 @@ extern value value_being_returned PARAMS ((struct type *valtype,
char retbuf[REGISTER_BYTES],
int struct_return));
+extern value value_in PARAMS ((value element, value set));
+
+extern int value_bit_index PARAMS ((struct type *type, char *addr, int index));
+
extern int
using_struct_return PARAMS ((value function, CORE_ADDR funcaddr,
struct type *value_type, int gcc_p));
@@ -420,7 +426,7 @@ extern CORE_ADDR
read_register PARAMS ((int regno));
extern void
-write_register PARAMS ((int regno, long val));
+write_register PARAMS ((int regno, LONGEST val));
extern void
supply_register PARAMS ((int regno, char *val));
@@ -435,7 +441,7 @@ extern void
modify_field PARAMS ((char *addr, LONGEST fieldval, int bitpos, int bitsize));
extern void
-type_print PARAMS ((struct type *type, char *varstring, FILE *stream,
+type_print PARAMS ((struct type *type, char *varstring, GDB_FILE *stream,
int show));
extern char *
@@ -443,28 +449,28 @@ baseclass_addr PARAMS ((struct type *type, int index, char *valaddr,
value *valuep, int *errp));
extern void
-print_longest PARAMS ((FILE *stream, int format, int use_local,
- LONGEST value));
+print_longest PARAMS ((GDB_FILE *stream, int format, int use_local,
+ LONGEST val));
extern void
-print_floating PARAMS ((char *valaddr, struct type *type, FILE *stream));
+print_floating PARAMS ((char *valaddr, struct type *type, GDB_FILE *stream));
extern int
-value_print PARAMS ((value val, FILE *stream, int format,
+value_print PARAMS ((value val, GDB_FILE *stream, int format,
enum val_prettyprint pretty));
extern int
val_print PARAMS ((struct type *type, char *valaddr, CORE_ADDR address,
- FILE *stream, int format, int deref_ref,
+ GDB_FILE *stream, int format, int deref_ref,
int recurse, enum val_prettyprint pretty));
extern int
-val_print_string PARAMS ((CORE_ADDR addr, unsigned int len, FILE *stream));
+val_print_string PARAMS ((CORE_ADDR addr, unsigned int len, GDB_FILE *stream));
/* FIXME: Assumes equivalence of "struct frame_info *" and "FRAME" */
extern void
print_variable_value PARAMS ((struct symbol *var, struct frame_info *frame,
- FILE *stream));
+ GDB_FILE *stream));
extern value
value_arg_coerce PARAMS ((value));
@@ -473,7 +479,7 @@ extern int
check_field PARAMS ((value, const char *));
extern void
-c_typedef_print PARAMS ((struct type *type, struct symbol *new, FILE *stream));
+c_typedef_print PARAMS ((struct type *type, struct symbol *new, GDB_FILE *stream));
extern char *
internalvar_name PARAMS ((struct internalvar *var));
diff --git a/gdb/values.c b/gdb/values.c
index 451cf51..34ea2d1 100644
--- a/gdb/values.c
+++ b/gdb/values.c
@@ -91,6 +91,7 @@ allocate_value (type)
VALUE_REGNO (val) = -1;
VALUE_LAZY (val) = 0;
VALUE_OPTIMIZED_OUT (val) = 0;
+ val->modifiable = 1;
return val;
}
@@ -210,6 +211,7 @@ value_copy (arg)
VALUE_BITSIZE (val) = VALUE_BITSIZE (arg);
VALUE_REGNO (val) = VALUE_REGNO (arg);
VALUE_LAZY (val) = VALUE_LAZY (arg);
+ val->modifiable = arg->modifiable;
if (!VALUE_LAZY (val))
{
memcpy (VALUE_CONTENTS_RAW (val), VALUE_CONTENTS_RAW (arg),
@@ -262,7 +264,10 @@ record_latest_value (val)
a value on the value history never changes. */
if (VALUE_LAZY (val))
value_fetch_lazy (val);
- VALUE_LVAL (val) = not_lval;
+ /* We preserve VALUE_LVAL so that the user can find out where it was fetched
+ from. This is a bit dubious, because then *&$1 does not just return $1
+ but the current contents of that location. c'est la vie... */
+ val->modifiable = 0;
release_value (val);
/* Now we regard value_history_count as origin-one