This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Regression: gdb.java/jprint.exp: inherited static call [3/5] make value_primitive_field respect virtual bases


>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> p x.addprint(1,2,3)
Jan> Cannot access memory at address 0x33
Jan> (gdb) FAIL: gdb.java/jprint.exp: inherited static call

I looked into this.

I think the test case is bogus, and/or gcj is generating the wrong
debuginfo:

    (gdb) whatis x
    type = jprint
    (gdb) info addr x
    Symbol "x" is a variable in $rax.
    (gdb) p $rax
    $1 = 51

The appended patch makes it work by keeping 'x' alive.

I also fixed a bug involving printing Java strings.
The old code here seems quite weird to me.

Built and regtested (just --directory=gdb.java) on Fedora 16 x86-64.

Tom

2012-03-05  Tom Tromey  <tromey@redhat.com>

	* jv-valprint.c (java_value_print): Correctly compute 'obj_addr'.

2012-03-05  Tom Tromey  <tromey@redhat.com>

	* gdb.java/jprint.java (jprint.main): Keep 'x' live.

diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c
index 648dbc7..12a960f 100644
--- a/gdb/jv-valprint.c
+++ b/gdb/jv-valprint.c
@@ -51,10 +51,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)
 	{
diff --git a/gdb/testsuite/gdb.java/jprint.java b/gdb/testsuite/gdb.java/jprint.java
index 3d55dc3..0a5e7d3 100644
--- a/gdb/testsuite/gdb.java/jprint.java
+++ b/gdb/testsuite/gdb.java/jprint.java
@@ -61,6 +61,7 @@ public class jprint extends jvclass {
     jprint x = new jprint ();
     x.dothat (44);
     print (k, 33);
+    print (x.addk(0), 33);
   }
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]