|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2018-2021 Apple Inc. All rights reserved. |
| 2 | + * Copyright (c) 2018-2022 Apple Inc. All rights reserved. |
3 | 3 | *
|
4 | 4 | * Redistribution and use in source and binary forms, with or without
|
5 | 5 | * modification, are permitted provided that the following conditions
|
|
65 | 65 |
|
66 | 66 | #if PAS_X86_64 || PAS_ARM64
|
67 | 67 |
|
| 68 | +#if PAS_OS(DARWIN) && PAS_VA_OPT_SUPPORTED |
| 69 | + |
| 70 | +PAS_NEVER_INLINE PAS_NO_RETURN void pas_crash_with_info_impl1(uint64_t reason, uint64_t misc1) |
| 71 | +{ |
| 72 | + register uint64_t reasonGPR asm(CRASH_GPR0) = reason; |
| 73 | + register uint64_t misc1GPR asm(CRASH_GPR1) = misc1; |
| 74 | + __asm__ volatile (CRASH_INST : : "r"(reasonGPR), "r"(misc1GPR)); |
| 75 | + __builtin_unreachable(); |
| 76 | +} |
| 77 | + |
| 78 | +PAS_NEVER_INLINE PAS_NO_RETURN void pas_crash_with_info_impl2(uint64_t reason, uint64_t misc1, uint64_t misc2) |
| 79 | +{ |
| 80 | + register uint64_t reasonGPR asm(CRASH_GPR0) = reason; |
| 81 | + register uint64_t misc1GPR asm(CRASH_GPR1) = misc1; |
| 82 | + register uint64_t misc2GPR asm(CRASH_GPR2) = misc2; |
| 83 | + __asm__ volatile (CRASH_INST : : "r"(reasonGPR), "r"(misc1GPR), "r"(misc2GPR)); |
| 84 | + __builtin_unreachable(); |
| 85 | +} |
| 86 | + |
| 87 | +PAS_NEVER_INLINE PAS_NO_RETURN void pas_crash_with_info_impl3(uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3) |
| 88 | +{ |
| 89 | + register uint64_t reasonGPR asm(CRASH_GPR0) = reason; |
| 90 | + register uint64_t misc1GPR asm(CRASH_GPR1) = misc1; |
| 91 | + register uint64_t misc2GPR asm(CRASH_GPR2) = misc2; |
| 92 | + register uint64_t misc3GPR asm(CRASH_GPR3) = misc3; |
| 93 | + __asm__ volatile (CRASH_INST : : "r"(reasonGPR), "r"(misc1GPR), "r"(misc2GPR), "r"(misc3GPR)); |
| 94 | + __builtin_unreachable(); |
| 95 | +} |
| 96 | + |
| 97 | +PAS_NEVER_INLINE PAS_NO_RETURN void pas_crash_with_info_impl4(uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3, uint64_t misc4) |
| 98 | +{ |
| 99 | + register uint64_t reasonGPR asm(CRASH_GPR0) = reason; |
| 100 | + register uint64_t misc1GPR asm(CRASH_GPR1) = misc1; |
| 101 | + register uint64_t misc2GPR asm(CRASH_GPR2) = misc2; |
| 102 | + register uint64_t misc3GPR asm(CRASH_GPR3) = misc3; |
| 103 | + register uint64_t misc4GPR asm(CRASH_GPR4) = misc4; |
| 104 | + __asm__ volatile (CRASH_INST : : "r"(reasonGPR), "r"(misc1GPR), "r"(misc2GPR), "r"(misc3GPR), "r"(misc4GPR)); |
| 105 | + __builtin_unreachable(); |
| 106 | +} |
| 107 | + |
| 108 | +PAS_NEVER_INLINE PAS_NO_RETURN void pas_crash_with_info_impl5(uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3, uint64_t misc4, uint64_t misc5) |
| 109 | +{ |
| 110 | + register uint64_t reasonGPR asm(CRASH_GPR0) = reason; |
| 111 | + register uint64_t misc1GPR asm(CRASH_GPR1) = misc1; |
| 112 | + register uint64_t misc2GPR asm(CRASH_GPR2) = misc2; |
| 113 | + register uint64_t misc3GPR asm(CRASH_GPR3) = misc3; |
| 114 | + register uint64_t misc4GPR asm(CRASH_GPR4) = misc4; |
| 115 | + register uint64_t misc5GPR asm(CRASH_GPR5) = misc5; |
| 116 | + __asm__ volatile (CRASH_INST : : "r"(reasonGPR), "r"(misc1GPR), "r"(misc2GPR), "r"(misc3GPR), "r"(misc4GPR), "r"(misc5GPR)); |
| 117 | + __builtin_unreachable(); |
| 118 | +} |
| 119 | + |
| 120 | +PAS_NEVER_INLINE PAS_NO_RETURN void pas_crash_with_info_impl6(uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3, uint64_t misc4, uint64_t misc5, uint64_t misc6) |
| 121 | +{ |
| 122 | + register uint64_t reasonGPR asm(CRASH_GPR0) = reason; |
| 123 | + register uint64_t misc1GPR asm(CRASH_GPR1) = misc1; |
| 124 | + register uint64_t misc2GPR asm(CRASH_GPR2) = misc2; |
| 125 | + register uint64_t misc3GPR asm(CRASH_GPR3) = misc3; |
| 126 | + register uint64_t misc4GPR asm(CRASH_GPR4) = misc4; |
| 127 | + register uint64_t misc5GPR asm(CRASH_GPR5) = misc5; |
| 128 | + register uint64_t misc6GPR asm(CRASH_GPR6) = misc6; |
| 129 | + __asm__ volatile (CRASH_INST : : "r"(reasonGPR), "r"(misc1GPR), "r"(misc2GPR), "r"(misc3GPR), "r"(misc4GPR), "r"(misc5GPR), "r"(misc6GPR)); |
| 130 | + __builtin_unreachable(); |
| 131 | +} |
| 132 | + |
| 133 | +#endif /* PAS_OS(DARWIN) && PAS_VA_OPT_SUPPORTED */ |
| 134 | + |
68 | 135 | PAS_NEVER_INLINE PAS_NO_RETURN static void pas_crash_with_info_impl(uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3, uint64_t misc4, uint64_t misc5, uint64_t misc6)
|
69 | 136 | {
|
70 | 137 | register uint64_t reasonGPR asm(CRASH_GPR0) = reason;
|
@@ -98,6 +165,13 @@ void pas_panic(const char* format, ...)
|
98 | 165 | }
|
99 | 166 |
|
100 | 167 | #if PAS_ENABLE_TESTING
|
| 168 | +PAS_NEVER_INLINE void pas_report_assertion_failed( |
| 169 | + const char* filename, int line, const char* function, const char* expression) |
| 170 | +{ |
| 171 | + pas_log("[%d] pas panic: ", getpid()); |
| 172 | + pas_log("%s:%d: %s: assertion %s failed.\n", filename, line, function, expression); |
| 173 | +} |
| 174 | + |
101 | 175 | void pas_assertion_failed(const char* filename, int line, const char* function, const char* expression)
|
102 | 176 | {
|
103 | 177 | pas_panic("%s:%d: %s: assertion %s failed.\n", filename, line, function, expression);
|
|
0 commit comments