[fpc-pascal] gdb, dwarf, and ansistring

2010-03-03 Thread Seth Grover
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:
(gdb) x/s S^
0x74:

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
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Determining procedure's name

2010-03-03 Thread Wimpie Nortje

Hello everybody,

Is there a macro or function that gives the current procedure's name?

E.g.

procedure TClass.SomeProc;
begin
 writeln(Format('This procedure's name is %s', [THE_MACRO]));
end;

should print

This procedure's name is TClass.SomeProc

or

This procedure's name is SomeProc
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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

2010-03-03 Thread Jonas Maebe

On 03 Mar 2010, at 16:02, Seth Grover wrote:

> How can I print the value of a var ansistring parameter in gdb with
> dwarf debugging information compiled in?

I believe this is a bug that was introduced with GDB 7.0 (I can reproduce it 
with GDB 7.0). Can you try with GDB 6.8 instead? With GDB 6.5 variants I get 
this:

(gdb) p s
$1 = (&ANSISTRING) @0x6252a0: 0x61fbc8 'test'

I don't know whether anyone already reported this bug to the GDB developers.


Jonas___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Determining procedure's name

2010-03-03 Thread Jonas Maebe

On 03 Mar 2010, at 20:33, Wimpie Nortje wrote:

> Is there a macro or function that gives the current procedure's name?

There is a function, but only for methods:

  class function TObject.MethodName(address : pointer) : shortstring;

Simply pass the address of a method as argument. There is no macro.


Jonas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Determining procedure's name

2010-03-03 Thread Mattias Gaertner
On Wed, 03 Mar 2010 21:33:45 +0200
Wimpie Nortje  wrote:

> Hello everybody,
> 
> Is there a macro or function that gives the current procedure's name?
> 
> E.g.
> 
> procedure TClass.SomeProc;
> begin
>   writeln(Format('This procedure's name is %s', [THE_MACRO]));
> end;

If you use Lazarus you can create a code template. Then you can type w
plus Ctrl+J and you will get:

  writeln(Format('This procedure's name is %s', ['TClass.SomeProc']));

I prefer
  writeln('TClass.SomeProc '|);

The | symbol is where the cursor is positioned after the template was
added.

 
> should print
> 
> This procedure's name is TClass.SomeProc
> 
> or
> 
> This procedure's name is SomeProc


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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

2010-03-03 Thread Seth Grover
> 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  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:    
> (gdb) x/s S^
> 0x74:    
>
> 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
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Determining procedure's name

2010-03-03 Thread Wimpie Nortje

Thanks, I will look at the suggestions

Mattias Gaertner wrote:

On Wed, 03 Mar 2010 21:33:45 +0200
Wimpie Nortje  wrote:

  

Hello everybody,

Is there a macro or function that gives the current procedure's name?

E.g.

procedure TClass.SomeProc;
begin
  writeln(Format('This procedure's name is %s', [THE_MACRO]));
end;



If you use Lazarus you can create a code template. Then you can type w
plus Ctrl+J and you will get:

  writeln(Format('This procedure's name is %s', ['TClass.SomeProc']));

I prefer
  writeln('TClass.SomeProc '|);

The | symbol is where the cursor is positioned after the template was
added.

 
  

should print

This procedure's name is TClass.SomeProc

or

This procedure's name is SomeProc




Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

  
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal