attempt to flush the compile log (if any) before crashing in SegFaultHandler::handle

This commit is contained in:
Joel Dice 2009-06-11 17:14:54 -06:00
parent 525318dabb
commit e1c7504eda

View File

@ -4183,24 +4183,25 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
} }
} }
FILE* compileLog = 0;
void void
logCompile(MyThread* t, const void* code, unsigned size, const char* class_, logCompile(MyThread* t, const void* code, unsigned size, const char* class_,
const char* name, const char* spec) const char* name, const char* spec)
{ {
static FILE* log = 0;
static bool open = false; static bool open = false;
if (not open) { if (not open) {
open = true; open = true;
const char* path = findProperty(t, "avian.jit.log"); const char* path = findProperty(t, "avian.jit.log");
if (path) { if (path) {
log = fopen(path, "wb"); compileLog = fopen(path, "wb");
} else if (DebugCompile) { } else if (DebugCompile) {
log = stderr; compileLog = stderr;
} }
} }
if (log) { if (compileLog) {
fprintf(log, "%p %p %s.%s%s\n", fprintf(compileLog, "%p %p %s.%s%s\n",
code, static_cast<const uint8_t*>(code) + size, code, static_cast<const uint8_t*>(code) + size,
class_, name, spec); class_, name, spec);
} }
@ -5872,6 +5873,11 @@ class SegFaultHandler: public System::SignalHandler {
return true; return true;
} }
} }
if (compileLog) {
fflush(compileLog);
}
return false; return false;
} }