Beginner can't debug a string grid lazarus / 12-Debugger ---------------------------------------------------------------------- mawg · 2024-09-16 20:53 I just switched from Delphi to Lazarus. I hi t a breakpoint, and examine my stringgrid, but can't see properties like RowCount, Rows or Cells. I could post what the debugger shows me, but it's 850+ lines long. It starts QuoteTStringGrid( {TCustomStringGrid}   private   FModified: False; So I am looking at a stringgrid. What's the "one weird trick" to let me examine the most common attributes? Apologies for asking something so basic. I really do want to switch to Lazarus ---------------------------------------------------------------------- Martin_fr · 2024-09-17 07:09 You need to know the fields that hold the data. Unfortunately properties (with getter function) are currently not available for the debugger. (gdb didn't know them, and the compiler hasn't yet been updated). In some cases you may be able to call the function directly (in the "watches" window). You need to enable function calling under menu: Tools > Options > Debugger And also in the properties of the watch. And then you can enter something like "MyGrid.GetWhateverNameTheFunctionHas()". In current Lazarus 3.4 it may not work always (because again the info is not always included by the compiler), with 3.99 more of the functions can be called. Mind that calling function can modify the state of your app. That is also true for inspecting properties in Delphi. If you call a function from the debugger (and again that includes inspecting properties in Delphi) then the function is executed. If that function has side efferts (such as changing any field/var) then that change persist, and the app may behave different than it would have otherwise. (And again: Same in Delphi). ---------------------------------------------------------------------- mawg · 2024-09-23 11:16 Apologies that it has taken me so long to reply. And thank you very much taking the time to try to help. I couldn't add a watch, because QuotePassagesStringGrid @$0000000001407310 = TStringGrid(... [snip] PassagesStringGrid.RowCount = Member not found: RowCount My initial reaction was to punch my laptop screen and go back to Delphi. I just can't understand why such a widely revered piece of software as Lazarus can't do something so basic. [/rant] However, if I fancy I challenge, I can latch on to what you said Quoteproperties (with getter function) are currently not available for the debugger 1) is there any plan to address this? And, 2) do you think that I could subclass the grid - and other controls - and add getters/setters? Of course, then I would have to create my entire GUI dynamically, and would not have access to the Object Inspector at design time, which is a major pain. I normally use Delphi, but am coding an app to help with designing Interactive Fiction. I thought it would be in the spirit of Open Source if I used Lazarus. Now I am thinking that I could be imposing problems on anyone who forks the project and should probably stick with Delphi Community edition. What do you think? No anger here, but the debugger is my best friend. Thanks again for your reply ---------------------------------------------------------------------- Zvoni · 2024-09-23 11:34 The way i do it (exactly because of the reasons mentioned): I introduce a (local) variable, which is only visible in Debug-Mode Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Var  {$IFDEF Debug}rc:Longint;{$IFEND}........  {$IFDEF Debug}rc:=MyStringGrid.RowCount;{$IFEND}  //And i examine the variable RC in the Debug-Window Yes, some might find that annoying, but... *shrug* ---------------------------------------------------------------------- Martin_fr · 2024-09-23 11:47 Quote1) is there any plan to address this?Kind of, yes. It involves a lot of ground work. For something to work in the debugger it is necessary that the compiler provides debug info, which means debug info must support it.... https://dwarfstd.org/issues/240507.1.html Then when debug info supports it (or earlier if enough info is avail) it must be added to the compiler. Which means the very earliest is FPC 3.4, if it is avail by then, and if the FPC team can fit it in. And then it can be added to the debugger. For now, this works: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Property Something: integer read FSomeThing;Because the compiler adds "Something" as a field to debug info (i.e. pretends its a field not a property). But this does not work Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Property Something: integer read GetSomeThing; If in the above "GetSomething is virtual then you can (should be able to) watch (in 3.4), at least on Windows, but afaik Linux too. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i StringGrid1.GetRowCount()(If you enabled "function calling" in the global settings, and in the watch properties). In Lazarus 3.99 then (as far as I tested) this works for non-virtual methods too. There may more issues if there are nested classes... ---------------------------------------------------------------------- Martin_fr · 2024-09-23 11:49 For your case, you can also watch: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i stringgrid1.FRows.Count Just navigate to the implementation of a getter function (alt cursor up), and check where the data comes from.