mirror of
https://github.com/corda/corda.git
synced 2025-06-04 08:30:52 +00:00
Trace writeout refactor
This commit is contained in:
parent
83e55ce9cc
commit
d5d2e50ac7
@ -4759,6 +4759,27 @@ visitRoots(Machine* m, Heap::Visitor* v)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
logTrace(FILE* f, const char* fmt, ...)
|
||||||
|
{
|
||||||
|
va_list a;
|
||||||
|
va_start(a, fmt);
|
||||||
|
#ifdef PLATFORM_WINDOWS
|
||||||
|
const unsigned length = _vscprintf(fmt, a);
|
||||||
|
#else
|
||||||
|
const unsigned length = vsnprintf(0, 0, fmt, a);
|
||||||
|
#endif
|
||||||
|
RUNTIME_ARRAY(char, buffer, length + 1);
|
||||||
|
vsnprintf(&buffer[0], length, fmt, a);
|
||||||
|
buffer[length] = 0;
|
||||||
|
va_end(a);
|
||||||
|
|
||||||
|
::fprintf(f, "%s", &buffer[0]);
|
||||||
|
#ifdef PLATFORM_WINDOWS
|
||||||
|
::OutputDebugStringA(&buffer[0]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printTrace(Thread* t, object exception)
|
printTrace(Thread* t, object exception)
|
||||||
{
|
{
|
||||||
@ -4768,34 +4789,19 @@ printTrace(Thread* t, object exception)
|
|||||||
|
|
||||||
for (object e = exception; e; e = throwableCause(t, e)) {
|
for (object e = exception; e; e = throwableCause(t, e)) {
|
||||||
if (e != exception) {
|
if (e != exception) {
|
||||||
fprintf(errorLog(t), "caused by: ");
|
logTrace(errorLog(t), "caused by: ");
|
||||||
#if defined(PLATFORM_WINDOWS)
|
|
||||||
OutputDebugStringA("caused by: ");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(errorLog(t), "%s", &byteArrayBody
|
logTrace(errorLog(t), "%s", &byteArrayBody
|
||||||
(t, className(t, objectClass(t, e)), 0));
|
(t, className(t, objectClass(t, e)), 0));
|
||||||
#if defined(PLATFORM_WINDOWS)
|
|
||||||
OutputDebugStringA((const CHAR*)&byteArrayBody
|
|
||||||
(t, className(t, objectClass(t, e)), 0));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (throwableMessage(t, e)) {
|
if (throwableMessage(t, e)) {
|
||||||
object m = throwableMessage(t, e);
|
object m = throwableMessage(t, e);
|
||||||
THREAD_RUNTIME_ARRAY(t, char, message, stringLength(t, m) + 1);
|
THREAD_RUNTIME_ARRAY(t, char, message, stringLength(t, m) + 1);
|
||||||
stringChars(t, m, RUNTIME_ARRAY_BODY(message));
|
stringChars(t, m, RUNTIME_ARRAY_BODY(message));
|
||||||
fprintf(errorLog(t), ": %s\n", RUNTIME_ARRAY_BODY(message));
|
logTrace(errorLog(t), ": %s\n", RUNTIME_ARRAY_BODY(message));
|
||||||
#if defined(PLATFORM_WINDOWS)
|
|
||||||
OutputDebugStringA(": ");
|
|
||||||
OutputDebugStringA(RUNTIME_ARRAY_BODY(message));
|
|
||||||
OutputDebugStringA("\n");
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(errorLog(t), "\n");
|
logTrace(errorLog(t), "\n");
|
||||||
#if defined(PLATFORM_WINDOWS)
|
|
||||||
OutputDebugStringA("\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object trace = throwableTrace(t, e);
|
object trace = throwableTrace(t, e);
|
||||||
@ -4809,36 +4815,17 @@ printTrace(Thread* t, object exception)
|
|||||||
int line = t->m->processor->lineNumber
|
int line = t->m->processor->lineNumber
|
||||||
(t, traceElementMethod(t, e), traceElementIp(t, e));
|
(t, traceElementMethod(t, e), traceElementIp(t, e));
|
||||||
|
|
||||||
fprintf(errorLog(t), " at %s.%s ", class_, method);
|
logTrace(errorLog(t), " at %s.%s ", class_, method);
|
||||||
#if defined(PLATFORM_WINDOWS)
|
|
||||||
OutputDebugStringA(" at ");
|
|
||||||
OutputDebugStringA((const CHAR*)class_);
|
|
||||||
OutputDebugStringA(".");
|
|
||||||
OutputDebugStringA((const CHAR*)method);
|
|
||||||
OutputDebugStringA(" ");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (line) {
|
switch (line) {
|
||||||
case NativeLine:
|
case NativeLine:
|
||||||
fprintf(errorLog(t), "(native)\n");
|
logTrace(errorLog(t), "(native)\n");
|
||||||
#if defined(PLATFORM_WINDOWS)
|
|
||||||
OutputDebugStringA("(native)\n");
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case UnknownLine:
|
case UnknownLine:
|
||||||
fprintf(errorLog(t), "(unknown line)\n");
|
logTrace(errorLog(t), "(unknown line)\n");
|
||||||
#if defined(PLATFORM_WINDOWS)
|
|
||||||
OutputDebugStringA("(unknown line)\n");
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(errorLog(t), "(line %d)\n", line);
|
logTrace(errorLog(t), "(line %d)\n", line);
|
||||||
#if defined(PLATFORM_WINDOWS)
|
|
||||||
OutputDebugStringA("(line ");
|
|
||||||
char buf[35];
|
|
||||||
OutputDebugStringA(itoa(line, buf, 10));
|
|
||||||
OutputDebugStringA(")\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4848,7 +4835,7 @@ printTrace(Thread* t, object exception)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush(errorLog(t));
|
::fflush(errorLog(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
object
|
object
|
||||||
|
Loading…
x
Reference in New Issue
Block a user