Forum
× Components and Libraries for Debugging Development, discussions, problems and suggestions.

Question Trying to inspect string lists, little luck

  • Fernando
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
5 months 2 weeks ago - 5 months 2 weeks ago #13070 by Fernando
I found some difficulties debugging, and did some tests, specifically trying to find what is in string lists.
I used a short project to test in Typhon32 v6.7 stable, on windows 10 64 bits with latest updates; just a window with one button and two edits, with the following code:
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private

  public

  end;

var
  Form1: TForm1;
  list1: TStringList;
  combo1: TComboBox;

implementation

{$R *.frm}

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
begin
  list1 := TStringList.Create;
  list1.Add('Uno');
  list1.Add('Dos');
  list1.Add('Tres');
  combo1 := TComboBox.Create(nil);
  combo1.Items.Add('One');
  combo1.Items.Add('Two');
  combo1.Items.Add('Three');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text:= list1.Text;
  Edit2.Text:= combo1.Items.Text;
end;

end.

I set a breakpoint in the first line of the click event handler and try to inspect list1 and combo1.items. tested with different debugger configurations; these are my results:

- With the default gdb, pressing Ctrl-F7 with the cursor on list1 gives a long listing of properties:
<TSTRINGLIST> = {
  <TSTRINGS> = {
    <TPERSISTENT> = {
      <TOBJECT> = {
        _vptr$TOBJECT = $58a7f4}, 
      FOBSERVERS = $0}, 
    FDEFAULTENCODING = $2708500, 
    FENCODING = $0, 
    FSPECIALCHARSINITED = false, 
    FALWAYSQUOTE = false, 
    FQUOTECHAR = 0 #0, 
    FDELIMITER = 0 #0, 
    FNAMEVALUESEPARATOR = 0 #0, 
    FUPDATECOUNT = 0, 
    FADAPTER = $0, 
    FLBS = TLBSLF, 
    FSKIPLASTLINEBREAK = false, 
    FSTRICTDELIMITER = false, 
    FLINEBREAK = $0, 
    FWRITEBOM = true, 
    UPDATECOUNT = 0, 
    DEFAULTENCODING = $2708500, 
    ENCODING = $0, 
    STRICTDELIMITER = false, 
    ALWAYSQUOTE = false, 
    STRINGSADAPTER = $0, 
    WRITEBOM = true}, 
  FLIST = $26f8390, 
  FCOUNT = 3, 
  FCAPACITY = 4, 
  FONCHANGE = {
    Proc = {
      procedure (POINTER, 
      TOBJECT)} 0x27180f0, 
    Self = $0}, 
  FONCHANGING = {
    Proc = {
      procedure (POINTER, 
      TOBJECT)} 0x27180f0, 
    Self = $0}, 
  FDUPLICATES = DUPIGNORE, 
  FCASESENSITIVE = false, 
  FFORCESORT = false, 
  FOWNSOBJECTS = false, 
  FSORTSTYLE = SSLNONE, 
  DUPLICATES = DUPIGNORE, 
  CASESENSITIVE = false, 
  ONCHANGE = {
    Proc = {
      procedure (POINTER, 
      TOBJECT)} 0x27180f0, 
    Self = $0}, 
  ONCHANGING = {
    Proc = {
      procedure (POINTER, 
      TOBJECT)} 0x27180f0, 
    Self = $0}, 
  OWNSOBJECTS = false, 
  SORTSTYLE = SSLNONE}
Typing list1[0] in the evaluate window gives the same result (or almost the same, I didn't inspect in detail). For reference, in delphi typing this results in "Uno" the first string in the list as expected.
Evaluating combo1.items gives a result similar to list1; however evaluating combo1.items[0] results in:
<TSTRINGS> = {
  <TPERSISTENT> = {
    <TOBJECT> = {
      _vptr$TOBJECT = $58a7f4}, 
    FOBSERVERS = $0}, 
  FDEFAULTENCODING = $2708500, 
  FENCODING = $0, 
  FSPECIALCHARSINITED = false, 
  FALWAYSQUOTE = false, 
  FQUOTECHAR = 0 #0, 
  FDELIMITER = 0 #0, 
  FNAMEVALUESEPARATOR = 0 #0, 
  FUPDATECOUNT = 0, 
  FADAPTER = $0, 
  FLBS = TLBSLF, 
  FSKIPLASTLINEBREAK = false, 
  FSTRICTDELIMITER = false, 
  FLINEBREAK = $0, 
  FWRITEBOM = true, 
  UPDATECOUNT = 0, 
  DEFAULTENCODING = $2708500, 
  ENCODING = $0, 
  STRICTDELIMITER = false, 
  ALWAYSQUOTE = false, 
  STRINGSADAPTER = $0, 
  WRITEBOM = true}
But the actual string is not shown either.
Finally, pressing F8 and trying to inspect Edit1.Text results in:
Type TEDIT has no component named TEXT.
However, inspecting Edit1.FCaption results in
TTranslatestring($02789C6C)  'Edit1'
The text seems not updated yet (running the program sets Edit1 and 2 to the full string lists).

- Selecting GDB with fpdebug as debugger, doing as above and inspecting list1, I get a shorter (but better looking) result:
TStringListTStringList (FLIST = $02678390;
 FCOUNT = 3;
 FCAPACITY = 4;
 FONCHANGE = TNOTIFYEVENT($00000000);
 FONCHANGING = TNOTIFYEVENT($00000000);
 FDUPLICATES = DUPIGNORE;
 FCASESENSITIVE = False;
 FFORCESORT = False;
 FOWNSOBJECTS = False;
 FSORTSTYLE = SSLNONE;
 DUPLICATES = DUPIGNORE;
 CASESENSITIVE = False;
 ONCHANGE = TNOTIFYEVENT($00000000);
 ONCHANGING = TNOTIFYEVENT($00000000);
 OWNSOBJECTS = False;
 SORTSTYLE = SSLNONE;
 FDEFAULTENCODING = TENCODING($02688500);
 FENCODING = nil;
 FSPECIALCHARSINITED = False;
 FALWAYSQUOTE = False;
 FQUOTECHAR = #$00;
 FDELIMITER = #$00;
 FNAMEVALUESEPARATOR = #$00;
 FUPDATECOUNT = 0;
 FADAPTER = nil;
 FLBS = TLBSLF;
 FSKIPLASTLINEBREAK = False;
 FSTRICTDELIMITER = False;
 FLINEBREAK = nil;
 FWRITEBOM = True;
 UPDATECOUNT = 0;
 DEFAULTENCODING = TENCODING($02688500);
 ENCODING = nil;
 STRICTDELIMITER = False;
 ALWAYSQUOTE = False;
 STRINGSADAPTER = nil;
 WRITEBOM = True;
 FOBSERVERS = nil;
 _vptr$TOBJECT = $0058A7F4)
However, asking for list1[0] results in:
Not a type or Array. Cannot access indexed element on expression [
Evaluating combo1.items and combo1.Items[0] I get the same results.
Pressing F8 and evaluating Edit1.Text results in
Member not found: Text
but evaluating Edit1.FCaption I get as before
TTRANSLATESTRING($02689C6C) 'Edit1'

- Selecting FpDebug internal Dwarf-debugger and choosing the standard Dwarf option gives the following:
Inspecting list1:
TStringList (FLIST = $025A82C8;
 FCOUNT = 3;
 FCAPACITY = 4;
 FONCHANGE = TNOTIFYEVENT($00000000);
 FONCHANGING = TNOTIFYEVENT($00000000);
 FDUPLICATES = DUPIGNORE;
 FCASESENSITIVE = False;
 FFORCESORT = False;
 FOWNSOBJECTS = False;
 FSORTSTYLE = SSLNONE;
 DUPLICATES = DUPIGNORE;
 CASESENSITIVE = False;
 ONCHANGE = TNOTIFYEVENT($00000000);
 ONCHANGING = TNOTIFYEVENT($00000000);
 OWNSOBJECTS = False;
 SORTSTYLE = SSLNONE;
 FDEFAULTENCODING = TENCODING($025B8438);
 FENCODING = nil;
 FSPECIALCHARSINITED = False;
 FALWAYSQUOTE = False;
 FQUOTECHAR = #$00;
 FDELIMITER = #$00;
 FNAMEVALUESEPARATOR = #$00;
 FUPDATECOUNT = 0;
 FADAPTER = nil;
 FLBS = TLBSLF;
 FSKIPLASTLINEBREAK = False;
 FSTRICTDELIMITER = False;
 FLINEBREAK = nil;
 FWRITEBOM = True;
 UPDATECOUNT = 0;
 DEFAULTENCODING = TENCODING($025B8438);
 ENCODING = nil;
 STRICTDELIMITER = False;
 ALWAYSQUOTE = False;
 STRINGSADAPTER = nil;
 WRITEBOM = True;
 FOBSERVERS = nil;
 _vptr$TOBJECT = $0058A7F4)
and list1[0]:
Not a type or Array. Cannot access indexed element on expression [
as before.
Pressing F8 the program does not stop at the next statement, seems to stop before quitting. Moreover, if I press the red stop button the assembly window is opened, the program quits (its icon in the taskbar disapperars) but the red button continues to be enabled whereas the execute buttons remain disabled, and the IDE gets stuck: if one tries to quit the IDE it asks to stop debugging but does nothing. The only way is to kill the IDE AND restart windows, otherwise the debugger (any) gets stuck equally


- Finally, with lldb (when it does not crash; ok, I undertand that this is alpha):
Ctrl-F7 on list1, I only get the FLIST property:
(TSTRINGLIST) $2 = 0x02688040
Suprisingly, trying to view list1[0] gives the full (or almost) property listing:
(TSTRINGLIST) $3 = {  (TSTRINGS) TSTRINGS = {    (TPERSISTENT) TPERSISTENT = {      (TFPLIST) FOBSERVERS = 0x00000000    }    (TENCODING) FDEFAULTENCODING = 0x02678450    (TENCODING) DEFAULTENCODING = 0x02678450    (TENCODING) FENCODING = 0x00000000    (TENCODING) ENCODING = 0x00000000    (BOOLEAN) FSPECIALCHARSINITED = false    (BOOLEAN) FALWAYSQUOTE = false    (BOOLEAN) ALWAYSQUOTE = false    (CHAR) FQUOTECHAR = '\0'    (CHAR) FDELIMITER = '\0'    (CHAR) FNAMEVALUESEPARATOR = '\0'    (LONGINT) UPDATECOUNT = 0    (LONGINT) FUPDATECOUNT = 0    (ISTRINGSADAPTER) STRINGSADAPTER = 0x00000000    (ISTRINGSADAPTER) FADAPTER = 0x00000000    (TTEXTLINEBREAKSTYLE) FLBS = TLBSLF    (BOOLEAN) FSKIPLASTLINEBREAK = false    (BOOLEAN) STRICTDELIMITER = false    (BOOLEAN) FSTRICTDELIMITER = false    (ANSISTRING) FLINEBREAK = 0x00000000 <no value available>    (BOOLEAN) WRITEBOM = true    (BOOLEAN) FWRITEBOM = true  }  (PSTRINGITEMLIST) FLIST = 0x026682e0  (LONGINT) FCOUNT = 3  (LONGINT) FCAPACITY = 4  (TNOTIFYEVENT) FONCHANGE = {    (TOBJECT) Self = 0x00000000  }  (TNOTIFYEVENT) FONCHANGING = {    (TOBJECT) Self = 0x00000000  }  (TDUPLICATES) FDUPLICATES = DUPIGNORE  (BOOLEAN) FCASESENSITIVE = false  (BOOLEAN) FFORCESORT = false  (BOOLEAN) FOWNSOBJECTS = false  (TSTRINGSSORTSTYLE) FSORTSTYLE = SSLNONE  (TDUPLICATES) DUPLICATES = DUPIGNORE  (BOOLEAN) CASESENSITIVE = false  (TNOTIFYEVENT) ONCHANGE = {    (TOBJECT) Self = 0x00000000  }  (TNOTIFYEVENT) ONCHANGING = {    (TOBJECT) Self = 0x00000000  }  (BOOLEAN) OWNSOBJECTS = false  (TSTRINGSSORTSTYLE) SORTSTYLE = SSLNONE}
The same happens with combo1.items.
Pressing F8 at this points opens the Assembly window with all 0s.

In summary, I cannot find a way to see what is inside a stringlist (other than directly searching memory). It would be desirable to be able: I know that debugging is a difficult point, but somewhere in the future that should be posible.

Regards
Last edit: 5 months 2 weeks ago by Fernando. Reason: Typo

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Away
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
5 months 2 weeks ago - 5 months 2 weeks ago #13073 by Sternas Stefanos
Replied by Sternas Stefanos on topic Trying to inspect string lists, little luck
Thanks Sir
we try to fix all these problems but as you have write, it's NOT so simple

PilotLogic Architect and Core Programmer
Last edit: 5 months 2 weeks ago by Sternas Stefanos.
The following user(s) said Thank You: Fernando

Please Log in or Create an account to join the conversation.

More
5 months 2 weeks ago #13084 by Peter Heckert
Replied by Peter Heckert on topic Trying to inspect string lists, little luck
The freepascal wiki (which is pretty outdated) says, the GNU debugger cannot evaluate properties that contain a method call.
For this the debugger must be able to execute methods, but it is not.
So this seems to be a missing feature of GDB and not a bug that can be fixed in some nearer future.
I would be happy, if my information is obsolete.

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Away
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
5 months 2 weeks ago #13085 by Sternas Stefanos
Replied by Sternas Stefanos on topic Trying to inspect string lists, little luck
This is possible Sir
but we have and 2 other debuggers to work with.

We will see

PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

More
5 months 2 weeks ago - 5 months 2 weeks ago #13086 by Peter Heckert
Replied by Peter Heckert on topic Trying to inspect string lists, little luck
Thank you very much Sir.
I just wanted to say, this is most probably not a Codetyphon specific problem.
Most probably other Freepascal distributions have the same problem.

I tried a little bit.
TEdit stores the Text in the private inherited string FCaption.
This can be readout by the debugger.

All the best, have fun and success!
Last edit: 5 months 2 weeks ago by Peter Heckert.

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Away
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
5 months 2 weeks ago - 5 months 2 weeks ago #13087 by Sternas Stefanos
Replied by Sternas Stefanos on topic Trying to inspect string lists, little luck
Yes FreePascal debugging has some problems.

The main problem I think is:
that Object Pascal it's now, to complex for GDB debugger.

Our LAB programmers suggest 3 options or 3 "Future Roads"

1) Put new C/C++ code or modify GDB sources, from our programmers, for better Pascal support.
In this helps that CT can build GDB for any OS from GDB sources info


2) Help native Pascal Debugger libraries like:

duby

Lazarus fpdebug pkg

and our LAB Pascal Debugger library, yes we have a lot of Source for this.


3) Support other External Debuggers Like LLDB.


Until now we follow for CT "Future Roads" 2 and 3.

PilotLogic Architect and Core Programmer
Last edit: 5 months 2 weeks ago by Sternas Stefanos.
The following user(s) said Thank You: Peter Heckert

Please Log in or Create an account to join the conversation.

More
5 months 2 weeks ago - 5 months 2 weeks ago #13095 by Peter Heckert
Replied by Peter Heckert on topic Trying to inspect string lists, little luck
Sir, I dont see a major problem with this restriction.
(The value of properties, that call methods cannot been displayed by the debugger,
properties that are mapped to variables can be displayed)

It is aways possible to insert debug code and dump the values.

However, people how are used to Delphi, or people like me who stopped DOS and pascal 30 years ago, when windows was unstable and delphi too expensive,
will be confused about this, if they dont know the problem.
(BTW 30 years ago my privately preferred Language was Modula II on Amigados. Unfortunately this was too unstable for professional use.)

So they should know.

If the current debugger problems are sorted out, I would be happy with that.
So I wait for the next LAB version.
Last edit: 5 months 2 weeks ago by Peter Heckert.

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Away
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
5 months 2 weeks ago - 5 months 2 weeks ago #13096 by Sternas Stefanos
Replied by Sternas Stefanos on topic Trying to inspect string lists, little luck
Sir, we prepare next CT lab version (ETA 2-3 days if all OK)
with a lot of fixes for ALL CT Debuggers

PilotLogic Architect and Core Programmer
Last edit: 5 months 2 weeks ago by Sternas Stefanos.

Please Log in or Create an account to join the conversation.

More
5 months 1 week ago #13097 by Peter Heckert
Replied by Peter Heckert on topic Trying to inspect string lists, little luck
Thank you very much.
I am already very happy with CT, and use it, so I am not in a hurry.
But then I am more than happy.

Please Log in or Create an account to join the conversation.

  • Fernando
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
4 months 3 weeks ago #13192 by Fernando
Replied by Fernando on topic Trying to inspect string lists, little luck
Hi,
I appreciate the efforts, and I am aware that all this is difficult. Of course one can get around the difficulties, such as inserting write statements in the old Fortran IV days (so you can guess how old am I). But if one can have all in view with simple keystrokes like Ctrl-F7 is easier and, most important, faster.
I am not expert in the inner aspects of debugging, but would bet that using a native Pascal library like FpDebug would be a better way.
Thanks a lot to the CT team.
Fernando

Please Log in or Create an account to join the conversation.

  • Fernando
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
4 months 2 weeks ago #13196 by Fernando
Replied by Fernando on topic Trying to inspect string lists, little luck
Hello,
With the new lab version (6720) I can view teh contents of string lists using the FpDebug. When I place the cursor on a string list and press Ctrl-F7, I get the display shown above, where only the pointer to the actual list, FLIST, is shown:
TStringList (FLIST = $027384D0;
 FCOUNT = 3;
 FCAPACITY = 4;
 FONCHANGE = TNOTIFYEVENT($00000000);
 FONCHANGING = TNOTIFYEVENT($00000000);
 FDUPLICATES = DUPIGNORE;
 FCASESENSITIVE = False;
 FFORCESORT = False;
 FOWNSOBJECTS = False;
 FSORTSTYLE = SSLNONE;
 DUPLICATES = DUPIGNORE;
 CASESENSITIVE = False;
 ONCHANGE = TNOTIFYEVENT($00000000);
 ONCHANGING = TNOTIFYEVENT($00000000);
 OWNSOBJECTS = False;
 SORTSTYLE = SSLNONE;
 FDEFAULTENCODING = TENCODING($02748640);
 FENCODING = nil;
 FSPECIALCHARSINITED = False;
 FALWAYSQUOTE = False;
 FQUOTECHAR = #$00;
 FDELIMITER = #$00;
 FNAMEVALUESEPARATOR = #$00;
 FUPDATECOUNT = 0;
 FADAPTER = nil;
 FLBS = TLBSLF;
 FSKIPLASTLINEBREAK = False;
 FSTRICTDELIMITER = False;
 FLINEBREAK = nil;
 FWRITEBOM = True;
 UPDATECOUNT = 0;
 DEFAULTENCODING = TENCODING($02748640);
 ENCODING = nil;
 STRICTDELIMITER = False;
 ALWAYSQUOTE = False;
 STRINGSADAPTER = nil;
 WRITEBOM = True;
 FOBSERVERS = nil;
 _vptr$TOBJECT = $0058C7F4)

. However, evaluating list1.Flist^ I can see the complete list:
(TSTRINGITEM (FSTRING = $00589EC8 'Uno';

FOBJECT = nil), TSTRINGITEM (FSTRING = $00589ED8 'Dos';

FOBJECT = nil), TSTRINGITEM (FSTRING = $00589EE8 'Tres';

FOBJECT = nil), TSTRINGITEM (FSTRING = nil;

FOBJECT = nil), TSTRINGITEM (FSTRING = $0000000A '';

FOBJECT = TOBJECT($02760248)), TSTRINGITEM (FSTRING = $BAADF00D '';

FOBJECT = TOBJECT($0058C031)), TSTRINGITEM (FSTRING = $00010000 'j';

FOBJECT = TOBJECT($00000001)), TSTRINGITEM (FSTRING = $00000011 '';

FOBJECT = TOBJECT($76656C65)), TSTRINGITEM (FSTRING = $6F697461 '';

FOBJECT = TOBJECT($7165726E)), TSTRINGITEM (FSTRING = $65726975 '';

FOBJECT = TOBJECT($00740064)), TSTRINGITEM (FSTRING = $006F0074 #$C0;

FOBJECT = TOBJECT($0000006E)), TSTRINGITEM (FSTRING = $BAAD0000 '';

FOBJECT = TOBJECT($005BC031)), TSTRINGITEM (FSTRING = $00010000 'j';

FOBJECT = TOBJECT($00000001)), TSTRINGITEM (FSTRING = $00000011 '';

FOBJECT = TOBJECT($73657270)), TSTRINGITEM (FSTRING = $69646573 '';

FOBJECT = TOBJECT($6567616D)), TSTRINGITEM (FSTRING = $65646E69 '';

FOBJECT = TOBJECT($BAAD0078)), TSTRINGITEM (FSTRING = $BAADF00D '';

FOBJECT = TOBJECT($BAADF00D)), TSTRINGITEM (FSTRING = $BAADF00D '';

FOBJECT = TOBJECT($005EC031)), TSTRINGITEM (FSTRING = $00010000 'j';

FOBJECT = TOBJECT($00000001)), TSTRINGITEM (FSTRING = $00000012 '';

FOBJECT = TOBJECT($656C6573)), TSTRINGITEM (FSTRING = $64657463 '';

FOBJECT = TOBJECT($67616D69)), TSTRINGITEM (FSTRING = $646E6965 '';

FOBJECT = TOBJECT($BA007865)), TSTRINGITEM (FSTRING = $BAADF00D '';

FOBJECT = TOBJECT($BAADF00D)), TSTRINGITEM (FSTRING = $BAADF00D '';

FOBJECT = TOBJECT($0061C031)), TSTRINGITEM (FSTRING = $005991C0 '$';

FOBJECT = nil), TSTRINGITEM (FSTRING = $00599268 #$18;

With gdb, at this point I only get "Cannot acces memory at ..." error.
Fine.

Please Log in or Create an account to join the conversation.

More
4 months 2 weeks ago #13199 by Matis A.
Replied by Matis A. on topic Trying to inspect string lists, little luck
Thanks Sir

PilotLogic Core Programmer

Please Log in or Create an account to join the conversation.