annotate tango/lib/compiler/llvmdc/eh.d @ 373:d1574e142e93 trunk

[svn r394] Fixed the new DtoNullValue function
author lindquist
date Tue, 15 Jul 2008 15:16:56 +0200
parents 5bea8a1ef905
children 3ad8295cfac6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
330
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
1 /**
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
2 * This module contains functions and structures required for
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
3 * exception handling.
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
diff changeset
4 */
330
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
5 module eh;
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
diff changeset
6
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
diff changeset
7 import util.console;
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
diff changeset
8
319
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 318
diff changeset
9 // debug = EH_personality;
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
10
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
diff changeset
11 private extern(C) void abort();
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
12 private extern(C) int printf(char*, ...);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
13
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
14 // D runtime functions
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
15 extern(C) {
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
16 int _d_isbaseof(ClassInfo oc, ClassInfo c);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
17 }
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
18
330
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
19 // libunwind headers
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
20 extern(C)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
21 {
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
22 enum _Unwind_Reason_Code
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
23 {
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
24 NO_REASON = 0,
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
25 FOREIGN_EXCEPTION_CAUGHT = 1,
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
26 FATAL_PHASE2_ERROR = 2,
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
27 FATAL_PHASE1_ERROR = 3,
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
28 NORMAL_STOP = 4,
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
29 END_OF_STACK = 5,
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
30 HANDLER_FOUND = 6,
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
31 INSTALL_CONTEXT = 7,
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
32 CONTINUE_UNWIND = 8
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
33 }
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
34
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
35 enum _Unwind_Action
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
36 {
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
37 SEARCH_PHASE = 1,
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
38 CLEANUP_PHASE = 2,
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
39 HANDLER_PHASE = 3,
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
40 FORCE_UNWIND = 4
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
41 }
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
42
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
43 alias void* _Unwind_Context_Ptr;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
44
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
45 alias void function(_Unwind_Reason_Code, _Unwind_Exception*) _Unwind_Exception_Cleanup_Fn;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
46
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
47 struct _Unwind_Exception
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
48 {
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
49 char[8] exception_class;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
50 _Unwind_Exception_Cleanup_Fn exception_cleanup;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
51 int private_1;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
52 int private_2;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
53 }
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
54
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
55 void _Unwind_Resume(_Unwind_Exception*);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
56 _Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Exception*);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
57 ulong _Unwind_GetLanguageSpecificData(_Unwind_Context_Ptr context);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
58 ulong _Unwind_GetIP(_Unwind_Context_Ptr context);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
59 ulong _Unwind_SetIP(_Unwind_Context_Ptr context, ulong new_value);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
60 ulong _Unwind_SetGR(_Unwind_Context_Ptr context, int index, ulong new_value);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
61 ulong _Unwind_GetRegionStart(_Unwind_Context_Ptr context);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
62 }
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
63
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
64
330
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
65 // helpers for reading certain DWARF data
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
66 //TODO: It may not be a good idea to use exceptions for error handling within exception handling code
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
67 private ubyte* get_uleb128(ubyte* addr, ref size_t res)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
68 {
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
69 res = 0;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
70 size_t bitsize = 0;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
71
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
72 // read as long as high bit is set
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
73 while(*addr & 0x80) {
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
74 res |= (*addr & 0x7f) << bitsize;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
75 bitsize += 7;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
76 addr += 1;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
77 if(bitsize >= size_t.sizeof*8)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
78 throw new Exception("tried to read uleb128 that exceeded size of size_t");
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
79 }
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
80 // read last
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
81 if(bitsize != 0 && *addr >= 1 << size_t.sizeof*8 - bitsize)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
82 throw new Exception("tried to read uleb128 that exceeded size of size_t");
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
83 res |= (*addr) << bitsize;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
84
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
85 return addr + 1;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
86 }
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
87
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
88 private ubyte* get_sleb128(ubyte* addr, ref ptrdiff_t res)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
89 {
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
90 res = 0;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
91 size_t bitsize = 0;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
92
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
93 // read as long as high bit is set
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
94 while(*addr & 0x80) {
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
95 res |= (*addr & 0x7f) << bitsize;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
96 bitsize += 7;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
97 addr += 1;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
98 if(bitsize >= size_t.sizeof*8)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
99 throw new Exception("tried to read sleb128 that exceeded size of size_t");
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
100 }
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
101 // read last
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
102 if(bitsize != 0 && *addr >= 1 << size_t.sizeof*8 - bitsize)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
103 throw new Exception("tried to read sleb128 that exceeded size of size_t");
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
104 res |= (*addr) << bitsize;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
105
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
106 // take care of sign
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
107 if(bitsize < size_t.sizeof*8 && ((*addr) & 0x40))
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
108 res |= cast(ptrdiff_t)(-1) ^ ((1 << (bitsize+7)) - 1);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
109
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
110 return addr + 1;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
111 }
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
112
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
113
330
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
114 // exception struct used by the runtime.
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
115 // _d_throw allocates a new instance and passes the address of its
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
116 // _Unwind_Exception member to the unwind call. The personality
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
117 // routine is then able to get the whole struct by looking at the data
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
118 // surrounding the unwind info.
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
119 struct _d_exception
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
120 {
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
121 Object exception_object;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
122 _Unwind_Exception unwind_info;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
123 }
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
124
330
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
125 // the 8-byte string identifying the type of exception
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
126 // the first 4 are for vendor, the second 4 for language
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
127 //TODO: This may be the wrong way around
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
128 char[8] _d_exception_class = "LLDCD1\0\0";
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
129
330
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
130 // the personality routine gets called by the unwind handler and is responsible for
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
131 // reading the EH tables and deciding what to do
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
132 extern(C) _Unwind_Reason_Code _d_eh_personality(int ver, _Unwind_Action actions, ulong exception_class, _Unwind_Exception* exception_info, _Unwind_Context_Ptr context)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
133 {
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
134 // check ver: the C++ Itanium ABI only allows ver == 1
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
135 if(ver != 1)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
136 return _Unwind_Reason_Code.FATAL_PHASE1_ERROR;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
137
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
138 // check exceptionClass
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
139 //TODO: Treat foreign exceptions with more respect
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
140 if((cast(char*)&exception_class)[0..8] != _d_exception_class)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
141 return _Unwind_Reason_Code.FATAL_PHASE1_ERROR;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
142
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
143 // find call site table, action table and classinfo table
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
144 // Note: callsite and action tables do not contain static-length
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
145 // data and will be parsed as needed
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
146 // Note: classinfo_table points past the end of the table
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
147 ubyte* callsite_table;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
148 ubyte* action_table;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
149 ClassInfo* classinfo_table;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
150 _d_getLanguageSpecificTables(context, callsite_table, action_table, classinfo_table);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
151
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
152
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
153 /*
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
154 find landing pad and action table index belonging to ip by walking
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
155 the callsite_table
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
156 */
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
157 ubyte* callsite_walker = callsite_table;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
158
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
159 // get the instruction pointer
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
160 // will be used to find the right entry in the callsite_table
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
161 // -1 because it will point past the last instruction
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
162 ulong ip = _Unwind_GetIP(context) - 1;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
163
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
164 // address block_start is relative to
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
165 ulong region_start = _Unwind_GetRegionStart(context);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
166
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
167 // table entries
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
168 uint block_start_offset, block_size;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
169 ulong landing_pad;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
170 size_t action_offset;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
171
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
172 while(true) {
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
173 // if we've gone through the list and found nothing...
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
174 if(callsite_walker >= action_table)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
175 return _Unwind_Reason_Code.CONTINUE_UNWIND;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
176
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
177 block_start_offset = *cast(uint*)callsite_walker;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
178 block_size = *(cast(uint*)callsite_walker + 1);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
179 landing_pad = *(cast(uint*)callsite_walker + 2);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
180 if(landing_pad)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
181 landing_pad += region_start;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
182 callsite_walker = get_uleb128(callsite_walker + 3*uint.sizeof, action_offset);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
183
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
184 debug(EH_personality_verbose) printf("%d %d %d\n", block_start_offset, block_size, landing_pad);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
185
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
186 // since the list is sorted, as soon as we're past the ip
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
187 // there's no handler to be found
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
188 if(ip < region_start + block_start_offset)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
189 return _Unwind_Reason_Code.CONTINUE_UNWIND;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
190
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
191 // if we've found our block, exit
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
192 if(ip < region_start + block_start_offset + block_size)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
193 break;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
194 }
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
195
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
196 debug(EH_personality) printf("Found correct landing pad and actionOffset %d\n", action_offset);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
197
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
198 // now we need the exception's classinfo to find a handler
330
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
199 // the exception_info is actually a member of a larger _d_exception struct
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
200 // the runtime allocated. get that now
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
201 _d_exception* exception_struct = cast(_d_exception*)(cast(ubyte*)exception_info - _d_exception.unwind_info.offsetof);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
202
330
5bea8a1ef905 [svn r351] Remove unused runtime file for DMD-style exception handling.
ChristianK
parents: 319
diff changeset
203 // if there's no action offset and no landing pad, continue unwinding
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
204 if(!action_offset && !landing_pad)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
205 return _Unwind_Reason_Code.CONTINUE_UNWIND;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
206
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
207 // if there's no action offset but a landing pad, this is a cleanup handler
318
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
208 else if(!action_offset && landing_pad)
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
209 return _d_eh_install_finally_context(actions, landing_pad, exception_struct, context);
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
210
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
211 /*
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
212 walk action table chain, comparing classinfos using _d_isbaseof
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
213 */
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
214 ubyte* action_walker = action_table + action_offset - 1;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
215
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
216 ptrdiff_t ti_offset, next_action_offset;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
217 while(true) {
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
218 action_walker = get_sleb128(action_walker, ti_offset);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
219 // it is intentional that we not modify action_walker here
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
220 // next_action_offset is from current action_walker position
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
221 get_sleb128(action_walker, next_action_offset);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
222
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
223 // negative are 'filters' which we don't use
318
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
224 assert(ti_offset >= 0 && "Filter actions are unsupported");
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
225
318
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
226 // zero means cleanup, which we require to be the last action
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
227 if(ti_offset == 0) {
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
228 assert(next_action_offset == 0 && "Cleanup action must be last in chain");
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
229 return _d_eh_install_finally_context(actions, landing_pad, exception_struct, context);
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
230 }
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
231
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
232 // get classinfo for action and check if the one in the
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
233 // exception structure is a base
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
234 ClassInfo catch_ci = classinfo_table[-ti_offset];
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
235 debug(EH_personality) printf("Comparing catch %s to exception %s\n", catch_ci.name.ptr, exception_struct.exception_object.classinfo.name.ptr);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
236 if(_d_isbaseof(exception_struct.exception_object.classinfo, catch_ci))
318
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
237 return _d_eh_install_catch_context(actions, ti_offset, landing_pad, exception_struct, context);
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
238
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
239 // we've walked through all actions and found nothing...
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
240 if(next_action_offset == 0)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
241 return _Unwind_Reason_Code.CONTINUE_UNWIND;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
242 else
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
243 action_walker += next_action_offset;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
244 }
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
245
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
246 assert(false);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
247 }
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
248
318
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
249 // These are the register numbers for SetGR that
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
250 // llvm's eh.exception and eh.selector intrinsics
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
251 // will pick up.
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
252 // Found by trial-and-error and probably platform dependent!
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
253 private int eh_exception_regno = 0;
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
254 private int eh_selector_regno = 2;
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
255
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
256 private _Unwind_Reason_Code _d_eh_install_catch_context(_Unwind_Action actions, ptrdiff_t switchval, ulong landing_pad, _d_exception* exception_struct, _Unwind_Context_Ptr context)
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
257 {
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
258 debug(EH_personality) printf("Found catch clause!\n");
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
259
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
260 if(actions & _Unwind_Action.SEARCH_PHASE)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
261 return _Unwind_Reason_Code.HANDLER_FOUND;
318
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
262
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
263 else if(actions & _Unwind_Action.HANDLER_PHASE)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
264 {
319
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 318
diff changeset
265 debug(EH_personality) printf("Setting switch value to: %d!\n", switchval);
318
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
266 _Unwind_SetGR(context, eh_exception_regno, cast(ulong)cast(void*)(exception_struct.exception_object));
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
267 _Unwind_SetGR(context, eh_selector_regno, switchval);
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
268 _Unwind_SetIP(context, landing_pad);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
269 return _Unwind_Reason_Code.INSTALL_CONTEXT;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
270 }
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
271
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
272 assert(false);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
273 }
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
274
318
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
275 private _Unwind_Reason_Code _d_eh_install_finally_context(_Unwind_Action actions, ulong landing_pad, _d_exception* exception_struct, _Unwind_Context_Ptr context)
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
276 {
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
277 // if we're merely in search phase, continue
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
278 if(actions & _Unwind_Action.SEARCH_PHASE)
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
279 return _Unwind_Reason_Code.CONTINUE_UNWIND;
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
280
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
281 debug(EH_personality) printf("Calling cleanup routine...\n");
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
282
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
283 _Unwind_SetGR(context, eh_exception_regno, cast(ulong)exception_struct);
319
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 318
diff changeset
284 _Unwind_SetGR(context, eh_selector_regno, 0);
318
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
285 _Unwind_SetIP(context, landing_pad);
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
286 return _Unwind_Reason_Code.INSTALL_CONTEXT;
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
287 }
8e570dbe4087 [svn r339] Add cleanup handling when within an action chain and some more documentation to the eh personality function.
ChristianK
parents: 314
diff changeset
288
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
289 private void _d_getLanguageSpecificTables(_Unwind_Context_Ptr context, ref ubyte* callsite, ref ubyte* action, ref ClassInfo* ci)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
290 {
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
291 ubyte* data = cast(ubyte*)_Unwind_GetLanguageSpecificData(context);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
292
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
293 //TODO: Do proper DWARF reading here
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
294 assert(*data++ == 0xff);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
295
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
296 assert(*data++ == 0x00);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
297 size_t cioffset;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
298 data = get_uleb128(data, cioffset);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
299 ci = cast(ClassInfo*)(data + cioffset);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
300
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
301 assert(*data++ == 0x03);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
302 size_t callsitelength;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
303 data = get_uleb128(data, callsitelength);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
304 action = data + callsitelength;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
305
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
306 callsite = data;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
307 }
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
diff changeset
308
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
diff changeset
309 extern(C) void _d_throw_exception(Object e)
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
diff changeset
310 {
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
diff changeset
311 if (e !is null)
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
diff changeset
312 {
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
313 _d_exception* exc_struct = new _d_exception;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
314 exc_struct.unwind_info.exception_class[] = _d_exception_class;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
315 exc_struct.exception_object = e;
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
316 _Unwind_Reason_Code ret = _Unwind_RaiseException(&exc_struct.unwind_info);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
317 console("_Unwind_RaiseException failed with reason code: ")(ret)("\n");
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
diff changeset
318 }
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
diff changeset
319 abort();
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
diff changeset
320 }
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
321
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
322 extern(C) void _d_eh_resume_unwind(_d_exception* exception_struct)
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
323 {
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
324 _Unwind_Resume(&exception_struct.unwind_info);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 133
diff changeset
325 }