Author Topic: Debugging a DLL  (Read 5914 times)

Phil H.

  • Guest
Debugging a DLL
« on: November 10, 2005, 09:04:51 pm »
How do you debug a DLL with Free Pascal/Lazarus?

The -gl switch doesn't display line tracing info if your program uses SysUtils (what program doesn't?!). Setting ExceptProc := nil disables SysUtils' exception handler, so line tracing is displayed. However, this line tracing info doesn't work if they exception occurs in a DLL. Instead, the trace shows only up to the call of the DLL function in the main program, which is completely useless.

Trapping the exception in the DLL and executing


displays the name of the source file and line number where the exception occurred (for example, in one of the run-time units), but not the place in the DLL source where the error started. How to trace back to this error location? Normally this is what -gl does automatically in an .exe.

Also, BackTraceStrFunc (and -gl) don't work right if the FPC-compiled DLL is called by a non-FPC program.



TinyPortal © 2005-2018