Given this example program: -------------------------------------- program project1; {$mode objfpc}{$H+} procedure doit (var s : ansistring); begin s := s + ' ' + s; end; var s : ansistring; begin s := 'test'; doit(s); end. -------------------------------------- Compiled with Free Pascal 2.4.0 with the command line "fpc -Px86_64 -g -gl -gw project1.lpr", when I set a breakpoint in "doit" and try to view the var ansistring variable "s": and set a breakpoint in "doit" in GDB, I see the following: (gdb) whatis S type = &ANSISTRING (gdb) print S $12 = (&ANSISTRING) @0x627130 (gdb) whatis S^ type = ANSISTRING (gdb) print S^ $13 = 116 't' (gdb) x/s S 0x74: <Address 0x74 out of bounds> (gdb) x/s S^ 0x74: <Address 0x74 out of bounds> Debugging with GDB 6.8 with the exact same program and compiler options, I get this instead: (gdb) print S $1 = (&ANSISTRING) @0x8069410: 0x8065074 'test' It appears ansistring variables passed by reference are no longer working correctly with "print" in GDB, and that this bug was introduced in GDB 7.0. My system is Ubuntu 9.10 64-bit: $ gdb --version GNU gdb (GDB) 7.0-ubuntu $ uname -a Linux user-desktop 2.6.31-19-generic #56-Ubuntu SMP Thu Jan 28 02:39:34 UTC 2010 x86_64 GNU/Linux $ fpc Free Pascal Compiler version 2.4.0 [2010/02/09] for x86_64
Created attachment 4643 [details] compiled program Here's the same program using pchar instead of ansistring, along with the compiled version of the program: program project1; procedure doit (var s : pchar); begin end; var s : pchar; begin s := 'test'; doit(s); end.
Created attachment 4644 [details] readelf -gw from compiled program readelf -gw of binary in attachment 4643 [details]
Created attachment 4645 [details] program compiled to assembly Assembly file generated by FPC from program in attachment 4643 [details] (compiled with "fpc -a -al -an -Px86_64 -g -gl -gw project1.lpr").
gdb bugs sit for a month before anyone even looks at them?
Subject: Bug 11349 CVSROOT: /cvs/src Module name: src Changes by: muller@sourceware.org 2010-05-03 13:38:27 Modified files: gdb : ChangeLog p-valprint.c Log message: PR pascal/11349. * p-valprint.c (pascal_value_print): Always dereference a value with type code TYPE_CODE_REF. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.11713&r2=1.11714 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/p-valprint.c.diff?cvsroot=src&r1=1.69&r2=1.70
Subject: Bug 11349 CVSROOT: /cvs/src Module name: src Changes by: muller@sourceware.org 2010-05-04 06:48:27 Modified files: gdb : ChangeLog printcmd.c gdb/testsuite : ChangeLog gdb/testsuite/gdb.cp: ref-types.exp Log message: PR exp/11349. * printcmd.c (x_command): Only dereference once implicitly for TYPE_CODE_REF. testsuite dir: PR exp/11349. * testsuite/gdb.cp/ref-types.exp: Add test to examine use a reference local variable. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.11717&r2=1.11718 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/printcmd.c.diff?cvsroot=src&r1=1.176&r2=1.177 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2260&r2=1.2261 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.cp/ref-types.exp.diff?cvsroot=src&r1=1.12&r2=1.13
The patches committed to trunk should solve the issue. Could you try it out and mark the issue as FIXED if all works correctly or report if you still get problems.
Thanks, that seems to have done the trick. With the test program from comment 1, here's what I get with the patched version: ============================ (gdb) break DOIT Breakpoint 1 at 0x80480a9: file project1.pas, line 5. (gdb) r Starting program: /home/tlacuache/tmp/project1 Breakpoint 1, DOIT (S=@0x8068240) at project1.pas:5 5 end; (gdb) print S $1 = (&PCHAR) @0x8068240: 0x806404c 'test' ============================ compared to what I used to get (with gdb 7.1 in the Ubuntu repositories): ============================ (gdb) break DOIT Breakpoint 1 at 0x80480a9: file project1.pas, line 5. (gdb) r Starting program: /home/tlacuache/tmp/project1 Breakpoint 1, DOIT (S=@0x8068240) at project1.pas:5 5 end; (gdb) print S $1 = (&PCHAR) @0x8068240 ============================ So the new behavior is correct. Thanks again.