Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2010-03

debugging exception handling in windows

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Seth Grover

Greetings,

I'm doing some win32 development (::shudder:: ;-)) and am trying to take a closer look at the way fatal exceptions (floating point exceptions, access violations, etc.) are handled as I try to figure out a way around the limitations described in mantis issue #12974. I've got fpc compiled and installed with debugging information and am successfully able to step through the RTL code in GDB.

I've got a very simple main program: I'm not even to the point where I'm experimenting with .dll's yet. All the main program does is cause a FPE inside a try/except block. When I run the program, I'm able to see, of course, that the exception is caught/handled in my except block.

However, when I get GDB involved, things get strange. I would like to debug into syswin32_i386_exception_handler step through it. Here's what happened in GDB:

----------------------------------------------
$ gdb ./project1.exe
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i686-pc-mingw32"...
(gdb) break fpc_raiseexception
Breakpoint 1 at 0x4081b5: file
C:/cygwin/home/nitrodev/fpc-2.4.0/rtl/inc/except.inc, line 195. (gdb) break SYSWIN32_I386_EXCEPTION_HANDLER
Breakpoint 2 at 0x40d9e6: file system.pp, line 694. (gdb) r
Starting program: c:\tmp/./project1.exe
Loaded symbols for C:\WINNT\system32\KERNEL32.DLL
Loaded symbols for C:\WINNT\system32\OLEAUT32.DLL
Loaded symbols for C:\WINNT\system32\OLE32.DLL
Loaded symbols for C:\WINNT\system32\rpcrt4.dll
Loaded symbols for C:\WINNT\system32\ADVAPI32.DLL
Loaded symbols for C:\WINNT\system32\GDI32.DLL
Loaded symbols for C:\WINNT\system32\USER32.DLL

Program received signal SIGFPE, Arithmetic exception. 0x00401526 in main () at project1.lpr:14
14 d := 5.0 / d;
(gdb) c
Continuing.

Program received signal SIGFPE, Arithmetic exception. 0x00401526 in main () at project1.lpr:14
14 d := 5.0 / d;
(gdb) c
Continuing.

Program exited with code 0200.
(gdb)
----------------------------------------------

So, I'm able to set the , when the program runs, for some reason GDB seems to see the SIGFPE exception twice (?), and then the program never stops inside SYSWIN32_I386_EXCEPTION_HANDLER for me to step through it.

Can somebody with more experience debugging under windows tell me what's going on? What's with GDB seeing the same exception twice? Why won't it stop inside syswin32_i386_exception_handler? I assume something Windows is doing to catch the exception and pass it on to the program is at odds with the way GDB tries to report it, but I don't know enough about exception handling in Windows yet to try to guess what it would be and what I can do about it, if anything.

Any thoughts?

Thanks,

-SG

This email is fiction. Any resemblance to actual events or persons living or dead is purely coincidental. Seth Grover sethdgrover[at]gmail[dot]com

Reply by email

Paul Ishenin
to Seth Grover
Seth Grover wrote
Any thoughts?

I think if fpc will implement exceptions properly using seh on windows the issue will gone as well as some dll exceptions problems. Currently fpc uses own exception handling on windows.

Best regards,
Paul Ishenin.

Reply by email