]> gitweb.factorcode.org Git - factor.git/commitdiff
Improve Unix signal and Windows structured exception reporting
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 20 Apr 2009 06:47:10 +0000 (01:47 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 20 Apr 2009 06:47:10 +0000 (01:47 -0500)
basis/debugger/debugger.factor
basis/debugger/unix/authors.txt [new file with mode: 0644]
basis/debugger/unix/unix.factor [new file with mode: 0644]
basis/debugger/windows/authors.txt [new file with mode: 0644]
basis/debugger/windows/windows.factor [new file with mode: 0644]

index 64bac3ecee69b3664d0ab136f7cddb6b87cefe41..9abd5a9033daf650224d60f23361229e197c31e1 100644 (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" ;
\ No newline at end of file
+M: wrong-values summary drop "Quotation called with wrong stack effect" ;
+
+{
+    { [ os windows? ] [ "debugger.windows" require ] }
+    { [ os unix? ] [ "debugger.unix" require ] }
+} cond
\ No newline at end of file
diff --git a/basis/debugger/unix/authors.txt b/basis/debugger/unix/authors.txt
new file mode 100644 (file)
index 0000000..d4f5d6b
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
\ No newline at end of file
diff --git a/basis/debugger/unix/unix.factor b/basis/debugger/unix/unix.factor
new file mode 100644 (file)
index 0000000..212908b
--- /dev/null
@@ -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 ;
diff --git a/basis/debugger/windows/authors.txt b/basis/debugger/windows/authors.txt
new file mode 100644 (file)
index 0000000..d4f5d6b
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
\ No newline at end of file
diff --git a/basis/debugger/windows/windows.factor b/basis/debugger/windows/windows.factor
new file mode 100644 (file)
index 0000000..1f4b8fb
--- /dev/null
@@ -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 ;
\ No newline at end of file