diff options
author | Per Bothner <per@bothner.com> | 1997-09-17 03:38:30 +0000 |
---|---|---|
committer | Per Bothner <per@bothner.com> | 1997-09-17 03:38:30 +0000 |
commit | fc655dc202bb59777269eeb2331aac40049140c2 (patch) | |
tree | daa8e68446981dcd6e2dc3662a22a8ca60e123ed /gdb/jv-valprint.c | |
parent | 1a6eb36b628c19e1064c342f98a7f6cb9eb3033a (diff) | |
download | gdb-fc655dc202bb59777269eeb2331aac40049140c2.zip gdb-fc655dc202bb59777269eeb2331aac40049140c2.tar.gz gdb-fc655dc202bb59777269eeb2331aac40049140c2.tar.bz2 |
* jv-exp.y (push_fieldnames): New, to handle EXP.FIELD1....FIELDN.
(push_expression_name): New, to handle expression names.
(push_qualified_expression_name): New, for qualified expression names.
(parse_number): Fix bugs in parsing of non-decimal integers.
* jv-lang.h, jv-lang.c (java_demangle_type_signature): New.
* jv-lang.c (type_from_class): Just use name with java_lookup_class.
(java_link_class_type): Add dummy "class" field.
(java_lookup_type): New.
(evaluate_subexp_java case STRUCTOP_STRUCT): Force to address.
* jv-typeprint.c (java_type_print_base): Don't print "class" field.
Use java_demangle_type_signature to print array class types.
* jv-valprint.c (java_value_print): Preliminary array support.
Print pointer as TYPE@HEXADDR, instead of (TYPE)0xHEXADDR.
(java_val_print): Move check for object type to java_value_print.
Check for null. Print pointer as @HEXADDR, not 0xHEXADDR.
Diffstat (limited to 'gdb/jv-valprint.c')
-rw-r--r-- | gdb/jv-valprint.c | 88 |
1 files changed, 73 insertions, 15 deletions
diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c index 06ea084..b4afa1e 100644 --- a/gdb/jv-valprint.c +++ b/gdb/jv-valprint.c @@ -36,14 +36,35 @@ java_value_print (val, stream, format, pretty) enum val_prettyprint pretty; { struct type *type = VALUE_TYPE (val); - if (TYPE_CODE (type) == TYPE_CODE_PTR) + CORE_ADDR address = VALUE_ADDRESS (val) + VALUE_OFFSET (val); + if (is_object_type (type)) + { + CORE_ADDR obj_addr = unpack_pointer (type, VALUE_CONTENTS (val)); + if (obj_addr != 0) + { + value_ptr obj_val + = value_at (TYPE_TARGET_TYPE (type), obj_addr, NULL); + type = type_from_class (java_class_from_object (obj_val)); + type = lookup_pointer_type (type); + } + } + if (TYPE_CODE (type) == TYPE_CODE_PTR && ! value_logical_not (val)) { - fprintf_filtered (stream, "("); type_print (TYPE_TARGET_TYPE (type), "", stream, -1); - fprintf_filtered (stream, ") "); } - return (val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), - VALUE_ADDRESS (val) + VALUE_OFFSET (val), + + if (TYPE_CODE (type) == TYPE_CODE_STRUCT && TYPE_TAG_NAME (type) != NULL + && TYPE_TAG_NAME (type)[0] == '[') + { + value_ptr len = value_at (java_int_type, address + JAVA_OBJECT_SIZE, 0); + long length = value_as_long (len); + fprintf_filtered (stream, "{"); + fprintf_filtered (stream, "length = %ld", length); + fprintf_filtered (stream, "}"); + return 0; + } + + return (val_print (type, VALUE_CONTENTS (val), address, stream, format, 1, 0, pretty)); } @@ -59,20 +80,57 @@ java_val_print (type, valaddr, address, stream, format, deref_ref, recurse, int recurse; enum val_prettyprint pretty; { + register unsigned int i = 0; /* Number of characters printed */ + struct type *elttype; + CORE_ADDR addr; + CHECK_TYPEDEF (type); - if (is_object_type (type)) + switch (TYPE_CODE (type)) { - CORE_ADDR obj_addr = unpack_pointer (type, valaddr); - if (obj_addr != 0) + case TYPE_CODE_PTR: + if (format && format != 's') { - value_ptr obj_val - = value_at (TYPE_TARGET_TYPE (type), obj_addr, NULL); - type = type_from_class (java_class_from_object (obj_val)); - type = lookup_pointer_type (type); + print_scalar_formatted (valaddr, type, format, 0, stream); + break; } - } - switch (TYPE_CODE (type)) - { +#if 0 + if (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.) */ + print_address_demangle(extract_address (valaddr, TYPE_LENGTH (type)), + stream, demangle); + break; + } +#endif + addr = unpack_pointer (type, valaddr); + if (addr == 0) + { + fputs_filtered ("null", stream); + return i; + } + elttype = check_typedef (TYPE_TARGET_TYPE (type)); + { + 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 (addr, stream, demangle); + /* Return value is irrelevant except for string pointers. */ + return (0); + } + + if (addressprint && format != 's') + { + fputs_filtered ("@", stream); + print_longest (stream, 'x', 0, (ULONGEST) addr); + } + return i; + } + break; default: return c_val_print (type, valaddr, address, stream, format, deref_ref, recurse, pretty); |