[fpc-devel] hot to handle SIGFPE, SIGSEGV using gdb as debugger

Jonas Maebe jonas.maebe at elis.ugent.be
Wed Mar 25 14:29:20 CET 2009


On 25 Mar 2009, at 14:14, Paul Ishenin wrote:

> Jonas Maebe wrote:
>>
>
>> File a bug against gdb, it should work (it works under Mac OS X and  
>> Linux). The gdb bug repository is at http://sourceware.org/gdb/bugs/
> First I need to be sure that this is a gdb bug. Maybe fpc doing a  
> bit different handling on osx and windows?

That is irrelevant:
a) it works without gdb
b) it doesn't work in gdb if you tell gdb to ignore all signal handlers

Just make sure you include a compiled program so that the gdb  
maintainers don't have to install FPC to test.

> Jonas, can you write a small similar C++ test?

No, because
a) the C++ exception handling system does *not* automatically catch OS  
or hardware exceptions, it only catches exceptions raised by C++ code  
(so you need to write a hardware-exception-to-C++-exception conversion  
framework, similar to the code in our RTL for converting hardware/OS  
exceptions into Pascal exceptions)
b) I don't know how to catch signals under Windows (and am not  
interested at this time in learning low level Windows programming)
c) my C++ knowledge/experience is extremely limited

A simple C program that triggers an FPU exception without installing  
any handlers, is of course easy (just make sure to compile it without  
optimizations, so the dead code is not removed):

int main()
{
   double a, b;

   a=1.0;
   b=0.0;
   a=a/b;
   return 0;
}


Jonas



More information about the fpc-devel mailing list