From 5b9bd4f9059729785a4e12b04883ee73f22c518c Mon Sep 17 00:00:00 2001
From: wellbye <fatfatson@users.noreply.github.com>
Date: Thu, 21 Jun 2018 09:36:40 +0800
Subject: [PATCH 1/2] Update ReactNativeExceptionHandler.m

bugfix for wrong userInfo
---
 ios/ReactNativeExceptionHandler.m | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/ios/ReactNativeExceptionHandler.m b/ios/ReactNativeExceptionHandler.m
index e8bae91..56f63ef 100644
--- a/ios/ReactNativeExceptionHandler.m
+++ b/ios/ReactNativeExceptionHandler.m
@@ -199,10 +199,7 @@ void SignalHandler(int signal)
       [NSString stringWithFormat:
        NSLocalizedString(@"Signal %d was raised.", nil),
        signal]
-      userInfo:
-      [NSDictionary
-       dictionaryWithObject:[NSNumber numberWithInt:signal]
-       forKey:RNUncaughtExceptionHandlerSignalKey]]
+      userInfo:userInfo]
      waitUntilDone:YES];
 }
 

From 7e75f309e91af577ed445523e13824411735a8b4 Mon Sep 17 00:00:00 2001
From: wellbye <wellbye@163.com>
Date: Thu, 21 Jun 2018 10:28:58 +0800
Subject: [PATCH 2/2] fix

---
 ios/ReactNativeExceptionHandler.m | 37 ++++++++++++++++++++++++++-----
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/ios/ReactNativeExceptionHandler.m b/ios/ReactNativeExceptionHandler.m
index 56f63ef..0808336 100644
--- a/ios/ReactNativeExceptionHandler.m
+++ b/ios/ReactNativeExceptionHandler.m
@@ -1,5 +1,5 @@
 #import "ReactNativeExceptionHandler.h"
-
+#import <mach-o/dyld.h>
 
 // CONSTANTS
 NSString * const RNUncaughtExceptionHandlerSignalExceptionName = @"RNUncaughtExceptionHandlerSignalExceptionName";
@@ -7,9 +7,31 @@
 NSString * const RNUncaughtExceptionHandlerAddressesKey = @"RNUncaughtExceptionHandlerAddressesKey";
 volatile int32_t RNUncaughtExceptionCount = 0;
 const int32_t RNUncaughtExceptionMaximum = 10;
-const NSInteger RNUncaughtExceptionHandlerSkipAddressCount = 4;
-const NSInteger RNUncaughtExceptionHandlerReportAddressCount = 5;
+const NSInteger RNUncaughtExceptionHandlerSkipAddressCount = 0;
+const NSInteger RNUncaughtExceptionHandlerReportAddressCount = 15;
+
 
+void getSlide(long* pheader,long* pslide) {
+    for (uint32_t i = 0; i < _dyld_image_count(); i++) {
+        if (_dyld_get_image_header(i)->filetype == MH_EXECUTE) {
+            long slide = _dyld_get_image_vmaddr_slide(i);
+            const struct mach_header* header = _dyld_get_image_header(i);
+            if(pheader)*pheader=header;
+            if(pslide)*pslide=slide;
+
+            return;
+        }
+    }
+}
+
+long letMeCrash(){
+    int* p = 1234;
+    *p = 1;
+    return 0;
+}
+long funcImyourDD(){ if(RNUncaughtExceptionCount%2) printf("funcImyourDD11");else printf("funcImyourDD22"); return letMeCrash();}
+long funcFuckyourBB(){ if(RNUncaughtExceptionCount%2) printf("funcFuckyourBB11");else printf("funcFuckyourBB22"); return RNUncaughtExceptionCount+funcImyourDD();}
+long funcAreyouSB(){ if(RNUncaughtExceptionCount%2) printf("funcAreyouSB11");else printf("funcAreyouSB22"); return RNUncaughtExceptionCount+funcFuckyourBB();}
 
 @implementation ReactNativeExceptionHandler
 
@@ -59,8 +81,9 @@ - (dispatch_queue_t)methodQueue
 // ====================================
 
 RCT_EXPORT_MODULE();
-
-// METHOD TO INITIALIZE THE EXCEPTION HANDLER AND SET THE JS CALLBACK BLOCK
+		RCT_EXPORT_METHOD(raiseTestNativeError) { NSLog(@"RAISING A TEST EXCEPTION"); [NSException raise:@"TEST EXCEPTION" format:@"THIS IS A TEST EXCEPTION"]; }
+		RCT_EXPORT_METHOD(raiseTestNativeErrorCXX) { NSLog(@"RAISING A TEST EXCEPTION"); funcAreyouSB(); }
+		// METHOD TO INITIALIZE THE EXCEPTION HANDLER AND SET THE JS CALLBACK BLOCK
 RCT_EXPORT_METHOD(setHandlerforNativeException:(RCTResponseSenderBlock)callback)
 {
     jsErrorCallbackBlock = ^(NSException *exception, NSString *readeableException){
@@ -216,6 +239,10 @@ + (NSArray *)backtrace
 
     int i;
     NSMutableArray *backtrace = [NSMutableArray arrayWithCapacity:frames];
+    
+    long header=0,slide=0;
+    getSlide(&header, &slide);
+    [backtrace addObject:[NSString stringWithFormat:@"slideheader: 0x%X",header]];
     for (
          i = RNUncaughtExceptionHandlerSkipAddressCount;
          i < RNUncaughtExceptionHandlerSkipAddressCount +