This is used by various system routines (the capabilities checker and dyld to name a few) to add extra color to an abort. This patch adds a frame recognizer so people can easily see the details, and also adds the information to the ExtendedCrashInformation dictionary. I also had to rework how the dictionary is held; previously it was created on demand, but that was inconvenient since it meant all the entries had to be produced at that same time. That didn't work for the recognizer.
34 lines
1.3 KiB
C
34 lines
1.3 KiB
C
// These defines are from bsd/sys/reason.h:
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
|
|
extern void abort_with_payload(uint32_t reason_namespace, uint64_t reason_code,
|
|
void *payload, uint32_t payload_size,
|
|
const char *reason_string,
|
|
uint64_t reason_flags);
|
|
|
|
extern void abort_with_reason(uint32_t reason_namespace, uint64_t reason_code,
|
|
const char *reason_string, uint64_t reason_flags);
|
|
|
|
#define OS_REASON_FLAG_FROM_USERSPACE 0x4
|
|
#define OS_REASON_FLAG_NO_CRASH_REPORT 0x1
|
|
#define OS_REASON_FLAG_ONE_TIME_FAILURE 0x80
|
|
|
|
#define MY_REASON_FLAGS \
|
|
OS_REASON_FLAG_FROM_USERSPACE | OS_REASON_FLAG_NO_CRASH_REPORT | \
|
|
OS_REASON_FLAG_ONE_TIME_FAILURE
|
|
#define OS_REASON_TEST 5
|
|
|
|
int main(int argc, char **argv) {
|
|
const char *reason_string = "This is the reason string";
|
|
const char *payload_string = "This is a payload that happens to be a string";
|
|
size_t payload_string_len = strlen(payload_string) + 1;
|
|
if (argc == 1) // Stop here before abort
|
|
abort_with_payload(OS_REASON_TEST, 100, (void *)payload_string,
|
|
payload_string_len, reason_string, MY_REASON_FLAGS);
|
|
else
|
|
abort_with_reason(OS_REASON_TEST, 100, reason_string, MY_REASON_FLAGS);
|
|
|
|
return 0;
|
|
}
|