GDB: debugger won't step into code / breakpoints won't break lazarus / 12-Debugger ---------------------------------------------------------------------- CCRDude · 2017-06-22 14:09 I'm currently trying out some debugger code outside the IDE (will be added as a package later), and have problems with reaching certain code. Situation: a FPCUnit console runner program. If I try to go through the whole program in the IDE pressing F7, I cannot reach my test code (probably because it's called from the test suite, which is in a package, which has no debugging information). If I set a break point within my test methods, I can reach them. Experienced: 1. using a self created instance of TGDBMIDebugger, I can stepinto the whole program as well, but would not reach my test methods (as above with Lazarus itself). 2. using gdb on the console, I can set breakpoints on the test methods, and this way, gdb will step into this code. 3. using a self created instance of TGDBMIDebugger, the breakpoints I set are not working. Expected: Breakpoints to break execution, even if stepinto would otherwise skip it. I log the OnCurrent event to see which lines are reached, and those of the test methods are not. OnBreakpointHit is not triggered either. Some very simple code: 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 TCodeCoverageDebugger.Go(AFilename: string);var   i: integer;begin   FDebugger.Free;   FDebugger := CreateDebugger;   FLineProtocol.Clear;   FDebugger.BreakPoints.Add('c:\Development\Projects\CodingTools\laz- codecoverage-helper\source\CodeCoverage.GDB.TestCase.pas', 65);   FDebugger.BreakPoints.Add('c:\Development\Projects\CodingTools\laz- codecoverage-helper\source\CodeCoverage.GDB.TestCase.pas', i);   FDebu gger.BreakPoints.Add('TCODECOVERAGEGDBTESTCASE__TESTLISTALLUNITFILENAM ES');   FDebugger.Init;   try      FDebugger.FileName := AFilename;    FDebugger.WorkingDir := ExtractFilePath(AFilename);      repeat       FDebugger.StepInto;      until (FDebugger.State in [dsStop]);   finally      FDebugger.Done;   end;end;       This is the debugger unit from which the above code is from, the TestDebugger project with the TestDebuggerForm form unit is there as well. (it uses a slightly modified version of GDBMIDebugger.pas, where I added support for breakpoints by name, but only because the line based approach did not work before) Has anyone enough direct experience with the debugger to see what I'm missing? ---------------------------------------------------------------------- CCRDude · 2017-06-23 07:34 I'm getting nearer: QuoteOutput: (gdb) Output: Output: &"info line \"c:\\Development\\Projects\\CodingTools\\laz- codecoverage-helper\\source\\CodeCoverage.GDB.TestCase.pas\":97\n" Output: ~"Line 97 of \"CodeCoverage.GDB.TestCase.pas\" is at address 0x423210 but contains no code.\n" Output: ^done Output: (gdb) Output: <-break-insert  "\"c:/Development/Projects/CodingTools/laz- codecoverage-helper/source/CodeCoverage.GDB.TestCase.pas\":97"> Output: ^done,bkpt={number="9",type="breakpoint",disp="keep",enabled=" y",addr="0x0042321e",func="TCODECOVERAGEGDBTESTCASE__TESTGETUNITFULLFI LENAME",file="CodeCoverage.GDB.TestCase.pas",fullname="C:\\Development \\Projects\\CodingTools\\laz-codecoverage- helper\\source\\CodeCoverage.GDB.TestCase.pas",line="97",thread- groups=["i1"],times="0",original- location="c:/Development/Projects/CodingTools/laz-codecoverage- helper/source/CodeCoverage.GDB.TestCase.pas:97"} Output: (gdb) Output: <-break-disable 9> Output: ^done Output: (gdb) Direct "break" command at the console seems to behave differently than the -break-insert of the MI interface; it does not complain about the line not containing code. Quote(gdb) break c:\Development\Projects\CodingTools\laz-codecoverage- helper\source\CodeCoverage.GDB.TestCase.pas:65 Breakpoint 1 at 0x42306e: file CodeCoverage.GDB.TestCase.pas, line 65. But even if I choose a line containing code, and set Enabled to true, -break-disable is called on my custom breakpoints... will need to dive deeper into the debugger units code. ---------------------------------------------------------------------- CCRDude · 2017-06-23 08:32 Problem found; breakpoints get disabled by GDBMIDebugger when created; setting Enabled only works after the process has started (which for gdb is an unnecessary restriction imho, based on my experience with gdb at the console).