X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fjv-valprint.c;h=29887376eb1f028e4543f211ca70825f7b08ba6a;hb=f231881ea65232b3f67379326a5b605c465dffc4;hp=7f6e93113def06b10d01a122e58d252e88c07cc0;hpb=6b446fdfb358bc4b7dc8ecd0fe7d9ac8bcbe3599;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c index 7f6e93113d..29887376eb 100644 --- a/gdb/jv-valprint.c +++ b/gdb/jv-valprint.c @@ -1,6 +1,6 @@ /* Support for printing Java values for GDB, the GNU debugger. - Copyright (C) 1997-2005, 2007-2012 Free Software Foundation, Inc. + Copyright (C) 1997-2016 Free Software Foundation, Inc. This file is part of GDB. @@ -29,11 +29,9 @@ #include "jv-lang.h" #include "c-lang.h" #include "annotate.h" -#include "gdb_string.h" - /* Local functions */ -int +void java_value_print (struct value *val, struct ui_file *stream, const struct value_print_options *options) { @@ -51,10 +49,13 @@ java_value_print (struct value *val, struct ui_file *stream, if (is_object_type (type)) { CORE_ADDR obj_addr; + struct value *tem = val; /* Get the run-time type, and cast the object into that. */ + while (TYPE_CODE (value_type (tem)) == TYPE_CODE_PTR) + tem = value_ind (tem); - obj_addr = unpack_pointer (type, value_contents (val)); + obj_addr = value_address (tem); if (obj_addr != 0) { @@ -62,6 +63,7 @@ java_value_print (struct value *val, struct ui_file *stream, type = lookup_pointer_type (type); val = value_at (type, address); + type = value_type (val); } } @@ -97,7 +99,8 @@ java_value_print (struct value *val, struct ui_file *stream, { gdb_byte *buf; - buf = alloca (gdbarch_ptr_bit (gdbarch) / HOST_CHAR_BIT); + buf = ((gdb_byte *) + alloca (gdbarch_ptr_bit (gdbarch) / HOST_CHAR_BIT)); fputs_filtered (", ", stream); wrap_here (n_spaces (2)); @@ -179,10 +182,10 @@ java_value_print (struct value *val, struct ui_file *stream, set_value_offset (next_v, value_offset (next_v) + TYPE_LENGTH (el_type)); value_fetch_lazy (next_v); - if (!(value_available_contents_eq - (v, value_embedded_offset (v), - next_v, value_embedded_offset (next_v), - TYPE_LENGTH (el_type)))) + if (!value_contents_eq (v, value_embedded_offset (v), + next_v, + value_embedded_offset (next_v), + TYPE_LENGTH (el_type))) break; } @@ -205,7 +208,7 @@ java_value_print (struct value *val, struct ui_file *stream, fprintf_filtered (stream, "}"); - return 0; + return; } /* If it's type String, print it. */ @@ -228,6 +231,8 @@ java_value_print (struct value *val, struct ui_file *stream, unsigned long count; struct value *mark; + fputs_filtered (" ", stream); + mark = value_mark (); /* Remember start of new values. */ data_val = value_struct_elt (&val, NULL, "data", NULL, NULL); @@ -245,12 +250,12 @@ java_value_print (struct value *val, struct ui_file *stream, val_print_string (char_type, NULL, data + boffset, count, stream, options); - return 0; + return; } opts = *options; opts.deref_ref = 1; - return common_val_print (val, stream, 0, &opts, current_language); + common_val_print (val, stream, 0, &opts, current_language); } /* TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the @@ -261,7 +266,7 @@ java_value_print (struct value *val, struct ui_file *stream, static void java_print_value_fields (struct type *type, const gdb_byte *valaddr, - int offset, + LONGEST offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, @@ -269,7 +274,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr, { int i, len, n_baseclasses; - CHECK_TYPEDEF (type); + type = check_typedef (type); fprintf_filtered (stream, "{"); len = TYPE_NFIELDS (type); @@ -294,7 +299,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr, boffset = 0; - if (options->pretty) + if (options->prettyformat) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 * (recurse + 1), stream); @@ -336,7 +341,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr, fprintf_filtered (stream, ", "); else if (n_baseclasses > 0) { - if (options->pretty) + if (options->prettyformat) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 + 2 * recurse, stream); @@ -347,7 +352,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr, } fields_seen = 1; - if (options->pretty) + if (options->prettyformat) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 + 2 * recurse, stream); @@ -356,36 +361,17 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr, { wrap_here (n_spaces (2 + 2 * recurse)); } - if (options->inspect_it) - { - if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR) - fputs_filtered ("\"( ptr \"", stream); - else - fputs_filtered ("\"( nodef \"", stream); - if (field_is_static (&TYPE_FIELD (type, i))) - fputs_filtered ("static ", stream); - fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i), - language_cplus, - DMGL_PARAMS | DMGL_ANSI); - fputs_filtered ("\" \"", stream); - fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i), - language_cplus, - DMGL_PARAMS | DMGL_ANSI); - fputs_filtered ("\") \"", stream); - } - else - { - 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), - language_cplus, - DMGL_PARAMS | DMGL_ANSI); - annotate_field_name_end (); - fputs_filtered (": ", stream); - annotate_field_value (); - } + + 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), + language_cplus, + DMGL_PARAMS | DMGL_ANSI); + annotate_field_name_end (); + fputs_filtered (": ", stream); + annotate_field_value (); if (!field_is_static (&TYPE_FIELD (type, i)) && TYPE_FIELD_PACKED (type, i)) @@ -406,11 +392,6 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr, { fputs_filtered (_(""), stream); } - else if (!value_bits_valid (val, TYPE_FIELD_BITPOS (type, i), - TYPE_FIELD_BITSIZE (type, i))) - { - val_print_optimized_out (stream); - } else { struct value_print_options opts; @@ -431,22 +412,16 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr, } else if (field_is_static (&TYPE_FIELD (type, i))) { + struct value_print_options opts; struct value *v = value_static_field (type, i); + struct type *t = check_typedef (value_type (v)); - if (v == NULL) - val_print_optimized_out (stream); - else - { - struct value_print_options opts; - struct type *t = check_typedef (value_type (v)); - - if (TYPE_CODE (t) == TYPE_CODE_STRUCT) - v = value_addr (v); - opts = *options; - opts.deref_ref = 0; - common_val_print (v, stream, recurse + 1, - &opts, current_language); - } + if (TYPE_CODE (t) == TYPE_CODE_STRUCT) + v = value_addr (v); + opts = *options; + opts.deref_ref = 0; + common_val_print (v, stream, recurse + 1, + &opts, current_language); } else if (TYPE_FIELD_TYPE (type, i) == NULL) fputs_filtered ("", stream); @@ -465,7 +440,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr, annotate_field_end (); } - if (options->pretty) + if (options->prettyformat) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 * recurse, stream); @@ -475,10 +450,9 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr, } /* See val_print for a description of the various parameters of this - function; they are identical. The semantics of the return value is - also identical to val_print. */ + function; they are identical. */ -int +void java_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, @@ -486,11 +460,10 @@ java_val_print (struct type *type, const gdb_byte *valaddr, const struct value_print_options *options) { struct gdbarch *gdbarch = get_type_arch (type); - unsigned int i = 0; /* Number of characters printed. */ struct type *target_type; CORE_ADDR addr; - CHECK_TYPEDEF (type); + type = check_typedef (type); switch (TYPE_CODE (type)) { case TYPE_CODE_PTR: @@ -504,16 +477,15 @@ java_val_print (struct type *type, const gdb_byte *valaddr, if (addr == 0) { fputs_filtered ("null", stream); - return i; + return; } target_type = check_typedef (TYPE_TARGET_TYPE (type)); if (TYPE_CODE (target_type) == TYPE_CODE_FUNC) { /* Try to print what function it points to. */ - print_address_demangle (gdbarch, addr, stream, demangle); - /* Return value is irrelevant except for string pointers. */ - return (0); + print_address_demangle (options, gdbarch, addr, stream, demangle); + return; } if (options->addressprint && options->format != 's') @@ -522,7 +494,7 @@ java_val_print (struct type *type, const gdb_byte *valaddr, print_longest (stream, 'x', 0, (ULONGEST) addr); } - return i; + return; case TYPE_CODE_CHAR: case TYPE_CODE_INT: @@ -553,9 +525,8 @@ java_val_print (struct type *type, const gdb_byte *valaddr, break; default: - return c_val_print (type, valaddr, embedded_offset, address, stream, - recurse, val, options); + c_val_print (type, valaddr, embedded_offset, address, stream, + recurse, val, options); + break; } - - return 0; }