Author Topic: Debugger step-over issue (step over perform step in)  (Read 2480 times)


  • Administrator
  • Hero Member
  • *
  • Posts: 6675
  • Debugger - SynEdit - and more
    • wiki
Debugger step-over issue (step over perform step in)
« on: February 02, 2019, 12:16:39 am »
This is a known issue under 64 bit Windows, when using the default debugger of Lazarus (gdb based / GDBMI debugger).
There have been sporadic reports that this may occur on other platforms too...

Anyway the symptoms of this issue are:
- During debugging you press F8 (or otherwise trigger step-over)
- The debugger will NOT step to the next line, but stop inside a function that was called by the line you tried to step over.

I myself have only reproduced this, in cases where the debugger stepped into code that has debug info. So the source of the stepped-into procedure is shown. If anyone has experienced stepping into assembler I would like feedback on this.

I have added some code, that may work around the issue. But that needs testing.
It is present in trunk (r60274) and fixes 2.0 branch (merge is actually pending, but is planned to happen before release).

Due to the lack of tests this feature is disabled by default.
Go to Tools > Option > Debugger
Find (in the property grid) "FixIncorrectStepOver" and enable it.

If the IDE detects a step-in when expecting a step over, it will try to solve the issue (perform a further step-over and then a step-out / a step out from the "begin" line of a procedure does not always work).

If you have cases where this does not work, could you please report with:
- a reproducible example (if you have)
- always (even if you have an example): a logfile


  • Sr. Member
  • ****
  • Posts: 267
  • Retired programmer
Re: Debugger step-over issue (step over perform step in)
« Reply #1 on: February 05, 2019, 01:26:08 pm »
Testing some personal hacks in x86_64 Win10 I fell on that F8 problem.
It seems to occur systematically every time a kernel procedure is called.

Example code :
Code: Pascal  [Select][+][-]
  1. function WriteProtectedMemory(aBaseAddress, aBuffer: Pointer; aSize: Cardinal):boolean;
  2. var
  3.   lOldProtect, lDummy: Cardinal;
  4. begin
  5.   if aSize > 0 then begin
  6.     lOldProtect := 0;
  7.     Result := VirtualProtect(aBaseAddress, aSize, PAGE_EXECUTE_READWRITE, lOldProtect);
  8.     if Result then begin
  9.       Move(aBuffer^, aBaseAddress^, aSize);
  11.       begin
  12.         FlushInstructionCache(GetCurrentProcess, aBaseAddress, aSize);
  13.         lDummy := 0;
  14.         VirtualProtect(aBaseAddress, aSize, lOldProtect, lDummy);
  15.       end
  16.       else
  17.         Exit(False);
  18.     end;
  19.   end;
  20. end;
Problems appears with F4, F7, F8 when on lines 7, 12 and 14. 

>>>> FixIncorrectStepOver Enabled seems to completly correct that situation, thanks  <<<<

GNU gdb (GDB) 8.2


TinyPortal © 2005-2018