[fpc-pascal] gdb, dwarf, and ansistring

Seth Grover sethdgrover at gmail.com
Wed Mar 3 16:02:45 CET 2010


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