* jv-lang.c (get_java_utf8_name): Re-write so it works with
[deliverable/binutils-gdb.git] / gdb / jv-valprint.c
CommitLineData
7a9eb4c4
PB
1/* Support for printing Java values for GDB, the GNU debugger.
2 Copyright 1997 Free Software Foundation, Inc.
3
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20#include "defs.h"
21#include "symtab.h"
22#include "gdbtypes.h"
23#include "expression.h"
24#include "value.h"
25#include "demangle.h"
26#include "valprint.h"
27#include "language.h"
166606b7 28#include "jv-lang.h"
40b647e9 29#include "c-lang.h"
7a9eb4c4
PB
30
31int
32java_value_print (val, stream, format, pretty)
33 value_ptr val;
34 GDB_FILE *stream;
35 int format;
36 enum val_prettyprint pretty;
37{
38 struct type *type = VALUE_TYPE (val);
39 if (TYPE_CODE (type) == TYPE_CODE_PTR)
40 {
41 fprintf_filtered (stream, "(");
42 type_print (TYPE_TARGET_TYPE (type), "", stream, -1);
43 fprintf_filtered (stream, ") ");
44 }
45 return (val_print (VALUE_TYPE (val), VALUE_CONTENTS (val),
46 VALUE_ADDRESS (val) + VALUE_OFFSET (val),
47 stream, format, 1, 0, pretty));
48}
49
50int
51java_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
52 pretty)
53 struct type *type;
54 char *valaddr;
55 CORE_ADDR address;
56 GDB_FILE *stream;
57 int format;
58 int deref_ref;
59 int recurse;
60 enum val_prettyprint pretty;
61{
d2e131a1 62 CHECK_TYPEDEF (type);
7a9eb4c4
PB
63 if (is_object_type (type))
64 {
65 CORE_ADDR obj_addr = unpack_pointer (type, valaddr);
66 if (obj_addr != 0)
67 {
68 value_ptr obj_val
69 = value_at (TYPE_TARGET_TYPE (type), obj_addr, NULL);
70 type = type_from_class (java_class_from_object (obj_val));
71 type = lookup_pointer_type (type);
72 }
73 }
d2e131a1
PB
74 switch (TYPE_CODE (type))
75 {
76 default:
77 return c_val_print (type, valaddr, address, stream, format,
78 deref_ref, recurse, pretty);
79 }
7a9eb4c4 80}
This page took 0.031494 seconds and 4 git commands to generate.