This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[08/15] Small Java fix
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 9 Jun 2009 17:18:43 +0200 (CEST)
- Subject: [08/15] Small Java fix
Hello,
this is a simple follow-on patch: now that a per-value architecture
is available, we can eliminate the current_gdbarch reference in the
get_java_object_header_size routine.
Bye,
Ulrich
ChangeLog:
* jv-lang.h (JAVA_OBJECT_SIZE): Remove.
(get_java_object_header_size): Add GDBARCH parameter.
* jv-lang.c (get_java_object_header_size): Add GDBARCH parameter.
Use it instead of current_gdbarch.
(evaluate_subexp_java): Replace JAVA_OBJECT_SIZE with call to
get_java_object_header_size.
* jv-valprint.c (java_value_print): Likewise.
Index: gdb-head/gdb/jv-lang.c
===================================================================
--- gdb-head.orig/gdb/jv-lang.c
+++ gdb-head/gdb/jv-lang.c
@@ -589,11 +589,11 @@ get_java_object_type (void)
}
int
-get_java_object_header_size (void)
+get_java_object_header_size (struct gdbarch *gdbarch)
{
struct type *objtype = get_java_object_type ();
if (objtype == NULL)
- return (2 * gdbarch_ptr_bit (current_gdbarch) / TARGET_CHAR_BIT);
+ return (2 * gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT);
else
return TYPE_LENGTH (objtype);
}
@@ -900,7 +900,7 @@ evaluate_subexp_java (struct type *expec
if (noside == EVAL_AVOID_SIDE_EFFECTS)
return value_zero (el_type, value_arch (arg1), VALUE_LVAL (arg1));
address = value_as_address (arg1);
- address += JAVA_OBJECT_SIZE;
+ address += get_java_object_header_size (value_arch (arg1));
read_memory (address, buf4, 4);
length = (long) extract_signed_integer (buf4, 4);
index = (long) value_as_long (arg2);
Index: gdb-head/gdb/jv-lang.h
===================================================================
--- gdb-head.orig/gdb/jv-lang.h
+++ gdb-head/gdb/jv-lang.h
@@ -27,9 +27,6 @@ extern int java_parse (void); /* Defined
extern void java_error (char *); /* Defined in jv-exp.y */
-/* sizeof (struct Object) */
-#define JAVA_OBJECT_SIZE (get_java_object_header_size ())
-
extern struct type *java_int_type;
extern struct type *java_byte_type;
extern struct type *java_short_type;
@@ -58,7 +55,7 @@ extern struct type *java_primitive_type_
extern struct type *java_array_type (struct type *, int);
extern struct type *get_java_object_type (void);
-extern int get_java_object_header_size (void);
+extern int get_java_object_header_size (struct gdbarch *);
extern struct type *java_lookup_class (char *);
Index: gdb-head/gdb/jv-valprint.c
===================================================================
--- gdb-head.orig/gdb/jv-valprint.c
+++ gdb-head/gdb/jv-valprint.c
@@ -79,7 +79,7 @@ java_value_print (struct value *val, str
struct type *el_type = java_primitive_type_from_name (name, i - 2);
i = 0;
- read_memory (address + JAVA_OBJECT_SIZE, buf4, 4);
+ read_memory (address + get_java_object_header_size (gdbarch), buf4, 4);
length = (long) extract_signed_integer (buf4, 4);
fprintf_filtered (stream, "{length: %ld", length);
@@ -89,7 +89,8 @@ java_value_print (struct value *val, str
CORE_ADDR element;
CORE_ADDR next_element = -1; /* dummy initial value */
- address += JAVA_OBJECT_SIZE + 4; /* Skip object header and length. */
+ /* Skip object header and length. */
+ address += get_java_object_header_size (gdbarch) + 4;
while (i < length && things_printed < options->print_max)
{
@@ -144,7 +145,8 @@ java_value_print (struct value *val, str
struct value *v = allocate_value (el_type, gdbarch);
struct value *next_v = allocate_value (el_type, gdbarch);
- set_value_address (v, address + JAVA_OBJECT_SIZE + 4);
+ address += get_java_object_header_size (gdbarch) + 4;
+ set_value_address (v, address);
set_value_address (next_v, value_raw_address (v));
while (i < length && things_printed < options->print_max)
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com