aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libjava/ChangeLog12
-rw-r--r--libjava/gnu/gcj/runtime/NameFinder.java15
-rw-r--r--libjava/include/java-stack.h3
-rw-r--r--libjava/stacktrace.cc23
4 files changed, 46 insertions, 7 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 8e092cf..2e14389 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,15 @@
+2006-02-16 Andrew Haley <aph@redhat.com>
+
+ * stacktrace.cc (GetStackTraceElements): Call
+ gnu::gcj::runtime::NameFinder::removeUnknown() to determine if
+ non-Java frames should be removed from a printed stack trace.
+ Pass methodName to getLineNumberForFrame().
+ (getLineNumberForFrame): Set method_name from info.dli_sname.
+ * gnu/gcj/runtime/NameFinder.java (removeUnknown): New method.
+ (remove_unknown): New variable.
+ * include/java-stack.h (_Jv_StackTrace::getLineNumberForFrame):
+ Add methodName arg.
+
2006-02-15 Matthias Klose <doko@debian.org>
* gnu/java/nio/charset, gnu/java/net/protocol/file,
diff --git a/libjava/gnu/gcj/runtime/NameFinder.java b/libjava/gnu/gcj/runtime/NameFinder.java
index 4c629bb..3a31a2d 100644
--- a/libjava/gnu/gcj/runtime/NameFinder.java
+++ b/libjava/gnu/gcj/runtime/NameFinder.java
@@ -34,6 +34,9 @@ import java.util.HashMap;
* source file and line number info. Throwable.printStackTrace() will
* be faster if this property is set to 'false'.
* </ul>
+ * <ul><code>gnu.gcj.runtime.NameFinder.remove_unknown</code>
+ * Whether calls to unknown functions (class and method names are unknown)
+ * should be removed from the stack trace. </ul>
* </li>
*
* <code>close()</code> should be called to get rid of all resources.
@@ -57,6 +60,18 @@ public class NameFinder
("gnu.gcj.runtime.NameFinder.use_addr2line", "true")
).booleanValue();
+ private static final boolean remove_unknown
+ = Boolean.valueOf(System.getProperty
+ ("gnu.gcj.runtime.NameFinder.remove_unknown", "true")
+ ).booleanValue();
+
+ // Return true if non-Java frames should be removed from stack
+ // traces.
+ static final boolean removeUnknown()
+ {
+ return remove_unknown;
+ }
+
class Addr2Line
{
Process proc;
diff --git a/libjava/include/java-stack.h b/libjava/include/java-stack.h
index 5905e26..7bf4d7b 100644
--- a/libjava/include/java-stack.h
+++ b/libjava/include/java-stack.h
@@ -105,7 +105,8 @@ private:
static jclass ClassForFrame (_Jv_StackFrame *frame);
static void FillInFrameInfo (_Jv_StackFrame *frame);
static void getLineNumberForFrame(_Jv_StackFrame *frame, NameFinder *finder,
- jstring *sourceFileName, jint *lineNum);
+ jstring *sourceFileName, jint *lineNum,
+ jstring *methodName);
static _Unwind_Reason_Code UnwindTraceFn (struct _Unwind_Context *context,
void *state_ptr);
diff --git a/libjava/stacktrace.cc b/libjava/stacktrace.cc
index 1bdabdf..16f944a 100644
--- a/libjava/stacktrace.cc
+++ b/libjava/stacktrace.cc
@@ -171,7 +171,8 @@ _Jv_StackTrace::GetStackTrace(void)
void
_Jv_StackTrace::getLineNumberForFrame(_Jv_StackFrame *frame, NameFinder *finder,
- jstring *sourceFileName, jint *lineNum)
+ jstring *sourceFileName, jint *lineNum,
+ jstring *methodName)
{
#ifdef INTERPRETER
if (frame->type == frame_interpreter)
@@ -200,6 +201,9 @@ _Jv_StackTrace::getLineNumberForFrame(_Jv_StackFrame *frame, NameFinder *finder,
else
return;
+ if (*methodName == NULL && info.dli_sname)
+ *methodName = JvNewStringUTF (info.dli_sname);
+
// addr2line expects relative addresses for shared libraries.
if (strcmp (info.dli_fname, argv0) == 0)
offset = (_Unwind_Ptr) ip;
@@ -323,16 +327,22 @@ _Jv_StackTrace::GetStackTraceElements (_Jv_StackTrace *trace,
end_idx = i - 1;
}
+ const jboolean remove_unknown
+ = gnu::gcj::runtime::NameFinder::removeUnknown();
+
// Second pass: Look up line-number info for remaining frames.
for (int i = start_idx; i <= end_idx; i++)
{
_Jv_StackFrame *frame = &trace->frames[i];
- if (frame->klass == NULL)
- // Not a Java frame.
+ if (frame->klass == NULL && remove_unknown)
+ // Not a Java frame.
continue;
-
- jstring className = frame->klass->getName ();
+
+ jstring className = NULL;
+ if (frame->klass != NULL)
+ className = frame->klass->getName ();
+
jstring methodName = NULL;
if (frame->meth)
methodName = JvNewStringUTF (frame->meth->name->chars());
@@ -340,7 +350,8 @@ _Jv_StackTrace::GetStackTraceElements (_Jv_StackTrace *trace,
jstring sourceFileName = NULL;
jint lineNum = -1;
- getLineNumberForFrame(frame, finder, &sourceFileName, &lineNum);
+ getLineNumberForFrame(frame, finder, &sourceFileName, &lineNum,
+ &methodName);
StackTraceElement *element = new StackTraceElement (sourceFileName, lineNum,
className, methodName, 0);