mirror of git://gcc.gnu.org/git/gcc.git
stacktrace.cc (GetStackTraceElements): Call gnu::gcj::runtime::NameFinder::removeUnknown() to determine if...
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. From-SVN: r111181
This commit is contained in:
parent
25f2dfd340
commit
24ca2a963a
|
@ -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>
|
2006-02-15 Matthias Klose <doko@debian.org>
|
||||||
|
|
||||||
* gnu/java/nio/charset, gnu/java/net/protocol/file,
|
* gnu/java/nio/charset, gnu/java/net/protocol/file,
|
||||||
|
|
|
@ -34,6 +34,9 @@ import java.util.HashMap;
|
||||||
* source file and line number info. Throwable.printStackTrace() will
|
* source file and line number info. Throwable.printStackTrace() will
|
||||||
* be faster if this property is set to 'false'.
|
* be faster if this property is set to 'false'.
|
||||||
* </ul>
|
* </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>
|
* </li>
|
||||||
*
|
*
|
||||||
* <code>close()</code> should be called to get rid of all resources.
|
* <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")
|
("gnu.gcj.runtime.NameFinder.use_addr2line", "true")
|
||||||
).booleanValue();
|
).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
|
class Addr2Line
|
||||||
{
|
{
|
||||||
Process proc;
|
Process proc;
|
||||||
|
|
|
@ -105,7 +105,8 @@ private:
|
||||||
static jclass ClassForFrame (_Jv_StackFrame *frame);
|
static jclass ClassForFrame (_Jv_StackFrame *frame);
|
||||||
static void FillInFrameInfo (_Jv_StackFrame *frame);
|
static void FillInFrameInfo (_Jv_StackFrame *frame);
|
||||||
static void getLineNumberForFrame(_Jv_StackFrame *frame, NameFinder *finder,
|
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,
|
static _Unwind_Reason_Code UnwindTraceFn (struct _Unwind_Context *context,
|
||||||
void *state_ptr);
|
void *state_ptr);
|
||||||
|
|
|
@ -171,7 +171,8 @@ _Jv_StackTrace::GetStackTrace(void)
|
||||||
|
|
||||||
void
|
void
|
||||||
_Jv_StackTrace::getLineNumberForFrame(_Jv_StackFrame *frame, NameFinder *finder,
|
_Jv_StackTrace::getLineNumberForFrame(_Jv_StackFrame *frame, NameFinder *finder,
|
||||||
jstring *sourceFileName, jint *lineNum)
|
jstring *sourceFileName, jint *lineNum,
|
||||||
|
jstring *methodName)
|
||||||
{
|
{
|
||||||
#ifdef INTERPRETER
|
#ifdef INTERPRETER
|
||||||
if (frame->type == frame_interpreter)
|
if (frame->type == frame_interpreter)
|
||||||
|
@ -200,6 +201,9 @@ _Jv_StackTrace::getLineNumberForFrame(_Jv_StackFrame *frame, NameFinder *finder,
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (*methodName == NULL && info.dli_sname)
|
||||||
|
*methodName = JvNewStringUTF (info.dli_sname);
|
||||||
|
|
||||||
// addr2line expects relative addresses for shared libraries.
|
// addr2line expects relative addresses for shared libraries.
|
||||||
if (strcmp (info.dli_fname, argv0) == 0)
|
if (strcmp (info.dli_fname, argv0) == 0)
|
||||||
offset = (_Unwind_Ptr) ip;
|
offset = (_Unwind_Ptr) ip;
|
||||||
|
@ -323,16 +327,22 @@ _Jv_StackTrace::GetStackTraceElements (_Jv_StackTrace *trace,
|
||||||
end_idx = i - 1;
|
end_idx = i - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const jboolean remove_unknown
|
||||||
|
= gnu::gcj::runtime::NameFinder::removeUnknown();
|
||||||
|
|
||||||
// Second pass: Look up line-number info for remaining frames.
|
// Second pass: Look up line-number info for remaining frames.
|
||||||
for (int i = start_idx; i <= end_idx; i++)
|
for (int i = start_idx; i <= end_idx; i++)
|
||||||
{
|
{
|
||||||
_Jv_StackFrame *frame = &trace->frames[i];
|
_Jv_StackFrame *frame = &trace->frames[i];
|
||||||
|
|
||||||
if (frame->klass == NULL)
|
if (frame->klass == NULL && remove_unknown)
|
||||||
// Not a Java frame.
|
// Not a Java frame.
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
jstring className = frame->klass->getName ();
|
jstring className = NULL;
|
||||||
|
if (frame->klass != NULL)
|
||||||
|
className = frame->klass->getName ();
|
||||||
|
|
||||||
jstring methodName = NULL;
|
jstring methodName = NULL;
|
||||||
if (frame->meth)
|
if (frame->meth)
|
||||||
methodName = JvNewStringUTF (frame->meth->name->chars());
|
methodName = JvNewStringUTF (frame->meth->name->chars());
|
||||||
|
@ -340,7 +350,8 @@ _Jv_StackTrace::GetStackTraceElements (_Jv_StackTrace *trace,
|
||||||
jstring sourceFileName = NULL;
|
jstring sourceFileName = NULL;
|
||||||
jint lineNum = -1;
|
jint lineNum = -1;
|
||||||
|
|
||||||
getLineNumberForFrame(frame, finder, &sourceFileName, &lineNum);
|
getLineNumberForFrame(frame, finder, &sourceFileName, &lineNum,
|
||||||
|
&methodName);
|
||||||
|
|
||||||
StackTraceElement *element = new StackTraceElement (sourceFileName, lineNum,
|
StackTraceElement *element = new StackTraceElement (sourceFileName, lineNum,
|
||||||
className, methodName, 0);
|
className, methodName, 0);
|
||||||
|
|
Loading…
Reference in New Issue