32
32
#import " PLCrashReporterConfig.h"
33
33
#endif
34
34
35
+ /* * @internal
36
+ * Maximum number of bytes that will be written to the crash report
37
+ * when not explicitly defined in PLCrashReporterConfig.
38
+ *
39
+ * Default: 1MB.
40
+ *
41
+ * For reference, most crash reports
42
+ * are approximately 7k, however, we've seen 283k report
43
+ * generated by an app that loads a pathologically
44
+ * large number (~1080) of shared libraries.
45
+ */
46
+ #define MAX_REPORT_BYTES (1024 * 1024 )
47
+
35
48
/* *
36
49
* Crash Reporter Configuration.
37
50
*
@@ -41,20 +54,28 @@ @implementation PLCrashReporterConfig {
41
54
42
55
/* * The configured signal handler type. */
43
56
PLCrashReporterSignalHandlerType _signalHandlerType;
44
-
57
+
45
58
/* * The configured symbolication strategy. */
46
59
PLCrashReporterSymbolicationStrategy _symbolicationStrategy;
47
-
48
- /* *
49
- * Flag indicating if the uncaughtExceptionHandler should be initialized or not. It usually is, except in a
50
- * Xamarin environment.
51
- */
52
- BOOL _shouldRegisterUncaughtExceptionHandler;
60
+
61
+ /* *
62
+ * Flag indicating if the uncaughtExceptionHandler should be initialized or not. It usually is, except in a
63
+ * Xamarin environment.
64
+ */
65
+ BOOL _shouldRegisterUncaughtExceptionHandler;
66
+
67
+ /* *
68
+ * Maximum number of bytes that will be written to the crash report.
69
+ *
70
+ * If not provided, the default value will be MAX_REPORT_BYTES (1MB).
71
+ */
72
+ NSUInteger _maxReportBytes;
53
73
}
54
74
55
75
@synthesize signalHandlerType = _signalHandlerType;
56
76
@synthesize symbolicationStrategy = _symbolicationStrategy;
57
77
@synthesize shouldRegisterUncaughtExceptionHandler = _shouldRegisterUncaughtExceptionHandler;
78
+ @synthesize maxReportBytes = _maxReportBytes;
58
79
59
80
/* *
60
81
* Return the default local configuration.
@@ -119,7 +140,11 @@ - (instancetype) initWithSignalHandlerType: (PLCrashReporterSignalHandlerType) s
119
140
symbolicationStrategy : (PLCrashReporterSymbolicationStrategy) symbolicationStrategy
120
141
shouldRegisterUncaughtExceptionHandler : (BOOL ) shouldRegisterUncaughtExceptionHandler
121
142
{
122
- return [self initWithSignalHandlerType: signalHandlerType symbolicationStrategy: symbolicationStrategy shouldRegisterUncaughtExceptionHandler: shouldRegisterUncaughtExceptionHandler basePath: nil ];
143
+ return [self initWithSignalHandlerType: signalHandlerType
144
+ symbolicationStrategy: symbolicationStrategy
145
+ shouldRegisterUncaughtExceptionHandler: shouldRegisterUncaughtExceptionHandler
146
+ basePath: nil
147
+ maxReportBytes: MAX_REPORT_BYTES];
123
148
}
124
149
125
150
/* *
@@ -134,6 +159,28 @@ - (instancetype) initWithSignalHandlerType: (PLCrashReporterSignalHandlerType) s
134
159
symbolicationStrategy : (PLCrashReporterSymbolicationStrategy) symbolicationStrategy
135
160
shouldRegisterUncaughtExceptionHandler : (BOOL ) shouldRegisterUncaughtExceptionHandler
136
161
basePath : (NSString *) basePath
162
+ {
163
+ return [self initWithSignalHandlerType: signalHandlerType
164
+ symbolicationStrategy: symbolicationStrategy
165
+ shouldRegisterUncaughtExceptionHandler: shouldRegisterUncaughtExceptionHandler
166
+ basePath: basePath
167
+ maxReportBytes: MAX_REPORT_BYTES];
168
+ }
169
+
170
+ /* *
171
+ * Initialize a new PLCrashReporterConfig instance.
172
+ *
173
+ * @param signalHandlerType The requested signal handler type.
174
+ * @param symbolicationStrategy A local symbolication strategy.
175
+ * @param shouldRegisterUncaughtExceptionHandler Flag indicating if an uncaught exception handler should be set.
176
+ * @param basePath The base path to save the crash data. May be nil.
177
+ * @param maxReportBytes Maximum number of bytes that will be written to the crash report.
178
+ */
179
+ - (instancetype ) initWithSignalHandlerType : (PLCrashReporterSignalHandlerType) signalHandlerType
180
+ symbolicationStrategy : (PLCrashReporterSymbolicationStrategy) symbolicationStrategy
181
+ shouldRegisterUncaughtExceptionHandler : (BOOL ) shouldRegisterUncaughtExceptionHandler
182
+ basePath : (NSString *) basePath
183
+ maxReportBytes : (NSUInteger ) maxReportBytes
137
184
{
138
185
if ((self = [super init ]) == nil )
139
186
return nil ;
@@ -142,7 +189,8 @@ - (instancetype) initWithSignalHandlerType: (PLCrashReporterSignalHandlerType) s
142
189
_symbolicationStrategy = symbolicationStrategy;
143
190
_shouldRegisterUncaughtExceptionHandler = shouldRegisterUncaughtExceptionHandler;
144
191
_basePath = basePath;
145
-
192
+ _maxReportBytes = maxReportBytes;
193
+
146
194
return self;
147
195
}
148
196
0 commit comments