embedded_offset missing in c-valprint.c

Emmanuel Thomé Emmanuel.Thome@gmail.com
Mon Jul 5 01:52:00 GMT 2010


Hi,

Could you please consider the attached patch to c-valprint.c ?

Unless I am mistaken (which is possible), the function c_val_print does
not correctly track the inferior addresses of struct members. This
affects pretty-printing via python scripting, which may require this
address.

I actually tested the version from the ubuntu package 7.1-1ubuntu2, but
the defect seems also present in the git head version.

Here is an example of a session transcript illustrating the misbehaviour/

$ gdb v
GNU gdb (GDB) 7.1-ubuntu
[...]
(gdb) b 19
Breakpoint 1 at 0x4004fb: file v.c, line 19.
(gdb) r
Starting program: /home/thome/Curves/CM/complex_analytic/regis/v 

Breakpoint 1, main () at v.c:19
19          return 0;
(gdb) p x
$1 = {{l = 42, a = {{{x = 0}}, {{x = 1}}}}}
(gdb) source u.py
(gdb) p x
$2 = {{l = 42, a = {42, 0}}}

v.c and u.py are attached (as well as the patch itself of course).

Best,

E.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v.c
Type: text/x-csrc
Size: 221 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20100705/12b8194f/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: u.py
Type: text/x-python
Size: 560 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20100705/12b8194f/attachment.py>
-------------- next part --------------
--- c-valprint.c	2010-07-04 23:06:32.000000000 +0200
+++ /tmp/c-valprint.c	2010-07-05 03:29:39.000000000 +0200
@@ -216,7 +216,7 @@
 		{
 		  i = 0;
 		}
-	      val_print_array_elements (type, valaddr + embedded_offset, address, stream,
+	      val_print_array_elements (type, valaddr + embedded_offset, address + embedded_offset, stream,
 					recurse, options, i);
 	      fprintf_filtered (stream, "}");
 	    }


More information about the Gdb-patches mailing list