enable segfault stack traces in stage1 compiler
parent
1a1598c58c
commit
7d4a0cfed0
|
@ -455,3 +455,10 @@ export const stage2_DepNextResult = extern struct {
|
|||
prereq,
|
||||
};
|
||||
};
|
||||
|
||||
// ABI warning
|
||||
export fn stage2_attach_segfault_handler() void {
|
||||
if (std.debug.runtime_safety and std.debug.have_segfault_handling_support) {
|
||||
std.debug.attachSegfaultHandler();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -262,6 +262,8 @@ static bool get_cache_opt(CacheOpt opt, bool default_value) {
|
|||
extern "C" int ZigClang_main(int argc, char **argv);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
stage2_attach_segfault_handler();
|
||||
|
||||
char *arg0 = argv[0];
|
||||
Error err;
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ void stage2_zen(const char **ptr, size_t *len) {
|
|||
stage2_panic(msg, strlen(msg));
|
||||
}
|
||||
|
||||
void stage2_attach_segfault_handler(void) { }
|
||||
|
||||
void stage2_panic(const char *ptr, size_t len) {
|
||||
fwrite(ptr, 1, len, stderr);
|
||||
fprintf(stderr, "\n");
|
||||
|
|
|
@ -113,6 +113,9 @@ ZIG_EXTERN_C void stage2_render_ast(struct Stage2Ast *ast, FILE *output_file);
|
|||
// ABI warning
|
||||
ZIG_EXTERN_C void stage2_zen(const char **ptr, size_t *len);
|
||||
|
||||
// ABI warning
|
||||
ZIG_EXTERN_C void stage2_attach_segfault_handler(void);
|
||||
|
||||
// ABI warning
|
||||
ZIG_EXTERN_C ZIG_ATTRIBUTE_NORETURN void stage2_panic(const char *ptr, size_t len);
|
||||
|
||||
|
|
Loading…
Reference in New Issue