Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch]: Fix NULL ptr handling in f_print_type
@ 2008-02-28  6:00 Markus Deuling
  2008-02-28 16:41 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Deuling @ 2008-02-28  6:00 UTC (permalink / raw)
  To: GDB Patches; +Cc: Ulrich Weigand

[-- Attachment #1: Type: text/plain, Size: 2094 bytes --]

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


[-- Attachment #2: fix-fortran --]
[-- Type: text/plain, Size: 1100 bytes --]

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch]: Fix NULL ptr handling in f_print_type
  2008-02-28  6:00 [patch]: Fix NULL ptr handling in f_print_type Markus Deuling
@ 2008-02-28 16:41 ` Daniel Jacobowitz
  2008-02-28 19:15   ` Markus Deuling
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2008-02-28 16:41 UTC (permalink / raw)
  To: Markus Deuling; +Cc: GDB Patches, Ulrich Weigand

On Thu, Feb 28, 2008 at 06:19:14AM +0100, Markus Deuling wrote:
> ChangeLog:
>
> 	* f-typeprint.c (f_print_type): Handle NULL pointer in VARSTRING
> 	properly.

OK.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch]: Fix NULL ptr handling in f_print_type
  2008-02-28 16:41 ` Daniel Jacobowitz
@ 2008-02-28 19:15   ` Markus Deuling
  0 siblings, 0 replies; 3+ messages in thread
From: Markus Deuling @ 2008-02-28 19:15 UTC (permalink / raw)
  To: Daniel Jacobowitz, GDB Patches, Ulrich Weigand

Daniel Jacobowitz schrieb:
> On Thu, Feb 28, 2008 at 06:19:14AM +0100, Markus Deuling wrote:
>> ChangeLog:
>>
>> 	* f-typeprint.c (f_print_type): Handle NULL pointer in VARSTRING
>> 	properly.
> 
> OK.
> 

Thank you very much. I've committed the patch.

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-02-28 19:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-28  6:00 [patch]: Fix NULL ptr handling in f_print_type Markus Deuling
2008-02-28 16:41 ` Daniel Jacobowitz
2008-02-28 19:15   ` Markus Deuling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox