Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-08

Debugging and Structured Data Arrays

8 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andrew Brunner

Hi All. I have a data type of TStringArray=Array of String...

Under debugger (GDB Linux) I can't access any of the elements.

Is there a compiler option to enable information during debugging and or watching?

Presently, when Inspecting or Viewing I get an error "Cannot perform pointer math on incomplete type TSTRINGARRAY..."

Any ideas?

Reply by email

Silvio Clecio
to Andrew Brunner
Andrew Brunner wrote 11 lines
Hi All. I have a data type of TStringArray=Array of String... Under debugger (GDB Linux) I can't access any of the elements. Is there a compiler option to enable information during debugging and or watching? Presently, when Inspecting or Viewing I get an error "Cannot perform pointer math on incomplete type TSTRINGARRAY..." Any ideas?

I not saw errors with the implementation below:

-------
   TStringArray = array of string;
implementation

{ TMainForm }

procedure TMainForm.TestButtonClick(Sender: TObject);
{$WRITEABLECONST ON}
const
   CStringArrayLength: Integer = 20;
{$WRITEABLECONST OFF}
var
   VStringArray: TStringArray;
begin
   SetLength(VStringArray, CStringArrayLength);
   VStringArray[0] := 'Test';
   ShowMessage(VStringArray[0]); // Show Test
end;
-------
[]'s, Silvio Cl?cio --- Linux User: #481900 Gmail, GTalk: E-mail, Y! Messenger: BlogSite: http://silvioprog.blogspot.com/ BlogSpot: http://silvioclecio.blogspot.com/ VirtualDriver: http://silvioprog.4shared.com/ ?oO| Seja livre, use Linux! |Oo?

Reply by email

Andrew Brunner
to Silvio Clecio

Thanks Silvio,

I'm not having a problem a problem with code running. I'm not able to Inspect the contents of VStringArray while debugging via GDB in Ubuntu.

Can you inspect the variable VStringArray? How about VStringArray[0]? I can not.

This is a fresh build of FPC and Lazarus from TRUNK and a BRAND new install of Ubuntu 9.04.

Silvio Clecio wrote 53 lines
Em 31/7/2009 21:17, Andrew Brunner escreveu: > > Hi All. ?I have a data type of TStringArray=Array of String... > > Under debugger (GDB Linux) I can't access any of the elements. > > Is there a compiler option to enable information during debugging and > or watching? > > Presently, when Inspecting or Viewing I get an error "Cannot perform > pointer math on incomplete type TSTRINGARRAY..." > > Any ideas? I not saw errors with the implementation below: ------- ?TStringArray = array of string; implementation { TMainForm } procedure TMainForm.TestButtonClick(Sender: TObject); {$WRITEABLECONST ON} const ?CStringArrayLength: Integer = 20; {$WRITEABLECONST OFF} var ?VStringArray: TStringArray; begin ?SetLength(VStringArray, CStringArrayLength); ?VStringArray[0] := 'Test'; ?ShowMessage(VStringArray[0]); // Show Test end; ------- -- []'s, Silvio Cl?cio --- Linux User: #481900 Gmail, GTalk: E-mail, Y! Messenger: BlogSite: http://silvioprog.blogspot.com/ BlogSpot: http://silvioclecio.blogspot.com/ VirtualDriver: http://silvioprog.4shared.com/ ?oO| Seja livre, use Linux! |Oo? -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Martin
to Andrew Brunner
Andrew Brunner wrote 13 lines
Thanks Silvio, I'm not having a problem a problem with code running. I'm not able to Inspect the contents of VStringArray while debugging via GDB in Ubuntu. Can you inspect the variable VStringArray? How about VStringArray[0]? I can not. This is a fresh build of FPC and Lazarus from TRUNK and a BRAND new install of Ubuntu 9.04.

There a various problems, like this. It is an issue between fpc and gdb. A lot may depend on the version of fpc and the version of gdb you use.

A few thinks you can try, but I don't know if they will work for you.

Try Dwarf versu stabs (Compiler option in Lazarus), Tab: Linking

While debugging the following has worked for me under window (not sure if I used dwarf, I think not). And it only worked if there was an explicit type:
type TStringArray = Array of String; var a: TStringArray but not for

  var a: Array of String;

instead of
a[0]
I wrote (in the watch window)
a^[0]

Reply by email

Martin
to Martin

please also read
http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips

Martin wrote 40 lines
Andrew Brunner wrote: > Thanks Silvio, > > I'm not having a problem a problem with code running. I'm not able to > Inspect the contents of VStringArray while debugging via GDB in > Ubuntu. > > Can you inspect the variable VStringArray? How about VStringArray[0]? > I can not. > > This is a fresh build of FPC and Lazarus from TRUNK and a BRAND new > install of Ubuntu 9.04. > > There a various problems, like this. It is an issue between fpc and gdb. A lot may depend on the version of fpc and the version of gdb you use. A few thinks you can try, but I don't know if they will work for you. Try Dwarf versu stabs (Compiler option in Lazarus), Tab: Linking While debugging the following has worked for me under window (not sure if I used dwarf, I think not). And it only worked if there was an explicit type: type TStringArray = Array of String; var a: TStringArray but not for var a: Array of String; instead of a[0] I wrote (in the watch window) a^[0] -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Silvio Clecio
to Martin
Martin wrote 36 lines
please also read http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips Martin wrote: > Andrew Brunner wrote: >> Thanks Silvio, >> >> I'm not having a problem a problem with code running. I'm not able to >> Inspect the contents of VStringArray while debugging via GDB in >> Ubuntu. >> >> Can you inspect the variable VStringArray? How about VStringArray[0]? >> I can not. >> >> This is a fresh build of FPC and Lazarus from TRUNK and a BRAND new >> install of Ubuntu 9.04. >> > > There a various problems, like this. It is an issue between fpc and gdb. > A lot may depend on the version of fpc and the version of gdb you use. > > A few thinks you can try, but I don't know if they will work for you. > > Try Dwarf versu stabs (Compiler option in Lazarus), Tab: Linking > > While debugging the following has worked for me under window (not sure > if I used dwarf, I think not). And it only worked if there was an > explicit type: > type TStringArray = Array of String; var a: TStringArray > but not for > var a: Array of String; > > instead of > a[0] > I wrote (in the watch window) > a^[0]

Martin, thanks for the strength ;-) .

With I showed, had no errors. I'm using now the following (see pictures):

GDB - [http://www.4shared.com/file/122487107/bfb46cfd/gdb.html]. Lazarus - [http://www.4shared.com/file/122487336/e01adbc6/lazarus.html].

ps. Friends, I don't know much English but I try to help somehow. :-)

[]'s, Silvio Cl?cio --- Linux User: #481900 Gmail, GTalk: E-mail, Y! Messenger: BlogSite: http://silvioprog.blogspot.com/ BlogSpot: http://silvioclecio.blogspot.com/ VirtualDriver: http://silvioprog.4shared.com/ ?oO| Seja livre, use Linux! |Oo?

Reply by email

Martin
to Silvio Clecio

Try (note you need to add 4, to get to the next string)

PChar(^LONGINT(^LONGINT(@t)^+0)^)
PChar(^LONGINT(^LONGINT(@t)^+4)^)
PChar(^LONGINT(^LONGINT(@t)^+8)^)

and for the length of array (minus 4)
^LONGINT(^LONGINT(@t)^-4)^

Read also
http://forum.lazarus.freepascal.org/index.php/topic,4763.msg22954.html#msg22954 (just strings are a pointer them self, so they need one level more) http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Dynamic_Arrays (updated)

If that doesn't help, then it wont work. (or i don't know how)

Problem is that the debugger doesn't understand the pascal concept. so you unfortunately need a lot of understanding, of how fpc encodes your data, what is a pointer, what is which kind of record....

It is improving in 2.3.1 (and maybe even more with dwarf).

If nothing helps:
LCLProc.debugln
writeln

Silvio Clecio wrote 47 lines
Em 2/8/2009 19:58, Martin escreveu: > please also read > http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips > > Martin wrote: >> Andrew Brunner wrote: >>> Thanks Silvio, >>> >>> I'm not having a problem a problem with code running. I'm not able to >>> Inspect the contents of VStringArray while debugging via GDB in >>> Ubuntu. >>> >>> Can you inspect the variable VStringArray? How about VStringArray[0]? >>> I can not. >>> >>> This is a fresh build of FPC and Lazarus from TRUNK and a BRAND new >>> install of Ubuntu 9.04. >>> >> >> There a various problems, like this. It is an issue between fpc and >> gdb. >> A lot may depend on the version of fpc and the version of gdb you use. >> >> A few thinks you can try, but I don't know if they will work for you. >> >> Try Dwarf versu stabs (Compiler option in Lazarus), Tab: Linking >> >> While debugging the following has worked for me under window (not sure >> if I used dwarf, I think not). And it only worked if there was an >> explicit type: >> type TStringArray = Array of String; var a: TStringArray >> but not for >> var a: Array of String; >> >> instead of >> a[0] >> I wrote (in the watch window) >> a^[0] Martin, thanks for the strength ;-) . With I showed, had no errors. I'm using now the following (see pictures): GDB - [http://www.4shared.com/file/122487107/bfb46cfd/gdb.html]. Lazarus - [http://www.4shared.com/file/122487336/e01adbc6/lazarus.html]. ps. Friends, I don't know much English but I try to help somehow. :-)

Reply by email

Andrew Brunner
to Martin: There a various problems, like this. It is an issue between fpc and gdb. A lot may depend…

Thanks guys.

I just wrote a toFile method for all StringArrays. And place a toFile call to inspect them. Seems easier for now. I'm sure at some point the debugger or inspector will start working :-)

Martin wrote 41 lines
Andrew Brunner wrote: > > Thanks Silvio, > > I'm not having a problem a problem with code running. ?I'm not able to > Inspect the contents of VStringArray while debugging via GDB in > Ubuntu. > > Can you inspect the variable VStringArray? ?How about VStringArray[0]? > ?I can not. > > This is a fresh build of FPC and Lazarus from TRUNK and a BRAND new > install of Ubuntu 9.04. > > There a various problems, like this. It is an issue between fpc and gdb. A lot may depend on the version of ?fpc and the version of gdb you use. A few thinks you can try, but I don't know if they will work for you. Try Dwarf versu stabs (Compiler option in Lazarus), Tab: Linking While debugging the following has worked for me under window (not sure if I used dwarf, I think not). And it only worked if there was an explicit type: ?type TStringArray = Array of String; var a: TStringArray but not for ?var a: Array of String; instead of a[0] I wrote (in the watch window) a^[0] -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email