[fpc-devel] Debug info for SEH exceptions (64 bit and upcoming 3.2 32 bit) [avoid regression in debugger]

Martin fpc at mfriebe.de
Wed Jan 16 13:32:18 CET 2019

I have added this to mantis.

It would be good to address this, before 32bit SEH becomes default. If 
not this will mean a regression to the debuggers functionality.

On 09/01/2019 14:54, Martin wrote:
> Marco V wrote  ( 
> http://forum.lazarus-ide.org/index.php/topic,42265.msg307537.html#msg307537 
> )
>> Current holdup is enabling SEH by default for 32-bit windows, so that 
>> it is COM compatible
> This reminds me of an unsolved issued, debugging exceptions with SEH 
> (currently Win64, but apparently soon Win32 too)
> The debugger (IDE + gdb/lldb, // todo for fpdebug) can currently "step 
> to except" and "step to finally" (except Win64 / seh).
> If an exception is raised the debugger stops on fpc_raiseexception. 
> (and re-raise if needed)
> - If stopped F8 will step to next except or finally
> - If it is ignored during a step-over, the debugger will step to the 
> next except/finally enclosing the line where the step started. 
> (stepping over any except/finally inside function calls)
> To do this the debugger will set breakpoints at  fpc_popaddrstack, 
> fpc_catches, fpc_reraise
> If it reaches fpc_popaddrstack, fpc_catches, it needs to step-out 
> once, and will be in finally or except.
> With SEH that does not work.
> And with SEH, I am unaware of sufficient debug info to implement all 
> of this in any other fashion. (some of it can be done)
> On Win64 a breakpoint can be set to RtlUnwindEx
> This will be called with the "except" handle address as 2nd argument. 
> (IIRC, 2nd arg)
> The address can be extracted, and a breakpoint can be set to it.
> => except block can be stepped to.
> As for the finally block, I have not yet found a way.
> __FPC_specific_handler will be called. And somewhere within it, it 
> will call the finally handler. No way to intercept by the debugger. 
> (It would need to set a breakpoint in the middle of 
> __FPC_specific_handler, but there is no debug info to find the line 
> that calls "finally")
> On Win32 I did some testing with SEH, and IIRC (but not sure its a 
> while ago) I could catch neither except nor finally.
> Afaik/IIRC the 2 handlers are...
> The __FPC_default_handler calls the except handler directly. So again 
> would need a breakpoint in the middle of it)
> Same for __FPC_finally_handler
> Any idea how to add/use debug info, so a debugger can deal with the 
> above?

More information about the fpc-devel mailing list