Mercurial > projects > doodle
annotate doodle/core/backtrace.d @ 103:345fb56d89fc
Blind checkpoint
author | David Bryant <bagnose@gmail.com> |
---|---|
date | Thu, 18 Nov 2010 12:00:02 +1030 |
parents | 100dd23c7bdf |
children | 7abaf5c3959f |
rev | line source |
---|---|
44 | 1 module doodle.core.backtrace; |
2 | |
3 // | |
103 | 4 // Register signal handlers and throw Error. |
5 // Technically we shouldn't be throwing an exception from | |
6 // a signal handler, but it happens to work. | |
44 | 7 // |
8 | |
9 private { | |
50
dfa1e219eafe
New version of backtrace based on the one in druntime.
daveb
parents:
45
diff
changeset
|
10 import core.stdc.signal; |
dfa1e219eafe
New version of backtrace based on the one in druntime.
daveb
parents:
45
diff
changeset
|
11 import std.string; |
44 | 12 |
13 // signal handler for otherwise-fatal thread-specific signals | |
66 | 14 extern (C) void signalHandler(int sig) { |
44 | 15 string name() { |
16 switch (sig) { | |
17 case SIGSEGV: return "SIGSEGV"; | |
18 case SIGFPE: return "SIGFPE"; | |
19 case SIGILL: return "SIGILL"; | |
20 case SIGABRT: return "SIGABRT"; | |
88 | 21 case SIGINT: return "SIGINT"; |
44 | 22 default: return ""; |
23 } | |
24 } | |
25 | |
26 throw new Error(format("Got signal %s %s", sig, name)); | |
27 } | |
28 | |
29 shared static this() { | |
30 // set up shared signal handlers for fatal thread-specific signals | |
66 | 31 signal(SIGABRT, &signalHandler); |
32 signal(SIGFPE, &signalHandler); | |
33 signal(SIGILL, &signalHandler); | |
34 signal(SIGSEGV, &signalHandler); | |
103 | 35 signal(SIGINT, &signalHandler); |
50
dfa1e219eafe
New version of backtrace based on the one in druntime.
daveb
parents:
45
diff
changeset
|
36 } |
44 | 37 } |