From e1c7504edabffbd33e30f281f36936d67f22d474 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 11 Jun 2009 17:14:54 -0600 Subject: [PATCH] attempt to flush the compile log (if any) before crashing in SegFaultHandler::handle --- src/compile.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/compile.cpp b/src/compile.cpp index 8b542d1874..5e4b523ba5 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -4183,24 +4183,25 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, } } +FILE* compileLog = 0; + void logCompile(MyThread* t, const void* code, unsigned size, const char* class_, const char* name, const char* spec) { - static FILE* log = 0; static bool open = false; if (not open) { open = true; const char* path = findProperty(t, "avian.jit.log"); if (path) { - log = fopen(path, "wb"); + compileLog = fopen(path, "wb"); } else if (DebugCompile) { - log = stderr; + compileLog = stderr; } } - if (log) { - fprintf(log, "%p %p %s.%s%s\n", + if (compileLog) { + fprintf(compileLog, "%p %p %s.%s%s\n", code, static_cast(code) + size, class_, name, spec); } @@ -5872,6 +5873,11 @@ class SegFaultHandler: public System::SignalHandler { return true; } } + + if (compileLog) { + fflush(compileLog); + } + return false; }