If you pass 0 to printTrace, it will print the stack trace of a null

pointer exception.  This dramatically simplifies debugging in GDB:

p vm::printTrace(t, 0)
This commit is contained in:
Eric Scharff 2007-10-12 14:54:37 -06:00
parent a9bbaff74f
commit 05321e97f9
2 changed files with 6 additions and 1 deletions

View File

@ -225,7 +225,7 @@ $(jni-objects): $(bld)/%.o: $(classpath)/%.cpp
$(jni-library): $(jni-objects)
@echo "linking $(@)"
$(cc) $(lflags) $(shared) $(^) -o $(@)
$(cc) $(lflags) $(shared) $(^) -o $(@) -lssl -lcrypto
$(executable): $(interpreter-objects) $(stdcpp-objects)
@echo "linking $(@)"

View File

@ -2605,6 +2605,11 @@ collect(Thread* t, Heap::CollectionType type)
void
printTrace(Thread* t, object exception)
{
if (exception == 0) {
exception = makeNullPointerException(t, 0,
makeTrace(t, t->m->processor->frameStart(t)),
0);
}
for (object e = exception; e; e = throwableCauseUnsafe(t, e)) {
if (e != exception) {
fprintf(stderr, "caused by: ");