Improve Unix signal and Windows structured exception reporting

db4
Slava Pestov 2009-04-20 01:47:10 -05:00
parent bcd0533794
commit 86e5ddf449
5 changed files with 38 additions and 22 deletions

View File

@ -88,27 +88,7 @@ M: string error. print ;
: divide-by-zero-error. ( obj -- )
"Division by zero" print drop ;
CONSTANT: signal-names
{
"SIGHUP" "SIGINT" "SIGQUIT" "SIGILL" "SIGTRAP" "SIGABRT"
"SIGEMT" "SIGFPE" "SIGKILL" "SIGBUS" "SIGSEGV" "SIGSYS"
"SIGPIPE" "SIGALRM" "SIGTERM" "SIGURG" "SIGSTOP" "SIGTSIP"
"SIGCONT" "SIGCHLD" "SIGTTIN" "SIGTTOU" "SIGIO" "SIGXCPU"
"SIGXFSZ" "SIGVTALRM" "SIGPROF" "SIGWINCH" "SIGINFO"
"SIGUSR1" "SIGUSR2"
}
: signal-name ( n -- str )
1- signal-names nth;
: signal-name. ( n -- )
dup signal-names length <=
os unix? and
[ " (" write signal-name write ")" write ] [ drop ] if ;
: signal-error. ( obj -- )
"Operating system signal " write
third [ pprint ] [ signal-name. ] bi nl ;
HOOK: signal-error. os ( obj -- )
: array-size-error. ( obj -- )
"Invalid array size: " write dup third .
@ -325,4 +305,9 @@ M: check-mixin-class summary drop "Not a mixin class" ;
M: not-found-in-roots summary drop "Cannot resolve vocab: path" ;
M: wrong-values summary drop "Quotation called with wrong stack effect" ;
M: wrong-values summary drop "Quotation called with wrong stack effect" ;
{
{ [ os windows? ] [ "debugger.windows" require ] }
{ [ os unix? ] [ "debugger.unix" require ] }
} cond

View File

@ -0,0 +1 @@
Slava Pestov

View File

@ -0,0 +1,23 @@
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: debugger io kernel math prettyprint sequences system ;
IN: debugger.unix
CONSTANT: signal-names
{
"SIGHUP" "SIGINT" "SIGQUIT" "SIGILL" "SIGTRAP" "SIGABRT"
"SIGEMT" "SIGFPE" "SIGKILL" "SIGBUS" "SIGSEGV" "SIGSYS"
"SIGPIPE" "SIGALRM" "SIGTERM" "SIGURG" "SIGSTOP" "SIGTSIP"
"SIGCONT" "SIGCHLD" "SIGTTIN" "SIGTTOU" "SIGIO" "SIGXCPU"
"SIGXFSZ" "SIGVTALRM" "SIGPROF" "SIGWINCH" "SIGINFO"
"SIGUSR1" "SIGUSR2"
}
: signal-name ( n -- str/f ) 1- signal-names ?nth ;
: signal-name. ( n -- )
signal-name [ " (" ")" surround write ] when* ;
M: unix signal-error. ( obj -- )
"Unix signal #" write
third [ pprint ] [ signal-name. ] bi nl ;

View File

@ -0,0 +1 @@
Slava Pestov

View File

@ -0,0 +1,6 @@
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: debugger io prettyprint sequences system ;
IN: debugger.windows
M: windows signal-error. "Windows exception #" write third .h ;