This is the mail archive of the gdb-patches@sources.redhat.com 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]

Patch: Java -vs- null strings


If you are debugging a Java program and try to print a String variable
whose value is null you will see this:

    (gdb) p name
    $3 = Cannot access memory at address 0x8

This is lame.  The appended patch fixes gdb to do this:

    (gdb) p p
    $1 = null

Is this ok?

2000-08-08  Tom Tromey  <tromey@cygnus.com>

	* jv-valprint.c (java_value_print): Only print non-null Strings.

Tom

Index: jv-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/jv-valprint.c,v
retrieving revision 1.3
diff -u -r1.3 jv-valprint.c
--- jv-valprint.c	2000/07/30 01:48:26	1.3
+++ jv-valprint.c	2000/08/08 20:11:49
@@ -197,9 +197,10 @@
   if (TYPE_CODE (type) == TYPE_CODE_PTR
       && TYPE_TARGET_TYPE (type)
       && TYPE_NAME (TYPE_TARGET_TYPE (type))
-    && strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)), "java.lang.String") == 0
+      && strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)), "java.lang.String") == 0
       && (format == 0 || format == 's')
-      && address != 0)
+      && address != 0
+      && value_as_pointer (val) != 0)
     {
       value_ptr data_val;
       CORE_ADDR data;

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