From 696dad4b6bbaf23576e59546d1bd3e93dd0e96c4 Mon Sep 17 00:00:00 2001 From: David Daney Date: Tue, 6 Jun 2006 17:00:16 +0000 Subject: gcj.texi (libgcj Runtime Properties): Document gnu.gcj.runtime.NameFinder.show_raw and... 2006-06-05 David Daney * gcj.texi (libgcj Runtime Properties): Document gnu.gcj.runtime.NameFinder.show_raw and gnu.gcj.runtime.NameFinder.remove_unknown. 2006-06-05 David Daney * gnu/gcj/runtime/NameFinder.java (show_raw): New field. (showRaw): New method. * stacktrace.cc : Include gnu/gcj/runtime/StringBuffer.h. (getLineNumberForFrame): Show IP offset in trace if line number not available and show_raw true. From-SVN: r114437 --- gcc/java/ChangeLog | 6 ++++++ gcc/java/gcj.texi | 15 +++++++++++++++ libjava/ChangeLog | 8 ++++++++ libjava/gnu/gcj/runtime/NameFinder.java | 20 ++++++++++++++++++-- libjava/stacktrace.cc | 12 ++++++++++++ 5 files changed, 59 insertions(+), 2 deletions(-) diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index e8b7c155..90f275c 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,9 @@ +2006-06-06 David Daney + + * gcj.texi (libgcj Runtime Properties): Document + gnu.gcj.runtime.NameFinder.show_raw and + gnu.gcj.runtime.NameFinder.remove_unknown. + 2006-06-06 Tom Tromey * jcf-dump.c (print_access_flags): Handle varargs, bridge, diff --git a/gcc/java/gcj.texi b/gcc/java/gcj.texi index 2f82d7f..38ae1ab 100644 --- a/gcc/java/gcj.texi +++ b/gcc/java/gcj.texi @@ -2793,6 +2793,21 @@ the java.util.logging infrastructure. However, performance may improve significantly for applications that print stack traces or make logging calls frequently. +@item gnu.gcj.runtime.NameFinder.show_raw +Whether the address of a stack frame should be printed when the line +number is unavailable. Setting this to @code{true} will cause the name +of the object and the offset within that object to be printed when no +line number is available. This allows for off-line decoding of +stack traces if necessary debug information is available. The default +is @code{false}, no raw addresses are printed. + +@item gnu.gcj.runtime.NameFinder.remove_unknown +Whether stack frames for non-java code should be included in a stack +trace. The default value is @code{true}, stack frames for non-java +code are suppressed. Setting this to @code{false} will cause any +non-java stack frames to be printed in addition to frames for the java +code. + @item gnu.gcj.runtime.VMClassLoader.library_control This controls how shared libraries are automatically loaded by the built-in class loader. If this property is set to @samp{full}, a full diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 76031d5..8117d08 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,11 @@ +2006-06-06 David Daney + + * gnu/gcj/runtime/NameFinder.java (show_raw): New field. + (showRaw): New method. + * stacktrace.cc : Include gnu/gcj/runtime/StringBuffer.h. + (getLineNumberForFrame): Show IP offset in trace if line number + not available and show_raw true. + 2006-06-06 Gary Benson * java/io/natFilePosix.cc (getCanonicalPath): Rewritten. diff --git a/libjava/gnu/gcj/runtime/NameFinder.java b/libjava/gnu/gcj/runtime/NameFinder.java index e43886f..0742af1 100644 --- a/libjava/gnu/gcj/runtime/NameFinder.java +++ b/libjava/gnu/gcj/runtime/NameFinder.java @@ -67,13 +67,29 @@ public class NameFinder ("gnu.gcj.runtime.NameFinder.use_addr2line", "true") ).booleanValue(); + private static boolean show_raw + = Boolean.valueOf(System.getProperty + ("gnu.gcj.runtime.NameFinder.show_raw", "false") + ).booleanValue(); + + /** + * Return true if raw addresses should be printed in stacktraces + * when no line number information is available. + */ + static final boolean showRaw() + { + return show_raw; + } + 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. + /** + * Return true if non-Java frames should be removed from stack + * traces. + */ static final boolean removeUnknown() { return remove_unknown; diff --git a/libjava/stacktrace.cc b/libjava/stacktrace.cc index 6423bbd8..5d429e6 100644 --- a/libjava/stacktrace.cc +++ b/libjava/stacktrace.cc @@ -27,6 +27,7 @@ details. */ #include #include #include +#include #include #include @@ -221,6 +222,17 @@ _Jv_StackTrace::getLineNumberForFrame(_Jv_StackFrame *frame, NameFinder *finder, finder->lookup (binaryName, (jlong) offset); *sourceFileName = finder->getSourceFile(); *lineNum = finder->getLineNum(); + if (*lineNum == -1 && NameFinder::showRaw()) + { + gnu::gcj::runtime::StringBuffer *t = + new gnu::gcj::runtime::StringBuffer(binaryName); + t->append ((jchar)' '); + t->append ((jchar)'['); + // + 1 to compensate for the - 1 adjustment above; + t->append (Long::toHexString (offset + 1)); + t->append ((jchar)']'); + *sourceFileName = t->toString(); + } } #endif } -- cgit v1.1