diff options
author | Martin Galvan <martin.galvan@tallertechnologies.com> | 2016-04-08 15:05:45 -0300 |
---|---|---|
committer | Martin Galvan <martin.galvan@tallertechnologies.com> | 2016-04-08 15:06:56 -0300 |
commit | 4bf7b526bed1c86b1f20b18e642865f446751e06 (patch) | |
tree | 5a133392fcfe9a0741a1a05a5d9ed06d2d2b8812 | |
parent | 136a43b762ce7bc692645cc0d9d50c934f9aa392 (diff) | |
download | gdb-4bf7b526bed1c86b1f20b18e642865f446751e06.zip gdb-4bf7b526bed1c86b1f20b18e642865f446751e06.tar.gz gdb-4bf7b526bed1c86b1f20b18e642865f446751e06.tar.bz2 |
value: Make accessor methods' parameters const-correct
I did a quick pass over value.c and value.h and made some of the accessor methods'
pass-by-reference parameters const-correct. Besides the obvious benefits, this is
required if we want to use them on values that are already declared as const
(such as the parameters to lval_funcs).
There's probably a lot more stuff that can be made const, here and elsewhere.
gdb/ChangeLog:
2016-04-08 Martin Galvan <martin.galvan@tallertechnologies.com>
* value.c (value_next): Make pass-by-reference parameters const-correct.
(value_parent): Likewise.
(value_enclosing_type): Likewise.
(value_lazy): Likewise.
(value_stack): Likewise.
(value_embedded_offset): Likewise.
(value_pointed_to_offset): Likewise.
(value_raw_address): Likewise.
(deprecated_value_modifiable): Likewise.
(value_free_to_mark): Likewise.
(value_release_to_mark): Likewise.
(internalvar_name): Likewise.
(readjust_indirect_value_type): Likewise.
(value_initialized): Likewise.
* value.h (value_next): Likewise.
(value_parent): Likewise.
(value_enclosing_type): Likewise.
(value_lazy): Likewise.
(value_stack): Likewise.
(value_embedded_offset): Likewise.
(value_pointed_to_offset): Likewise.
(value_raw_address): Likewise.
(deprecated_value_modifiable): Likewise.
(value_free_to_mark): Likewise.
(value_release_to_mark): Likewise.
(internalvar_name): Likewise.
(readjust_indirect_value_type): Likewise.
(value_initialized): Likewise.
-rw-r--r-- | gdb/ChangeLog | 31 | ||||
-rw-r--r-- | gdb/value.c | 30 | ||||
-rw-r--r-- | gdb/value.h | 30 |
3 files changed, 61 insertions, 30 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index dfd49b9..87f7679 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,34 @@ +2016-04-08 Martin Galvan <martin.galvan@tallertechnologies.com> + + * value.c (value_next): Make pass-by-reference parameters const-correct. + (value_parent): Likewise. + (value_enclosing_type): Likewise. + (value_lazy): Likewise. + (value_stack): Likewise. + (value_embedded_offset): Likewise. + (value_pointed_to_offset): Likewise. + (value_raw_address): Likewise. + (deprecated_value_modifiable): Likewise. + (value_free_to_mark): Likewise. + (value_release_to_mark): Likewise. + (internalvar_name): Likewise. + (readjust_indirect_value_type): Likewise. + (value_initialized): Likewise. + * value.h (value_next): Likewise. + (value_parent): Likewise. + (value_enclosing_type): Likewise. + (value_lazy): Likewise. + (value_stack): Likewise. + (value_embedded_offset): Likewise. + (value_pointed_to_offset): Likewise. + (value_raw_address): Likewise. + (deprecated_value_modifiable): Likewise. + (value_free_to_mark): Likewise. + (value_release_to_mark): Likewise. + (internalvar_name): Likewise. + (readjust_indirect_value_type): Likewise. + (value_initialized): Likewise. + 2016-04-07 Yao Qi <yao.qi@linaro.org> * record-full.c (record_full_insert_breakpoint): Return diff --git a/gdb/value.c b/gdb/value.c index 3b66946..5aeed02 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1093,7 +1093,7 @@ allocate_optimized_out_value (struct type *type) /* Accessor methods. */ struct value * -value_next (struct value *value) +value_next (const struct value *value) { return value->next; } @@ -1143,7 +1143,7 @@ set_value_bitsize (struct value *value, int bit) } struct value * -value_parent (struct value *value) +value_parent (const struct value *value) { return value->parent; } @@ -1179,7 +1179,7 @@ value_contents_all_raw (struct value *value) } struct type * -value_enclosing_type (struct value *value) +value_enclosing_type (const struct value *value) { return value->enclosing_type; } @@ -1388,7 +1388,7 @@ value_contents_copy (struct value *dst, int dst_offset, } int -value_lazy (struct value *value) +value_lazy (const struct value *value) { return value->lazy; } @@ -1400,7 +1400,7 @@ set_value_lazy (struct value *value, int val) } int -value_stack (struct value *value) +value_stack (const struct value *value) { return value->stack; } @@ -1481,7 +1481,7 @@ value_bits_synthetic_pointer (const struct value *value, } int -value_embedded_offset (struct value *value) +value_embedded_offset (const struct value *value) { return value->embedded_offset; } @@ -1493,7 +1493,7 @@ set_value_embedded_offset (struct value *value, int val) } int -value_pointed_to_offset (struct value *value) +value_pointed_to_offset (const struct value *value) { return value->pointed_to_offset; } @@ -1546,7 +1546,7 @@ value_address (const struct value *value) } CORE_ADDR -value_raw_address (struct value *value) +value_raw_address (const struct value *value) { if (value->lval == lval_internalvar || value->lval == lval_internalvar_component @@ -1583,7 +1583,7 @@ deprecated_value_regnum_hack (struct value *value) } int -deprecated_value_modifiable (struct value *value) +deprecated_value_modifiable (const struct value *value) { return value->modifiable; } @@ -1644,7 +1644,7 @@ value_free (struct value *val) /* Free all values allocated since MARK was obtained by value_mark (except for those released). */ void -value_free_to_mark (struct value *mark) +value_free_to_mark (const struct value *mark) { struct value *val; struct value *next; @@ -1736,7 +1736,7 @@ release_value_or_incref (struct value *val) /* Release all values up to mark */ struct value * -value_release_to_mark (struct value *mark) +value_release_to_mark (const struct value *mark) { struct value *val; struct value *next; @@ -2500,7 +2500,7 @@ clear_internalvar (struct internalvar *var) } char * -internalvar_name (struct internalvar *var) +internalvar_name (const struct internalvar *var) { return var->name; } @@ -3772,8 +3772,8 @@ coerce_ref_if_computed (const struct value *arg) struct value * readjust_indirect_value_type (struct value *value, struct type *enc_type, - struct type *original_type, - struct value *original_value) + const struct type *original_type, + const struct value *original_value) { /* Re-adjust type. */ deprecated_set_value_type (value, TYPE_TARGET_TYPE (original_type)); @@ -3878,7 +3878,7 @@ set_value_initialized (struct value *val, int status) /* Return the initialized field in a value struct. */ int -value_initialized (struct value *val) +value_initialized (const struct value *val) { return val->initialized; } diff --git a/gdb/value.h b/gdb/value.h index 2eac5ef..f8ec854 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -93,7 +93,7 @@ struct value; put into the value history or exposed to Python are taken off this list. */ -struct value *value_next (struct value *); +struct value *value_next (const struct value *); /* Type of the value. */ @@ -126,7 +126,7 @@ extern void set_value_bitpos (struct value *, int bit); single read from the target when displaying multiple bitfields. */ -struct value *value_parent (struct value *); +struct value *value_parent (const struct value *); extern void set_value_parent (struct value *value, struct value *parent); /* Describes offset of a value within lval of a structure in bytes. @@ -142,7 +142,7 @@ extern void set_value_offset (struct value *, int offset); relevant if lval != not_lval.''. Shouldn't the value instead be not_lval and be done with it? */ -extern int deprecated_value_modifiable (struct value *value); +extern int deprecated_value_modifiable (const struct value *value); /* If a value represents a C++ object, then the `type' field gives the object's compile-time type. If the object actually belongs to some @@ -185,7 +185,7 @@ extern int deprecated_value_modifiable (struct value *value); `type', and `embedded_offset' is zero, so everything works normally. */ -extern struct type *value_enclosing_type (struct value *); +extern struct type *value_enclosing_type (const struct value *); extern void set_value_enclosing_type (struct value *val, struct type *new_type); @@ -205,9 +205,9 @@ extern struct type *value_actual_type (struct value *value, int resolve_simple_types, int *real_type_found); -extern int value_pointed_to_offset (struct value *value); +extern int value_pointed_to_offset (const struct value *value); extern void set_value_pointed_to_offset (struct value *value, int val); -extern int value_embedded_offset (struct value *value); +extern int value_embedded_offset (const struct value *value); extern void set_value_embedded_offset (struct value *value, int val); /* For lval_computed values, this structure holds functions used to @@ -312,10 +312,10 @@ extern void *value_computed_closure (const struct value *value); element. If you ever change the way lazy flag is set and reset, be sure to consider this use as well! */ -extern int value_lazy (struct value *); +extern int value_lazy (const struct value *); extern void set_value_lazy (struct value *value, int val); -extern int value_stack (struct value *); +extern int value_stack (const struct value *); extern void set_value_stack (struct value *value, int val); /* Throw an error complaining that the value has been optimized @@ -398,7 +398,7 @@ extern void mark_value_bits_optimized_out (struct value *value, /* Set or return field indicating whether a variable is initialized or not, based on debugging information supplied by the compiler. 1 = initialized; 0 = uninitialized. */ -extern int value_initialized (struct value *); +extern int value_initialized (const struct value *); extern void set_value_initialized (struct value *, int); /* Set COMPONENT's location as appropriate for a component of WHOLE @@ -425,7 +425,7 @@ extern CORE_ADDR value_address (const struct value *); /* Like value_address, except the result does not include value's offset. */ -extern CORE_ADDR value_raw_address (struct value *); +extern CORE_ADDR value_raw_address (const struct value *); /* Set the address of a value. */ extern void set_value_address (struct value *, CORE_ADDR); @@ -458,8 +458,8 @@ extern struct value *coerce_ref_if_computed (const struct value *arg); extern struct value * readjust_indirect_value_type (struct value *value, struct type *enc_type, - struct type *original_type, - struct value *original_val); + const struct type *original_type, + const struct value *original_val); /* Convert a REF to the object referenced. */ @@ -694,7 +694,7 @@ extern struct value *allocate_repeat_value (struct type *type, int count); extern struct value *value_mark (void); -extern void value_free_to_mark (struct value *mark); +extern void value_free_to_mark (const struct value *mark); extern struct value *value_cstring (const char *ptr, ssize_t len, struct type *char_type); @@ -1006,7 +1006,7 @@ extern void value_print_array_elements (struct value *val, struct ui_file *stream, int format, enum val_prettyformat pretty); -extern struct value *value_release_to_mark (struct value *mark); +extern struct value *value_release_to_mark (const struct value *mark); extern void val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, CORE_ADDR address, @@ -1034,7 +1034,7 @@ extern void print_variable_and_value (const char *name, extern void typedef_print (struct type *type, struct symbol *news, struct ui_file *stream); -extern char *internalvar_name (struct internalvar *var); +extern char *internalvar_name (const struct internalvar *var); extern void preserve_values (struct objfile *); |