Debugger won't evaluate stringlist contents or count lazarus / 12-Debugger ---------------------------------------------------------------------- keithfre · 2011-09-21 18:20 I have a var tablist (a derivative of TStringlist) populated with strings from a file. If I assign tablist[0] or InttoStr(tablist.count) to a TEdit.Text the result is fine. But I can't get the debugger to evaluate tablist[0] or tablist.count (using mouseover, Ctrl-F7 or a watch). 0.9.30 (from the Downloads page), Windows XP ---------------------------------------------------------------------- Martin_fr · 2011-09-21 19:07 Unfortunately the answer is, it doesn't work (yet). It is one of the big known issues.  And one that will require a lot of time and work to fix. The basic behind it is, that "Count" and "Items[x]" are properties with a getter. So in order to get what you want to see, the getter (a function like GetCount(): Integer) must actually be executed. This is simply not yet implemented. If you google, or even wait for further replies, you will find idealogical arguments, if it should be done at all. Ignore them. It should, and in time it will  (but it may be long time). That much about the current situation. Feel free to ask, if you want to know about internal details. --------------------------- Looking at your particular situation, it is possible to get the info, but in some cases requires a lot of experience. In case of "Count", it is very easy. You can just try (using ctrl-F7 for evaluate, or open the watches window from "View" menu ("Debug windows") ctrl-alt-w):  Code: [Select]   FCountwill return the count. Often properties map to a field of the same name, with an "F" in the front. In some cases the debugger can actually resolve it for you. But for TStringList it cant. To confirm that FCount is indeed Count, in the base class TStrings: Code: [Select]    property Count: Integer read GetCount;And in TStringList: Code: [Select]Function TStringList.GetCount: Integer; begin   Result:=FCount; end; 2) in case of Items, it is harder: Code: [Select]Function TStringList.Get(Index: Integer): string; begin   If (Index<0) or (INdex>=Fcount)  then     Error (SListIndexError,Index);   Result:=Flist^[Index].FString; end; You will have to follow the declaration of "FString" Code: [Select]    FList: PStringItemList; I will spare the details, if you want to see the items, use this: Code: [Select]^TStringItem(FLazarusDirsHistory.Flist)[0] ---------------------------------------------------------------------- keithfre · 2011-09-21 19:21 Thanks, I get the picture. So it looks like I can type in  "^TStringItem(tablist.Flist)[0]" to evalute my tablist[0]. Even that's better than nothing at all ;-} ---------------------------------------------------------------------- Martin_fr · 2011-09-21 19:35 Yes, it should. I should say, I tested with the latest snapshot, and there are changes => but I expect this one to work on 0.9.30 too As a general rule: you can always start (in ctrl-f7 / evaluate), by looking at the entire object: Code: [Select]tablist It will give you a list, of all the fields in the object. It should show the presence of an "FList", including type, and since it is a pointer, it will show an address as value. Normally you can just dereference (^) pointers, or use an index [] on them: Code: [Select]tablist.FList^ tablist.FList[0] unfortunately, not in this case. gdb doesn't seem to like the special way that FList is declared. That's why in this case the typecast is needed. As a general rule, if gdb has issues with arrays or pointers, try typecasting. --- gdb is the debugger used by Lazarus and fpc