@@ -8,6 +8,14 @@ typedef struct objc_object* id;
8
8
#include " objc/runtime.h"
9
9
#include " objc/objc-arc.h"
10
10
11
+ #define DEBUG_EXCEPTIONS
12
+
13
+ #ifndef DEBUG_EXCEPTIONS
14
+ #define DEBUG_LOG (...)
15
+ #else
16
+ #define DEBUG_LOG (str, ...) fprintf(stderr, str, ## __VA_ARGS__)
17
+ #endif
18
+
11
19
/* *
12
20
* Helper function that has a custom personality function.
13
21
* This calls `cxx_throw` and has a destructor that must be run. We intercept
@@ -295,10 +303,18 @@ namespace gnustep
295
303
/* libc++-abi does not have __is_pointer_p and won't do the double dereference
296
304
* required to get the object pointer. We need to do it ourselves if we have
297
305
* caught an exception with libc++'s exception class. */
306
+ #ifndef __MINGW32__
298
307
if (cxx_exception_class == llvm_cxx_exception_class) {
299
308
return **(id**)obj;
300
309
}
301
310
return *(id*)obj;
311
+ #else
312
+ #ifdef _LIBCPP_VERSION
313
+ return **(id**)obj;
314
+ #else
315
+ return *(id*)obj;
316
+ #endif // _LIBCPP_VERSION
317
+ #endif // __MINGW32__
302
318
}
303
319
};
304
320
@@ -355,14 +371,17 @@ bool gnustep::libobjc::__objc_id_type_info::__do_catch(const type_info *thrownTy
355
371
// Id catch matches any ObjC throw
356
372
if (dynamic_cast <const __objc_class_type_info*>(thrownType))
357
373
{
358
- *obj = *(id*)obj;
374
+ *obj = dereference_thrown_object_pointer (obj);
375
+ DEBUG_LOG (" gnustep::libobjc::__objc_id_type_info::__do_catch caught 0x%x\n " , *obj);
359
376
return true ;
360
377
}
361
378
if (dynamic_cast <const __objc_id_type_info*>(thrownType))
362
379
{
363
- *obj = *(id*)obj;
380
+ *obj = dereference_thrown_object_pointer (obj);
381
+ DEBUG_LOG (" gnustep::libobjc::__objc_id_type_info::__do_catch caught 0x%x\n " , *obj);
364
382
return true ;
365
383
}
384
+ DEBUG_LOG (" gnustep::libobjc::__objc_id_type_info::__do_catch returning false\n " );
366
385
return false ;
367
386
};
368
387
@@ -494,6 +513,7 @@ extern "C" void test_cxx_eh_implementation()
494
513
#else
495
514
static void eh_cleanup (void *exception )
496
515
{
516
+ DEBUG_LOG (" eh_cleanup: Releasing 0x%x\n " , *(id*)exception );
497
517
objc_release (*(id*)exception );
498
518
}
499
519
@@ -504,6 +524,7 @@ void objc_exception_throw(id object)
504
524
id *exc = (id *)__cxa_allocate_exception (sizeof (id));
505
525
*exc = object;
506
526
objc_retain (object);
527
+ DEBUG_LOG (" objc_exception_throw: Throwing 0x%x\n " , *exc);
507
528
__cxa_throw (exc, & __objc_id_type_info, eh_cleanup);
508
529
}
509
530
#endif
0 commit comments