From: Per Bothner Date: Fri, 6 Oct 1995 00:37:40 +0000 (+0000) Subject: * values.c allocate_repeat_value): Allocate an array type, and X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=398f584f64021b362462a308c37db2e852c5ebd1;p=binutils-gdb.git * values.c allocate_repeat_value): Allocate an array type, and a value of that type; use that instead of setting VALUE_REPEATED. * value.h (struct value): Remove fields repetitions and repeated. (VALUE_REPEATED, VALUE_REPETITIONS): Removed, no longer used. * c-valprint.c, ch-valprint.c, eval.c, printcmd.c, valops.c, value.h, values.c: Simplify, since now VALUE_REPEATED is never used. * valprint.c (value_print_array_elemen): Removed never-used function. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8e203d7a779..ddfa05f6c0a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +Thu Oct 5 17:28:09 1995 Per Bothner + + * values.c allocate_repeat_value): Allocate an array type, and + a value of that type; use that instead of setting VALUE_REPEATED. + * value.h (struct value): Remove fields repetitions and repeated. + (VALUE_REPEATED, VALUE_REPETITIONS): Removed, no longer used. + * c-valprint.c, ch-valprint.c, eval.c, printcmd.c, valops.c, + value.h, values.c: Simplify, since now VALUE_REPEATED is never used. + * valprint.c (value_print_array_elemen): Removed never-used function. + Thu Oct 5 15:14:36 1995 Per Bothner * parse.c (write_dollar_variable): New function. diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index f5866e2bd19..042ac2f7c1a 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -456,56 +456,33 @@ c_value_print (val, stream, format, pretty) int format; enum val_prettyprint pretty; { - /* A "repeated" value really contains several values in a row. - They are made by the @ operator. - Print such values as if they were arrays. */ + struct type *type = VALUE_TYPE (val); - if (VALUE_REPEATED (val)) + /* If it is a pointer, indicate what it points to. + + Print type also if it is a reference. + + C++: if it is a member pointer, we will take care + of that when we print it. */ + if (TYPE_CODE (type) == TYPE_CODE_PTR || + TYPE_CODE (type) == TYPE_CODE_REF) { - register unsigned int n = VALUE_REPETITIONS (val); - register unsigned int typelen = TYPE_LENGTH (VALUE_TYPE (val)); - fprintf_filtered (stream, "{"); - /* Print arrays of characters using string syntax. */ - if (typelen == 1 && TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_INT - && format == 0) - LA_PRINT_STRING (stream, VALUE_CONTENTS (val), n, 0); - else + /* Hack: remove (char *) for char strings. Their + type is indicated by the quoted string anyway. */ + if (TYPE_CODE (type) == TYPE_CODE_PTR && + TYPE_NAME (type) == NULL && + TYPE_NAME (TYPE_TARGET_TYPE (type)) != NULL && + STREQ (TYPE_NAME (TYPE_TARGET_TYPE (type)), "char")) { - value_print_array_elements (val, stream, format, pretty); + /* Print nothing */ } - fprintf_filtered (stream, "}"); - return (n * typelen); - } - else - { - struct type *type = VALUE_TYPE (val); - - /* If it is a pointer, indicate what it points to. - - Print type also if it is a reference. - - C++: if it is a member pointer, we will take care - of that when we print it. */ - if (TYPE_CODE (type) == TYPE_CODE_PTR || - TYPE_CODE (type) == TYPE_CODE_REF) + else { - /* Hack: remove (char *) for char strings. Their - type is indicated by the quoted string anyway. */ - if (TYPE_CODE (type) == TYPE_CODE_PTR && - TYPE_NAME (type) == NULL && - TYPE_NAME (TYPE_TARGET_TYPE (type)) != NULL && - STREQ (TYPE_NAME (TYPE_TARGET_TYPE (type)), "char")) - { - /* Print nothing */ - } - else - { - fprintf_filtered (stream, "("); - type_print (type, "", stream, -1); - fprintf_filtered (stream, ") "); - } + fprintf_filtered (stream, "("); + type_print (type, "", stream, -1); + fprintf_filtered (stream, ") "); } - return (val_print (type, VALUE_CONTENTS (val), - VALUE_ADDRESS (val), stream, format, 1, 0, pretty)); } + return (val_print (type, VALUE_CONTENTS (val), + VALUE_ADDRESS (val), stream, format, 1, 0, pretty)); } diff --git a/gdb/ch-valprint.c b/gdb/ch-valprint.c index 120d8ad8709..695530b74d4 100644 --- a/gdb/ch-valprint.c +++ b/gdb/ch-valprint.c @@ -574,65 +574,42 @@ chill_value_print (val, stream, format, pretty) int format; enum val_prettyprint pretty; { - /* A "repeated" value really contains several values in a row. - They are made by the @ operator. - Print such values as if they were arrays. */ + struct type *type = VALUE_TYPE (val); - if (VALUE_REPEATED (val)) - { - register unsigned int n = VALUE_REPETITIONS (val); - register unsigned int typelen = TYPE_LENGTH (VALUE_TYPE (val)); - fprintf_filtered (stream, "["); - /* Print arrays of characters using string syntax. */ - if (typelen == 1 && TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_INT - && format == 0) - LA_PRINT_STRING (stream, VALUE_CONTENTS (val), n, 0); - else - { - value_print_array_elements (val, stream, format, pretty); - } - fprintf_filtered (stream, "]"); - return (n * typelen); - } - else - { - struct type *type = VALUE_TYPE (val); + /* If it is a pointer, indicate what it points to. - /* If it is a pointer, indicate what it points to. + Print type also if it is a reference. - Print type also if it is a reference. - - C++: if it is a member pointer, we will take care - of that when we print it. */ - if (TYPE_CODE (type) == TYPE_CODE_PTR || - TYPE_CODE (type) == TYPE_CODE_REF) + C++: if it is a member pointer, we will take care + of that when we print it. */ + if (TYPE_CODE (type) == TYPE_CODE_PTR || + TYPE_CODE (type) == TYPE_CODE_REF) + { + char *valaddr = VALUE_CONTENTS (val); + CORE_ADDR addr = unpack_pointer (type, valaddr); + if (TYPE_CODE (type) != TYPE_CODE_PTR || addr != 0) { - char *valaddr = VALUE_CONTENTS (val); - CORE_ADDR addr = unpack_pointer (type, valaddr); - if (TYPE_CODE (type) != TYPE_CODE_PTR || addr != 0) + int i; + char *name = TYPE_NAME (type); + if (name) + fputs_filtered (name, stream); + else if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID) + fputs_filtered ("PTR", stream); + else { - int i; - char *name = TYPE_NAME (type); - if (name) - fputs_filtered (name, stream); - else if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID) - fputs_filtered ("PTR", stream); - else - { - fprintf_filtered (stream, "("); - type_print (type, "", stream, -1); - fprintf_filtered (stream, ")"); - } fprintf_filtered (stream, "("); - i = val_print (type, valaddr, VALUE_ADDRESS (val), - stream, format, 1, 0, pretty); + type_print (type, "", stream, -1); fprintf_filtered (stream, ")"); - return i; } + fprintf_filtered (stream, "("); + i = val_print (type, valaddr, VALUE_ADDRESS (val), + stream, format, 1, 0, pretty); + fprintf_filtered (stream, ")"); + return i; } - return (val_print (type, VALUE_CONTENTS (val), - VALUE_ADDRESS (val), stream, format, 1, 0, pretty)); } + return (val_print (type, VALUE_CONTENTS (val), + VALUE_ADDRESS (val), stream, format, 1, 0, pretty)); } diff --git a/gdb/values.c b/gdb/values.c index f4d01df083b..e076f5b4377 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -86,8 +86,6 @@ allocate_value (type) VALUE_OFFSET (val) = 0; VALUE_BITPOS (val) = 0; VALUE_BITSIZE (val) = 0; - VALUE_REPEATED (val) = 0; - VALUE_REPETITIONS (val) = 0; VALUE_REGNO (val) = -1; VALUE_LAZY (val) = 0; VALUE_OPTIMIZED_OUT (val) = 0; @@ -103,25 +101,17 @@ allocate_repeat_value (type, count) struct type *type; int count; { - register value_ptr val; - - val = - (value_ptr) xmalloc (sizeof (struct value) + TYPE_LENGTH (type) * count); - VALUE_NEXT (val) = all_values; - all_values = val; - VALUE_TYPE (val) = type; - VALUE_LVAL (val) = not_lval; - VALUE_ADDRESS (val) = 0; - VALUE_FRAME (val) = 0; - VALUE_OFFSET (val) = 0; - VALUE_BITPOS (val) = 0; - VALUE_BITSIZE (val) = 0; - VALUE_REPEATED (val) = 1; - VALUE_REPETITIONS (val) = count; - VALUE_REGNO (val) = -1; - VALUE_LAZY (val) = 0; - VALUE_OPTIMIZED_OUT (val) = 0; - return val; + struct type *element_type = type; + int low_bound = current_language->string_lower_bound; /* ??? */ + /* FIXME-type-allocation: need a way to free this type when we are + done with it. */ + struct type *range_type + = create_range_type ((struct type *) NULL, builtin_type_int, + low_bound, count + low_bound - 1); + /* FIXME-type-allocation: need a way to free this type when we are + done with it. */ + return allocate_value (create_array_type ((struct type *) NULL, + type, range_type)); } /* Return a mark in the value chain. All values allocated after the @@ -217,12 +207,8 @@ value_ptr value_copy (arg) value_ptr arg; { - register value_ptr val; register struct type *type = VALUE_TYPE (arg); - if (VALUE_REPEATED (arg)) - val = allocate_repeat_value (type, VALUE_REPETITIONS (arg)); - else - val = allocate_value (type); + register value_ptr val = allocate_value (type); VALUE_LVAL (val) = VALUE_LVAL (arg); VALUE_ADDRESS (val) = VALUE_ADDRESS (arg); VALUE_OFFSET (val) = VALUE_OFFSET (arg); @@ -236,8 +222,7 @@ value_copy (arg) if (!VALUE_LAZY (val)) { memcpy (VALUE_CONTENTS_RAW (val), VALUE_CONTENTS_RAW (arg), - TYPE_LENGTH (VALUE_TYPE (arg)) - * (VALUE_REPEATED (arg) ? VALUE_REPETITIONS (arg) : 1)); + TYPE_LENGTH (VALUE_TYPE (arg))); } return val; } @@ -1025,7 +1010,7 @@ value_from_vtable_info (arg, type) /* Take care of preliminaries. */ if (TYPE_VPTR_FIELDNO (type) < 0) fill_in_vptr_fieldno (type); - if (TYPE_VPTR_FIELDNO (type) < 0 || VALUE_REPEATED (arg)) + if (TYPE_VPTR_FIELDNO (type) < 0) return 0; return value_headof (arg, 0, type);