aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/lang/natThrowable.cc
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2002-07-12 12:52:44 +0000
committerMark Wielaard <mark@gcc.gnu.org>2002-07-12 12:52:44 +0000
commitdc7b1dda60ba8c8aa03da26f5555d07074cdce3f (patch)
treefd16f76f98f4b5e364614153e8902a370d5f36e2 /libjava/java/lang/natThrowable.cc
parent26af4041b70d3722d36c4e0d95640bd4f7f9b691 (diff)
downloadgcc-dc7b1dda60ba8c8aa03da26f5555d07074cdce3f.zip
gcc-dc7b1dda60ba8c8aa03da26f5555d07074cdce3f.tar.gz
gcc-dc7b1dda60ba8c8aa03da26f5555d07074cdce3f.tar.bz2
natThrowable.cc (printRawStackTrace): removed.
* java/lang/natThrowable.cc (printRawStackTrace): removed. (getStackTrace0): new method. * java/lang/Throwable.java (CPlusPlusDemangler): removed. (printStackTrace(PrintWriter)): replace with pure java implementation. (printRawStackTrace): removed. (getStackTrace0): new method. * java/lang/StackTraceElement.java (toString): add extra whitespace. * gcj/javaprims.h: regenerate class list. * include/name-finder.h (lookup): new returns StackTraceElement*. (method_name, file_name): fields removed. (pid2, f2_pipe, b2_pipe, b2_pipe_fd): new fields. (~_Jv_name_finder): close new descriptors. * name-finder.cc(_Jv_name_finder): setup c++filt helper process. (createStackTraceElement): new method. (lookup): returns StackTraceElement*, uses createStackTraceElement(). From-SVN: r55424
Diffstat (limited to 'libjava/java/lang/natThrowable.cc')
-rw-r--r--libjava/java/lang/natThrowable.cc39
1 files changed, 17 insertions, 22 deletions
diff --git a/libjava/java/lang/natThrowable.cc b/libjava/java/lang/natThrowable.cc
index e644708..c2f7d1b 100644
--- a/libjava/java/lang/natThrowable.cc
+++ b/libjava/java/lang/natThrowable.cc
@@ -22,6 +22,7 @@ details. */
#include <java/lang/Object.h>
#include <java-threads.h>
#include <java/lang/Throwable.h>
+#include <java/lang/StackTraceElement.h>
#include <java/io/PrintStream.h>
#include <java/io/PrintWriter.h>
#include <java/io/IOException.h>
@@ -67,38 +68,32 @@ java::lang::Throwable::fillInStackTrace (void)
return this;
}
-void
-java::lang::Throwable::printRawStackTrace (java::io::PrintWriter *wr)
+JArray<java::lang::StackTraceElement*> *
+java::lang::Throwable::getStackTrace0 ()
{
- wr->println (toString ());
#ifdef HAVE_BACKTRACE
if (!stackTraceBytes)
- return;
+ return NULL;
int depth = stackTraceBytes->length / sizeof (void *);
void *p[depth];
+ // This memcpy is esential; it ensures that the array of void* is
+ // correctly aligned.
memcpy (p, elements (stackTraceBytes), sizeof p);
+ JArray<java::lang::StackTraceElement*> *result;
+ java::lang::StackTraceElement** el;
+ result = reinterpret_cast <JArray<java::lang::StackTraceElement *>*>
+ (JvNewObjectArray (depth, &java::lang::StackTraceElement::class$, NULL));
+ el = elements (result);
+
_Jv_name_finder finder (_Jv_ThisExecutable ());
for (int i = 0; i < depth; i++)
- {
- bool found = finder.lookup (p[i]);
- wr->print (JvNewStringLatin1 (" at "));
- wr->print (JvNewStringLatin1 (finder.hex));
- if (found)
- {
- wr->print (JvNewStringLatin1 (": "));
- wr->print (JvNewStringLatin1 (finder.method_name));
- if (finder.file_name[0])
- {
- wr->print (JvNewStringLatin1 (" ("));
- wr->print (JvNewStringLatin1 (finder.file_name));
- wr->print (JvNewStringLatin1 (")"));
- }
- }
- wr->println ();
- }
+ el[i] = finder.lookup (p[i]);
+
+ return result;
+#else
+ return NULL;
#endif /* HAVE_BACKTRACE */
- wr->flush ();
}