Strange IDE behavior at code location lazarus / 16-Databases ---------------------------------------------------------------------- davec · 2024-05-11 05:49 Hello everyone, I am new to Lazarus and Delphi and have a strange behavior in my project. It is about the following place in the code (mainmenu.pas): 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 frmDatenEinlesen.DataExchange := Self;  After I execute the program in the IDE and confirm the "Insert new Data" button in the "mainmenu.lfm", the program exits (without a debug message) and I end up in the source code view. However, as soon as I compile the program and execute the EXE file, everything works perfectly. What is the reason for this? Do you have a solution for this? I have attached the project. The sqlite3.dll must be inserted in the program directory for correct program execution (unfortunately only ZIPS up to max. 500 KB are allowed here, otherwise I would have already inserted it): https://www.sqlite.org/download.html (sqlite-dll-win-x64-3450300.zip) Many thanks for your help! Best regards Dave ---------------------------------------------------------------------- Martin_fr · 2024-05-12 08:42 I am not currently going to run it on my machine, but a few ideas.... Quotethe program exits (without a debug message) and I end up in the source code view.Just to double check - the IDE title no longer says "debugging"? - the blue dots in the editor-gutter disappear? Menu: View > debug windows > event log When the app ends, does it say anything in the event log window? Menu: Tools > Option / Debugger > Backend Have you tried FpDebug and/or GDB based backends? Have you set a breakpoint on that line, and then stepped in with F7? Have you compiled both (the "debugging" and "run outside the IDE") with the same settings? ---------------------------------------------------------------------- cdbc · 2024-05-12 09:20 Hi OK, so I've got your program running in my laz 2.2.6, debugging, doesn't matter that it's on linux  Right so what exactly is your problem?!? Regards Benny ---------------------------------------------------------------------- davec · 2024-05-12 09:55 @Martin_fr Thank you! 1. the IDE title says still "debugging..." 2. the blue dots in the editor-gutter are already there. 3. the event log is empty 4. i changed the debugger backend from FpDebug to GDB. Now it works flawlessly! What could be the reason? Why does it not work with FpDebug? @cdbc In FpDebug, the application exits in the middle of execution. I am using Windows 10 with Lazarus 3.2. I have attached a screenshot. @all I have another problem 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 procedure TFormDatenEinlesen.AnalyzeDataSorting(const Data: TStringList) string;var  I: Integer;  Ascending, Descending, PartiallySorted: Boolean;begin  if Data.Count = 0 then    Exit('No data available for analysis.');   Ascending := True;  Descending := True;  PartiallySorted := False;   // Check for complete sorting  for I := 0 to Data.Count - 2 do  begin    if Data[I] > Data[I+1] then      Ascending := False;    if Data[I] < Data[I+1] then      Descending := False;  end;   if Ascending then    Exit('Already sorted: ascending');  if Descending then    Exit('Already sorted: descending');    // Check for partial sorting  for I := 0 to Data.Count - 3 do // Attention: Change to Data.Count - 3 to avoid index errors   begin     if (Data[I] <= Data[I+1]) and (Data[I+1] <= Data[I+2]) then       PartiallySorted := True;     else if (Data[I] >= Data[I+1]) and (Data[I+1] >= Data[I+2]) then       PartiallySorted := True;   end;   if PartiallySorted then    Exit('Partially sorted');   Result := 'Randomly distributed';end;   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 unit FormDatenEinlesen; interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, DB,  SQLite3Conn, SQLDB, IDataExchange; type  { TFormDatenEinlesen }  TFormDatenEinlesen = class(TForm) ...  private ...    function AnalyzeDataSorting(const Data: TStringList): string;     Where did I make the mistake? The debugger tells me: 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 formdateneinlesen.pas(110,74) Error: Syntax error, ";" expected but "STRING" found on this line: 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 procedure TFormDatenEinlesen.AnalyzeDataSorting(const Data: TStringList) string; Thank you! Regrads Dave ---------------------------------------------------------------------- cdbc · 2024-05-12 11:03 Hi 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 unit FormDatenEinlesen; interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, DB,  SQLite3Conn, SQLDB, IDataExchange; type  { TFormDatenEinlesen }  TFormDatenEinlesen = class(TForm) ...  private ...    function AnalyzeDataSorting(const Data: TStringList): string;    ////////////////////////////////////////////////////////////////////  procedure TFormDatenEinlesen.AnalyzeDataSorting(const Data: TStringList) string;    ?????????///////////////////////////////////// //////////??????????<:>????  Well Duh!!! Regards Benny ---------------------------------------------------------------------- Martin_fr · 2024-05-12 11:17 Ok, forgot to ask, what version of Lazarus do you use?  (I can infer from the dll link that you are on 64bit Windows) Quote from: davec on May 12, 2024, 11:55:21 am1. the IDE title says still "debugging..." So then it is still debugging. Just for some reason not telling you that/where/if it paused... With the original issue (fpdebug) 1) Check the run/pause buttons in the main bar. Is the green run button enabled? Then the app is paused 2) Check menu View > debug windows > callstack   It should show something, likely you are paused in some dll   Normally in such cases the assemble window opens.... If it is paused still leaves the question why gdb does not enter pause. Quote4. i changed the debugger backend from FpDebug to GDB. Now it works flawlessly! What could be the reason? Why does it not work with FpDebug? Looking at your screenshot... 1) You have a breakpoint on the "unit" line 2) You are paused at the unit line. Normally, that "unit" line does not produce code, and you can't pause there. If (in case of normally) there is no code there, then - FpDebug will ignore such a breakpoint - GDB will break at the first line of code below that => that will be potentially 100 lines later, in the very first procedure of the unit. And if it isn't "normally".... And I am not sure that applies here. I have seen similar but not exactly... But you seem to be paused on that line, and that means it isn't "normally". Sometimes FPC generates incorrect line info. (especially if you have optimization enabled, but sometimes even without that). In that case the "unit" line would most likely be attributed to the last line of code in some other unit (really complex underlaying issue). So if it is not normally, have a look at the callstack, and the name of the procedure it says on the first line of the callstack As for how to get it work => remove the breakpoint from that "unit MainMenu" line. Check for other breakpoints in places that aren't inside a procedure. ---------------------------------------------------------------------- 440bx · 2024-05-12 11:41 I must be missing something... one of the code pieces shows an error about the compiler expecting a semicolon and finding "string" instead. How can code that doesn't compile be debugged ??? something doesn't add up. ---------------------------------------------------------------------- cdbc · 2024-05-12 11:54 Hi @440bx: Look at my response to his error: I just put 2 of his listings into 1 and 'lo and behold' => one is a *function*, but becomes a *procedure* in the implementation... Something is functioning at his end, because the code I've got running /from him/ doesn't have this function/procedure  , methinks the problem lies higher & further away...  Regards Benny ---------------------------------------------------------------------- TRon · 2024-05-12 11:58 Quote from: 440bx on May 12, 2024, 01:41:19 pmsomething doesn't add up. Things usually adds up to 42 for me