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]

[patch]: Fix NULL ptr handling in f_print_type


Hi,

f_print_type from f-typeprint.c is currently not able to handle (varstring == NULL) properly
like for example its c counterpart does. Here is an example:


(gdb) set language fortran Warning: the current language does not match this frame. (gdb) set debug expression 1 (gdb) set $r0%uint128=1 Dump of expression @ 0x102f4c78' Language fortran, 15 elements, 16 bytes each. Index Opcode Hex Value String Value 0 OP_REGISTER 197568495616 ................ 1 OP_NULL 2 ................ <snip> 14 BINOP_ASSIGN 90194313216 ................ Dump of expression @ 0x102f4c78, after conversion to prefix form: Expression: `$r0.uint128 = 1' Language fortran, 15 elements, 16 bytes each.


0 BINOP_ASSIGN 1 STRUCTOP_STRUCT Element name: `uint128'
6 OP_REGISTER Register $r0
11 OP_LONG Type @0x102e9528 (intSegmentation fault (core dumped)



The attached patch fixes it:


(gdb) set language fortran
(gdb) set $r0%uint128=6
Dump of expression @ 0x102f4d30'
       Language fortran, 15 elements, 16 bytes each.
       Index                Opcode         Hex Value  String Value
           0           OP_REGISTER  197568495616  ................
           1               OP_NULL  2  ................
<snip>
          14          BINOP_ASSIGN  90194313216  ................
Dump of expression @ 0x102f4d30, after conversion to prefix form:
Expression: `$r0.uint128 = 6'
       Language fortran, 15 elements, 16 bytes each.


0 BINOP_ASSIGN 1 STRUCTOP_STRUCT Element name: `uint128'
6 OP_REGISTER Register $r0
11 OP_LONG Type @0x102e9528 (int), value 6 (0x6)



Tested on SPU and x86 without regression. Ok ?


ChangeLog:

	* f-typeprint.c (f_print_type): Handle NULL pointer in VARSTRING
	properly.


-- Markus Deuling GNU Toolchain for Linux on Cell BE deuling@de.ibm.com

diff -urpN gdb-6.7.1.orig/gdb/f-typeprint.c gdb-6.7.1/gdb/f-typeprint.c
--- gdb-6.7.1.orig/gdb/f-typeprint.c	2008-02-27 11:01:53.000000000 +0100
+++ gdb-6.7.1/gdb/f-typeprint.c	2008-02-28 06:13:22.000000000 +0100
@@ -76,13 +76,16 @@ f_print_type (struct type *type, char *v
     fputs_filtered (" ", stream);
   f_type_print_varspec_prefix (type, stream, show, 0);
 
-  fputs_filtered (varstring, stream);
+  if (varstring != NULL)
+    {
+      fputs_filtered (varstring, stream);
 
-  /* For demangled function names, we have the arglist as part of the name,
-     so don't print an additional pair of ()'s */
+      /* For demangled function names, we have the arglist as part of the name,
+         so don't print an additional pair of ()'s */
 
-  demangled_args = varstring[strlen (varstring) - 1] == ')';
-  f_type_print_varspec_suffix (type, stream, show, 0, demangled_args);
+      demangled_args = varstring[strlen (varstring) - 1] == ')'; 
+      f_type_print_varspec_suffix (type, stream, show, 0, demangled_args);
+   }
 }
 
 /* Print any asterisks or open-parentheses needed before the

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