[fpc-pascal] Re: gdb, dwarf, and ansistring

Seth Grover sethdgrover at gmail.com
Thu Mar 4 00:27:58 CET 2010


> I believe this is a bug that was introduced with GDB 7.0
> Jonas

You're right, I tried it with gdb 6.8 and it worked as you described:

(gdb) print S
$1 = (&ANSISTRING) @0x8069410: 0x8065074 'test'

-SG

--
This email is fiction. Any resemblance to actual events
or persons living or dead is purely coincidental.

Seth Grover
sethdgrover[at]gmail[dot]com



On Wed, Mar 3, 2010 at 8:02 AM, Seth Grover <sethdgrover at gmail.com> wrote:
> Given the following example:
>
> ----------------------------------------
> program project1;
>
> {$mode objfpc}{$H+}
>
>  procedure doit (var s : ansistring);
>  begin
>    s := s + ' ' + s;
>  end;
>
> var
>  s : ansistring;
> begin
>  s := 'test';
>  doit(s);
> end.
> ----------------------------------------
>
> When I compile for x86_64 with "fpc -Px86_64 -g -gl -gw project1.lpr",
> 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>
>
> When I compile with "fpc -Px86_64 -g -gl project1.lpr", I get the same
> result. When I compile for i386 with "fpc -Pi386 -g -gl -gw
> project1.lpr", I have the same issue. However, when I compile for i386
> with "fpc -Pi386 -g -gl project1.lpr", I get:
>
> (gdb) whatis S
> type = ANSISTRING
> (gdb) print S
> $1 = (ANSISTRING) 0x8064074 "test"
> (gdb) x/s S
> 0x8064074 <_$PROJECT1$_Ld3>:     "test"
>
> How can I print the value of a var ansistring parameter in gdb with
> dwarf debugging information compiled in?
>
> I am compiling with FPC 2.4.0 (built from svn from the 2.4.0 release
> tag) on Ubuntu 9.10 x86_64.
>
> Thanks,
>
> -SG
>
>
> --
> This email is fiction. Any resemblance to actual events
> or persons living or dead is purely coincidental.
>
> Seth Grover
> sethdgrover[at]gmail[dot]com
>



More information about the fpc-pascal mailing list