Skip to content

Commit ef373cc

Browse files
authored
Add files via upload
1 parent db442db commit ef373cc

37 files changed

+3477
-0
lines changed

WalkingDollar/source/Contents.json

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
{
2+
"images" : [
3+
{
4+
"extent" : "full-screen",
5+
"filename" : "Default.png",
6+
"idiom" : "iphone",
7+
"orientation" : "portrait",
8+
"scale" : "1x"
9+
},
10+
{
11+
"extent" : "full-screen",
12+
"filename" : "[email protected]",
13+
"idiom" : "iphone",
14+
"orientation" : "portrait",
15+
"scale" : "2x"
16+
},
17+
{
18+
"extent" : "full-screen",
19+
"filename" : "[email protected]",
20+
"idiom" : "iphone",
21+
"minimum-system-version" : "7.0",
22+
"orientation" : "portrait",
23+
"scale" : "2x"
24+
},
25+
{
26+
"extent" : "full-screen",
27+
"filename" : "[email protected]",
28+
"idiom" : "iphone",
29+
"orientation" : "portrait",
30+
"scale" : "2x",
31+
"subtype" : "retina4"
32+
},
33+
{
34+
"extent" : "full-screen",
35+
"filename" : "[email protected]",
36+
"idiom" : "iphone",
37+
"minimum-system-version" : "7.0",
38+
"orientation" : "portrait",
39+
"scale" : "2x",
40+
"subtype" : "retina4"
41+
},
42+
{
43+
"extent" : "full-screen",
44+
"filename" : "[email protected]",
45+
"idiom" : "iphone",
46+
"minimum-system-version" : "8.0",
47+
"orientation" : "portrait",
48+
"scale" : "2x",
49+
"subtype" : "667h"
50+
},
51+
{
52+
"extent" : "full-screen",
53+
"filename" : "[email protected]",
54+
"idiom" : "iphone",
55+
"minimum-system-version" : "8.0",
56+
"orientation" : "portrait",
57+
"scale" : "3x",
58+
"subtype" : "736h"
59+
},
60+
{
61+
"extent" : "full-screen",
62+
"filename" : "[email protected]",
63+
"idiom" : "iphone",
64+
"minimum-system-version" : "8.0",
65+
"orientation" : "landscape",
66+
"scale" : "3x",
67+
"subtype" : "736h"
68+
},
69+
{
70+
"extent" : "full-screen",
71+
"filename" : "Default-Portrait-2436h.png",
72+
"idiom" : "iphone",
73+
"minimum-system-version" : "11.0",
74+
"orientation" : "portrait",
75+
"scale" : "3x",
76+
"subtype" : "2436h"
77+
},
78+
{
79+
"extent" : "full-screen",
80+
"filename" : "Default-Landscape-2436h.png",
81+
"idiom" : "iphone",
82+
"minimum-system-version" : "11.0",
83+
"orientation" : "landscape",
84+
"scale" : "3x",
85+
"subtype" : "2436h"
86+
},
87+
{
88+
"extent" : "full-screen",
89+
"filename" : "Default-Portrait.png",
90+
"idiom" : "ipad",
91+
"orientation" : "portrait",
92+
"scale" : "1x"
93+
},
94+
{
95+
"extent" : "full-screen",
96+
"filename" : "Default-Portrait.png",
97+
"idiom" : "ipad",
98+
"minimum-system-version" : "7.0",
99+
"orientation" : "portrait",
100+
"scale" : "1x"
101+
},
102+
{
103+
"extent" : "full-screen",
104+
"filename" : "Default-Landscape.png",
105+
"idiom" : "ipad",
106+
"orientation" : "landscape",
107+
"scale" : "1x"
108+
},
109+
{
110+
"extent" : "full-screen",
111+
"filename" : "Default-Landscape.png",
112+
"idiom" : "ipad",
113+
"minimum-system-version" : "7.0",
114+
"orientation" : "landscape",
115+
"scale" : "1x"
116+
},
117+
{
118+
"extent" : "full-screen",
119+
"filename" : "[email protected]",
120+
"idiom" : "ipad",
121+
"orientation" : "portrait",
122+
"scale" : "2x"
123+
},
124+
{
125+
"extent" : "full-screen",
126+
"filename" : "[email protected]",
127+
"idiom" : "ipad",
128+
"minimum-system-version" : "7.0",
129+
"orientation" : "portrait",
130+
"scale" : "2x"
131+
},
132+
{
133+
"extent" : "full-screen",
134+
"filename" : "[email protected]",
135+
"idiom" : "ipad",
136+
"orientation" : "landscape",
137+
"scale" : "2x"
138+
},
139+
{
140+
"extent" : "full-screen",
141+
"filename" : "[email protected]",
142+
"idiom" : "ipad",
143+
"minimum-system-version" : "7.0",
144+
"orientation" : "landscape",
145+
"scale" : "2x"
146+
}
147+
],
148+
"info" : {
149+
"author" : "xcode",
150+
"version" : 1
151+
}
152+
}

WalkingDollar/source/CrashReporter.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#pragma once
2+
3+
// Enabling this will force app to do a hard crash instead of a nice exit when UnhandledException
4+
// is thrown. This will force iOS to generate a standard crash report, that can be submitted to
5+
// iTunes by app users and inspected by developers.
6+
#define ENABLE_IOS_CRASH_REPORTING 1
7+
8+
// Enabling this will add a custom Objective-C Uncaught Exception handler, which will print out
9+
// exception information to console.
10+
#define ENABLE_OBJC_UNCAUGHT_EXCEPTION_HANDLER 1
11+
12+
// Enable custom crash reporter to capture crashes. Crash logs will be available to scripts via
13+
// CrashReport API.
14+
#define ENABLE_CUSTOM_CRASH_REPORTER 0
15+
16+
// Enable submission of custom crash reports to Unity servers. This will enable custom crash
17+
// reporter.
18+
#define ENABLE_CRASH_REPORT_SUBMISSION 0
19+
20+
21+
#if ENABLE_CRASH_REPORT_SUBMISSION && !ENABLE_CUSTOM_CRASH_REPORTER
22+
#undef ENABLE_CUSTOM_CRASH_REPORTER
23+
#define ENABLE_CUSTOM_CRASH_REPORTER 0
24+
#endif
25+
26+
#if PLATFORM_TVOS
27+
#undef ENABLE_CUSTOM_CRASH_REPORTER
28+
#define ENABLE_CUSTOM_CRASH_REPORTER 0
29+
#endif
30+
31+
extern "C" void UnityInstallPostCrashCallback();
32+
void InitCrashHandling();

WalkingDollar/source/CrashReporter.mm

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#import "PLCrashReporter.h"
2+
#import "CrashReporter.h"
3+
#include <mach-o/ldsyms.h>
4+
5+
extern "C" NSString* UnityGetCrashReportsPath();
6+
7+
8+
static NSUncaughtExceptionHandler* gsCrashReporterUEHandler = NULL;
9+
10+
extern "C" uint8_t* UnityGetAppLoadAddress()
11+
{
12+
// _mh_execute_header points to a mach header, and is located right at the address of where the
13+
// app is loaded.
14+
return (uint8_t*)&_mh_execute_header;
15+
}
16+
17+
extern "C" const uint8_t * UnityGetAppLoadCommandAddress()
18+
{
19+
return (const uint8_t*)(&_mh_execute_header + 1);
20+
}
21+
22+
extern "C" int UnityGetAppLoadCommandCount()
23+
{
24+
return _mh_execute_header.ncmds;
25+
}
26+
27+
static void SavePendingCrashReport()
28+
{
29+
if (![[UnityPLCrashReporter sharedReporter] hasPendingCrashReport])
30+
return;
31+
32+
NSFileManager *fm = [NSFileManager defaultManager];
33+
NSError *error;
34+
35+
if (![fm createDirectoryAtPath: UnityGetCrashReportsPath() withIntermediateDirectories: YES attributes: nil error: &error])
36+
{
37+
::printf("CrashReporter: could not create crash report directory: %s\n", [[error localizedDescription] UTF8String]);
38+
return;
39+
}
40+
41+
NSData *data = [[UnityPLCrashReporter sharedReporter] loadPendingCrashReportDataAndReturnError: &error];
42+
if (data == nil)
43+
{
44+
::printf("CrashReporter: failed to load crash report data: %s\n", [[error localizedDescription] UTF8String]);
45+
return;
46+
}
47+
48+
NSString* file = [UnityGetCrashReportsPath() stringByAppendingPathComponent: @"crash-"];
49+
unsigned long long seconds = (unsigned long long)[[NSDate date] timeIntervalSince1970];
50+
file = [file stringByAppendingString: [NSString stringWithFormat: @"%llu", seconds]];
51+
file = [file stringByAppendingString: @".plcrash"];
52+
if ([data writeToFile: file atomically: YES])
53+
{
54+
::printf("CrashReporter: saved pending crash report.\n");
55+
if (![[UnityPLCrashReporter sharedReporter] purgePendingCrashReportAndReturnError: &error])
56+
{
57+
::printf("CrashReporter: couldn't remove pending report: %s\n", [[error localizedDescription] UTF8String]);
58+
}
59+
}
60+
else
61+
{
62+
::printf("CrashReporter: couldn't save crash report.\n");
63+
}
64+
65+
// Now copy out a pending version that we can delete if/when we send it
66+
file = [UnityGetCrashReportsPath() stringByAppendingPathComponent: @"crash-pending.plcrash"];
67+
if ([data writeToFile: file atomically: YES])
68+
{
69+
::printf("CrashReporter: saved copy of pending crash report.\n");
70+
}
71+
else
72+
{
73+
::printf("CrashReporter: couldn't save copy of pending crash report.\n");
74+
}
75+
}
76+
77+
static void InitCrashReporter()
78+
{
79+
NSError *error;
80+
81+
UnityInstallPostCrashCallback();
82+
if ([[UnityPLCrashReporter sharedReporter] enableCrashReporterAndReturnError: &error])
83+
::printf("CrashReporter: initialized\n");
84+
else
85+
NSLog(@"CrashReporter: could not enable crash reporter: %@", error);
86+
87+
SavePendingCrashReport();
88+
}
89+
90+
static void UncaughtExceptionHandler(NSException *exception)
91+
{
92+
NSLog(@"Uncaught exception: %@: %@\n%@", [exception name], [exception reason], [exception callStackSymbols]);
93+
if (gsCrashReporterUEHandler)
94+
gsCrashReporterUEHandler(exception);
95+
}
96+
97+
static void InitObjCUEHandler()
98+
{
99+
// Crash reporter sets its own handler, so we have to save it and call it manually
100+
gsCrashReporterUEHandler = NSGetUncaughtExceptionHandler();
101+
NSSetUncaughtExceptionHandler(&UncaughtExceptionHandler);
102+
}
103+
104+
void InitCrashHandling()
105+
{
106+
#if ENABLE_CUSTOM_CRASH_REPORTER
107+
InitCrashReporter();
108+
#endif
109+
110+
#if ENABLE_OBJC_UNCAUGHT_EXCEPTION_HANDLER
111+
InitObjCUEHandler();
112+
#endif
113+
}
114+
115+
// This function will be called when AppDomain.CurrentDomain.UnhandledException event is triggered.
116+
// When running on device the app will do a hard crash and it will generate a crash log.
117+
extern "C" void CrashedCheckBelowForHintsWhy()
118+
{
119+
#if ENABLE_IOS_CRASH_REPORTING || ENABLE_CUSTOM_CRASH_REPORTER
120+
// Make app crash hard here
121+
__builtin_trap();
122+
123+
// Just in case above doesn't work
124+
abort();
125+
#endif
126+
}
3.58 KB
Loading
4.76 KB
Loading
10.4 KB
Loading
3.39 KB
Loading
12.4 KB
Loading
13.3 KB
Loading
11.2 KB
Loading

0 commit comments

Comments
 (0)