Recent

Author Topic: Source line with only 'Exit' cannot have a breakpoint?  (Read 1075 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 2570
    • UVviewsoft
Source line with only 'Exit' cannot have a breakpoint?
« on: March 18, 2022, 07:24:33 pm »
As I see - SUBJ - yes, it cannot have a breakpoint.

Code: Pascal  [Select][+][-]
  1. if SomeTest() then
  2.   Exit;
  3.  
IDE don't allow to place it on 'Exit' line.
So I must add 'begin end' with additional fake operator like "if Assigned(fm) then ;".

Not handy.
« Last Edit: March 18, 2022, 07:40:15 pm by AlexTP »

MarkMLl

  • Hero Member
  • *****
  • Posts: 8398
Re: Source line with only 'Exit' cannot have a breakpoint?
« Reply #1 on: March 18, 2022, 07:27:38 pm »
But exit(something) will usually work since it actually generates code rather than being a syntactic element... I've not tried exit(result).

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11181
  • Debugger - SynEdit - and more
    • wiki
Re: Source line with only 'Exit' cannot have a breakpoint?
« Reply #2 on: March 18, 2022, 07:40:38 pm »
It's something the compiler decides. The debugger just "reacts".

(Not tested, but...) Have you tried with -O- ? No optimization at all. Even -O1 could cause stuff like this.

(At leat on Win...) In the same way, the compiler adds the info that some of the code in the final "end;" of a procedure is in the "begin" line. Hence the debugger jumps around.
The fact that it jumps several times, is because it "steps over" the internal "finally" block that fpc added (and finally is a subroutine). That (the several times jumping around) is something that should be fixable in the debugger (in FpDebug).

MarkMLl

  • Hero Member
  • *****
  • Posts: 8398
Re: Source line with only 'Exit' cannot have a breakpoint?
« Reply #3 on: March 18, 2022, 07:46:58 pm »
Curiously, I've noticed both of the issues Alex mentions myself over the last couple of weeks (Linux+gdb), which might be related to upgrading FPC from 3.2.0 to 3.2.2.

if exit(result) worked I'd be tempted to define it as a macro EXIT_ or similar (I say that in order to bait somebody into telling me that it could be done better with templates).

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

markftl

  • Newbie
  • Posts: 4
Re: Source line with only 'Exit' cannot have a breakpoint?
« Reply #4 on: March 18, 2022, 10:28:32 pm »
I usually use

Code: Pascal  [Select][+][-]
  1.     if SomeTest() then begin
  2.       Exit;
  3.     end;
  4.  

if I need to break at the exit. Has always worked for me.

 

TinyPortal © 2005-2018