From 05321e97f9f4494b4adb540d0b160f2fad10a3a0 Mon Sep 17 00:00:00 2001 From: Eric Scharff Date: Fri, 12 Oct 2007 14:54:37 -0600 Subject: [PATCH] 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) --- makefile | 2 +- src/machine.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/makefile b/makefile index ae82a6c8a1..fc84091fd0 100644 --- a/makefile +++ b/makefile @@ -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 $(@)" diff --git a/src/machine.cpp b/src/machine.cpp index 3331926b56..5462a43808 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -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: ");