Skip to content

Commit ef4be0d

Browse files
ref: Delete dead code in SentryCrashMach (#3827)
1 parent 00cbe5c commit ef4be0d

File tree

3 files changed

+0
-125
lines changed

3 files changed

+0
-125
lines changed

Sources/SentryCrash/Recording/Tools/SentryCrashMach.c

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -128,63 +128,3 @@ sentrycrashmach_kernelReturnCodeName(const int64_t returnCode)
128128
#define EXC_UNIX_BAD_SYSCALL 0x10000 /* SIGSYS */
129129
#define EXC_UNIX_BAD_PIPE 0x10001 /* SIGPIPE */
130130
#define EXC_UNIX_ABORT 0x10002 /* SIGABRT */
131-
132-
int
133-
sentrycrashmach_machExceptionForSignal(const int sigNum)
134-
{
135-
switch (sigNum) {
136-
case SIGFPE:
137-
return EXC_ARITHMETIC;
138-
case SIGSEGV:
139-
return EXC_BAD_ACCESS;
140-
case SIGBUS:
141-
return EXC_BAD_ACCESS;
142-
case SIGILL:
143-
return EXC_BAD_INSTRUCTION;
144-
case SIGTRAP:
145-
return EXC_BREAKPOINT;
146-
case SIGEMT:
147-
return EXC_EMULATION;
148-
case SIGSYS:
149-
return EXC_UNIX_BAD_SYSCALL;
150-
case SIGPIPE:
151-
return EXC_UNIX_BAD_PIPE;
152-
case SIGABRT:
153-
// The Apple reporter uses EXC_CRASH instead of EXC_UNIX_ABORT
154-
return EXC_CRASH;
155-
case SIGKILL:
156-
return EXC_SOFT_SIGNAL;
157-
}
158-
return 0;
159-
}
160-
161-
int
162-
sentrycrashmach_signalForMachException(const int exception, const mach_exception_code_t code)
163-
{
164-
switch (exception) {
165-
case EXC_ARITHMETIC:
166-
return SIGFPE;
167-
case EXC_BAD_ACCESS:
168-
return code == KERN_INVALID_ADDRESS ? SIGSEGV : SIGBUS;
169-
case EXC_BAD_INSTRUCTION:
170-
return SIGILL;
171-
case EXC_BREAKPOINT:
172-
return SIGTRAP;
173-
case EXC_EMULATION:
174-
return SIGEMT;
175-
case EXC_SOFTWARE: {
176-
switch (code) {
177-
case EXC_UNIX_BAD_SYSCALL:
178-
return SIGSYS;
179-
case EXC_UNIX_BAD_PIPE:
180-
return SIGPIPE;
181-
case EXC_UNIX_ABORT:
182-
return SIGABRT;
183-
case EXC_SOFT_SIGNAL:
184-
return SIGKILL;
185-
}
186-
break;
187-
}
188-
}
189-
return 0;
190-
}

Sources/SentryCrash/Recording/Tools/SentryCrashMach.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,6 @@ const char *sentrycrashmach_exceptionName(int64_t exceptionType);
4747
*/
4848
const char *sentrycrashmach_kernelReturnCodeName(int64_t returnCode);
4949

50-
/** Get the signal equivalent of a mach exception.
51-
*
52-
* @param exception The mach exception.
53-
*
54-
* @param code The mach exception code.
55-
*
56-
* @return The matching signal, or 0 if not found.
57-
*/
58-
int sentrycrashmach_signalForMachException(int exception, int64_t code);
59-
60-
/** Get the mach exception equivalent of a signal.
61-
*
62-
* @param signal The signal.
63-
*
64-
* @return The matching mach exception, or 0 if not found.
65-
*/
66-
int sentrycrashmach_machExceptionForSignal(int signal);
67-
6850
#ifdef __cplusplus
6951
}
7052
#endif

Tests/SentryTests/SentryCrash/SentryCrashMach_Tests.m

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -65,51 +65,4 @@ - (void)testVeryHighKernReturnCodeName
6565
XCTAssertTrue(result == NULL, @"");
6666
}
6767

68-
#define EXC_UNIX_BAD_SYSCALL 0x10000 /* SIGSYS */
69-
#define EXC_UNIX_BAD_PIPE 0x10001 /* SIGPIPE */
70-
#define EXC_UNIX_ABORT 0x10002 /* SIGABRT */
71-
72-
- (void)testMachExeptionsForSignals
73-
{
74-
[self assertMachException:EXC_ARITHMETIC code:0 matchesSignal:SIGFPE];
75-
[self assertMachException:EXC_BAD_ACCESS code:0 matchesSignal:SIGBUS];
76-
[self assertMachException:EXC_BAD_ACCESS code:KERN_INVALID_ADDRESS matchesSignal:SIGSEGV];
77-
[self assertMachException:EXC_BAD_INSTRUCTION code:0 matchesSignal:SIGILL];
78-
[self assertMachException:EXC_BREAKPOINT code:0 matchesSignal:SIGTRAP];
79-
[self assertMachException:EXC_EMULATION code:0 matchesSignal:SIGEMT];
80-
[self assertMachException:EXC_SOFTWARE code:EXC_UNIX_BAD_SYSCALL matchesSignal:SIGSYS];
81-
[self assertMachException:EXC_SOFTWARE code:EXC_UNIX_BAD_PIPE matchesSignal:SIGPIPE];
82-
[self assertMachException:EXC_SOFTWARE code:EXC_UNIX_ABORT matchesSignal:SIGABRT];
83-
[self assertMachException:EXC_SOFTWARE code:EXC_SOFT_SIGNAL matchesSignal:SIGKILL];
84-
[self assertMachException:EXC_SOFTWARE code:100000000 matchesSignal:0];
85-
[self assertMachException:1000000000 code:0 matchesSignal:0];
86-
}
87-
88-
- (void)testSignalsForMachExeptions
89-
{
90-
[self assertSignal:SIGFPE matchesMachException:EXC_ARITHMETIC];
91-
[self assertSignal:SIGSEGV matchesMachException:EXC_BAD_ACCESS];
92-
[self assertSignal:SIGBUS matchesMachException:EXC_BAD_ACCESS];
93-
[self assertSignal:SIGILL matchesMachException:EXC_BAD_INSTRUCTION];
94-
[self assertSignal:SIGTRAP matchesMachException:EXC_BREAKPOINT];
95-
[self assertSignal:SIGEMT matchesMachException:EXC_EMULATION];
96-
[self assertSignal:SIGSYS matchesMachException:EXC_UNIX_BAD_SYSCALL];
97-
[self assertSignal:SIGPIPE matchesMachException:EXC_UNIX_BAD_PIPE];
98-
[self assertSignal:SIGABRT matchesMachException:EXC_CRASH];
99-
[self assertSignal:SIGKILL matchesMachException:EXC_SOFT_SIGNAL];
100-
[self assertSignal:1000000000 matchesMachException:0];
101-
}
102-
103-
- (void)assertMachException:(int)exception code:(int)code matchesSignal:(int)signal
104-
{
105-
int result = sentrycrashmach_signalForMachException(exception, code);
106-
XCTAssertEqual(result, signal, @"");
107-
}
108-
109-
- (void)assertSignal:(int)signal matchesMachException:(int)exception
110-
{
111-
int result = sentrycrashmach_machExceptionForSignal(signal);
112-
XCTAssertEqual(result, exception, @"");
113-
}
114-
11568
@end

0 commit comments

Comments
 (0)