Hello, FPC developers' list

I attached a simple program which handles division by zero (EDivByZero) exception and writes to the console when this happen.
Run without debugger gives next output:
Exception is handled
1

When I run it with gdb I cannot continue usual execution after SIGFPE happen.

(gdb) run
Starting program: C:\programming\mytest\debugger_exceptions/test_exception.exe
[New thread 6100.0x13e4]

Program received signal SIGFPE, Arithmetic exception.
0x00401502 in EXCEPTION1 () at test_exception.lpr:15
15          a := a div (a - 1); // EDivByZero
(gdb) continue
Continuing.

Program received signal SIGFPE, Arithmetic exception.
0x00401502 in EXCEPTION1 () at test_exception.lpr:15
15          a := a div (a - 1); // EDivByZero
(gdb) continue
Continuing.

Program exited with code 030000000224.

Ok, tried "info signals" and found that gdb handles SIGFPE. I changed behavior:

(gdb) handle SIGFPE noprint
Signal        Stop      Print   Pass to program Description
SIGFPE        No        No      Yes             Arithmetic exception
(gdb) handle SIGFPE nostop
Signal        Stop      Print   Pass to program Description
SIGFPE        No        No      Yes             Arithmetic exception
(gdb) run
Starting program: C:\programming\mytest\debugger_exceptions/test_exception.exe
[New thread 5912.0xa3c]

Program exited with code 030000000224.

No luck :(

The same thing with SIGSEGV (look at Exception2 procedure).

Best regards,
Paul Ishenin.
program test_exception;

{$mode objfpc}{$H+}
{$apptype console}

uses
  sysutils;

procedure Exception1;
var
  a: integer;
begin
  a := 1;
  try
    a := a div (a - 1); // EDivByZero
  except
    WriteLn('Exception is handled');
  end;
  WriteLn(a);
end;

procedure Exception2;
begin
  try
    PInteger(nil)^ := 1;
  except
    WriteLn('Exception is handled');
  end;
end;

begin
  Exception1;
  //Exception2;
end.

_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to