enable segfault stack traces in stage1 compiler

master
Andrew Kelley 2019-07-02 13:38:33 -04:00
parent 1a1598c58c
commit 7d4a0cfed0
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
4 changed files with 14 additions and 0 deletions

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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");

View File

@ -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);