From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id C37FE394B02F; Sat, 14 Mar 2020 00:09:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C37FE394B02F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1584144547; bh=Ggk2O/BVcn3J6jLfGWQVPemMc9EcEU+B9zMgcK8Zeyc=; h=From:To:Subject:Date:From; b=cz8iFTV/qBHRftzcCVHVSuNbHSQ+sLtdL/wUDJClT3OiEggNUKlx9e5cldZlj87uF Pr2baX8ifaL4sRsxYFX7xvMmrzOM7EACw5Bjf8+v9oaj+P0w69lA47wIcE5TSu/nL2 pdCZZzJXpu7M1AzAvJiafIKFgB2iHYIIGl6oCNv0= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Remove val_print X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 42331a1ea2a13ce15ec202c5f0fbef3e5171253c X-Git-Newrev: 426a9c18dddcdd5f640b702734dd8f9c108b7372 Message-Id: <20200314000907.C37FE394B02F@sourceware.org> Date: Sat, 14 Mar 2020 00:09:05 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Mar 2020 00:09:08 -0000 https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=426a9c18dddcdd5f640b702734dd8f9c108b7372 commit 426a9c18dddcdd5f640b702734dd8f9c108b7372 Author: Tom Tromey Date: Fri Mar 13 17:39:52 2020 -0600 Remove val_print We can finally remove val_print and various helper functions that are no longer needed. gdb/ChangeLog 2020-03-13 Tom Tromey * value.h (val_print): Don't declare. * valprint.h (val_print_array_elements) (val_print_scalar_formatted, generic_val_print): Don't declare. * valprint.c (generic_val_print_array): Take a struct value. (generic_val_print_ptr, generic_val_print_memberptr) (generic_val_print_bool, generic_val_print_int) (generic_val_print_char, generic_val_print_complex) (generic_val_print): Remove. (generic_value_print): Update. (do_val_print): Remove unused parameters. Don't call la_val_print. (val_print): Remove. (common_val_print): Update. Don't call value_check_printable. (val_print_scalar_formatted, val_print_array_elements): Remove. * rust-lang.c (rust_val_print): Remove. (rust_language_defn): Update. * p-valprint.c (pascal_val_print): Remove. (pascal_value_print_inner): Update. (pascal_object_print_val_fields, pascal_object_print_val): Remove. (pascal_object_print_static_field): Update. * p-lang.h (pascal_val_print): Don't declare. * p-lang.c (pascal_language_defn): Update. * opencl-lang.c (opencl_language_defn): Update. * objc-lang.c (objc_language_defn): Update. * m2-valprint.c (m2_print_unbounded_array, m2_val_print): Remove. * m2-lang.h (m2_val_print): Don't declare. * m2-lang.c (m2_language_defn): Update. * language.h (struct language_defn) : Remove. * language.c (unk_lang_value_print_inner): Rename. Change argument types. (unknown_language_defn, auto_language_defn): Update. * go-valprint.c (go_val_print): Remove. * go-lang.h (go_val_print): Don't declare. * go-lang.c (go_language_defn): Update. * f-valprint.c (f_val_print): Remove. * f-lang.h (f_value_print): Don't declare. * f-lang.c (f_language_defn): Update. * d-valprint.c (d_val_print): Remove. * d-lang.h (d_value_print): Don't declare. * d-lang.c (d_language_defn): Update. * cp-valprint.c (cp_print_value_fields) (cp_print_value_fields_rtti, cp_print_value): Remove. (cp_print_static_field): Update. * c-valprint.c (c_val_print_array, c_val_print_ptr) (c_val_print_struct, c_val_print_union, c_val_print_int) (c_val_print_memberptr, c_val_print): Remove. * c-lang.h (c_val_print_array, cp_print_value_fields) (cp_print_value_fields_rtti): Don't declare. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Update. * ada-valprint.c (ada_val_print_ptr, ada_val_print_num): Remove. (ada_val_print_enum): Take a struct value. (ada_val_print_flt, ada_val_print_array, ada_val_print_1) (ada_val_print): Remove. (ada_value_print_1): Update. (printable_val_type): Remove. * ada-lang.h (ada_val_print): Don't declare. * ada-lang.c (ada_language_defn): Update. Diff: --- gdb/ChangeLog | 62 ++++ gdb/ada-lang.c | 1 - gdb/ada-lang.h | 5 - gdb/ada-valprint.c | 309 +------------------ gdb/c-lang.c | 4 - gdb/c-lang.h | 20 -- gdb/c-valprint.c | 330 --------------------- gdb/cp-valprint.c | 514 +------------------------------- gdb/d-lang.c | 1 - gdb/d-lang.h | 8 - gdb/d-valprint.c | 24 -- gdb/f-lang.c | 1 - gdb/f-lang.h | 5 - gdb/f-valprint.c | 186 ------------ gdb/go-lang.c | 1 - gdb/go-lang.h | 8 - gdb/go-valprint.c | 39 --- gdb/language.c | 16 +- gdb/language.h | 24 -- gdb/m2-lang.c | 1 - gdb/m2-lang.h | 5 - gdb/m2-valprint.c | 223 -------------- gdb/objc-lang.c | 1 - gdb/opencl-lang.c | 1 - gdb/p-lang.c | 1 - gdb/p-lang.h | 5 - gdb/p-valprint.c | 855 +++++------------------------------------------------ gdb/rust-lang.c | 13 - gdb/valprint.c | 566 +---------------------------------- gdb/valprint.h | 19 -- gdb/value.h | 7 - 31 files changed, 169 insertions(+), 3086 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ac1a4f867ef..a4ed9944407 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,65 @@ +2020-03-13 Tom Tromey + + * value.h (val_print): Don't declare. + * valprint.h (val_print_array_elements) + (val_print_scalar_formatted, generic_val_print): Don't declare. + * valprint.c (generic_val_print_array): Take a struct value. + (generic_val_print_ptr, generic_val_print_memberptr) + (generic_val_print_bool, generic_val_print_int) + (generic_val_print_char, generic_val_print_complex) + (generic_val_print): Remove. + (generic_value_print): Update. + (do_val_print): Remove unused parameters. Don't call + la_val_print. + (val_print): Remove. + (common_val_print): Update. Don't call value_check_printable. + (val_print_scalar_formatted, val_print_array_elements): Remove. + * rust-lang.c (rust_val_print): Remove. + (rust_language_defn): Update. + * p-valprint.c (pascal_val_print): Remove. + (pascal_value_print_inner): Update. + (pascal_object_print_val_fields, pascal_object_print_val): + Remove. + (pascal_object_print_static_field): Update. + * p-lang.h (pascal_val_print): Don't declare. + * p-lang.c (pascal_language_defn): Update. + * opencl-lang.c (opencl_language_defn): Update. + * objc-lang.c (objc_language_defn): Update. + * m2-valprint.c (m2_print_unbounded_array, m2_val_print): Remove. + * m2-lang.h (m2_val_print): Don't declare. + * m2-lang.c (m2_language_defn): Update. + * language.h (struct language_defn) : Remove. + * language.c (unk_lang_value_print_inner): Rename. Change + argument types. + (unknown_language_defn, auto_language_defn): Update. + * go-valprint.c (go_val_print): Remove. + * go-lang.h (go_val_print): Don't declare. + * go-lang.c (go_language_defn): Update. + * f-valprint.c (f_val_print): Remove. + * f-lang.h (f_value_print): Don't declare. + * f-lang.c (f_language_defn): Update. + * d-valprint.c (d_val_print): Remove. + * d-lang.h (d_value_print): Don't declare. + * d-lang.c (d_language_defn): Update. + * cp-valprint.c (cp_print_value_fields) + (cp_print_value_fields_rtti, cp_print_value): Remove. + (cp_print_static_field): Update. + * c-valprint.c (c_val_print_array, c_val_print_ptr) + (c_val_print_struct, c_val_print_union, c_val_print_int) + (c_val_print_memberptr, c_val_print): Remove. + * c-lang.h (c_val_print_array, cp_print_value_fields) + (cp_print_value_fields_rtti): Don't declare. + * c-lang.c (c_language_defn, cplus_language_defn) + (asm_language_defn, minimal_language_defn): Update. + * ada-valprint.c (ada_val_print_ptr, ada_val_print_num): Remove. + (ada_val_print_enum): Take a struct value. + (ada_val_print_flt, ada_val_print_array, ada_val_print_1) + (ada_val_print): Remove. + (ada_value_print_1): Update. + (printable_val_type): Remove. + * ada-lang.h (ada_val_print): Don't declare. + * ada-lang.c (ada_language_defn): Update. + 2020-03-13 Tom Tromey * valprint.c (do_val_print): Update. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 9fb59e3a628..2822d40c8cd 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -14109,7 +14109,6 @@ extern const struct language_defn ada_language_defn = { emit_char, /* Function to print single char (not used) */ ada_print_type, /* Print a type using appropriate syntax */ ada_print_typedef, /* Print a typedef using appropriate syntax */ - ada_val_print, /* Print a value using appropriate syntax */ ada_value_print_inner, /* la_value_print_inner */ ada_value_print, /* Print a top-level value */ ada_read_var_value, /* la_read_var_value */ diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h index f7c09519be6..1f427b0494d 100644 --- a/gdb/ada-lang.h +++ b/gdb/ada-lang.h @@ -164,11 +164,6 @@ extern void ada_print_type (struct type *, const char *, struct ui_file *, int, extern void ada_print_typedef (struct type *type, struct symbol *new_symbol, struct ui_file *stream); -extern void ada_val_print (struct type *, int, CORE_ADDR, - struct ui_file *, int, - struct value *, - const struct value_print_options *); - /* Implement la_value_print_inner for Ada. */ extern void ada_value_print_inner (struct value *, struct ui_file *, int, diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index 8631f7ab228..abf7ba4b959 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -274,12 +274,6 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr, value_free_to_mark (mark); } -static struct type * -printable_val_type (struct type *type, const gdb_byte *valaddr) -{ - return ada_to_fixed_type (ada_aligned_type (type), valaddr, 0, NULL, 1); -} - /* Print the character C on STREAM as part of the contents of a literal string whose delimiter is QUOTER. TYPE_LEN is the length in bytes of the character. */ @@ -782,32 +776,6 @@ ada_val_print_gnat_array (struct value *val, language_def (language_ada)); } -/* Implement Ada val_print'ing for the case where TYPE is - a TYPE_CODE_PTR. */ - -static void -ada_val_print_ptr (struct type *type, const gdb_byte *valaddr, - int offset, int offset_aligned, CORE_ADDR address, - struct ui_file *stream, int recurse, - struct value *original_value, - const struct value_print_options *options) -{ - val_print (type, offset, address, stream, recurse, - original_value, options, language_def (language_c)); - - if (ada_is_tag_type (type)) - { - struct value *val = - value_from_contents_and_address (type, - valaddr + offset_aligned, - address + offset_aligned); - const char *name = ada_tag_name (val); - - if (name != NULL) - fprintf_filtered (stream, " (%s)", name); - } -} - /* Implement Ada value_print'ing for the case where TYPE is a TYPE_CODE_PTR. */ @@ -828,109 +796,6 @@ ada_value_print_ptr (struct value *val, } } -/* Implement Ada val_print'ing for the case where TYPE is - a TYPE_CODE_INT or TYPE_CODE_RANGE. */ - -static void -ada_val_print_num (struct type *type, const gdb_byte *valaddr, - int offset, int offset_aligned, CORE_ADDR address, - struct ui_file *stream, int recurse, - struct value *original_value, - const struct value_print_options *options) -{ - if (ada_is_fixed_point_type (type)) - { - struct value *scale = ada_scaling_factor (type); - struct value *v = value_from_contents (type, valaddr + offset_aligned); - v = value_cast (value_type (scale), v); - v = value_binop (v, scale, BINOP_MUL); - - const char *fmt = TYPE_LENGTH (type) < 4 ? "%.11g" : "%.17g"; - std::string str - = target_float_to_string (value_contents (v), value_type (v), fmt); - fputs_filtered (str.c_str (), stream); - return; - } - else if (TYPE_CODE (type) == TYPE_CODE_RANGE - && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ENUM - || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_BOOL - || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CHAR)) - { - /* For enum-valued ranges, we want to recurse, because we'll end - up printing the constant's name rather than its numeric - value. Character and fixed-point types are also printed - differently, so recuse for those as well. */ - struct type *target_type = TYPE_TARGET_TYPE (type); - - if (TYPE_LENGTH (type) != TYPE_LENGTH (target_type)) - { - /* Obscure case of range type that has different length from - its base type. Perform a conversion, or we will get a - nonsense value. Actually, we could use the same - code regardless of lengths; I'm just avoiding a cast. */ - struct value *v1 - = value_from_contents_and_address (type, valaddr + offset, 0); - struct value *v = value_cast (target_type, v1); - - val_print (target_type, - value_embedded_offset (v), 0, stream, - recurse + 1, v, options, - language_def (language_ada)); - } - else - val_print (TYPE_TARGET_TYPE (type), offset, - address, stream, recurse, original_value, - options, language_def (language_ada)); - return; - } - else - { - int format = (options->format ? options->format - : options->output_format); - - if (format) - { - struct value_print_options opts = *options; - - opts.format = format; - val_print_scalar_formatted (type, offset_aligned, - original_value, &opts, 0, stream); - } - else if (ada_is_system_address_type (type)) - { - /* FIXME: We want to print System.Address variables using - the same format as for any access type. But for some - reason GNAT encodes the System.Address type as an int, - so we have to work-around this deficiency by handling - System.Address values as a special case. */ - - struct gdbarch *gdbarch = get_type_arch (type); - struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; - CORE_ADDR addr = extract_typed_address (valaddr + offset_aligned, - ptr_type); - - fprintf_filtered (stream, "("); - type_print (type, "", stream, -1); - fprintf_filtered (stream, ") "); - fputs_filtered (paddress (gdbarch, addr), stream); - } - else - { - val_print_scalar_formatted (type, offset_aligned, - original_value, options, 0, stream); - if (ada_is_character_type (type)) - { - LONGEST c; - - fputs_filtered (" ", stream); - c = unpack_long (type, valaddr + offset_aligned); - ada_printchar (c, type, stream); - } - } - return; - } -} - /* Implement Ada val_print'ing for the case where TYPE is a TYPE_CODE_INT or TYPE_CODE_RANGE. */ @@ -1017,10 +882,7 @@ ada_value_print_num (struct value *val, struct ui_file *stream, int recurse, a TYPE_CODE_ENUM. */ static void -ada_val_print_enum (struct type *type, const gdb_byte *valaddr, - int offset, int offset_aligned, CORE_ADDR address, - struct ui_file *stream, int recurse, - struct value *original_value, +ada_val_print_enum (struct value *value, struct ui_file *stream, int recurse, const struct value_print_options *options) { int i; @@ -1029,11 +891,14 @@ ada_val_print_enum (struct type *type, const gdb_byte *valaddr, if (options->format) { - val_print_scalar_formatted (type, offset_aligned, - original_value, options, 0, stream); + value_print_scalar_formatted (value, options, 0, stream); return; } + struct type *type = ada_check_typedef (value_type (value)); + const gdb_byte *valaddr = value_contents_for_printing (value); + int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr; + len = TYPE_NFIELDS (type); val = unpack_long (type, valaddr + offset_aligned); for (i = 0; i < len; i++) @@ -1058,26 +923,6 @@ ada_val_print_enum (struct type *type, const gdb_byte *valaddr, print_longest (stream, 'd', 0, val); } -/* Implement Ada val_print'ing for the case where TYPE is - a TYPE_CODE_FLT. */ - -static void -ada_val_print_flt (struct type *type, const gdb_byte *valaddr, - int offset, int offset_aligned, CORE_ADDR address, - struct ui_file *stream, int recurse, - struct value *original_value, - const struct value_print_options *options) -{ - if (options->format) - { - val_print (type, offset, address, stream, recurse, - original_value, options, language_def (language_c)); - return; - } - - ada_print_floating (valaddr + offset, type, stream); -} - /* Implement Ada val_print'ing for the case where TYPE is a TYPE_CODE_STRUCT or TYPE_CODE_UNION. */ @@ -1109,37 +954,6 @@ ada_val_print_struct_union fprintf_filtered (stream, ")"); } -/* Implement Ada val_print'ing for the case where TYPE is - a TYPE_CODE_ARRAY. */ - -static void -ada_val_print_array (struct type *type, const gdb_byte *valaddr, - int offset, int offset_aligned, CORE_ADDR address, - struct ui_file *stream, int recurse, - struct value *original_value, - const struct value_print_options *options) -{ - /* For an array of characters, print with string syntax. */ - if (ada_is_string_type (type) - && (options->format == 0 || options->format == 's')) - { - ada_val_print_string (type, valaddr, offset_aligned, - stream, recurse, options); - return; - } - - fprintf_filtered (stream, "("); - print_optional_low_bound (stream, type, options); - if (TYPE_FIELD_BITSIZE (type, 0) > 0) - val_print_packed_array_elements (type, valaddr, offset_aligned, - stream, recurse, options); - else - val_print_array_elements (type, offset_aligned, address, - stream, recurse, original_value, - options, 0); - fprintf_filtered (stream, ")"); -} - /* Implement Ada value_print'ing for the case where TYPE is a TYPE_CODE_ARRAY. */ @@ -1238,113 +1052,6 @@ ada_val_print_ref (struct type *type, const gdb_byte *valaddr, options, language_def (language_ada)); } -/* See the comment on ada_val_print. This function differs in that it - does not catch evaluation errors (leaving that to ada_val_print). */ - -static void -ada_val_print_1 (struct type *type, - int offset, CORE_ADDR address, - struct ui_file *stream, int recurse, - struct value *original_value, - const struct value_print_options *options) -{ - int offset_aligned; - const gdb_byte *valaddr = value_contents_for_printing (original_value); - - type = ada_check_typedef (type); - - if (ada_is_array_descriptor_type (type) - || (ada_is_constrained_packed_array_type (type) - && TYPE_CODE (type) != TYPE_CODE_PTR)) - { - struct value *val = value_from_contents_and_address (type, - valaddr + offset, - address); - ada_val_print_gnat_array (val, stream, recurse, options); - return; - } - - offset_aligned = offset + ada_aligned_value_addr (type, valaddr) - valaddr; - type = printable_val_type (type, valaddr + offset_aligned); - type = resolve_dynamic_type (type, valaddr + offset_aligned, - address + offset_aligned); - - switch (TYPE_CODE (type)) - { - default: - val_print (type, offset, address, stream, recurse, - original_value, options, language_def (language_c)); - break; - - case TYPE_CODE_PTR: - ada_val_print_ptr (type, valaddr, offset, offset_aligned, - address, stream, recurse, original_value, - options); - break; - - case TYPE_CODE_INT: - case TYPE_CODE_RANGE: - ada_val_print_num (type, valaddr, offset, offset_aligned, - address, stream, recurse, original_value, - options); - break; - - case TYPE_CODE_ENUM: - ada_val_print_enum (type, valaddr, offset, offset_aligned, - address, stream, recurse, original_value, - options); - break; - - case TYPE_CODE_FLT: - ada_val_print_flt (type, valaddr, offset, offset_aligned, - address, stream, recurse, original_value, - options); - break; - - case TYPE_CODE_UNION: - case TYPE_CODE_STRUCT: - ada_val_print_struct_union (type, valaddr, offset, offset_aligned, - address, stream, recurse, - original_value, options); - break; - - case TYPE_CODE_ARRAY: - ada_val_print_array (type, valaddr, offset, offset_aligned, - address, stream, recurse, original_value, - options); - return; - - case TYPE_CODE_REF: - ada_val_print_ref (type, valaddr, offset, offset_aligned, - address, stream, recurse, original_value, - options); - break; - } -} - -/* See val_print for a description of the various parameters of this - function; they are identical. */ - -void -ada_val_print (struct type *type, - int embedded_offset, CORE_ADDR address, - struct ui_file *stream, int recurse, - struct value *val, - const struct value_print_options *options) -{ - try - { - ada_val_print_1 (type, embedded_offset, address, - stream, recurse, val, options); - } - catch (const gdb_exception_error &except) - { - fprintf_styled (stream, metadata_style.style (), - _(""), - except.what ()); - } -} - /* See the comment on ada_value_print. This function differs in that it does not catch evaluation errors (leaving that to ada_value_print). */ @@ -1393,9 +1100,7 @@ ada_value_print_1 (struct value *val, struct ui_file *stream, int recurse, break; case TYPE_CODE_ENUM: - ada_val_print_enum (type, valaddr, 0, 0, - address, stream, recurse, val, - options); + ada_val_print_enum (val, stream, recurse, options); break; case TYPE_CODE_FLT: diff --git a/gdb/c-lang.c b/gdb/c-lang.c index c919f02fa72..c335044b06b 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -903,7 +903,6 @@ extern const struct language_defn c_language_defn = c_emit_char, /* Print a single char */ c_print_type, /* Print a type using appropriate syntax */ c_print_typedef, /* Print a typedef using appropriate syntax */ - c_val_print, /* Print a value using appropriate syntax */ c_value_print_inner, /* la_value_print_inner */ c_value_print, /* Print a top-level value */ default_read_var_value, /* la_read_var_value */ @@ -1049,7 +1048,6 @@ extern const struct language_defn cplus_language_defn = c_emit_char, /* Print a single char */ c_print_type, /* Print a type using appropriate syntax */ c_print_typedef, /* Print a typedef using appropriate syntax */ - c_val_print, /* Print a value using appropriate syntax */ c_value_print_inner, /* la_value_print_inner */ c_value_print, /* Print a top-level value */ default_read_var_value, /* la_read_var_value */ @@ -1104,7 +1102,6 @@ extern const struct language_defn asm_language_defn = c_emit_char, /* Print a single char */ c_print_type, /* Print a type using appropriate syntax */ c_print_typedef, /* Print a typedef using appropriate syntax */ - c_val_print, /* Print a value using appropriate syntax */ c_value_print_inner, /* la_value_print_inner */ c_value_print, /* Print a top-level value */ default_read_var_value, /* la_read_var_value */ @@ -1159,7 +1156,6 @@ extern const struct language_defn minimal_language_defn = c_emit_char, /* Print a single char */ c_print_type, /* Print a type using appropriate syntax */ c_print_typedef, /* Print a typedef using appropriate syntax */ - c_val_print, /* Print a value using appropriate syntax */ c_value_print_inner, /* la_value_print_inner */ c_value_print, /* Print a top-level value */ default_read_var_value, /* la_read_var_value */ diff --git a/gdb/c-lang.h b/gdb/c-lang.h index e513805c001..642157125a8 100644 --- a/gdb/c-lang.h +++ b/gdb/c-lang.h @@ -81,12 +81,6 @@ extern void c_print_typedef (struct type *, struct symbol *, struct ui_file *); -extern void c_val_print (struct type *, - int, CORE_ADDR, - struct ui_file *, int, - struct value *, - const struct value_print_options *); - /* Implement la_value_print_inner for the C family of languages. */ extern void c_value_print_inner (struct value *, struct ui_file *, int, @@ -140,20 +134,6 @@ extern void cp_print_value_fields (struct value *, const struct value_print_options *, struct type **, int); -extern void cp_print_value_fields (struct type *, struct type *, - LONGEST, CORE_ADDR, - struct ui_file *, int, - struct value *, - const struct value_print_options *, - struct type **, int); - -extern void cp_print_value_fields_rtti (struct type *, - const gdb_byte *, LONGEST, CORE_ADDR, - struct ui_file *, int, - struct value *, - const struct value_print_options *, - struct type **, int); - /* gcc-2.6 or later (when using -fvtable-thunks) emits a unique named type for a vtable entry. Some gdb code depends on that specific name. */ diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 0f40a86872a..76a86faea6a 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -228,113 +228,6 @@ print_unpacked_pointer (struct type *type, struct type *elttype, } } -/* c_val_print helper for TYPE_CODE_ARRAY. */ - -static void -c_val_print_array (struct type *type, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, - struct ui_file *stream, int recurse, - struct value *original_value, - const struct value_print_options *options) -{ - struct type *unresolved_elttype = TYPE_TARGET_TYPE (type); - struct type *elttype = check_typedef (unresolved_elttype); - struct gdbarch *arch = get_type_arch (type); - int unit_size = gdbarch_addressable_memory_unit_size (arch); - - if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (unresolved_elttype) > 0) - { - LONGEST low_bound, high_bound; - int eltlen, len; - enum bfd_endian byte_order = type_byte_order (type); - - if (!get_array_bounds (type, &low_bound, &high_bound)) - error (_("Could not determine the array high bound")); - - eltlen = TYPE_LENGTH (elttype); - len = high_bound - low_bound + 1; - if (options->prettyformat_arrays) - { - print_spaces_filtered (2 + 2 * recurse, stream); - } - - /* Print arrays of textual chars with a string syntax, as - long as the entire array is valid. */ - if (c_textual_element_type (unresolved_elttype, - options->format) - && value_bytes_available (original_value, embedded_offset, - TYPE_LENGTH (type)) - && !value_bits_any_optimized_out (original_value, - TARGET_CHAR_BIT * embedded_offset, - TARGET_CHAR_BIT * TYPE_LENGTH (type))) - { - int force_ellipses = 0; - - /* If requested, look for the first null char and only - print elements up to it. */ - if (options->stop_print_at_null) - { - unsigned int temp_len; - - for (temp_len = 0; - (temp_len < len - && temp_len < options->print_max - && extract_unsigned_integer (valaddr - + embedded_offset * unit_size - + temp_len * eltlen, - eltlen, byte_order) != 0); - ++temp_len) - ; - - /* Force LA_PRINT_STRING to print ellipses if - we've printed the maximum characters and - the next character is not \000. */ - if (temp_len == options->print_max && temp_len < len) - { - ULONGEST val - = extract_unsigned_integer (valaddr - + embedded_offset * unit_size - + temp_len * eltlen, - eltlen, byte_order); - if (val != 0) - force_ellipses = 1; - } - - len = temp_len; - } - - LA_PRINT_STRING (stream, unresolved_elttype, - valaddr + embedded_offset * unit_size, len, - NULL, force_ellipses, options); - } - else - { - unsigned int i = 0; - fprintf_filtered (stream, "{"); - /* If this is a virtual function table, print the 0th - entry specially, and the rest of the members - normally. */ - if (cp_is_vtbl_ptr_type (elttype)) - { - i = 1; - fprintf_filtered (stream, _("%d vtable entries"), - len - 1); - } - val_print_array_elements (type, embedded_offset, - address, stream, - recurse, original_value, options, i); - fprintf_filtered (stream, "}"); - } - } - else - { - /* Array of unspecified length: treat like pointer to first elt. */ - print_unpacked_pointer (type, elttype, unresolved_elttype, valaddr, - embedded_offset, address + embedded_offset, - stream, recurse, options); - } -} - /* c_value_print helper for TYPE_CODE_ARRAY. */ static void @@ -431,46 +324,6 @@ c_value_print_array (struct value *val, } } -/* c_val_print helper for TYPE_CODE_PTR. */ - -static void -c_val_print_ptr (struct type *type, const gdb_byte *valaddr, - int embedded_offset, struct ui_file *stream, int recurse, - struct value *original_value, - const struct value_print_options *options) -{ - struct gdbarch *arch = get_type_arch (type); - int unit_size = gdbarch_addressable_memory_unit_size (arch); - - if (options->format && options->format != 's') - { - val_print_scalar_formatted (type, embedded_offset, - original_value, options, 0, stream); - } - else if (options->vtblprint && cp_is_vtbl_ptr_type (type)) - { - /* 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.) */ - CORE_ADDR addr - = extract_typed_address (valaddr + embedded_offset, type); - struct gdbarch *gdbarch = get_type_arch (type); - - print_function_pointer_address (options, gdbarch, addr, stream); - } - else - { - struct type *unresolved_elttype = TYPE_TARGET_TYPE (type); - struct type *elttype = check_typedef (unresolved_elttype); - CORE_ADDR addr = unpack_pointer (type, - valaddr + embedded_offset * unit_size); - - print_unpacked_pointer (type, elttype, unresolved_elttype, valaddr, - embedded_offset, addr, stream, recurse, options); - } -} - /* c_value_print_inner helper for TYPE_CODE_PTR. */ static void @@ -508,38 +361,6 @@ c_value_print_ptr (struct value *val, struct ui_file *stream, int recurse, } } -/* c_val_print helper for TYPE_CODE_STRUCT. */ - -static void -c_val_print_struct (struct type *type, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, - struct ui_file *stream, int recurse, - struct value *original_value, - const struct value_print_options *options) -{ - if (options->vtblprint && cp_is_vtbl_ptr_type (type)) - { - /* Print the unmangled name if desired. */ - /* Print vtable entry - we only get here if NOT using - -fvtable_thunks. (Otherwise, look under - TYPE_CODE_PTR.) */ - struct gdbarch *gdbarch = get_type_arch (type); - 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_function_pointer_address (options, gdbarch, addr, stream); - } - else - cp_print_value_fields_rtti (type, valaddr, - embedded_offset, address, - stream, recurse, - original_value, options, - NULL, 0); -} - /* c_value_print helper for TYPE_CODE_STRUCT and TYPE_CODE_UNION. */ static void @@ -568,64 +389,6 @@ c_value_print_struct (struct value *val, struct ui_file *stream, int recurse, cp_print_value_fields (val, stream, recurse, options, NULL, 0); } -/* c_val_print helper for TYPE_CODE_UNION. */ - -static void -c_val_print_union (struct type *type, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, - struct ui_file *stream, int recurse, - struct value *original_value, - const struct value_print_options *options) -{ - if (recurse && !options->unionprint) - { - fprintf_filtered (stream, "{...}"); - } - else - { - c_val_print_struct (type, valaddr, embedded_offset, address, stream, - recurse, original_value, options); - } -} - -/* c_val_print helper for TYPE_CODE_INT. */ - -static void -c_val_print_int (struct type *type, struct type *unresolved_type, - const gdb_byte *valaddr, int embedded_offset, - struct ui_file *stream, struct value *original_value, - const struct value_print_options *options) -{ - struct gdbarch *arch = get_type_arch (type); - int unit_size = gdbarch_addressable_memory_unit_size (arch); - - if (options->format || options->output_format) - { - struct value_print_options opts = *options; - - opts.format = (options->format ? options->format - : options->output_format); - val_print_scalar_formatted (type, embedded_offset, - original_value, &opts, 0, stream); - } - else - { - val_print_scalar_formatted (type, embedded_offset, - original_value, options, 0, stream); - /* C and C++ has no single byte int type, char is used - instead. Since we don't know whether the value is really - intended to be used as an integer or a character, print - the character equivalent as well. */ - if (c_textual_element_type (unresolved_type, options->format)) - { - fputs_filtered (" ", stream); - LA_PRINT_CHAR (unpack_long (type, - valaddr + embedded_offset * unit_size), - unresolved_type, stream); - } - } -} - /* c_value_print helper for TYPE_CODE_INT. */ static void @@ -657,26 +420,6 @@ c_value_print_int (struct value *val, struct ui_file *stream, } } -/* c_val_print helper for TYPE_CODE_MEMBERPTR. */ - -static void -c_val_print_memberptr (struct type *type, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, - struct ui_file *stream, int recurse, - struct value *original_value, - const struct value_print_options *options) -{ - if (!options->format) - { - cp_print_class_member (valaddr + embedded_offset, type, stream, "&"); - } - else - { - generic_val_print (type, embedded_offset, address, stream, - recurse, original_value, options, &c_decorations); - } -} - /* c_value_print helper for TYPE_CODE_MEMBERPTR. */ static void @@ -694,79 +437,6 @@ c_value_print_memberptr (struct value *val, struct ui_file *stream, generic_value_print (val, stream, recurse, options, &c_decorations); } -/* See val_print for a description of the various parameters of this - function; they are identical. */ - -void -c_val_print (struct type *type, - int embedded_offset, CORE_ADDR address, - struct ui_file *stream, int recurse, - struct value *original_value, - const struct value_print_options *options) -{ - struct type *unresolved_type = type; - const gdb_byte *valaddr = value_contents_for_printing (original_value); - - type = check_typedef (type); - switch (TYPE_CODE (type)) - { - case TYPE_CODE_ARRAY: - c_val_print_array (type, valaddr, embedded_offset, address, stream, - recurse, original_value, options); - break; - - case TYPE_CODE_METHODPTR: - cplus_print_method_ptr (valaddr + embedded_offset, type, stream); - break; - - case TYPE_CODE_PTR: - c_val_print_ptr (type, valaddr, embedded_offset, stream, recurse, - original_value, options); - break; - - case TYPE_CODE_UNION: - c_val_print_union (type, valaddr, embedded_offset, address, stream, - recurse, original_value, options); - break; - - case TYPE_CODE_STRUCT: - c_val_print_struct (type, valaddr, embedded_offset, address, stream, - recurse, original_value, options); - break; - - case TYPE_CODE_INT: - c_val_print_int (type, unresolved_type, valaddr, embedded_offset, stream, - original_value, options); - break; - - case TYPE_CODE_MEMBERPTR: - c_val_print_memberptr (type, valaddr, embedded_offset, address, stream, - recurse, original_value, options); - break; - - case TYPE_CODE_REF: - case TYPE_CODE_RVALUE_REF: - case TYPE_CODE_ENUM: - case TYPE_CODE_FLAGS: - case TYPE_CODE_FUNC: - case TYPE_CODE_METHOD: - case TYPE_CODE_BOOL: - case TYPE_CODE_RANGE: - case TYPE_CODE_FLT: - case TYPE_CODE_DECFLOAT: - case TYPE_CODE_VOID: - case TYPE_CODE_ERROR: - case TYPE_CODE_UNDEF: - case TYPE_CODE_COMPLEX: - case TYPE_CODE_CHAR: - default: - generic_val_print (type, embedded_offset, address, - stream, recurse, original_value, options, - &c_decorations); - break; - } -} - /* See c-lang.h. */ void diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 5e4cb3cad64..5625a58ee75 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -47,13 +47,6 @@ static void cp_print_static_field (struct type *, struct value *, struct ui_file *, int, const struct value_print_options *); -static void cp_print_value (struct type *, struct type *, - LONGEST, - CORE_ADDR, struct ui_file *, - int, struct value *, - const struct value_print_options *, - struct type **); - static void cp_print_value (struct value *, struct ui_file *, int, const struct value_print_options *, struct type **); @@ -124,287 +117,6 @@ cp_is_vtbl_member (struct type *type) DONT_PRINT is an array of baseclass types that we should not print, or zero if called from top level. */ -void -cp_print_value_fields (struct type *type, struct type *real_type, - LONGEST offset, - CORE_ADDR address, struct ui_file *stream, - int recurse, struct value *val, - const struct value_print_options *options, - struct type **dont_print_vb, - int dont_print_statmem) -{ - int i, len, n_baseclasses; - int fields_seen = 0; - static int last_set_recurse = -1; - - type = check_typedef (type); - - if (recurse == 0) - { - /* Any object can be left on obstacks only during an unexpected - error. */ - - if (obstack_object_size (&dont_print_statmem_obstack) > 0) - { - obstack_free (&dont_print_statmem_obstack, NULL); - obstack_begin (&dont_print_statmem_obstack, - 32 * sizeof (CORE_ADDR)); - } - if (obstack_object_size (&dont_print_stat_array_obstack) > 0) - { - obstack_free (&dont_print_stat_array_obstack, NULL); - obstack_begin (&dont_print_stat_array_obstack, - 32 * sizeof (struct type *)); - } - } - - fprintf_filtered (stream, "{"); - len = TYPE_NFIELDS (type); - n_baseclasses = TYPE_N_BASECLASSES (type); - - /* First, print out baseclasses such that we don't print - duplicates of virtual baseclasses. */ - - if (n_baseclasses > 0) - cp_print_value (type, real_type, - offset, address, stream, - recurse + 1, val, options, - dont_print_vb); - - /* Second, print out data fields */ - - /* If there are no data fields, skip this part */ - if (len == n_baseclasses || !len) - fprintf_styled (stream, metadata_style.style (), ""); - else - { - size_t statmem_obstack_initial_size = 0; - size_t stat_array_obstack_initial_size = 0; - struct type *vptr_basetype = NULL; - int vptr_fieldno; - - if (dont_print_statmem == 0) - { - statmem_obstack_initial_size = - obstack_object_size (&dont_print_statmem_obstack); - - if (last_set_recurse != recurse) - { - stat_array_obstack_initial_size = - obstack_object_size (&dont_print_stat_array_obstack); - - last_set_recurse = recurse; - } - } - - vptr_fieldno = get_vptr_fieldno (type, &vptr_basetype); - for (i = n_baseclasses; i < len; i++) - { - const gdb_byte *valaddr = value_contents_for_printing (val); - - /* If requested, skip printing of static fields. */ - if (!options->static_field_print - && field_is_static (&TYPE_FIELD (type, i))) - continue; - - if (fields_seen) - { - fputs_filtered (",", stream); - if (!options->prettyformat) - fputs_filtered (" ", stream); - } - else if (n_baseclasses > 0) - { - if (options->prettyformat) - { - fprintf_filtered (stream, "\n"); - print_spaces_filtered (2 + 2 * recurse, stream); - fputs_filtered ("members of ", stream); - fputs_filtered (TYPE_NAME (type), stream); - fputs_filtered (":", stream); - } - } - fields_seen = 1; - - if (options->prettyformat) - { - fprintf_filtered (stream, "\n"); - print_spaces_filtered (2 + 2 * recurse, stream); - } - else - { - wrap_here (n_spaces (2 + 2 * recurse)); - } - - annotate_field_begin (TYPE_FIELD_TYPE (type, i)); - - if (field_is_static (&TYPE_FIELD (type, i))) - { - fputs_filtered ("static ", stream); - fprintf_symbol_filtered (stream, - TYPE_FIELD_NAME (type, i), - current_language->la_language, - DMGL_PARAMS | DMGL_ANSI); - } - else - fputs_styled (TYPE_FIELD_NAME (type, i), - variable_name_style.style (), stream); - annotate_field_name_end (); - - /* We tweak various options in a few cases below. */ - value_print_options options_copy = *options; - value_print_options *opts = &options_copy; - - /* Do not print leading '=' in case of anonymous - unions. */ - if (strcmp (TYPE_FIELD_NAME (type, i), "")) - fputs_filtered (" = ", stream); - else - { - /* If this is an anonymous field then we want to consider it - as though it is at its parent's depth when it comes to the - max print depth. */ - if (opts->max_depth != -1 && opts->max_depth < INT_MAX) - ++opts->max_depth; - } - annotate_field_value (); - - if (!field_is_static (&TYPE_FIELD (type, i)) - && TYPE_FIELD_PACKED (type, i)) - { - struct value *v; - - /* Bitfields require special handling, especially due to - byte order problems. */ - if (TYPE_FIELD_IGNORE (type, i)) - { - fputs_styled ("", - metadata_style.style (), stream); - } - else if (value_bits_synthetic_pointer (val, - TYPE_FIELD_BITPOS (type, - i), - TYPE_FIELD_BITSIZE (type, - i))) - { - fputs_styled (_(""), - metadata_style.style (), stream); - } - else - { - opts->deref_ref = 0; - - v = value_field_bitfield (type, i, valaddr, offset, val); - - common_val_print (v, stream, recurse + 1, - opts, current_language); - } - } - else - { - if (TYPE_FIELD_IGNORE (type, i)) - { - fputs_styled ("", - metadata_style.style (), stream); - } - else if (field_is_static (&TYPE_FIELD (type, i))) - { - try - { - struct value *v = value_static_field (type, i); - - cp_print_static_field (TYPE_FIELD_TYPE (type, i), - v, stream, recurse + 1, - opts); - } - catch (const gdb_exception_error &ex) - { - fprintf_styled (stream, metadata_style.style (), - _(""), - ex.what ()); - } - } - else if (i == vptr_fieldno && type == vptr_basetype) - { - int i_offset = offset + TYPE_FIELD_BITPOS (type, i) / 8; - struct type *i_type = TYPE_FIELD_TYPE (type, i); - - if (valprint_check_validity (stream, i_type, i_offset, val)) - { - CORE_ADDR addr; - - i_offset += value_embedded_offset (val); - addr = extract_typed_address (valaddr + i_offset, i_type); - print_function_pointer_address (opts, - get_type_arch (type), - addr, stream); - } - } - else - { - opts->deref_ref = 0; - val_print (TYPE_FIELD_TYPE (type, i), - offset + TYPE_FIELD_BITPOS (type, i) / 8, - address, - stream, recurse + 1, val, opts, - current_language); - } - } - annotate_field_end (); - } - - if (dont_print_statmem == 0) - { - size_t obstack_final_size = - obstack_object_size (&dont_print_statmem_obstack); - - if (obstack_final_size > statmem_obstack_initial_size) - { - /* In effect, a pop of the printed-statics stack. */ - size_t shrink_bytes - = statmem_obstack_initial_size - obstack_final_size; - obstack_blank_fast (&dont_print_statmem_obstack, shrink_bytes); - } - - if (last_set_recurse != recurse) - { - obstack_final_size = - obstack_object_size (&dont_print_stat_array_obstack); - - if (obstack_final_size > stat_array_obstack_initial_size) - { - void *free_to_ptr = - (char *) obstack_next_free (&dont_print_stat_array_obstack) - - (obstack_final_size - - stat_array_obstack_initial_size); - - obstack_free (&dont_print_stat_array_obstack, - free_to_ptr); - } - last_set_recurse = -1; - } - } - - if (options->prettyformat) - { - fprintf_filtered (stream, "\n"); - print_spaces_filtered (2 * recurse, stream); - } - } /* if there are data fields */ - - fprintf_filtered (stream, "}"); -} - -/* Mutually recursive subroutines of cp_print_value and c_value_print - to print out a structure's fields: cp_print_value_fields and - cp_print_value. - - VAL, ADDRESS, STREAM, RECURSE, and OPTIONS have the same meanings - as in cp_print_value and c_value_print. - - DONT_PRINT is an array of baseclass types that we should not print, - or zero if called from top level. */ - void cp_print_value_fields (struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options, @@ -669,222 +381,6 @@ cp_print_value_fields (struct value *val, struct ui_file *stream, fprintf_filtered (stream, "}"); } -/* Like cp_print_value_fields, but find the runtime type of the object - and pass it as the `real_type' argument to cp_print_value_fields. - This function is a hack to work around the fact that - common_val_print passes the embedded offset to val_print, but not - the enclosing type. */ - -void -cp_print_value_fields_rtti (struct type *type, - const gdb_byte *valaddr, LONGEST offset, - CORE_ADDR address, - struct ui_file *stream, int recurse, - struct value *val, - const struct value_print_options *options, - struct type **dont_print_vb, - int dont_print_statmem) -{ - struct type *real_type = NULL; - - /* We require all bits to be valid in order to attempt a - conversion. */ - if (!value_bits_any_optimized_out (val, - TARGET_CHAR_BIT * offset, - TARGET_CHAR_BIT * TYPE_LENGTH (type))) - { - struct value *value; - int full, using_enc; - LONGEST top; - - /* Ugh, we have to convert back to a value here. */ - value = value_from_contents_and_address (type, valaddr + offset, - address + offset); - type = value_type (value); - /* We don't actually care about most of the result here -- just - the type. We already have the correct offset, due to how - val_print was initially called. */ - real_type = value_rtti_type (value, &full, &top, &using_enc); - } - - if (!real_type) - real_type = type; - - cp_print_value_fields (type, real_type, offset, - address, stream, recurse, val, options, - dont_print_vb, dont_print_statmem); -} - -/* Special value_print routine to avoid printing multiple copies of - virtual baseclasses. */ - -static void -cp_print_value (struct type *type, struct type *real_type, - LONGEST offset, - CORE_ADDR address, struct ui_file *stream, - int recurse, struct value *val, - const struct value_print_options *options, - struct type **dont_print_vb) -{ - struct type **last_dont_print - = (struct type **) obstack_next_free (&dont_print_vb_obstack); - struct obstack tmp_obstack = dont_print_vb_obstack; - int i, n_baseclasses = TYPE_N_BASECLASSES (type); - LONGEST thisoffset; - struct type *thistype; - const gdb_byte *valaddr = value_contents_for_printing (val); - - if (dont_print_vb == 0) - { - /* If we're at top level, carve out a completely fresh chunk of - the obstack and use that until this particular invocation - returns. */ - /* Bump up the high-water mark. Now alpha is omega. */ - obstack_finish (&dont_print_vb_obstack); - } - - for (i = 0; i < n_baseclasses; i++) - { - LONGEST boffset = 0; - int skip = 0; - struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i)); - const char *basename = TYPE_NAME (baseclass); - struct value *base_val = NULL; - - if (BASETYPE_VIA_VIRTUAL (type, i)) - { - struct type **first_dont_print - = (struct type **) obstack_base (&dont_print_vb_obstack); - - int j = (struct type **) - obstack_next_free (&dont_print_vb_obstack) - first_dont_print; - - while (--j >= 0) - if (baseclass == first_dont_print[j]) - goto flush_it; - - obstack_ptr_grow (&dont_print_vb_obstack, baseclass); - } - - thisoffset = offset; - thistype = real_type; - - try - { - boffset = baseclass_offset (type, i, valaddr, offset, address, val); - } - catch (const gdb_exception_error &ex) - { - if (ex.error == NOT_AVAILABLE_ERROR) - skip = -1; - else - skip = 1; - } - - if (skip == 0) - { - if (BASETYPE_VIA_VIRTUAL (type, i)) - { - /* The virtual base class pointer might have been - clobbered by the user program. Make sure that it - still points to a valid memory location. */ - - if ((boffset + offset) < 0 - || (boffset + offset) >= TYPE_LENGTH (real_type)) - { - gdb::byte_vector buf (TYPE_LENGTH (baseclass)); - - if (target_read_memory (address + boffset, buf.data (), - TYPE_LENGTH (baseclass)) != 0) - skip = 1; - base_val = value_from_contents_and_address (baseclass, - buf.data (), - address + boffset); - baseclass = value_type (base_val); - thisoffset = 0; - boffset = 0; - thistype = baseclass; - } - else - { - base_val = val; - } - } - else - { - base_val = val; - } - } - - /* Now do the printing. */ - if (options->prettyformat) - { - fprintf_filtered (stream, "\n"); - print_spaces_filtered (2 * recurse, stream); - } - fputs_filtered ("<", stream); - /* Not sure what the best notation is in the case where there is - no baseclass name. */ - fputs_filtered (basename ? basename : "", stream); - fputs_filtered ("> = ", stream); - - if (skip < 0) - val_print_unavailable (stream); - else if (skip > 0) - val_print_invalid_address (stream); - else - { - int result = 0; - - if (options->max_depth > -1 - && recurse >= options->max_depth) - { - const struct language_defn *language = current_language; - gdb_assert (language->la_struct_too_deep_ellipsis != NULL); - fputs_filtered (language->la_struct_too_deep_ellipsis, stream); - } - else - { - /* Attempt to run an extension language pretty-printer on the - baseclass if possible. */ - if (!options->raw) - { - struct value *v - = value_from_component (base_val, baseclass, - thisoffset + boffset); - result - = apply_ext_lang_val_pretty_printer (v, stream, recurse, - options, - current_language); - } - - if (!result) - cp_print_value_fields (baseclass, thistype, - thisoffset + boffset, - value_address (base_val), - stream, recurse, base_val, options, - ((struct type **) - obstack_base (&dont_print_vb_obstack)), - 0); - } - } - fputs_filtered (", ", stream); - - flush_it: - ; - } - - if (dont_print_vb == 0) - { - /* Free the space used to deal with the printing - of this type from top level. */ - obstack_free (&dont_print_vb_obstack, last_dont_print); - /* Reset watermark so that we can continue protecting - ourselves from whatever we were protecting ourselves. */ - dont_print_vb_obstack = tmp_obstack; - } -} - /* Special val_print routine to avoid printing multiple copies of virtual baseclasses. */ @@ -1070,7 +566,7 @@ cp_print_static_field (struct type *type, if (TYPE_CODE (real_type) == TYPE_CODE_STRUCT) { CORE_ADDR *first_dont_print; - CORE_ADDR addr; + CORE_ADDR addr = value_address (val); int i; first_dont_print @@ -1080,7 +576,7 @@ cp_print_static_field (struct type *type, while (--i >= 0) { - if (value_address (val) == first_dont_print[i]) + if (addr == first_dont_print[i]) { fputs_styled (_(""), @@ -1089,13 +585,9 @@ cp_print_static_field (struct type *type, } } - addr = value_address (val); obstack_grow (&dont_print_statmem_obstack, (char *) &addr, sizeof (CORE_ADDR)); - cp_print_value_fields (type, value_enclosing_type (val), - value_embedded_offset (val), addr, - stream, recurse, val, - options, NULL, 1); + cp_print_value_fields (val, stream, recurse, options, NULL, 1); return; } diff --git a/gdb/d-lang.c b/gdb/d-lang.c index 4dbcf53bba7..f50c31a018e 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -224,7 +224,6 @@ extern const struct language_defn d_language_defn = c_print_type, /* Print a type using appropriate syntax. */ c_print_typedef, /* Print a typedef using appropriate syntax. */ - d_val_print, /* Print a value using appropriate syntax. */ d_value_print_inner, /* la_value_print_inner */ c_value_print, /* Print a top-level value. */ default_read_var_value, /* la_read_var_value */ diff --git a/gdb/d-lang.h b/gdb/d-lang.h index 9b4e504024f..a0319f1a48f 100644 --- a/gdb/d-lang.h +++ b/gdb/d-lang.h @@ -76,14 +76,6 @@ extern struct block_symbol d_lookup_symbol_nonlocal (const struct language_defn extern struct block_symbol d_lookup_nested_symbol (struct type *, const char *, const struct block *); -/* Defined in d-valprint.c */ - -extern void d_val_print (struct type *type, - int embedded_offset, CORE_ADDR address, - struct ui_file *stream, int recurse, - struct value *val, - const struct value_print_options *options); - /* Implement la_value_print_inner for D. */ extern void d_value_print_inner (struct value *val, diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c index e26c1ea8fa1..109049cd1de 100644 --- a/gdb/d-valprint.c +++ b/gdb/d-valprint.c @@ -69,30 +69,6 @@ dynamic_array_type (struct type *type, return 1; } -/* Implements the la_val_print routine for language D. */ -void -d_val_print (struct type *type, int embedded_offset, - CORE_ADDR address, struct ui_file *stream, int recurse, - struct value *val, - const struct value_print_options *options) -{ - int ret; - - type = check_typedef (type); - switch (TYPE_CODE (type)) - { - case TYPE_CODE_STRUCT: - ret = dynamic_array_type (type, embedded_offset, address, - stream, recurse, val, options); - if (ret == 0) - break; - /* Fall through. */ - default: - c_val_print (type, embedded_offset, address, stream, - recurse, val, options); - } -} - /* See d-lang.h. */ void diff --git a/gdb/f-lang.c b/gdb/f-lang.c index e0a21849e65..75a131d76d8 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -646,7 +646,6 @@ extern const struct language_defn f_language_defn = f_emit_char, /* Function to print a single character */ f_print_type, /* Print a type using appropriate syntax */ f_print_typedef, /* Print a typedef using appropriate syntax */ - f_val_print, /* Print a value using appropriate syntax */ f_value_print_innner, /* la_value_print_inner */ c_value_print, /* FIXME */ default_read_var_value, /* la_read_var_value */ diff --git a/gdb/f-lang.h b/gdb/f-lang.h index 5cc59adde7e..84a63a8a410 100644 --- a/gdb/f-lang.h +++ b/gdb/f-lang.h @@ -36,11 +36,6 @@ extern void f_print_typedef (struct type *type, struct symbol *new_symbol, extern void f_print_type (struct type *, const char *, struct ui_file *, int, int, const struct type_print_options *); -extern void f_val_print (struct type *, int, CORE_ADDR, - struct ui_file *, int, - struct value *, - const struct value_print_options *); - /* Implement la_value_print_inner for Fortran. */ extern void f_value_print_innner (struct value *val, struct ui_file *stream, diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index f927214ae65..36328c796ca 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -208,192 +208,6 @@ static const struct generic_val_print_decorations f_decorations = "}" }; -/* See val_print for a description of the various parameters of this - function; they are identical. */ - -void -f_val_print (struct type *type, int embedded_offset, - CORE_ADDR address, struct ui_file *stream, int recurse, - struct value *original_value, - const struct value_print_options *options) -{ - struct gdbarch *gdbarch = get_type_arch (type); - int printed_field = 0; /* Number of fields printed. */ - struct type *elttype; - CORE_ADDR addr; - int index; - const gdb_byte *valaddr =value_contents_for_printing (original_value); - - type = check_typedef (type); - switch (TYPE_CODE (type)) - { - case TYPE_CODE_STRING: - f77_get_dynamic_length_of_aggregate (type); - LA_PRINT_STRING (stream, builtin_type (gdbarch)->builtin_char, - valaddr + embedded_offset, - TYPE_LENGTH (type), NULL, 0, options); - break; - - case TYPE_CODE_ARRAY: - if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_CHAR) - { - fprintf_filtered (stream, "("); - f77_print_array (type, valaddr, embedded_offset, - address, stream, recurse, original_value, options); - fprintf_filtered (stream, ")"); - } - else - { - struct type *ch_type = TYPE_TARGET_TYPE (type); - - f77_get_dynamic_length_of_aggregate (type); - LA_PRINT_STRING (stream, ch_type, - valaddr + embedded_offset, - TYPE_LENGTH (type) / TYPE_LENGTH (ch_type), - NULL, 0, options); - } - break; - - case TYPE_CODE_PTR: - if (options->format && options->format != 's') - { - val_print_scalar_formatted (type, embedded_offset, - original_value, options, 0, stream); - break; - } - else - { - int want_space = 0; - - addr = unpack_pointer (type, valaddr + embedded_offset); - elttype = check_typedef (TYPE_TARGET_TYPE (type)); - - if (TYPE_CODE (elttype) == TYPE_CODE_FUNC) - { - /* Try to print what function it points to. */ - print_function_pointer_address (options, gdbarch, addr, stream); - return; - } - - if (options->symbol_print) - want_space = print_address_demangle (options, gdbarch, addr, - stream, demangle); - else if (options->addressprint && options->format != 's') - { - fputs_filtered (paddress (gdbarch, addr), stream); - want_space = 1; - } - - /* For a pointer to char or unsigned char, also print the string - pointed to, unless pointer is null. */ - if (TYPE_LENGTH (elttype) == 1 - && TYPE_CODE (elttype) == TYPE_CODE_INT - && (options->format == 0 || options->format == 's') - && addr != 0) - { - if (want_space) - fputs_filtered (" ", stream); - val_print_string (TYPE_TARGET_TYPE (type), NULL, addr, -1, - stream, options); - } - return; - } - break; - - case TYPE_CODE_INT: - if (options->format || options->output_format) - { - struct value_print_options opts = *options; - - opts.format = (options->format ? options->format - : options->output_format); - val_print_scalar_formatted (type, embedded_offset, - original_value, &opts, 0, stream); - } - else - val_print_scalar_formatted (type, embedded_offset, - original_value, options, 0, stream); - break; - - case TYPE_CODE_STRUCT: - case TYPE_CODE_UNION: - /* Starting from the Fortran 90 standard, Fortran supports derived - types. */ - fprintf_filtered (stream, "( "); - for (index = 0; index < TYPE_NFIELDS (type); index++) - { - struct value *field = value_field - ((struct value *)original_value, index); - - struct type *field_type = check_typedef (TYPE_FIELD_TYPE (type, index)); - - - if (TYPE_CODE (field_type) != TYPE_CODE_FUNC) - { - const char *field_name; - - if (printed_field > 0) - fputs_filtered (", ", stream); - - field_name = TYPE_FIELD_NAME (type, index); - if (field_name != NULL) - { - fputs_styled (field_name, variable_name_style.style (), - stream); - fputs_filtered (" = ", stream); - } - - common_val_print (field, stream, recurse + 1, - options, current_language); - - ++printed_field; - } - } - fprintf_filtered (stream, " )"); - break; - - case TYPE_CODE_BOOL: - if (options->format || options->output_format) - { - struct value_print_options opts = *options; - opts.format = (options->format ? options->format - : options->output_format); - val_print_scalar_formatted (type, embedded_offset, - original_value, &opts, 0, stream); - } - else - { - int unit_size = gdbarch_addressable_memory_unit_size (gdbarch); - LONGEST val - = unpack_long (type, valaddr + embedded_offset * unit_size); - /* The Fortran standard doesn't specify how logical types are - represented. Different compilers use different non zero - values to represent logical true. */ - if (val == 0) - fputs_filtered (f_decorations.false_name, stream); - else - fputs_filtered (f_decorations.true_name, stream); - } - break; - - case TYPE_CODE_REF: - case TYPE_CODE_FUNC: - case TYPE_CODE_FLAGS: - case TYPE_CODE_FLT: - case TYPE_CODE_VOID: - case TYPE_CODE_ERROR: - case TYPE_CODE_RANGE: - case TYPE_CODE_UNDEF: - case TYPE_CODE_COMPLEX: - case TYPE_CODE_CHAR: - default: - generic_val_print (type, embedded_offset, address, - stream, recurse, original_value, options, - &f_decorations); - break; - } -} - /* See f-lang.h. */ void diff --git a/gdb/go-lang.c b/gdb/go-lang.c index 667c4aeb1a5..53e342963d9 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -595,7 +595,6 @@ extern const struct language_defn go_language_defn = go_print_type, /* Print a type using appropriate syntax. */ c_print_typedef, /* Print a typedef using appropriate syntax. */ - go_val_print, /* Print a value using appropriate syntax. */ go_value_print_inner, /* la_value_print_inner */ c_value_print, /* Print a top-level value. */ default_read_var_value, /* la_read_var_value */ diff --git a/gdb/go-lang.h b/gdb/go-lang.h index 8647964ab60..1f079071995 100644 --- a/gdb/go-lang.h +++ b/gdb/go-lang.h @@ -80,14 +80,6 @@ extern void go_print_type (struct type *type, const char *varstring, struct ui_file *stream, int show, int level, const struct type_print_options *flags); -/* Defined in go-valprint.c. */ - -extern void go_val_print (struct type *type, - int embedded_offset, CORE_ADDR address, - struct ui_file *stream, int recurse, - struct value *val, - const struct value_print_options *options); - /* Implement la_value_print_inner for Go. */ extern void go_value_print_inner (struct value *value, diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c index 79b3ad58d5a..fe2ee46ef1d 100644 --- a/gdb/go-valprint.c +++ b/gdb/go-valprint.c @@ -84,45 +84,6 @@ print_go_string (struct type *type, val_print_string (elt_type, NULL, addr, length, stream, options); } -/* Implements the la_val_print routine for language Go. */ - -void -go_val_print (struct type *type, int embedded_offset, - CORE_ADDR address, struct ui_file *stream, int recurse, - struct value *val, - const struct value_print_options *options) -{ - type = check_typedef (type); - - switch (TYPE_CODE (type)) - { - case TYPE_CODE_STRUCT: - { - enum go_type go_type = go_classify_struct_type (type); - - switch (go_type) - { - case GO_TYPE_STRING: - if (! options->raw) - { - print_go_string (type, embedded_offset, address, - stream, recurse, val, options); - return; - } - break; - default: - break; - } - } - /* Fall through. */ - - default: - c_val_print (type, embedded_offset, address, stream, - recurse, val, options); - break; - } -} - /* See go-lang.h. */ void diff --git a/gdb/language.c b/gdb/language.c index d1dfd2df92b..454c6dc45a7 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -792,14 +792,12 @@ unk_lang_print_type (struct type *type, const char *varstring, } static void -unk_lang_val_print (struct type *type, - int embedded_offset, CORE_ADDR address, - struct ui_file *stream, int recurse, - struct value *val, - const struct value_print_options *options) +unk_lang_value_print_inner (struct value *val, + struct ui_file *stream, int recurse, + const struct value_print_options *options) { error (_("internal error - unimplemented " - "function unk_lang_val_print called.")); + "function unk_lang_value_print_inner called.")); } static void @@ -859,8 +857,7 @@ const struct language_defn unknown_language_defn = unk_lang_emit_char, unk_lang_print_type, /* Print a type using appropriate syntax */ default_print_typedef, /* Print a typedef using appropriate syntax */ - unk_lang_val_print, /* Print a value using appropriate syntax */ - nullptr, /* la_value_print_inner */ + unk_lang_value_print_inner, /* la_value_print_inner */ unk_lang_value_print, /* Print a top-level value */ default_read_var_value, /* la_read_var_value */ unk_lang_trampoline, /* Language specific skip_trampoline */ @@ -911,8 +908,7 @@ const struct language_defn auto_language_defn = unk_lang_emit_char, unk_lang_print_type, /* Print a type using appropriate syntax */ default_print_typedef, /* Print a typedef using appropriate syntax */ - unk_lang_val_print, /* Print a value using appropriate syntax */ - nullptr, /* la_value_print_inner */ + unk_lang_value_print_inner, /* la_value_print_inner */ unk_lang_value_print, /* Print a top-level value */ default_read_var_value, /* la_read_var_value */ unk_lang_trampoline, /* Language specific skip_trampoline */ diff --git a/gdb/language.h b/gdb/language.h index c6d5496cde3..ea8aae511b0 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -248,30 +248,6 @@ struct language_defn void (*la_print_typedef) (struct type *type, struct symbol *new_symbol, struct ui_file *stream); - /* Print a value using syntax appropriate for this language. - - TYPE is the type of the sub-object to be printed. - - EMBEDDED_OFFSET is the offset into the outermost object of the - sub-object represented by TYPE. This is the object which this - call should print. Note that the enclosing type is not - available. - - ADDRESS is the address in the inferior of the enclosing object. - - STREAM is the stream on which the value is to be printed. - - RECURSE is the recursion depth. It is zero-based. - - OPTIONS are the formatting options to be used when - printing. */ - - void (*la_val_print) (struct type *type, - int embedded_offset, CORE_ADDR address, - struct ui_file *stream, int recurse, - struct value *val, - const struct value_print_options *options); - /* Print a value using syntax appropriate for this language. RECURSE is the recursion depth. It is zero-based. */ diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index c500366d651..af3cf3ad85f 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -393,7 +393,6 @@ extern const struct language_defn m2_language_defn = m2_emit_char, /* Function to print a single character */ m2_print_type, /* Print a type using appropriate syntax */ m2_print_typedef, /* Print a typedef using appropriate syntax */ - m2_val_print, /* Print a value using appropriate syntax */ m2_value_print_inner, /* la_value_print_inner */ c_value_print, /* Print a top-level value */ default_read_var_value, /* la_read_var_value */ diff --git a/gdb/m2-lang.h b/gdb/m2-lang.h index 636ba39841d..de477e58d5a 100644 --- a/gdb/m2-lang.h +++ b/gdb/m2-lang.h @@ -35,11 +35,6 @@ extern void m2_print_typedef (struct type *, struct symbol *, extern int m2_is_long_set (struct type *type); extern int m2_is_unbounded_array (struct type *type); -extern void m2_val_print (struct type *, int, CORE_ADDR, - struct ui_file *, int, - struct value *, - const struct value_print_options *); - /* Implement la_value_print_inner for Modula-2. */ extern void m2_value_print_inner (struct value *, struct ui_file *, int, diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c index facd15e2393..844a63f3bd6 100644 --- a/gdb/m2-valprint.c +++ b/gdb/m2-valprint.c @@ -181,31 +181,6 @@ m2_print_unbounded_array (struct value *value, fprintf_filtered (stream, ", HIGH = %d}", (int) len); } -static void -m2_print_unbounded_array (struct type *type, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, - struct ui_file *stream, int recurse, - const struct value_print_options *options) -{ - CORE_ADDR addr; - LONGEST len; - struct value *val; - - type = check_typedef (type); - - addr = unpack_pointer (TYPE_FIELD_TYPE (type, 0), - (TYPE_FIELD_BITPOS (type, 0) / 8) + - valaddr + embedded_offset); - - val = value_at_lazy (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 0)), - addr); - len = unpack_field_as_long (type, valaddr + embedded_offset, 1); - - fprintf_filtered (stream, "{"); - m2_print_array_contents (val, stream, recurse, options, len); - fprintf_filtered (stream, ", HIGH = %d}", (int) len); -} - static int print_unpacked_pointer (struct type *type, CORE_ADDR address, CORE_ADDR addr, @@ -323,204 +298,6 @@ static const struct generic_val_print_decorations m2_decorations = "}" }; -/* See val_print for a description of the various parameters of this - function; they are identical. */ - -void -m2_val_print (struct type *type, int embedded_offset, - CORE_ADDR address, struct ui_file *stream, int recurse, - struct value *original_value, - const struct value_print_options *options) -{ - unsigned len; - struct type *elttype; - CORE_ADDR addr; - const gdb_byte *valaddr = value_contents_for_printing (original_value); - - type = check_typedef (type); - switch (TYPE_CODE (type)) - { - case TYPE_CODE_ARRAY: - if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0) - { - elttype = check_typedef (TYPE_TARGET_TYPE (type)); - len = TYPE_LENGTH (type) / TYPE_LENGTH (elttype); - if (options->prettyformat_arrays) - print_spaces_filtered (2 + 2 * recurse, stream); - /* For an array of chars, print with string syntax. */ - if (TYPE_LENGTH (elttype) == 1 && - ((TYPE_CODE (elttype) == TYPE_CODE_INT) - || ((current_language->la_language == language_m2) - && (TYPE_CODE (elttype) == TYPE_CODE_CHAR))) - && (options->format == 0 || options->format == 's')) - { - /* If requested, look for the first null char and only print - elements up to it. */ - if (options->stop_print_at_null) - { - unsigned int temp_len; - - /* Look for a NULL char. */ - for (temp_len = 0; - (valaddr + embedded_offset)[temp_len] - && temp_len < len && temp_len < options->print_max; - temp_len++); - len = temp_len; - } - - LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type), - valaddr + embedded_offset, len, NULL, - 0, options); - } - else - { - fprintf_filtered (stream, "{"); - val_print_array_elements (type, embedded_offset, - address, stream, - recurse, original_value, - options, 0); - fprintf_filtered (stream, "}"); - } - break; - } - /* Array of unspecified length: treat like pointer to first elt. */ - print_unpacked_pointer (type, address, address, options, stream); - break; - - case TYPE_CODE_PTR: - if (TYPE_CONST (type)) - print_variable_at_address (type, valaddr + embedded_offset, - stream, recurse, options); - else if (options->format && options->format != 's') - val_print_scalar_formatted (type, embedded_offset, - original_value, options, 0, stream); - else - { - addr = unpack_pointer (type, valaddr + embedded_offset); - print_unpacked_pointer (type, addr, address, options, stream); - } - break; - - case TYPE_CODE_UNION: - if (recurse && !options->unionprint) - { - fprintf_filtered (stream, "{...}"); - break; - } - /* Fall through. */ - case TYPE_CODE_STRUCT: - if (m2_is_long_set (type)) - m2_print_long_set (type, valaddr, embedded_offset, address, - stream); - else if (m2_is_unbounded_array (type)) - m2_print_unbounded_array (type, valaddr, embedded_offset, - address, stream, recurse, options); - else - cp_print_value_fields (type, type, embedded_offset, - address, stream, recurse, original_value, - options, NULL, 0); - break; - - case TYPE_CODE_SET: - elttype = TYPE_INDEX_TYPE (type); - elttype = check_typedef (elttype); - if (TYPE_STUB (elttype)) - { - fprintf_styled (stream, metadata_style.style (), - _("")); - break; - } - else - { - struct type *range = elttype; - LONGEST low_bound, high_bound; - int i; - int need_comma = 0; - - fputs_filtered ("{", stream); - - i = get_discrete_bounds (range, &low_bound, &high_bound); - maybe_bad_bstring: - if (i < 0) - { - fputs_styled (_(""), metadata_style.style (), - stream); - goto done; - } - - for (i = low_bound; i <= high_bound; i++) - { - int element = value_bit_index (type, valaddr + embedded_offset, - i); - - if (element < 0) - { - i = element; - goto maybe_bad_bstring; - } - if (element) - { - if (need_comma) - fputs_filtered (", ", stream); - print_type_scalar (range, i, stream); - need_comma = 1; - - if (i + 1 <= high_bound - && value_bit_index (type, valaddr + embedded_offset, - ++i)) - { - int j = i; - - fputs_filtered ("..", stream); - while (i + 1 <= high_bound - && value_bit_index (type, - valaddr + embedded_offset, - ++i)) - j = i; - print_type_scalar (range, j, stream); - } - } - } - done: - fputs_filtered ("}", stream); - } - break; - - case TYPE_CODE_RANGE: - if (TYPE_LENGTH (type) == TYPE_LENGTH (TYPE_TARGET_TYPE (type))) - { - m2_val_print (TYPE_TARGET_TYPE (type), embedded_offset, - address, stream, recurse, original_value, options); - break; - } - /* FIXME: create_static_range_type does not set the unsigned bit in a - range type (I think it probably should copy it from the target - type), so we won't print values which are too large to - fit in a signed integer correctly. */ - /* FIXME: Doesn't handle ranges of enums correctly. (Can't just - print with the target type, though, because the size of our type - and the target type might differ). */ - /* FALLTHROUGH */ - - case TYPE_CODE_REF: - case TYPE_CODE_ENUM: - case TYPE_CODE_FUNC: - case TYPE_CODE_INT: - case TYPE_CODE_FLT: - case TYPE_CODE_METHOD: - case TYPE_CODE_VOID: - case TYPE_CODE_ERROR: - case TYPE_CODE_UNDEF: - case TYPE_CODE_BOOL: - case TYPE_CODE_CHAR: - default: - generic_val_print (type, embedded_offset, address, - stream, recurse, original_value, options, - &m2_decorations); - break; - } -} - /* See m2-lang.h. */ void diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 5126e9f4ca9..1c7ec560197 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -381,7 +381,6 @@ extern const struct language_defn objc_language_defn = { c_emit_char, c_print_type, /* Print a type using appropriate syntax */ c_print_typedef, /* Print a typedef using appropriate syntax */ - c_val_print, /* Print a value using appropriate syntax */ c_value_print_inner, /* la_value_print_inner */ c_value_print, /* Print a top-level value */ default_read_var_value, /* la_read_var_value */ diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index a48079881b5..a4fdc5a1176 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -1060,7 +1060,6 @@ extern const struct language_defn opencl_language_defn = c_emit_char, /* Print a single char */ opencl_print_type, /* Print a type using appropriate syntax */ c_print_typedef, /* Print a typedef using appropriate syntax */ - c_val_print, /* Print a value using appropriate syntax */ c_value_print_inner, /* la_value_print_inner */ c_value_print, /* Print a top-level value */ default_read_var_value, /* la_read_var_value */ diff --git a/gdb/p-lang.c b/gdb/p-lang.c index 87ddf341802..944a077506c 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -447,7 +447,6 @@ extern const struct language_defn pascal_language_defn = pascal_emit_char, /* Print a single char */ pascal_print_type, /* Print a type using appropriate syntax */ pascal_print_typedef, /* Print a typedef using appropriate syntax */ - pascal_val_print, /* Print a value using appropriate syntax */ pascal_value_print_inner, /* la_value_print_inner */ pascal_value_print, /* Print a top-level value */ default_read_var_value, /* la_read_var_value */ diff --git a/gdb/p-lang.h b/gdb/p-lang.h index ae0b2aaede0..9ce61318761 100644 --- a/gdb/p-lang.h +++ b/gdb/p-lang.h @@ -37,11 +37,6 @@ extern void pascal_print_type (struct type *, const char *, struct ui_file *, extern void pascal_print_typedef (struct type *, struct symbol *, struct ui_file *); -extern void pascal_val_print (struct type *, int, - CORE_ADDR, struct ui_file *, int, - struct value *, - const struct value_print_options *); - /* Implement la_value_print_inner for Pascal. */ extern void pascal_value_print_inner (struct value *, struct ui_file *, int, diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index d53cfd54a63..35a4e59d250 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -42,14 +42,6 @@ #include "cli/cli-style.h" -static void pascal_object_print_value_fields (struct type *, const gdb_byte *, - LONGEST, - CORE_ADDR, struct ui_file *, - int, - struct value *, - const struct value_print_options *, - struct type **, int); - static void pascal_object_print_value_fields (struct value *, struct ui_file *, int, const struct value_print_options *, @@ -69,16 +61,15 @@ static const struct generic_val_print_decorations p_decorations = "}" }; -/* See val_print for a description of the various parameters of this - function; they are identical. */ +/* See p-lang.h. */ void -pascal_val_print (struct type *type, - int embedded_offset, CORE_ADDR address, - struct ui_file *stream, int recurse, - struct value *original_value, - const struct value_print_options *options) +pascal_value_print_inner (struct value *val, struct ui_file *stream, + int recurse, + const struct value_print_options *options) + { + struct type *type = check_typedef (value_type (val)); struct gdbarch *gdbarch = get_type_arch (type); enum bfd_endian byte_order = type_byte_order (type); unsigned int i = 0; /* Number of characters printed */ @@ -89,9 +80,8 @@ pascal_val_print (struct type *type, struct type *char_type; CORE_ADDR addr; int want_space = 0; - const gdb_byte *valaddr = value_contents_for_printing (original_value); + const gdb_byte *valaddr = value_contents_for_printing (val); - type = check_typedef (type); switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: @@ -123,17 +113,15 @@ pascal_val_print (struct type *type, /* Look for a NULL char. */ for (temp_len = 0; - extract_unsigned_integer (valaddr + embedded_offset + - temp_len * eltlen, eltlen, - byte_order) + extract_unsigned_integer (valaddr + temp_len * eltlen, + eltlen, byte_order) && temp_len < len && temp_len < options->print_max; temp_len++); len = temp_len; } LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type), - valaddr + embedded_offset, len, NULL, 0, - options); + valaddr, len, NULL, 0, options); i = len; } else @@ -150,23 +138,20 @@ pascal_val_print (struct type *type, { i = 0; } - val_print_array_elements (type, embedded_offset, - address, stream, recurse, - original_value, options, i); + value_print_array_elements (val, stream, recurse, options, i); fprintf_filtered (stream, "}"); } break; } /* Array of unspecified length: treat like pointer to first elt. */ - addr = address + embedded_offset; + addr = value_address (val); } goto print_unpacked_pointer; case TYPE_CODE_PTR: if (options->format && options->format != 's') { - val_print_scalar_formatted (type, embedded_offset, - original_value, options, 0, stream); + value_print_scalar_formatted (val, options, 0, stream); break; } if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type)) @@ -175,14 +160,14 @@ pascal_val_print (struct type *type, /* Print vtable entry - we only get here if we ARE using -fvtable_thunks. (Otherwise, look under TYPE_CODE_STRUCT.) */ /* Extract the address, assume that it is unsigned. */ - addr = extract_unsigned_integer (valaddr + embedded_offset, + addr = extract_unsigned_integer (valaddr, TYPE_LENGTH (type), byte_order); print_address_demangle (options, gdbarch, addr, stream, demangle); break; } check_typedef (TYPE_TARGET_TYPE (type)); - addr = unpack_pointer (type, valaddr + embedded_offset); + addr = unpack_pointer (type, valaddr); print_unpacked_pointer: elttype = check_typedef (TYPE_TARGET_TYPE (type)); @@ -240,8 +225,7 @@ pascal_val_print (struct type *type, else if (pascal_object_is_vtbl_member (type)) { /* Print vtbl's nicely. */ - CORE_ADDR vt_address = unpack_pointer (type, - valaddr + embedded_offset); + CORE_ADDR vt_address = unpack_pointer (type, valaddr); struct bound_minimal_symbol msymbol = lookup_minimal_symbol_by_pc (vt_address); @@ -306,9 +290,7 @@ pascal_val_print (struct type *type, case TYPE_CODE_UNDEF: case TYPE_CODE_BOOL: case TYPE_CODE_CHAR: - generic_val_print (type, embedded_offset, address, - stream, recurse, original_value, options, - &p_decorations); + generic_value_print (val, stream, recurse, options, &p_decorations); break; case TYPE_CODE_UNION: @@ -327,7 +309,7 @@ pascal_val_print (struct type *type, /* Extract the address, assume that it is unsigned. */ print_address_demangle (options, gdbarch, - extract_unsigned_integer (valaddr + embedded_offset + extract_unsigned_integer (valaddr + TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8, TYPE_LENGTH (TYPE_FIELD_TYPE (type, @@ -340,18 +322,14 @@ pascal_val_print (struct type *type, if (is_pascal_string_type (type, &length_pos, &length_size, &string_pos, &char_type, NULL)) { - len = extract_unsigned_integer (valaddr + embedded_offset - + length_pos, length_size, - byte_order); - LA_PRINT_STRING (stream, char_type, - valaddr + embedded_offset + string_pos, + len = extract_unsigned_integer (valaddr + length_pos, + length_size, byte_order); + LA_PRINT_STRING (stream, char_type, valaddr + string_pos, len, NULL, 0, options); } else - pascal_object_print_value_fields (type, valaddr, embedded_offset, - address, stream, recurse, - original_value, options, - NULL, 0); + pascal_object_print_value_fields (val, stream, recurse, + options, NULL, 0); } break; @@ -389,8 +367,7 @@ pascal_val_print (struct type *type, for (i = low_bound; i <= high_bound; i++) { - int element = value_bit_index (type, - valaddr + embedded_offset, i); + int element = value_bit_index (type, valaddr, i); if (element < 0) { @@ -405,16 +382,13 @@ pascal_val_print (struct type *type, need_comma = 1; if (i + 1 <= high_bound - && value_bit_index (type, - valaddr + embedded_offset, ++i)) + && value_bit_index (type, valaddr, ++i)) { int j = i; fputs_filtered ("..", stream); while (i + 1 <= high_bound - && value_bit_index (type, - valaddr + embedded_offset, - ++i)) + && value_bit_index (type, valaddr, ++i)) j = i; print_type_scalar (range, j, stream); } @@ -431,428 +405,75 @@ pascal_val_print (struct type *type, } } -/* See p-lang.h. */ - + void -pascal_value_print_inner (struct value *val, struct ui_file *stream, - int recurse, - const struct value_print_options *options) - +pascal_value_print (struct value *val, struct ui_file *stream, + const struct value_print_options *options) { - struct type *type = check_typedef (value_type (val)); - struct gdbarch *gdbarch = get_type_arch (type); - enum bfd_endian byte_order = type_byte_order (type); - unsigned int i = 0; /* Number of characters printed */ - unsigned len; - struct type *elttype; - unsigned eltlen; - int length_pos, length_size, string_pos; - struct type *char_type; - CORE_ADDR addr; - int want_space = 0; - const gdb_byte *valaddr = value_contents_for_printing (val); - - switch (TYPE_CODE (type)) - { - case TYPE_CODE_ARRAY: - { - LONGEST low_bound, high_bound; + struct type *type = value_type (val); + struct value_print_options opts = *options; - if (get_array_bounds (type, &low_bound, &high_bound)) - { - len = high_bound - low_bound + 1; - elttype = check_typedef (TYPE_TARGET_TYPE (type)); - eltlen = TYPE_LENGTH (elttype); - if (options->prettyformat_arrays) - { - print_spaces_filtered (2 + 2 * recurse, stream); - } - /* If 's' format is used, try to print out as string. - If no format is given, print as string if element type - is of TYPE_CODE_CHAR and element size is 1,2 or 4. */ - if (options->format == 's' - || ((eltlen == 1 || eltlen == 2 || eltlen == 4) - && TYPE_CODE (elttype) == TYPE_CODE_CHAR - && options->format == 0)) - { - /* If requested, look for the first null char and only print - elements up to it. */ - if (options->stop_print_at_null) - { - unsigned int temp_len; + opts.deref_ref = 1; - /* Look for a NULL char. */ - for (temp_len = 0; - extract_unsigned_integer (valaddr + temp_len * eltlen, - eltlen, byte_order) - && temp_len < len && temp_len < options->print_max; - temp_len++); - len = temp_len; - } + /* If it is a pointer, indicate what it points to. - LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type), - valaddr, len, NULL, 0, options); - i = len; - } - else - { - fprintf_filtered (stream, "{"); - /* If this is a virtual function table, print the 0th - entry specially, and the rest of the members normally. */ - if (pascal_object_is_vtbl_ptr_type (elttype)) - { - i = 1; - fprintf_filtered (stream, "%d vtable entries", len - 1); - } - else - { - i = 0; - } - value_print_array_elements (val, stream, recurse, options, i); - fprintf_filtered (stream, "}"); - } - break; - } - /* Array of unspecified length: treat like pointer to first elt. */ - addr = value_address (val); - } - goto print_unpacked_pointer; + Print type also if it is a reference. - case TYPE_CODE_PTR: - if (options->format && options->format != 's') + Object pascal: 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) + { + /* 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 + && strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)), "char") == 0) { - value_print_scalar_formatted (val, options, 0, stream); - break; + /* Print nothing. */ } - if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type)) + else { - /* 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.) */ - /* Extract the address, assume that it is unsigned. */ - addr = extract_unsigned_integer (valaddr, - TYPE_LENGTH (type), byte_order); - print_address_demangle (options, gdbarch, addr, stream, demangle); - break; + fprintf_filtered (stream, "("); + type_print (type, "", stream, -1); + fprintf_filtered (stream, ") "); } - check_typedef (TYPE_TARGET_TYPE (type)); + } + common_val_print (val, stream, 0, &opts, current_language); +} - addr = unpack_pointer (type, valaddr); - print_unpacked_pointer: - elttype = check_typedef (TYPE_TARGET_TYPE (type)); - if (TYPE_CODE (elttype) == TYPE_CODE_FUNC) - { - /* Try to print what function it points to. */ - print_address_demangle (options, gdbarch, addr, stream, demangle); - return; - } +static void +show_pascal_static_field_print (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + fprintf_filtered (file, _("Printing of pascal static members is %s.\n"), + value); +} - if (options->addressprint && options->format != 's') - { - fputs_filtered (paddress (gdbarch, addr), stream); - want_space = 1; - } +static struct obstack dont_print_vb_obstack; +static struct obstack dont_print_statmem_obstack; - /* For a pointer to char or unsigned char, also print the string - pointed to, unless pointer is null. */ - if (((TYPE_LENGTH (elttype) == 1 - && (TYPE_CODE (elttype) == TYPE_CODE_INT - || TYPE_CODE (elttype) == TYPE_CODE_CHAR)) - || ((TYPE_LENGTH (elttype) == 2 || TYPE_LENGTH (elttype) == 4) - && TYPE_CODE (elttype) == TYPE_CODE_CHAR)) - && (options->format == 0 || options->format == 's') - && addr != 0) - { - if (want_space) - fputs_filtered (" ", stream); - /* No wide string yet. */ - i = val_print_string (elttype, NULL, addr, -1, stream, options); - } - /* Also for pointers to pascal strings. */ - /* Note: this is Free Pascal specific: - as GDB does not recognize stabs pascal strings - Pascal strings are mapped to records - with lowercase names PM. */ - if (is_pascal_string_type (elttype, &length_pos, &length_size, - &string_pos, &char_type, NULL) - && addr != 0) - { - ULONGEST string_length; - gdb_byte *buffer; +static void pascal_object_print_static_field (struct value *, + struct ui_file *, int, + const struct value_print_options *); - if (want_space) - fputs_filtered (" ", stream); - buffer = (gdb_byte *) xmalloc (length_size); - read_memory (addr + length_pos, buffer, length_size); - string_length = extract_unsigned_integer (buffer, length_size, - byte_order); - xfree (buffer); - i = val_print_string (char_type, NULL, - addr + string_pos, string_length, - stream, options); - } - else if (pascal_object_is_vtbl_member (type)) - { - /* Print vtbl's nicely. */ - CORE_ADDR vt_address = unpack_pointer (type, valaddr); - struct bound_minimal_symbol msymbol = - lookup_minimal_symbol_by_pc (vt_address); +static void pascal_object_print_value (struct value *, struct ui_file *, int, + const struct value_print_options *, + struct type **); - /* If 'symbol_print' is set, we did the work above. */ - if (!options->symbol_print - && (msymbol.minsym != NULL) - && (vt_address == BMSYMBOL_VALUE_ADDRESS (msymbol))) - { - if (want_space) - fputs_filtered (" ", stream); - fputs_filtered ("<", stream); - fputs_filtered (msymbol.minsym->print_name (), stream); - fputs_filtered (">", stream); - want_space = 1; - } - if (vt_address && options->vtblprint) - { - struct value *vt_val; - struct symbol *wsym = NULL; - struct type *wtype; +/* It was changed to this after 2.4.5. */ +const char pascal_vtbl_ptr_name[] = +{'_', '_', 'v', 't', 'b', 'l', '_', 'p', 't', 'r', '_', 't', 'y', 'p', 'e', 0}; - if (want_space) - fputs_filtered (" ", stream); +/* Return truth value for assertion that TYPE is of the type + "pointer to virtual function". */ - if (msymbol.minsym != NULL) - { - const char *search_name = msymbol.minsym->search_name (); - wsym = lookup_symbol_search_name (search_name, NULL, - VAR_DOMAIN).symbol; - } - - if (wsym) - { - wtype = SYMBOL_TYPE (wsym); - } - else - { - wtype = TYPE_TARGET_TYPE (type); - } - vt_val = value_at (wtype, vt_address); - common_val_print (vt_val, stream, recurse + 1, options, - current_language); - if (options->prettyformat) - { - fprintf_filtered (stream, "\n"); - print_spaces_filtered (2 + 2 * recurse, stream); - } - } - } - - return; - - case TYPE_CODE_REF: - case TYPE_CODE_ENUM: - case TYPE_CODE_FLAGS: - case TYPE_CODE_FUNC: - case TYPE_CODE_RANGE: - case TYPE_CODE_INT: - case TYPE_CODE_FLT: - case TYPE_CODE_VOID: - case TYPE_CODE_ERROR: - case TYPE_CODE_UNDEF: - case TYPE_CODE_BOOL: - case TYPE_CODE_CHAR: - generic_value_print (val, stream, recurse, options, &p_decorations); - break; - - case TYPE_CODE_UNION: - if (recurse && !options->unionprint) - { - fprintf_filtered (stream, "{...}"); - break; - } - /* Fall through. */ - case TYPE_CODE_STRUCT: - if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type)) - { - /* Print the unmangled name if desired. */ - /* Print vtable entry - we only get here if NOT using - -fvtable_thunks. (Otherwise, look under TYPE_CODE_PTR.) */ - /* Extract the address, assume that it is unsigned. */ - print_address_demangle - (options, gdbarch, - extract_unsigned_integer (valaddr - + TYPE_FIELD_BITPOS (type, - VTBL_FNADDR_OFFSET) / 8, - TYPE_LENGTH (TYPE_FIELD_TYPE (type, - VTBL_FNADDR_OFFSET)), - byte_order), - stream, demangle); - } - else - { - if (is_pascal_string_type (type, &length_pos, &length_size, - &string_pos, &char_type, NULL)) - { - len = extract_unsigned_integer (valaddr + length_pos, - length_size, byte_order); - LA_PRINT_STRING (stream, char_type, valaddr + string_pos, - len, NULL, 0, options); - } - else - pascal_object_print_value_fields (type, valaddr, 0, - value_address (val), stream, - recurse, val, options, - NULL, 0); - } - break; - - case TYPE_CODE_SET: - elttype = TYPE_INDEX_TYPE (type); - elttype = check_typedef (elttype); - if (TYPE_STUB (elttype)) - { - fprintf_styled (stream, metadata_style.style (), ""); - break; - } - else - { - struct type *range = elttype; - LONGEST low_bound, high_bound; - int need_comma = 0; - - fputs_filtered ("[", stream); - - int bound_info = get_discrete_bounds (range, &low_bound, &high_bound); - if (low_bound == 0 && high_bound == -1 && TYPE_LENGTH (type) > 0) - { - /* If we know the size of the set type, we can figure out the - maximum value. */ - bound_info = 0; - high_bound = TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1; - TYPE_HIGH_BOUND (range) = high_bound; - } - maybe_bad_bstring: - if (bound_info < 0) - { - fputs_styled ("", metadata_style.style (), stream); - goto done; - } - - for (i = low_bound; i <= high_bound; i++) - { - int element = value_bit_index (type, valaddr, i); - - if (element < 0) - { - i = element; - goto maybe_bad_bstring; - } - if (element) - { - if (need_comma) - fputs_filtered (", ", stream); - print_type_scalar (range, i, stream); - need_comma = 1; - - if (i + 1 <= high_bound - && value_bit_index (type, valaddr, ++i)) - { - int j = i; - - fputs_filtered ("..", stream); - while (i + 1 <= high_bound - && value_bit_index (type, valaddr, ++i)) - j = i; - print_type_scalar (range, j, stream); - } - } - } - done: - fputs_filtered ("]", stream); - } - break; - - default: - error (_("Invalid pascal type code %d in symbol table."), - TYPE_CODE (type)); - } -} - - -void -pascal_value_print (struct value *val, struct ui_file *stream, - const struct value_print_options *options) -{ - struct type *type = value_type (val); - struct value_print_options opts = *options; - - opts.deref_ref = 1; - - /* If it is a pointer, indicate what it points to. - - Print type also if it is a reference. - - Object pascal: 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) - { - /* 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 - && strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)), "char") == 0) - { - /* Print nothing. */ - } - else - { - fprintf_filtered (stream, "("); - type_print (type, "", stream, -1); - fprintf_filtered (stream, ") "); - } - } - common_val_print (val, stream, 0, &opts, current_language); -} - - -static void -show_pascal_static_field_print (struct ui_file *file, int from_tty, - struct cmd_list_element *c, const char *value) -{ - fprintf_filtered (file, _("Printing of pascal static members is %s.\n"), - value); -} - -static struct obstack dont_print_vb_obstack; -static struct obstack dont_print_statmem_obstack; - -static void pascal_object_print_static_field (struct value *, - struct ui_file *, int, - const struct value_print_options *); - -static void pascal_object_print_value (struct type *, const gdb_byte *, - LONGEST, - CORE_ADDR, struct ui_file *, int, - struct value *, - const struct value_print_options *, - struct type **); - -static void pascal_object_print_value (struct value *, struct ui_file *, int, - const struct value_print_options *, - struct type **); - -/* It was changed to this after 2.4.5. */ -const char pascal_vtbl_ptr_name[] = -{'_', '_', 'v', 't', 'b', 'l', '_', 'p', 't', 'r', '_', 't', 'y', 'p', 'e', 0}; - -/* Return truth value for assertion that TYPE is of the type - "pointer to virtual function". */ - -int -pascal_object_is_vtbl_ptr_type (struct type *type) -{ - const char *type_name = TYPE_NAME (type); +int +pascal_object_is_vtbl_ptr_type (struct type *type) +{ + const char *type_name = TYPE_NAME (type); return (type_name != NULL && strcmp (type_name, pascal_vtbl_ptr_name) == 0); @@ -883,194 +504,6 @@ pascal_object_is_vtbl_member (struct type *type) return 0; } -/* Mutually recursive subroutines of pascal_object_print_value and - c_val_print to print out a structure's fields: - pascal_object_print_value_fields and pascal_object_print_value. - - TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the - same meanings as in pascal_object_print_value and c_val_print. - - DONT_PRINT is an array of baseclass types that we - should not print, or zero if called from top level. */ - -static void -pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr, - LONGEST offset, - CORE_ADDR address, struct ui_file *stream, - int recurse, - struct value *val, - const struct value_print_options *options, - struct type **dont_print_vb, - int dont_print_statmem) -{ - int i, len, n_baseclasses; - char *last_dont_print - = (char *) obstack_next_free (&dont_print_statmem_obstack); - - type = check_typedef (type); - - fprintf_filtered (stream, "{"); - len = TYPE_NFIELDS (type); - n_baseclasses = TYPE_N_BASECLASSES (type); - - /* Print out baseclasses such that we don't print - duplicates of virtual baseclasses. */ - if (n_baseclasses > 0) - pascal_object_print_value (type, valaddr, offset, address, - stream, recurse + 1, val, - options, dont_print_vb); - - if (!len && n_baseclasses == 1) - fprintf_styled (stream, metadata_style.style (), ""); - else - { - struct obstack tmp_obstack = dont_print_statmem_obstack; - int fields_seen = 0; - - if (dont_print_statmem == 0) - { - /* If we're at top level, carve out a completely fresh - chunk of the obstack and use that until this particular - invocation returns. */ - obstack_finish (&dont_print_statmem_obstack); - } - - for (i = n_baseclasses; i < len; i++) - { - /* If requested, skip printing of static fields. */ - if (!options->pascal_static_field_print - && field_is_static (&TYPE_FIELD (type, i))) - continue; - if (fields_seen) - fprintf_filtered (stream, ", "); - else if (n_baseclasses > 0) - { - if (options->prettyformat) - { - fprintf_filtered (stream, "\n"); - print_spaces_filtered (2 + 2 * recurse, stream); - fputs_filtered ("members of ", stream); - fputs_filtered (TYPE_NAME (type), stream); - fputs_filtered (": ", stream); - } - } - fields_seen = 1; - - if (options->prettyformat) - { - fprintf_filtered (stream, "\n"); - print_spaces_filtered (2 + 2 * recurse, stream); - } - else - { - wrap_here (n_spaces (2 + 2 * recurse)); - } - - annotate_field_begin (TYPE_FIELD_TYPE (type, i)); - - if (field_is_static (&TYPE_FIELD (type, i))) - { - fputs_filtered ("static ", stream); - fprintf_symbol_filtered (stream, - TYPE_FIELD_NAME (type, i), - current_language->la_language, - DMGL_PARAMS | DMGL_ANSI); - } - else - fputs_styled (TYPE_FIELD_NAME (type, i), - variable_name_style.style (), stream); - annotate_field_name_end (); - fputs_filtered (" = ", stream); - annotate_field_value (); - - if (!field_is_static (&TYPE_FIELD (type, i)) - && TYPE_FIELD_PACKED (type, i)) - { - struct value *v; - - /* Bitfields require special handling, especially due to byte - order problems. */ - if (TYPE_FIELD_IGNORE (type, i)) - { - fputs_styled ("", - metadata_style.style (), stream); - } - else if (value_bits_synthetic_pointer (val, - TYPE_FIELD_BITPOS (type, - i), - TYPE_FIELD_BITSIZE (type, - i))) - { - fputs_styled (_("