* src/vm/jit/stacktrace.c: Moved to .cpp.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Wed, 16 Jul 2008 10:54:56 +0000 (12:54 +0200)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Wed, 16 Jul 2008 10:54:56 +0000 (12:54 +0200)
* src/vm/jit/stacktrace.h: Moved to .hpp.
* src/vm/jit/stacktrace.cpp: New file.
* src/vm/jit/stacktrace.hpp: Likewise.
* src/mm/cacao-gc/rootset.c,
src/native/jni.cpp,
src/native/jvmti/jvmti.c,
src/native/vm/cldc1.1/java_lang_Throwable.c,
src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.c,
src/native/vm/gnuclasspath/java_lang_VMThrowable.cpp,
src/native/vm/gnuclasspath/java_lang_reflect_VMField.cpp,
src/native/vm/gnuclasspath/java_security_VMAccessController.c,
src/native/vm/openjdk/hpi.c,
src/native/vm/openjdk/jvm.c,
src/threads/none/thread-none.c,
src/threads/none/thread-none.h,
src/threads/posix/thread-posix.h,
src/threads/thread.c,
src/vm/access.c,
src/vm/exceptions.c,
src/vm/jit/Makefile.am,
src/vm/jit/alpha/codegen.c,
src/vm/jit/alpha/linux/md-os.c,
src/vm/jit/alpha/patcher.c,
src/vm/jit/arm/linux/md-os.c,
src/vm/jit/codegen-common.c,
src/vm/jit/i386/codegen.c,
src/vm/jit/i386/cygwin/md-os.c,
src/vm/jit/i386/darwin/md-os.c,
src/vm/jit/i386/freebsd/md-os.c,
src/vm/jit/i386/linux/md-os.c,
src/vm/jit/i386/patcher.c,
src/vm/jit/i386/solaris/md-os.c,
src/vm/jit/intrp/codegen.c,
src/vm/jit/intrp/engine.c,
src/vm/jit/jit.h,
src/vm/jit/m68k/codegen.c,
src/vm/jit/m68k/patcher.c,
src/vm/jit/mips/irix/md-os.c,
src/vm/jit/mips/linux/md-os.c,
src/vm/jit/powerpc/codegen.c,
src/vm/jit/powerpc/darwin/md-os.c,
src/vm/jit/powerpc/linux/md-os.c,
src/vm/jit/powerpc/netbsd/md-os.c,
src/vm/jit/powerpc/patcher.c,
src/vm/jit/powerpc64/codegen.c,
src/vm/jit/powerpc64/linux/md-os.c,
src/vm/jit/powerpc64/patcher.c,
src/vm/jit/replace.c,
src/vm/jit/replace.h,
src/vm/jit/s390/codegen.c,
src/vm/jit/s390/md.c,
src/vm/jit/s390/patcher.c,
src/vm/jit/sparc64/codegen.c,
src/vm/jit/sparc64/linux/md-os.c,
src/vm/jit/sparc64/patcher.c,
src/vm/jit/sparc64/solaris/md-os.c,
src/vm/jit/trap.c,
src/vm/jit/x86_64/codegen.c,
src/vm/jit/x86_64/freebsd/md-os.c,
src/vm/jit/x86_64/linux/md-os.c,
src/vm/jit/x86_64/patcher.c,
src/vm/jit/x86_64/solaris/md-os.c: Fixed includes.

--HG--
rename : src/vm/jit/stacktrace.c => src/vm/jit/stacktrace.cpp
rename : src/vm/jit/stacktrace.h => src/vm/jit/stacktrace.hpp

63 files changed:
src/mm/cacao-gc/rootset.c
src/native/jni.cpp
src/native/jvmti/jvmti.c
src/native/vm/cldc1.1/java_lang_Throwable.c
src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.c
src/native/vm/gnuclasspath/java_lang_VMThrowable.cpp
src/native/vm/gnuclasspath/java_lang_reflect_VMField.cpp
src/native/vm/gnuclasspath/java_security_VMAccessController.c
src/native/vm/openjdk/hpi.c
src/native/vm/openjdk/jvm.c
src/threads/none/thread-none.c
src/threads/none/thread-none.h
src/threads/posix/thread-posix.h
src/threads/thread.c
src/vm/access.c
src/vm/exceptions.c
src/vm/jit/Makefile.am
src/vm/jit/alpha/codegen.c
src/vm/jit/alpha/linux/md-os.c
src/vm/jit/alpha/patcher.c
src/vm/jit/arm/linux/md-os.c
src/vm/jit/codegen-common.c
src/vm/jit/i386/codegen.c
src/vm/jit/i386/cygwin/md-os.c
src/vm/jit/i386/darwin/md-os.c
src/vm/jit/i386/freebsd/md-os.c
src/vm/jit/i386/linux/md-os.c
src/vm/jit/i386/patcher.c
src/vm/jit/i386/solaris/md-os.c
src/vm/jit/intrp/codegen.c
src/vm/jit/intrp/engine.c
src/vm/jit/jit.h
src/vm/jit/m68k/codegen.c
src/vm/jit/m68k/patcher.c
src/vm/jit/mips/irix/md-os.c
src/vm/jit/mips/linux/md-os.c
src/vm/jit/powerpc/codegen.c
src/vm/jit/powerpc/darwin/md-os.c
src/vm/jit/powerpc/linux/md-os.c
src/vm/jit/powerpc/netbsd/md-os.c
src/vm/jit/powerpc/patcher.c
src/vm/jit/powerpc64/codegen.c
src/vm/jit/powerpc64/linux/md-os.c
src/vm/jit/powerpc64/patcher.c
src/vm/jit/replace.c
src/vm/jit/replace.h
src/vm/jit/s390/codegen.c
src/vm/jit/s390/md.c
src/vm/jit/s390/patcher.c
src/vm/jit/sparc64/codegen.c
src/vm/jit/sparc64/linux/md-os.c
src/vm/jit/sparc64/patcher.c
src/vm/jit/sparc64/solaris/md-os.c
src/vm/jit/stacktrace.c [deleted file]
src/vm/jit/stacktrace.cpp [new file with mode: 0644]
src/vm/jit/stacktrace.h [deleted file]
src/vm/jit/stacktrace.hpp [new file with mode: 0644]
src/vm/jit/trap.c
src/vm/jit/x86_64/codegen.c
src/vm/jit/x86_64/freebsd/md-os.c
src/vm/jit/x86_64/linux/md-os.c
src/vm/jit/x86_64/patcher.c
src/vm/jit/x86_64/solaris/md-os.c

index 89ac2c2018b6df521a8f32f70583ca6bb55db34d..4e3e9589901a1d4de9a5abce7c4d4fb124443e37 100644 (file)
@@ -39,7 +39,7 @@
 
 #include "vm/global.h"
 #include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 
 rootset_t *rootset_create(void)
index fa529f5263eaef9a9e5c79bba39f08934a9cdf91..5f4a25ef611f214a99844b60d37b4dd3988666aa 100644 (file)
@@ -113,7 +113,7 @@ struct java_lang_ClassLoader;
 #include "vm/jit/argument.h"
 #include "vm/jit/asmpart.h"
 #include "vm/jit/jit.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 #include "vmcore/loader.h"
 #include "vmcore/options.h"
@@ -3674,7 +3674,7 @@ void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf)
 #  endif
        void                          *p;
 
-       TRACEJNICALLS(("_Jv_JNI_GetDirectBufferAddress(env=%p, buf=%p)", env, buf));
+       TRACEJNICALLSENTER(("_Jv_JNI_GetDirectBufferAddress(env=%p, buf=%p)", env, buf));
 
        /* Prevent compiler warning. */
 
@@ -3693,13 +3693,17 @@ void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf)
        paddress = (gnu_classpath_Pointer32 *) po;
 #  endif
 
-       if (paddress == NULL)
+       if (paddress == NULL) {
+               TRACEJNICALLSEXIT(("->%p", NULL));
                return NULL;
+       }
 
        LLNI_field_get_val(paddress, data, address);
 
        p = (void *) (intptr_t) address;
 
+       TRACEJNICALLSEXIT(("->%p", p));
+
        return p;
 
 # elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
index 12cf243f0c5d107e3a20cb486cf94939dca60c19..d7d7d13f7e9791dc6243c3eface59d766903bb81 100644 (file)
@@ -40,7 +40,7 @@
 #include "native/native.h"
 #include "native/jvmti/cacaodbg.h"
 #include "native/jvmti/jvmti.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/global.h"
 #include "vm/loader.h"
 #include "vm/builtin.h"
index 35885d1355e98dbf85bd9005f4c54c0963410045..0188a739e7812ee87c6de4f560c2c1ccca33ca72 100644 (file)
@@ -36,7 +36,7 @@
 #include "native/include/java_lang_Throwable.h"
 
 #include "vm/exceptions.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 
 /* native methods implemented by this file ************************************/
index eca8f531a7935dde6fa5d7df6319180b85d306ac..ee0857e0b9e22698d67d0e9d0e88681bcb025520 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "vm/global.h"
 
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 #include "vmcore/class.h"
 #include "vmcore/utf8.h"
index 85af51cda0905b543fef54793120b9c9792e002d..8b192e82b41fd7ef9a4c57d927b2aa027cc262de 100644 (file)
@@ -52,7 +52,7 @@ extern "C" {
 
 #include "vm/jit/code.h"
 #include "vm/jit/linenumbertable.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 #include "vmcore/class.h"
 #include "vmcore/loader.h"
index 4177531e48280cdde58b0e36f0896162e31bddb3..a1ab5674a16cbd13dc3b3153a70fff0fcad2b6f1 100644 (file)
@@ -66,8 +66,6 @@ extern "C" {
 #include "vm/resolve.h"
 #include "vm/stringlocal.h"
 
-#include "vm/jit/stacktrace.h"
-
 #include "vmcore/loader.h"
 #include "vmcore/utf8.h"
 
index 7e86b68925264d29f48c6233bba73e50b6db63ae..e585ffa7ed51ae2b1371baf67a719ee9cb9c3f7f 100644 (file)
@@ -1,9 +1,7 @@
-/* src/native/vm/gnu/java_security_VMAccessController.c
+/* src/native/vm/gnuclasspath/java_security_VMAccessController.c
 
-   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
@@ -36,7 +34,7 @@
 
 #include "vm/global.h"
 
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 #include "vmcore/utf8.h"
 
index 65c28ddbaadafe7f8d019a4817816e66f023761d..86f0c676df55c1af53e7a475774b1113afa06493 100644 (file)
@@ -78,7 +78,7 @@ HPI_SystemInterface  *hpi_system        = NULL;
 
 void hpi_initialize(void)
 {
-       char* boot_library_path;
+       const char* boot_library_path;
        int   len;
        char* p;
        utf*  u;
index af4e1a3c14658e091ca2c8db24ee2ce958fda7e7..b06b56b129a77b17ed3c8eb5a09cfb0a6fb2c8c5 100644 (file)
@@ -89,7 +89,7 @@
 #include "vm/stringlocal.h"
 #include "vm/vm.hpp"
 
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 #include "vmcore/classcache.h"
 #include "vmcore/options.h"
index 8c333adaf254c1109a534d0e75d54db45c15b440..2e40fb8d398638b534f06a98e62242225234af38 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "threads/thread.h"
 
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 
 /* global variables ***********************************************************/
index cefeeacebc589cf37770ab75767c46192784ee28..bd149bc3773937a1c1f757ec837281df71a72e44 100644 (file)
@@ -34,7 +34,7 @@
 
 #include "vm/builtin.h"
 
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 
 /* define some stuff we need to no-ops ****************************************/
index 23395267596248f6daebe2fe2b7956fc6847e1ec..5449cadfa6dbd23287859f9122fd0a43bbca857a 100644 (file)
@@ -59,7 +59,7 @@ typedef struct threadobject threadobject;
 # include "vm/jit/replace.h"
 #endif
 
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 #if defined(ENABLE_INTRP)
 #include "vm/jit/intrp/intrp.h"
index 79ae1a9d9a4548a26de06efca74d4a3e6a41ec93..133bb7e985b36697dee76305dad985375ee9d6af 100644 (file)
@@ -64,7 +64,7 @@
 #include "vm/stringlocal.h"
 #include "vm/vm.hpp"
 
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 #include "vmcore/class.h"
 #include "vmcore/method.h"
index 81ea76412329c8d74e8a2a52a876aa52d973e5b5..99d22406bcf49b3e6c2a21273fa7cae8e33ab4e0 100644 (file)
@@ -38,7 +38,7 @@
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
 
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 #include "vmcore/class.h"
 #include "vmcore/field.h"
index 642c31325dd7b3c5e87a75cba42e3538f59557ff..96badf145261b6b4141dbce04364a0cc149ad931 100644 (file)
@@ -61,7 +61,7 @@
 #include "vm/jit/methodheader.h"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/show.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trace.h"
 
 #include "vmcore/class.h"
index 015a917ce6cc392c394ac03c84dfd99e8638e1cd..00fbda82c4278b7f0c87c4aa9dae33ad337f4215 100644 (file)
@@ -174,8 +174,8 @@ libjit_la_SOURCES = \
        show.c \
        show.h \
        $(STACK_SOURCES) \
-       stacktrace.c \
-       stacktrace.h \
+       stacktrace.cpp \
+       stacktrace.hpp \
        trace.c \
        trace.h \
        $(TRAP_SOURCES)
index 7fcac9cee3e996546488a7d1d34624cd879f7a29..3ddee6c0a96f3181877a17097fab90145b82b14d 100644 (file)
@@ -60,7 +60,7 @@
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 #if defined(ENABLE_SSA)
index daad38ff3b8dea6e1c63f92628b2344c99322060..fb1b41005943ff079f0c48388106f144a89bd934 100644 (file)
@@ -42,7 +42,6 @@
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
-#include "vm/jit/stacktrace.h"
 #include "vm/jit/trap.h"
 
 #include "vmcore/system.h"
index f990bbe99fdcac16251520844b4b0d69f25646fd..219e60771e34114937adb43c3ebd7574940a6062 100644 (file)
@@ -42,7 +42,6 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/methodheader.h"
-#include "vm/jit/stacktrace.h"
 
 #include "vmcore/class.h"
 #include "vmcore/field.h"
index 9b78fa1e4e161e29c2190a22bd671410c18e08c4..9775b3f11f255e798cbe497b0b55216f92ff8f36 100644 (file)
@@ -58,7 +58,6 @@ typedef struct ucontext {
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
-#include "vm/jit/stacktrace.h"
 #include "vm/jit/trap.h"
 
 
index 5c2f9480cda2a95c4e7e3b36d9fd87952e5939bf..506f9c3063b5f3ffaaed56f363e2b7063676423d 100644 (file)
 # include "vm/jit/optimizing/lsra.h"
 # include "vm/jit/optimizing/ssa.h"
 #endif
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trace.h"
 
 #if defined(ENABLE_INTRP)
index 8e43cfe411be34d3367d09e9b3294feb8e7e6f9a..47c0f383b4188ead560609972843a4dc51f4b2d6 100644 (file)
@@ -61,7 +61,7 @@
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 #if defined(ENABLE_SSA)
index d629147551ee05cb1bcebce44fba1949456447c1..db19675b6b77a4821739fc225a4d49e95f063338 100644 (file)
@@ -36,7 +36,6 @@
 #include "vm/signallocal.h"
 #include "vm/stringlocal.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/stacktrace.h"
 
 
 /* md_signal_handler_sigsegv ***************************************************
index 26e86b21deb8a55a31a3328bd87a31f3a270235f..708a2ddab8a2be4977e1690ca0e0006f081d2645 100644 (file)
@@ -44,7 +44,7 @@
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 #include "vm/jit/i386/codegen.h"
index e9886e392146d53347e66bb08ff0ec7f99857102..a2d3246cfe0d2be923609c995a504a5c6d25b0fe 100644 (file)
@@ -32,7 +32,7 @@
 #include "vm/exceptions.h"
 #include "vm/signallocal.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 
 /* md_signal_handler_sigsegv ***************************************************
index 77a88c63b3efdf8b3245d8359ac6dc25b7f07a32..e5f6d8f37429c4d2f66154d06f9e5c8aad09cfc7 100644 (file)
@@ -43,7 +43,7 @@
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 
index 661c245e4ad0851dac5d088a938b982937d924aa..bc50dee7e64b990c907e99c40915f74732405e1e 100644 (file)
@@ -40,7 +40,6 @@
 #include "vm/initialize.h"
 
 #include "vm/jit/patcher-common.h"
-#include "vm/jit/stacktrace.h"
 
 #include "vmcore/class.h"
 #include "vmcore/field.h"
index a6929248293d5e2f9d6cb4f22ed4bf16a1e77b51..ee78ecc48d4b15411828f645050d2894db94e99e 100644 (file)
@@ -41,7 +41,7 @@
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 
index 41274d2e2d84fe033b1fc4dbfb0c1e4494a58b56..84f65fcac518a0b643a43b629c58d5a98b1a7e56 100644 (file)
@@ -60,7 +60,7 @@
 #include "vm/jit/parse.h"
 #include "vm/jit/patcher.h"
 #include "vm/jit/stack.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 #include "vmcore/class.h"
 #include "vmcore/options.h"
index 419fefe5da289d5b9e7b4eee6797e59efdfa908e..324073eacffb3080ced6210e5e58efbb3a3216dc 100644 (file)
@@ -46,7 +46,7 @@
 
 #include "vm/jit/methodheader.h"
 #include "vm/jit/patcher.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 #include "vmcore/loader.h"
 #include "vmcore/options.h"
index c447b1bd2db27018ba14c9e0eb2c7f3a6e3e4cc0..06e09aa45118ffea3cd5c9937fd6a2eaafa3b98c 100644 (file)
@@ -47,7 +47,7 @@ typedef struct exception_entry exception_entry;
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.h"
 #include "vm/jit/stack.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 #if defined(ENABLE_INLINING)
 # include "vm/jit/inline/inline.h"
index 9ec755cc5a3272e86cb4c00ad9b1aa2407557592..a50827ecd36ba269771a012deda04bc5f611fd90 100644 (file)
@@ -58,7 +58,7 @@
 #include "vm/jit/parse.h"
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 #include "vmcore/loader.h"
index 71607c7f42010a38a489cde522f59c4533c31759..659957c5ac45f993b73cc7ed10bba9e91089deea 100644 (file)
@@ -41,7 +41,6 @@
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/patcher-common.h"
-#include "vm/jit/stacktrace.h"
 
 #include "vmcore/class.h"
 #include "vmcore/field.h"
index 2ede96024f2ebb3302dc2e171983af488cbe55d7..73633f727d8e8ea62ad6514a9f10ba7b19890c59 100644 (file)
@@ -43,7 +43,6 @@
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/codegen-common.h"
-#include "vm/jit/stacktrace.h"
 
 
 /* md_init *********************************************************************
index 15f45c048624356f87e4d191f6a42844d3b5e0c1..c86e237f996826041c21bb15078d39fdab20f40e 100644 (file)
@@ -45,7 +45,6 @@
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
-#include "vm/jit/stacktrace.h"
 #include "vm/jit/trap.h"
 
 
index f29f6216b176a5a60c5198236f46e006c72602ee..dea7ada75f415c557355c88085b11bf48740533d 100644 (file)
@@ -62,7 +62,7 @@
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 #if defined(ENABLE_LSRA)
index b5fd3498a90697d3aa2e802539ebe407fe862549..a4f16f77579b375fe6fc63a9b9bd19a36fa7ddf7 100644 (file)
@@ -44,7 +44,6 @@
 #include "vm/stringlocal.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/stacktrace.h"
 
 
 /* md_signal_handler_sigsegv ***************************************************
index d56123600db2948fe3902ca1974c3ef0688c7b46..af37cd4d38ea16bb9a34e1fed9d425dec7c177c9 100644 (file)
@@ -49,7 +49,6 @@
 # include "vm/jit/optimizing/profile.h"
 #endif
 
-#include "vm/jit/stacktrace.h"
 #include "vm/jit/trap.h"
 
 #include "vmcore/system.h"
index e28f9a3f96f3a3f17ef2d2e5ba48297ff4c4f752..6b32ed4b8dd653955e07d42d0585b565827abeae 100644 (file)
@@ -35,7 +35,7 @@
 #include "vm/signallocal.h"
 #include "vm/stringlocal.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 
 /* md_signal_handle_sigsegv ****************************************************
index f87a1a99dc0a9b8c89fe739fffae0948071c1bb7..6abff234004eb966572e3c41b2d97bb68f687958 100644 (file)
@@ -43,7 +43,6 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/patcher-common.h"
-#include "vm/jit/stacktrace.h"
 
 #include "vmcore/class.h"
 #include "vmcore/field.h"
index 165d9bcc7a9e7610bf974e4b7eae7ecec0e21ed1..5474443e8de5e2b3224dde2713aaa9ebf473b8a7 100644 (file)
@@ -62,7 +62,7 @@
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 #include "vmcore/loader.h"
index 5a0c0497b3512800e979c59b2adcbe2f7f9cbd12..3ffba6f22e542362acb4d9d6474cfb445fc8cec1 100644 (file)
@@ -48,7 +48,6 @@
 # include "vm/jit/optimizing/profile.h"
 #endif
 
-#include "vm/jit/stacktrace.h"
 #include "vm/jit/trap.h"
 
 
index 8f6f160ad37bf1e942993e94e7206f5df6121fd4..ca12c5d4901243c79d9d231268c9ae355cbd16c1 100644 (file)
@@ -43,7 +43,6 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/patcher-common.h"
-#include "vm/jit/stacktrace.h"
 
 #include "vmcore/class.h"
 #include "vmcore/field.h"
index cf17b13fa9fd2d841a5f42102b5eb03bba252f99..53c13c652311c1230b81b73479c72af6f59d6846 100644 (file)
@@ -2304,7 +2304,7 @@ static void replace_pop_native_frame(executionstate_t *es,
        /* remember pc and size of native frame */
 
        frame->nativepc = es->pc;
-       frame->nativeframesize = (es->sp != 0) ? (sfi->sp - es->sp) : 0;
+       frame->nativeframesize = (es->sp != 0) ? (((uintptr_t) sfi->sp) - ((uintptr_t) es->sp)) : 0;
        assert(frame->nativeframesize >= 0);
 
        /* remember values of saved registers */
@@ -2376,12 +2376,12 @@ static void replace_pop_native_frame(executionstate_t *es,
 
        /* XXX michi: use this instead:
        es->sp = sfi->sp + code->stackframesize; */
-       es->sp   = sfi->sp + (*(s4 *) (sfi->pv + FrameSize));
+       es->sp   = (void*) (((uintptr_t) sfi->sp) + (*(s4 *) (((uintptr_t) sfi->pv) + FrameSize)));
 #if defined(REPLACE_RA_BETWEEN_FRAMES)
        es->sp  += SIZE_OF_STACKSLOT; /* skip return address */
 #endif
        es->pv   = md_codegen_get_pv_from_pc(sfi->ra);
-       es->pc   = ((sfi->xpc) ? sfi->xpc : sfi->ra) - 1;
+       es->pc   = (void*) (((uintptr_t) ((sfi->xpc) ? sfi->xpc : sfi->ra)) - 1);
        es->code = code_get_codeinfo_for_pv(es->pv);
 }
 
@@ -2425,7 +2425,7 @@ static void replace_push_native_frame(executionstate_t *es, sourcestate_t *ss)
 
        /* skip sp for the native stub */
 
-       es->sp -= (*(s4 *) (frame->sfi->pv + FrameSize));
+       es->sp -= (*(s4 *) (((uintptr_t) frame->sfi->pv) + FrameSize));
 #if defined(REPLACE_RA_BETWEEN_FRAMES)
        es->sp -= SIZE_OF_STACKSLOT; /* skip return address */
 #endif
index 294e367274311efbc4e22ddd179830050b6b239e..7f5c2885ef3b3ac14355ca748c9f608aa5bd2807 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/replace.h - on-stack replacement of methods
 
-   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
@@ -60,7 +58,7 @@ typedef union  replace_val_t replace_val_t;
 #include "md-abi.h"
 
 #include "vm/jit/reg.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 #include "vmcore/method.h"
 
index 79c39b22b15dd0df0a8a4bfe55eac52fc9a6dc99..e2748a2ded28b00aa80c6457622c166ef29f42d9 100644 (file)
@@ -68,7 +68,7 @@
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 
index b21bbb87190bebee9e8eeb6eb98d1f99a09e7f3d..3b6249907a84e01ae32c76ddd7386f4d29918300 100644 (file)
@@ -44,7 +44,7 @@
 #include "vm/jit/executionstate.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/methodtree.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 #if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER)
index 667aa07587c0f05db22fb65ce0ee78b20727c4c3..a2acfc9f5745251f16e7e18a4ef6bf5810a7fbfb 100644 (file)
@@ -36,7 +36,6 @@
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/s390/codegen.h"
 #include "vm/jit/s390/md-abi.h"
-#include "vm/jit/stacktrace.h"
 #include "vm/resolve.h"
 #include "vm/types.h"
 #include "vmcore/class.h"
index e32761a5864ee426903381ee7cdc577e9efecee7..803d27c6510adf1a25106082a2dea2daa02625f7 100644 (file)
@@ -57,7 +57,7 @@
 #include "vm/jit/patcher.h"
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 #include "vmcore/loader.h"
 #include "vmcore/options.h"
index 815308bd6b2acaf24bcb22208ac8613dd77a1201..c33efe3c56c485362231ae4be3b1de33d1fc4a3d 100644 (file)
@@ -38,7 +38,7 @@
 #include "vm/stringlocal.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 
index 576e710c918b8b8bf324722167953d0121066f21..44479aafb774efdb193ad052524d059673025c39 100644 (file)
@@ -44,7 +44,7 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/patcher.h"
 #include "vm/jit/methodheader.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 #include "vmcore/class.h"
 #include "vmcore/field.h"
index af39da6e8d215c48e3eae776388345e0f5d8dfd4..33959e76d8f88dd0d18d21fb6d9e49cdf09da44c 100644 (file)
@@ -42,7 +42,7 @@
 #include "vm/stringlocal.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 
diff --git a/src/vm/jit/stacktrace.c b/src/vm/jit/stacktrace.c
deleted file mode 100644 (file)
index a0d6933..0000000
+++ /dev/null
@@ -1,1328 +0,0 @@
-/* src/vm/jit/stacktrace.c - machine independent stacktrace system
-
-   Copyright (C) 1996-2005, 2006, 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   This file is part of CACAO.
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2, or (at
-   your option) any later version.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "vm/types.h"
-
-#include "md.h"
-
-#include "mm/gc.hpp"
-#include "mm/memory.h"
-
-#include "vm/jit/stacktrace.h"
-
-#include "vm/global.h"                   /* required here for native includes */
-#include "native/jni.h"
-#include "native/llni.h"
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Throwable.h"
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-# include "native/include/gnu_classpath_Pointer.h"
-# include "native/include/java_lang_VMThrowable.h"
-#endif
-
-#include "threads/thread.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/array.h"
-#include "vm/builtin.h"
-#include "vm/cycles-stats.h"
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.hpp"
-
-#include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/linenumbertable.h"
-#include "vm/jit/methodheader.h"
-#include "vm/jit/methodtree.h"
-
-#include "vmcore/class.h"
-#include "vmcore/loader.h"
-#include "vmcore/method.h"
-#include "vmcore/options.h"
-
-
-/* global variables ***********************************************************/
-
-CYCLES_STATS_DECLARE(stacktrace_overhead        , 100, 1)
-CYCLES_STATS_DECLARE(stacktrace_fillInStackTrace, 40,  5000)
-CYCLES_STATS_DECLARE(stacktrace_get,              40,  5000)
-CYCLES_STATS_DECLARE(stacktrace_getClassContext , 40,  5000)
-CYCLES_STATS_DECLARE(stacktrace_getCurrentClass , 40,  5000)
-CYCLES_STATS_DECLARE(stacktrace_get_stack       , 40,  10000)
-
-
-/* stacktrace_stackframeinfo_add ***********************************************
-
-   Fills a stackframe info structure with the given or calculated
-   values and adds it to the chain.
-
-*******************************************************************************/
-
-void stacktrace_stackframeinfo_add(stackframeinfo_t *sfi, u1 *pv, u1 *sp, u1 *ra, u1 *xpc)
-{
-       stackframeinfo_t *currentsfi;
-       codeinfo         *code;
-#if defined(ENABLE_JIT)
-       s4                 framesize;
-#endif
-
-       /* Get current stackframe info. */
-
-       currentsfi = threads_get_current_stackframeinfo();
-
-       /* sometimes we don't have pv handy (e.g. in asmpart.S:
-       L_asm_call_jit_compiler_exception or in the interpreter). */
-
-       if (pv == NULL) {
-#if defined(ENABLE_INTRP)
-               if (opt_intrp)
-                       pv = methodtree_find(ra);
-               else
-#endif
-                       {
-#if defined(ENABLE_JIT)
-# if defined(__SPARC_64__)
-                               pv = md_get_pv_from_stackframe(sp);
-# else
-                               pv = md_codegen_get_pv_from_pc(ra);
-# endif
-#endif
-                       }
-       }
-
-       /* Get codeinfo pointer for the parent Java method. */
-
-       code = code_get_codeinfo_for_pv(pv);
-
-       /* XXX */
-       /*      assert(m != NULL); */
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       /* When using the interpreter, we pass RA to the function. */
-
-       if (!opt_intrp) {
-# endif
-# if defined(__I386__) || defined(__X86_64__) || defined(__S390__) || defined(__M68K__)
-               /* On i386 and x86_64 we always have to get the return address
-                  from the stack. */
-               /* m68k has return address on stack always */
-               /* On S390 we use REG_RA as REG_ITMP3, so we have always to get
-                  the RA from stack. */
-
-               framesize = *((u4 *) (pv + FrameSize));
-
-               ra = md_stacktrace_get_returnaddress(sp, framesize);
-# else
-               /* If the method is a non-leaf function, we need to get the
-                  return address from the stack.  For leaf functions the
-                  return address is set correctly.  This makes the assembler
-                  and the signal handler code simpler.  The code is NULL is
-                  the asm_vm_call_method special case. */
-
-               if ((code == NULL) || !code_is_leafmethod(code)) {
-                       framesize = *((u4 *) (pv + FrameSize));
-
-                       ra = md_stacktrace_get_returnaddress(sp, framesize);
-               }
-# endif
-# if defined(ENABLE_INTRP)
-       }
-# endif
-#endif
-
-       /* Calculate XPC when not given.  The XPC is then the return
-          address of the current method minus 1 because the RA points to
-          the instruction after the call instruction.  This is required
-          e.g. for method stubs. */
-
-       if (xpc == NULL) {
-               xpc = (void *) (((intptr_t) ra) - 1);
-       }
-
-       /* Fill new stackframeinfo structure. */
-
-       sfi->prev = currentsfi;
-       sfi->code = code;
-       sfi->pv   = pv;
-       sfi->sp   = sp;
-       sfi->ra   = ra;
-       sfi->xpc  = xpc;
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackFrameInfo) {
-               log_start();
-               log_print("[stackframeinfo add   : sfi=%p, method=%p, pv=%p, sp=%p, ra=%p, xpc=%p, method=",
-                                 sfi, sfi->code->m, sfi->pv, sfi->sp, sfi->ra, sfi->xpc);
-               method_print(sfi->code->m);
-               log_print("]");
-               log_finish();
-       }
-#endif
-
-       /* Store new stackframeinfo pointer. */
-
-       threads_set_current_stackframeinfo(sfi);
-
-       /* set the native world flag for the current thread */
-       /* ATTENTION: This flag tells the GC how to treat this thread in case of
-          a collection. Set this flag _after_ a valid stackframe info was set. */
-
-       THREAD_NATIVEWORLD_ENTER;
-}
-
-
-/* stacktrace_stackframeinfo_remove ********************************************
-
-   Remove the given stackframeinfo from the chain in the current
-   thread.
-
-*******************************************************************************/
-
-void stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi)
-{
-       /* Clear the native world flag for the current thread. */
-       /* ATTENTION: Clear this flag _before_ removing the stackframe info. */
-
-       THREAD_NATIVEWORLD_EXIT;
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackFrameInfo) {
-               log_start();
-               log_print("[stackframeinfo remove: sfi=%p, method=%p, pv=%p, sp=%p, ra=%p, xpc=%p, method=",
-                                 sfi, sfi->code->m, sfi->pv, sfi->sp, sfi->ra, sfi->xpc);
-               method_print(sfi->code->m);
-               log_print("]");
-               log_finish();
-       }
-#endif
-
-       /* Set previous stackframe info. */
-
-       threads_set_current_stackframeinfo(sfi->prev);
-}
-
-
-/* stacktrace_stackframeinfo_fill **********************************************
-
-   Fill the temporary stackframeinfo structure with the values given
-   in sfi.
-
-   IN:
-       tmpsfi ... temporary stackframeinfo
-       sfi ...... stackframeinfo to be used in the next iteration
-
-*******************************************************************************/
-
-static inline void stacktrace_stackframeinfo_fill(stackframeinfo_t *tmpsfi, stackframeinfo_t *sfi)
-{
-       /* Sanity checks. */
-
-       assert(tmpsfi != NULL);
-       assert(sfi != NULL);
-
-       /* Fill the temporary stackframeinfo. */
-
-       tmpsfi->code = sfi->code;
-       tmpsfi->pv   = sfi->pv;
-       tmpsfi->sp   = sfi->sp;
-       tmpsfi->ra   = sfi->ra;
-       tmpsfi->xpc  = sfi->xpc;
-
-       /* Set the previous stackframe info of the temporary one to the
-          next in the chain. */
-
-       tmpsfi->prev = sfi->prev;
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackTrace)
-               log_println("[stacktrace fill]");
-#endif
-}
-
-
-/* stacktrace_stackframeinfo_next **********************************************
-
-   Walk the stack (or the stackframeinfo-chain) to the next method and
-   return the new stackframe values in the temporary stackframeinfo
-   passed.
-
-   ATTENTION: This function does NOT skip builtin methods!
-
-   IN:
-       tmpsfi ... temporary stackframeinfo of current method
-
-*******************************************************************************/
-
-static inline void stacktrace_stackframeinfo_next(stackframeinfo_t *tmpsfi)
-{
-       codeinfo         *code;
-       void             *pv;
-       void             *sp;
-       void             *ra;
-       void             *xpc;
-       uint32_t          framesize;
-       stackframeinfo_t *prevsfi;
-
-       /* Sanity check. */
-
-       assert(tmpsfi != NULL);
-
-       /* Get values from the stackframeinfo. */
-
-       code = tmpsfi->code;
-       pv   = tmpsfi->pv;
-       sp   = tmpsfi->sp;
-       ra   = tmpsfi->ra;
-       xpc  = tmpsfi->xpc;
-       /* Get the current stack frame size. */
-
-       framesize = *((uint32_t *) (((intptr_t) pv) + FrameSize));
-
-       /* Get the RA of the current stack frame (RA to the parent Java
-          method) if the current method is a non-leaf method.  Otherwise
-          the value in the stackframeinfo is correct (from the signal
-          handler). */
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               ra = intrp_md_stacktrace_get_returnaddress(sp, framesize);
-       else
-# endif
-               {
-                       if (!code_is_leafmethod(code))
-                               ra = md_stacktrace_get_returnaddress(sp, framesize);
-               }
-#else
-       ra = intrp_md_stacktrace_get_returnaddress(sp, framesize);
-#endif
-
-       /* Get the PV for the parent Java method. */
-
-#if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               pv = methodtree_find(ra);
-       else
-#endif
-               {
-#if defined(ENABLE_JIT)
-# if defined(__SPARC_64__)
-                       sp = md_get_framepointer(sp);
-                       pv = md_get_pv_from_stackframe(sp);
-# else
-                       pv = md_codegen_get_pv_from_pc(ra);
-# endif
-#endif
-               }
-
-       /* Get the codeinfo pointer for the parent Java method. */
-
-       code = code_get_codeinfo_for_pv(pv);
-
-       /* Calculate the SP for the parent Java method. */
-
-#if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               sp = *(u1 **) (sp - framesize);
-       else
-#endif
-               {
-#if defined(__I386__) || defined (__X86_64__) || defined (__M68K__)
-                       sp = (void *) (((intptr_t) sp) + framesize + SIZEOF_VOID_P);
-#elif defined(__SPARC_64__)
-                       /* already has the new sp */
-#else
-                       sp = (void *) (((intptr_t) sp) + framesize);
-#endif
-               }
-
-       /* If the new codeinfo pointer is NULL we reached a
-          asm_vm_call_method function.  In this case we get the next
-          values from the previous stackframeinfo in the chain.
-          Otherwise the new values have been calculated before. */
-
-       if (code == NULL) {
-               prevsfi = tmpsfi->prev;
-
-               /* If the previous stackframeinfo in the chain is NULL we
-                  reached the top of the stacktrace.  We set code and prev to
-                  NULL to mark the end, which is checked in
-                  stacktrace_stackframeinfo_end_check. */
-
-               if (prevsfi == NULL) {
-                       tmpsfi->code = NULL;
-                       tmpsfi->prev = NULL;
-                       return;
-               }
-
-               /* Fill the temporary stackframeinfo with the new values. */
-
-               stacktrace_stackframeinfo_fill(tmpsfi, prevsfi);
-       }
-       else {
-               /* Store the new values in the stackframeinfo.  NOTE: We
-                  subtract 1 from the RA to get the XPC, because the RA
-                  points to the instruction after the call instruction. */
-
-               tmpsfi->code = code;
-               tmpsfi->pv   = pv;
-               tmpsfi->sp   = sp;
-               tmpsfi->ra   = ra;
-               tmpsfi->xpc  = (void *) (((intptr_t) ra) - 1);
-       }
-
-#if !defined(NDEBUG)
-       /* Print current method information. */
-
-       if (opt_DebugStackTrace) {
-               log_start();
-               log_print("[stacktrace: method=%p, pv=%p, sp=%p, ra=%p, xpc=%p, method=",
-                                 tmpsfi->code->m, tmpsfi->pv, tmpsfi->sp, tmpsfi->ra,
-                                 tmpsfi->xpc);
-               method_print(tmpsfi->code->m);
-               log_print("]");
-               log_finish();
-       }
-#endif
-}
-
-
-/* stacktrace_stackframeinfo_end_check *****************************************
-
-   Check if we reached the end of the stacktrace.
-
-   IN:
-       tmpsfi ... temporary stackframeinfo of current method
-
-   RETURN:
-       true .... the end is reached
-          false ... the end is not reached
-
-*******************************************************************************/
-
-static inline bool stacktrace_stackframeinfo_end_check(stackframeinfo_t *tmpsfi)
-{
-       /* Sanity check. */
-
-       assert(tmpsfi != NULL);
-
-       if ((tmpsfi->code == NULL) && (tmpsfi->prev == NULL)) {
-#if !defined(NDEBUG)
-               if (opt_DebugStackTrace)
-                       log_println("[stacktrace stop]");
-#endif
-
-               return true;
-       }
-
-       return false;
-}
-
-
-/* stacktrace_depth ************************************************************
-
-   Calculates and returns the depth of the current stacktrace.
-
-   IN:
-       sfi ... stackframeinfo where to start the stacktrace
-
-   RETURN:
-       depth of the stacktrace
-
-*******************************************************************************/
-
-static int stacktrace_depth(stackframeinfo_t *sfi)
-{
-       stackframeinfo_t  tmpsfi;
-       int               depth;
-       methodinfo       *m;
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackTrace)
-               log_println("[stacktrace_depth]");
-#endif
-
-       /* XXX This is not correct, but a workaround for threads-dump for
-          now. */
-/*     assert(sfi != NULL); */
-       if (sfi == NULL)
-               return 0;
-
-       /* Iterate over all stackframes. */
-
-       depth = 0;
-
-       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
-                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
-                stacktrace_stackframeinfo_next(&tmpsfi)) {
-               /* Get methodinfo. */
-
-               m = tmpsfi.code->m;
-
-               /* Skip builtin methods. */
-
-               if (m->flags & ACC_METHOD_BUILTIN)
-                       continue;
-
-               depth++;
-       }
-
-       return depth;
-}
-
-
-/* stacktrace_get **************************************************************
-
-   Builds and returns a stacktrace starting from the given stackframe
-   info and returns the stacktrace structure wrapped in a Java
-   byte-array to not confuse the GC.
-
-   IN:
-       sfi ... stackframe info to start stacktrace from
-
-   RETURN:
-       stacktrace as Java byte-array
-
-*******************************************************************************/
-
-java_handle_bytearray_t *stacktrace_get(stackframeinfo_t *sfi)
-{
-       stackframeinfo_t         tmpsfi;
-       int                      depth;
-       java_handle_bytearray_t *ba;
-       int32_t                  ba_size;
-       stacktrace_t            *st;
-       stacktrace_entry_t      *ste;
-       methodinfo              *m;
-       bool                     skip_fillInStackTrace;
-       bool                     skip_init;
-
-       CYCLES_STATS_DECLARE_AND_START_WITH_OVERHEAD
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackTrace)
-               log_println("[stacktrace_get]");
-#endif
-
-       skip_fillInStackTrace = true;
-       skip_init             = true;
-
-       depth = stacktrace_depth(sfi);
-
-       if (depth == 0)
-               return NULL;
-
-       /* Allocate memory from the GC heap and copy the stacktrace
-          buffer. */
-       /* ATTENTION: Use a Java byte-array for this to not confuse the
-          GC. */
-       /* FIXME: We waste some memory here as we skip some entries
-          later. */
-
-       ba_size = sizeof(stacktrace_t) + sizeof(stacktrace_entry_t) * depth;
-
-       ba = builtin_newarray_byte(ba_size);
-
-       if (ba == NULL)
-               goto return_NULL;
-
-       /* Get a stacktrace entry pointer. */
-       /* ATTENTION: We need a critical section here because we use the
-          byte-array data pointer directly. */
-
-       LLNI_CRITICAL_START;
-
-       st = (stacktrace_t *) LLNI_array_data(ba);
-
-       ste = st->entries;
-
-       /* Iterate over the whole stack. */
-
-       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
-                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
-                stacktrace_stackframeinfo_next(&tmpsfi)) {
-               /* Get the methodinfo. */
-
-               m = tmpsfi.code->m;
-
-               /* Skip builtin methods. */
-
-               if (m->flags & ACC_METHOD_BUILTIN)
-                       continue;
-
-               /* This logic is taken from
-                  hotspot/src/share/vm/classfile/javaClasses.cpp
-                  (java_lang_Throwable::fill_in_stack_trace). */
-
-               if (skip_fillInStackTrace == true) {
-                       /* Check "fillInStackTrace" only once, so we negate the
-                          flag after the first time check. */
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-                       /* For GNU Classpath we also need to skip
-                          VMThrowable.fillInStackTrace(). */
-
-                       if ((m->clazz == class_java_lang_VMThrowable) &&
-                               (m->name  == utf_fillInStackTrace))
-                               continue;
-#endif
-
-                       skip_fillInStackTrace = false;
-
-                       if (m->name == utf_fillInStackTrace)
-                               continue;
-               }
-
-               /* Skip <init> methods of the exceptions klass.  If there is
-                  <init> methods that belongs to a superclass of the
-                  exception we are going to skipping them in stack trace. */
-
-               if (skip_init == true) {
-                       if ((m->name == utf_init) &&
-                               (class_issubclass(m->clazz, class_java_lang_Throwable))) {
-                               continue;
-                       }
-                       else {
-                               /* If no "Throwable.init()" method found, we stop
-                                  checking it next time. */
-
-                               skip_init = false;
-                       }
-               }
-
-               /* Store the stacktrace entry and increment the pointer. */
-
-               ste->code = tmpsfi.code;
-               ste->pc   = tmpsfi.xpc;
-
-               ste++;
-       }
-
-       /* Store the number of entries in the stacktrace structure. */
-
-       st->length = ste - st->entries;
-
-       LLNI_CRITICAL_END;
-
-       /* release dump memory */
-
-/*     dump_release(dumpsize); */
-
-       CYCLES_STATS_END_WITH_OVERHEAD(stacktrace_fillInStackTrace,
-                                                                  stacktrace_overhead)
-       return ba;
-
-return_NULL:
-/*     dump_release(dumpsize); */
-
-       CYCLES_STATS_END_WITH_OVERHEAD(stacktrace_fillInStackTrace,
-                                                                  stacktrace_overhead)
-
-       return NULL;
-}
-
-
-/* stacktrace_get_current ******************************************************
-
-   Builds and returns a stacktrace from the current thread and returns
-   the stacktrace structure wrapped in a Java byte-array to not
-   confuse the GC.
-
-   RETURN:
-       stacktrace as Java byte-array
-
-*******************************************************************************/
-
-java_handle_bytearray_t *stacktrace_get_current(void)
-{
-       stackframeinfo_t        *sfi;
-       java_handle_bytearray_t *ba;
-
-       sfi = threads_get_current_stackframeinfo();
-       ba  = stacktrace_get(sfi);
-
-       return ba;
-}
-
-
-/* stacktrace_get_caller_class *************************************************
-
-   Get the class on the stack at the given depth.  This function skips
-   various special classes or methods.
-
-   ARGUMENTS:
-       depth ... depth to get caller class of
-
-   RETURN:
-       caller class
-
-*******************************************************************************/
-
-#if defined(ENABLE_JAVASE)
-classinfo *stacktrace_get_caller_class(int depth)
-{
-       stackframeinfo_t *sfi;
-       stackframeinfo_t  tmpsfi;
-       methodinfo       *m;
-       classinfo        *c;
-       int               i;
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackTrace)
-               log_println("[stacktrace_get_caller_class]");
-#endif
-
-       /* Get the stackframeinfo of the current thread. */
-
-       sfi = threads_get_current_stackframeinfo();
-
-       /* Iterate over the whole stack until we reached the requested
-          depth. */
-
-       i = 0;
-
-       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
-                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
-                stacktrace_stackframeinfo_next(&tmpsfi)) {
-
-               m = tmpsfi.code->m;
-               c = m->clazz;
-
-               /* Skip builtin methods. */
-
-               if (m->flags & ACC_METHOD_BUILTIN)
-                       continue;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-               /* NOTE: See hotspot/src/share/vm/runtime/vframe.cpp
-                  (vframeStreamCommon::security_get_caller_frame). */
-
-               /* This is java.lang.reflect.Method.invoke(), skip it. */
-
-               if (m == method_java_lang_reflect_Method_invoke)
-                       continue;
-
-               /* This is an auxiliary frame, skip it. */
-
-               if (class_issubclass(c, class_sun_reflect_MagicAccessorImpl))
-                       continue;
-#endif
-
-               /* We reached the requested depth. */
-
-               if (i >= depth)
-                       return c;
-
-               i++;
-       }
-
-       return NULL;
-}
-#endif
-
-
-/* stacktrace_first_nonnull_classloader ****************************************
-
-   Returns the first non-null (user-defined) classloader on the stack.
-   If none is found NULL is returned.
-
-   RETURN:
-       classloader
-
-*******************************************************************************/
-
-classloader_t *stacktrace_first_nonnull_classloader(void)
-{
-       stackframeinfo_t *sfi;
-       stackframeinfo_t  tmpsfi;
-       methodinfo       *m;
-       classloader_t    *cl;
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackTrace)
-               log_println("[stacktrace_first_nonnull_classloader]");
-#endif
-
-       /* Get the stackframeinfo of the current thread. */
-
-       sfi = threads_get_current_stackframeinfo();
-
-       /* Iterate over the whole stack. */
-
-       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
-                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
-                stacktrace_stackframeinfo_next(&tmpsfi)) {
-
-               m  = tmpsfi.code->m;
-               cl = class_get_classloader(m->clazz);
-
-               if (cl != NULL)
-                       return cl;
-       }
-
-       return NULL;
-}
-
-
-/* stacktrace_getClassContext **************************************************
-
-   Creates a Class context array.
-
-   RETURN VALUE:
-      the array of java.lang.Class objects, or
-         NULL if an exception has been thrown
-
-*******************************************************************************/
-
-java_handle_objectarray_t *stacktrace_getClassContext(void)
-{
-       stackframeinfo_t           *sfi;
-       stackframeinfo_t            tmpsfi;
-       int                         depth;
-       java_handle_objectarray_t  *oa;
-       java_object_t             **data;
-       int                         i;
-       methodinfo                 *m;
-
-       CYCLES_STATS_DECLARE_AND_START
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackTrace)
-               log_println("[stacktrace_getClassContext]");
-#endif
-
-       sfi = threads_get_current_stackframeinfo();
-
-       /* Get the depth of the current stack. */
-
-       depth = stacktrace_depth(sfi);
-
-       /* The first stackframe corresponds to the method whose
-          implementation calls this native function.  We remove that
-          entry. */
-
-       depth--;
-       stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
-       stacktrace_stackframeinfo_next(&tmpsfi);
-
-       /* Allocate the Class array. */
-
-       oa = builtin_anewarray(depth, class_java_lang_Class);
-
-       if (oa == NULL) {
-               CYCLES_STATS_END(stacktrace_getClassContext);
-
-               return NULL;
-       }
-
-       /* Fill the Class array from the stacktrace list. */
-
-       LLNI_CRITICAL_START;
-
-       data = LLNI_array_data(oa);
-
-       /* Iterate over the whole stack. */
-
-       i = 0;
-
-       for (;
-                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
-                stacktrace_stackframeinfo_next(&tmpsfi)) {
-               /* Get methodinfo. */
-
-               m = tmpsfi.code->m;
-
-               /* Skip builtin methods. */
-
-               if (m->flags & ACC_METHOD_BUILTIN)
-                       continue;
-
-               /* Store the class in the array. */
-
-               data[i] = (java_object_t *) m->clazz;
-
-               i++;
-       }
-
-       LLNI_CRITICAL_END;
-
-       CYCLES_STATS_END(stacktrace_getClassContext)
-
-       return oa;
-}
-
-
-/* stacktrace_getCurrentClass **************************************************
-
-   Find the current class by walking the stack trace.
-
-   Quote from the JNI documentation:
-        
-   In the Java 2 Platform, FindClass locates the class loader
-   associated with the current native method.  If the native code
-   belongs to a system class, no class loader will be
-   involved. Otherwise, the proper class loader will be invoked to
-   load and link the named class. When FindClass is called through the
-   Invocation Interface, there is no current native method or its
-   associated class loader. In that case, the result of
-   ClassLoader.getBaseClassLoader is used."
-
-*******************************************************************************/
-
-#if defined(ENABLE_JAVASE)
-classinfo *stacktrace_get_current_class(void)
-{
-       stackframeinfo_t *sfi;
-       stackframeinfo_t  tmpsfi;
-       methodinfo       *m;
-
-       CYCLES_STATS_DECLARE_AND_START;
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackTrace)
-               log_println("[stacktrace_get_current_class]");
-#endif
-
-       /* Get the stackframeinfo of the current thread. */
-
-       sfi = threads_get_current_stackframeinfo();
-
-       /* If the stackframeinfo is NULL then FindClass is called through
-          the Invocation Interface and we return NULL */
-
-       if (sfi == NULL) {
-               CYCLES_STATS_END(stacktrace_getCurrentClass);
-
-               return NULL;
-       }
-
-       /* Iterate over the whole stack. */
-
-       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
-                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
-                stacktrace_stackframeinfo_next(&tmpsfi)) {
-               /* Get the methodinfo. */
-
-               m = tmpsfi.code->m;
-
-               if (m->clazz == class_java_security_PrivilegedAction) {
-                       CYCLES_STATS_END(stacktrace_getCurrentClass);
-
-                       return NULL;
-               }
-
-               if (m->clazz != NULL) {
-                       CYCLES_STATS_END(stacktrace_getCurrentClass);
-
-                       return m->clazz;
-               }
-       }
-
-       /* No Java method found on the stack. */
-
-       CYCLES_STATS_END(stacktrace_getCurrentClass);
-
-       return NULL;
-}
-#endif /* ENABLE_JAVASE */
-
-
-/* stacktrace_get_stack ********************************************************
-
-   Create a 2-dimensional array for java.security.VMAccessControler.
-
-   RETURN VALUE:
-      the arrary, or
-         NULL if an exception has been thrown
-
-*******************************************************************************/
-
-#if defined(ENABLE_JAVASE) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-java_handle_objectarray_t *stacktrace_get_stack(void)
-{
-       stackframeinfo_t          *sfi;
-       stackframeinfo_t           tmpsfi;
-       int                        depth;
-       java_handle_objectarray_t *oa;
-       java_handle_objectarray_t *classes;
-       java_handle_objectarray_t *methodnames;
-       methodinfo                *m;
-       java_handle_t             *string;
-       int                        i;
-
-       CYCLES_STATS_DECLARE_AND_START
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackTrace)
-               log_println("[stacktrace_get_stack]");
-#endif
-
-       /* Get the stackframeinfo of the current thread. */
-
-       sfi = threads_get_current_stackframeinfo();
-
-       /* Get the depth of the current stack. */
-
-       depth = stacktrace_depth(sfi);
-
-       if (depth == 0)
-               return NULL;
-
-       /* Allocate the required arrays. */
-
-       oa = builtin_anewarray(2, arrayclass_java_lang_Object);
-
-       if (oa == NULL)
-               goto return_NULL;
-
-       classes = builtin_anewarray(depth, class_java_lang_Class);
-
-       if (classes == NULL)
-               goto return_NULL;
-
-       methodnames = builtin_anewarray(depth, class_java_lang_String);
-
-       if (methodnames == NULL)
-               goto return_NULL;
-
-       /* Set up the 2-dimensional array. */
-
-       array_objectarray_element_set(oa, 0, (java_handle_t *) classes);
-       array_objectarray_element_set(oa, 1, (java_handle_t *) methodnames);
-
-       /* Iterate over the whole stack. */
-       /* TODO We should use a critical section here to speed things
-          up. */
-
-       i = 0;
-
-       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
-                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
-                stacktrace_stackframeinfo_next(&tmpsfi)) {
-               /* Get the methodinfo. */
-
-               m = tmpsfi.code->m;
-
-               /* Skip builtin methods. */
-
-               if (m->flags & ACC_METHOD_BUILTIN)
-                       continue;
-
-               /* Store the class in the array. */
-               /* NOTE: We use a LLNI-macro here, because a classinfo is not
-                  a handle. */
-
-               LLNI_array_direct(classes, i) = (java_object_t *) m->clazz;
-
-               /* Store the name in the array. */
-
-               string = javastring_new(m->name);
-
-               if (string == NULL)
-                       goto return_NULL;
-
-               array_objectarray_element_set(methodnames, i, string);
-
-               i++;
-       }
-
-       CYCLES_STATS_END(stacktrace_get_stack)
-
-       return oa;
-
-return_NULL:
-       CYCLES_STATS_END(stacktrace_get_stack)
-
-       return NULL;
-}
-#endif
-
-
-/* stacktrace_print_entry ****************************************************
-
-   Print line for a stacktrace entry.
-
-   ARGUMENTS:
-       m ............ methodinfo of the entry
-       linenumber ... linenumber of the entry
-
-*******************************************************************************/
-
-static void stacktrace_print_entry(methodinfo *m, int32_t linenumber)
-{
-       /* Sanity check. */
-
-       assert(m != NULL);
-
-       printf("\tat ");
-
-       if (m->flags & ACC_METHOD_BUILTIN)
-               printf("NULL");
-       else
-               utf_display_printable_ascii_classname(m->clazz->name);
-
-       printf(".");
-       utf_display_printable_ascii(m->name);
-       utf_display_printable_ascii(m->descriptor);
-
-       if (m->flags & ACC_NATIVE) {
-               puts("(Native Method)");
-       }
-       else {
-               if (m->flags & ACC_METHOD_BUILTIN) {
-                       puts("(builtin)");
-               }
-               else {
-                       printf("(");
-                       utf_display_printable_ascii(m->clazz->sourcefile);
-                       printf(":%d)\n", linenumber);
-               }
-       }
-
-       fflush(stdout);
-}
-
-
-/* stacktrace_print ************************************************************
-
-   Print the given stacktrace with CACAO intern methods only (no Java
-   code required).
-
-   This method is used by stacktrace_dump_trace and
-   builtin_trace_exception.
-
-   IN:
-       st ... stacktrace to print
-
-*******************************************************************************/
-
-void stacktrace_print(stacktrace_t *st)
-{
-       stacktrace_entry_t *ste;
-       methodinfo         *m;
-       int32_t             linenumber;
-       int                 i;
-
-       ste = &(st->entries[0]);
-
-       for (i = 0; i < st->length; i++, ste++) {
-               m = ste->code->m;
-
-               /* Get the line number. */
-
-               linenumber = linenumbertable_linenumber_for_pc(&m, ste->code, ste->pc);
-
-               stacktrace_print_entry(m, linenumber);
-       }
-}
-
-
-/* stacktrace_print_current ****************************************************
-
-   Print the current stacktrace of the current thread.
-
-   NOTE: This function prints all frames of the stacktrace and does
-   not skip frames like stacktrace_get.
-
-*******************************************************************************/
-
-void stacktrace_print_current(void)
-{
-       stackframeinfo_t *sfi;
-       stackframeinfo_t  tmpsfi;
-       codeinfo         *code;
-       methodinfo       *m;
-       int32_t           linenumber;
-
-       sfi = threads_get_current_stackframeinfo();
-
-       if (sfi == NULL) {
-               puts("\t<<No stacktrace available>>");
-               fflush(stdout);
-               return;
-       }
-
-       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
-                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
-                stacktrace_stackframeinfo_next(&tmpsfi)) {
-               /* Get the methodinfo. */
-
-               code = tmpsfi.code;
-               m    = code->m;
-
-               /* Get the line number. */
-
-               linenumber = linenumbertable_linenumber_for_pc(&m, code, tmpsfi.xpc);
-
-               stacktrace_print_entry(m, linenumber);
-       }
-}
-
-
-/* stacktrace_print_of_thread **************************************************
-
-   Print the current stacktrace of the given thread.
-
-   ARGUMENTS:
-       t ... thread
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void stacktrace_print_of_thread(threadobject *t)
-{
-       stackframeinfo_t *sfi;
-       stackframeinfo_t  tmpsfi;
-       codeinfo         *code;
-       methodinfo       *m;
-       int32_t           linenumber;
-
-       /* Build a stacktrace for the passed thread. */
-
-       sfi = t->_stackframeinfo;
-       
-       if (sfi == NULL) {
-               puts("\t<<No stacktrace available>>");
-               fflush(stdout);
-               return;
-       }
-
-       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
-                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
-                stacktrace_stackframeinfo_next(&tmpsfi)) {
-               /* Get the methodinfo. */
-
-               code = tmpsfi.code;
-               m    = code->m;
-
-               /* Get the line number. */
-
-               linenumber = linenumbertable_linenumber_for_pc(&m, code, tmpsfi.xpc);
-
-               stacktrace_print_entry(m, linenumber);
-       }
-}
-#endif
-
-
-/* stacktrace_print_exception **************************************************
-
-   Print the stacktrace of a given exception (more or less a wrapper
-   to stacktrace_print).
-
-   IN:
-       h ... handle of exception to print
-
-*******************************************************************************/
-
-void stacktrace_print_exception(java_handle_t *h)
-{
-       java_lang_Throwable     *o;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       java_lang_VMThrowable   *vmt;
-#endif
-
-       java_lang_Object        *backtrace;
-       java_handle_bytearray_t *ba;
-       stacktrace_t            *st;
-
-       o = (java_lang_Throwable *) h;
-
-       if (o == NULL)
-               return;
-
-       /* now print the stacktrace */
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       LLNI_field_get_ref(o,   vmState, vmt);
-       LLNI_field_get_ref(vmt, vmdata,  backtrace);
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
-
-       LLNI_field_get_ref(o, backtrace, backtrace);
-
-#else
-# error unknown classpath configuration
-#endif
-
-       ba = (java_handle_bytearray_t *) backtrace;
-
-       /* Sanity check. */
-
-       assert(ba != NULL);
-
-       /* We need a critical section here as we use the byte-array data
-          pointer directly. */
-
-       LLNI_CRITICAL_START;
-       
-       st = (stacktrace_t *) LLNI_array_data(ba);
-
-       stacktrace_print(st);
-
-       LLNI_CRITICAL_END;
-}
-
-
-#if defined(ENABLE_CYCLES_STATS)
-void stacktrace_print_cycles_stats(FILE *file)
-{
-       CYCLES_STATS_PRINT_OVERHEAD(stacktrace_overhead, file);
-       CYCLES_STATS_PRINT(stacktrace_get,               file);
-       CYCLES_STATS_PRINT(stacktrace_getClassContext ,  file);
-       CYCLES_STATS_PRINT(stacktrace_getCurrentClass ,  file);
-       CYCLES_STATS_PRINT(stacktrace_get_stack,         file);
-}
-#endif
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
diff --git a/src/vm/jit/stacktrace.cpp b/src/vm/jit/stacktrace.cpp
new file mode 100644 (file)
index 0000000..0055467
--- /dev/null
@@ -0,0 +1,1333 @@
+/* src/vm/jit/stacktrace.cpp - machine independent stacktrace system
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "vm/types.h"
+
+#include "md.h"
+
+#include "mm/gc.hpp"
+#include "mm/memory.h"
+
+#include "vm/jit/stacktrace.hpp"
+
+#include "vm/global.h"                   /* required here for native includes */
+#include "native/jni.h"
+#include "native/llni.h"
+
+#include "native/include/java_lang_Object.h"
+#include "native/include/java_lang_Throwable.h"
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+# include "native/include/gnu_classpath_Pointer.h"
+# include "native/include/java_lang_VMThrowable.h"
+#endif
+
+#include "threads/thread.h"
+
+#include "toolbox/logging.h"
+
+#include "vm/array.h"
+#include "vm/builtin.h"
+#include "vm/cycles-stats.h"
+#include "vm/exceptions.h"
+#include "vm/stringlocal.h"
+#include "vm/vm.hpp"
+
+#include "vm/jit/asmpart.h"
+#include "vm/jit/codegen-common.h"
+#include "vm/jit/linenumbertable.h"
+#include "vm/jit/methodheader.h"
+#include "vm/jit/methodtree.h"
+
+#include "vmcore/class.h"
+#include "vmcore/loader.h"
+#include "vmcore/method.h"
+#include "vmcore/options.h"
+
+
+// FIXME Use C-linkage for now.
+extern "C" {
+
+/* global variables ***********************************************************/
+
+CYCLES_STATS_DECLARE(stacktrace_overhead        , 100, 1)
+CYCLES_STATS_DECLARE(stacktrace_fillInStackTrace, 40,  5000)
+CYCLES_STATS_DECLARE(stacktrace_get,              40,  5000)
+CYCLES_STATS_DECLARE(stacktrace_getClassContext , 40,  5000)
+CYCLES_STATS_DECLARE(stacktrace_getCurrentClass , 40,  5000)
+CYCLES_STATS_DECLARE(stacktrace_get_stack       , 40,  10000)
+
+
+/* stacktrace_stackframeinfo_add ***********************************************
+
+   Fills a stackframe info structure with the given or calculated
+   values and adds it to the chain.
+
+*******************************************************************************/
+
+void stacktrace_stackframeinfo_add(stackframeinfo_t* sfi, void* pv, void* sp, void* ra, void* xpc)
+{
+       stackframeinfo_t *currentsfi;
+       codeinfo         *code;
+#if defined(ENABLE_JIT)
+       s4                 framesize;
+#endif
+
+       /* Get current stackframe info. */
+
+       currentsfi = threads_get_current_stackframeinfo();
+
+       /* sometimes we don't have pv handy (e.g. in asmpart.S:
+       L_asm_call_jit_compiler_exception or in the interpreter). */
+
+       if (pv == NULL) {
+#if defined(ENABLE_INTRP)
+               if (opt_intrp)
+                       pv = methodtree_find(ra);
+               else
+#endif
+                       {
+#if defined(ENABLE_JIT)
+# if defined(__SPARC_64__)
+                               pv = md_get_pv_from_stackframe(sp);
+# else
+                               pv = md_codegen_get_pv_from_pc(ra);
+# endif
+#endif
+                       }
+       }
+
+       /* Get codeinfo pointer for the parent Java method. */
+
+       code = code_get_codeinfo_for_pv(pv);
+
+       /* XXX */
+       /*      assert(m != NULL); */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       /* When using the interpreter, we pass RA to the function. */
+
+       if (!opt_intrp) {
+# endif
+# if defined(__I386__) || defined(__X86_64__) || defined(__S390__) || defined(__M68K__)
+               /* On i386 and x86_64 we always have to get the return address
+                  from the stack. */
+               /* m68k has return address on stack always */
+               /* On S390 we use REG_RA as REG_ITMP3, so we have always to get
+                  the RA from stack. */
+
+               framesize = *((u4 *) (((uintptr_t) pv) + FrameSize));
+
+               ra = md_stacktrace_get_returnaddress(sp, framesize);
+# else
+               /* If the method is a non-leaf function, we need to get the
+                  return address from the stack.  For leaf functions the
+                  return address is set correctly.  This makes the assembler
+                  and the signal handler code simpler.  The code is NULL is
+                  the asm_vm_call_method special case. */
+
+               if ((code == NULL) || !code_is_leafmethod(code)) {
+                       framesize = *((u4 *) (((uintptr_t) pv) + FrameSize));
+
+                       ra = md_stacktrace_get_returnaddress(sp, framesize);
+               }
+# endif
+# if defined(ENABLE_INTRP)
+       }
+# endif
+#endif
+
+       /* Calculate XPC when not given.  The XPC is then the return
+          address of the current method minus 1 because the RA points to
+          the instruction after the call instruction.  This is required
+          e.g. for method stubs. */
+
+       if (xpc == NULL) {
+               xpc = (void *) (((intptr_t) ra) - 1);
+       }
+
+       /* Fill new stackframeinfo structure. */
+
+       sfi->prev = currentsfi;
+       sfi->code = code;
+       sfi->pv   = pv;
+       sfi->sp   = sp;
+       sfi->ra   = ra;
+       sfi->xpc  = xpc;
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackFrameInfo) {
+               log_start();
+               log_print("[stackframeinfo add   : sfi=%p, method=%p, pv=%p, sp=%p, ra=%p, xpc=%p, method=",
+                                 sfi, sfi->code->m, sfi->pv, sfi->sp, sfi->ra, sfi->xpc);
+               method_print(sfi->code->m);
+               log_print("]");
+               log_finish();
+       }
+#endif
+
+       /* Store new stackframeinfo pointer. */
+
+       threads_set_current_stackframeinfo(sfi);
+
+       /* set the native world flag for the current thread */
+       /* ATTENTION: This flag tells the GC how to treat this thread in case of
+          a collection. Set this flag _after_ a valid stackframe info was set. */
+
+       THREAD_NATIVEWORLD_ENTER;
+}
+
+
+/* stacktrace_stackframeinfo_remove ********************************************
+
+   Remove the given stackframeinfo from the chain in the current
+   thread.
+
+*******************************************************************************/
+
+void stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi)
+{
+       /* Clear the native world flag for the current thread. */
+       /* ATTENTION: Clear this flag _before_ removing the stackframe info. */
+
+       THREAD_NATIVEWORLD_EXIT;
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackFrameInfo) {
+               log_start();
+               log_print("[stackframeinfo remove: sfi=%p, method=%p, pv=%p, sp=%p, ra=%p, xpc=%p, method=",
+                                 sfi, sfi->code->m, sfi->pv, sfi->sp, sfi->ra, sfi->xpc);
+               method_print(sfi->code->m);
+               log_print("]");
+               log_finish();
+       }
+#endif
+
+       /* Set previous stackframe info. */
+
+       threads_set_current_stackframeinfo(sfi->prev);
+}
+
+
+/* stacktrace_stackframeinfo_fill **********************************************
+
+   Fill the temporary stackframeinfo structure with the values given
+   in sfi.
+
+   IN:
+       tmpsfi ... temporary stackframeinfo
+       sfi ...... stackframeinfo to be used in the next iteration
+
+*******************************************************************************/
+
+static inline void stacktrace_stackframeinfo_fill(stackframeinfo_t *tmpsfi, stackframeinfo_t *sfi)
+{
+       /* Sanity checks. */
+
+       assert(tmpsfi != NULL);
+       assert(sfi != NULL);
+
+       /* Fill the temporary stackframeinfo. */
+
+       tmpsfi->code = sfi->code;
+       tmpsfi->pv   = sfi->pv;
+       tmpsfi->sp   = sfi->sp;
+       tmpsfi->ra   = sfi->ra;
+       tmpsfi->xpc  = sfi->xpc;
+
+       /* Set the previous stackframe info of the temporary one to the
+          next in the chain. */
+
+       tmpsfi->prev = sfi->prev;
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackTrace)
+               log_println("[stacktrace fill]");
+#endif
+}
+
+
+/* stacktrace_stackframeinfo_next **********************************************
+
+   Walk the stack (or the stackframeinfo-chain) to the next method and
+   return the new stackframe values in the temporary stackframeinfo
+   passed.
+
+   ATTENTION: This function does NOT skip builtin methods!
+
+   IN:
+       tmpsfi ... temporary stackframeinfo of current method
+
+*******************************************************************************/
+
+static inline void stacktrace_stackframeinfo_next(stackframeinfo_t *tmpsfi)
+{
+       codeinfo         *code;
+       void             *pv;
+       void             *sp;
+       void             *ra;
+       void             *xpc;
+       uint32_t          framesize;
+       stackframeinfo_t *prevsfi;
+
+       /* Sanity check. */
+
+       assert(tmpsfi != NULL);
+
+       /* Get values from the stackframeinfo. */
+
+       code = tmpsfi->code;
+       pv   = tmpsfi->pv;
+       sp   = tmpsfi->sp;
+       ra   = tmpsfi->ra;
+       xpc  = tmpsfi->xpc;
+       /* Get the current stack frame size. */
+
+       framesize = *((uint32_t *) (((intptr_t) pv) + FrameSize));
+
+       /* Get the RA of the current stack frame (RA to the parent Java
+          method) if the current method is a non-leaf method.  Otherwise
+          the value in the stackframeinfo is correct (from the signal
+          handler). */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       if (opt_intrp)
+               ra = intrp_md_stacktrace_get_returnaddress(sp, framesize);
+       else
+# endif
+               {
+                       if (!code_is_leafmethod(code))
+                               ra = md_stacktrace_get_returnaddress(sp, framesize);
+               }
+#else
+       ra = intrp_md_stacktrace_get_returnaddress(sp, framesize);
+#endif
+
+       /* Get the PV for the parent Java method. */
+
+#if defined(ENABLE_INTRP)
+       if (opt_intrp)
+               pv = methodtree_find(ra);
+       else
+#endif
+               {
+#if defined(ENABLE_JIT)
+# if defined(__SPARC_64__)
+                       sp = md_get_framepointer(sp);
+                       pv = md_get_pv_from_stackframe(sp);
+# else
+                       pv = md_codegen_get_pv_from_pc(ra);
+# endif
+#endif
+               }
+
+       /* Get the codeinfo pointer for the parent Java method. */
+
+       code = code_get_codeinfo_for_pv(pv);
+
+       /* Calculate the SP for the parent Java method. */
+
+#if defined(ENABLE_INTRP)
+       if (opt_intrp)
+               sp = *(u1 **) (sp - framesize);
+       else
+#endif
+               {
+#if defined(__I386__) || defined (__X86_64__) || defined (__M68K__)
+                       sp = (void *) (((intptr_t) sp) + framesize + SIZEOF_VOID_P);
+#elif defined(__SPARC_64__)
+                       /* already has the new sp */
+#else
+                       sp = (void *) (((intptr_t) sp) + framesize);
+#endif
+               }
+
+       /* If the new codeinfo pointer is NULL we reached a
+          asm_vm_call_method function.  In this case we get the next
+          values from the previous stackframeinfo in the chain.
+          Otherwise the new values have been calculated before. */
+
+       if (code == NULL) {
+               prevsfi = tmpsfi->prev;
+
+               /* If the previous stackframeinfo in the chain is NULL we
+                  reached the top of the stacktrace.  We set code and prev to
+                  NULL to mark the end, which is checked in
+                  stacktrace_stackframeinfo_end_check. */
+
+               if (prevsfi == NULL) {
+                       tmpsfi->code = NULL;
+                       tmpsfi->prev = NULL;
+                       return;
+               }
+
+               /* Fill the temporary stackframeinfo with the new values. */
+
+               stacktrace_stackframeinfo_fill(tmpsfi, prevsfi);
+       }
+       else {
+               /* Store the new values in the stackframeinfo.  NOTE: We
+                  subtract 1 from the RA to get the XPC, because the RA
+                  points to the instruction after the call instruction. */
+
+               tmpsfi->code = code;
+               tmpsfi->pv   = pv;
+               tmpsfi->sp   = sp;
+               tmpsfi->ra   = ra;
+               tmpsfi->xpc  = (void *) (((intptr_t) ra) - 1);
+       }
+
+#if !defined(NDEBUG)
+       /* Print current method information. */
+
+       if (opt_DebugStackTrace) {
+               log_start();
+               log_print("[stacktrace: method=%p, pv=%p, sp=%p, ra=%p, xpc=%p, method=",
+                                 tmpsfi->code->m, tmpsfi->pv, tmpsfi->sp, tmpsfi->ra,
+                                 tmpsfi->xpc);
+               method_print(tmpsfi->code->m);
+               log_print("]");
+               log_finish();
+       }
+#endif
+}
+
+
+/* stacktrace_stackframeinfo_end_check *****************************************
+
+   Check if we reached the end of the stacktrace.
+
+   IN:
+       tmpsfi ... temporary stackframeinfo of current method
+
+   RETURN:
+       true .... the end is reached
+          false ... the end is not reached
+
+*******************************************************************************/
+
+static inline bool stacktrace_stackframeinfo_end_check(stackframeinfo_t *tmpsfi)
+{
+       /* Sanity check. */
+
+       assert(tmpsfi != NULL);
+
+       if ((tmpsfi->code == NULL) && (tmpsfi->prev == NULL)) {
+#if !defined(NDEBUG)
+               if (opt_DebugStackTrace)
+                       log_println("[stacktrace stop]");
+#endif
+
+               return true;
+       }
+
+       return false;
+}
+
+
+/* stacktrace_depth ************************************************************
+
+   Calculates and returns the depth of the current stacktrace.
+
+   IN:
+       sfi ... stackframeinfo where to start the stacktrace
+
+   RETURN:
+       depth of the stacktrace
+
+*******************************************************************************/
+
+static int stacktrace_depth(stackframeinfo_t *sfi)
+{
+       stackframeinfo_t  tmpsfi;
+       int               depth;
+       methodinfo       *m;
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackTrace)
+               log_println("[stacktrace_depth]");
+#endif
+
+       /* XXX This is not correct, but a workaround for threads-dump for
+          now. */
+/*     assert(sfi != NULL); */
+       if (sfi == NULL)
+               return 0;
+
+       /* Iterate over all stackframes. */
+
+       depth = 0;
+
+       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
+                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
+                stacktrace_stackframeinfo_next(&tmpsfi)) {
+               /* Get methodinfo. */
+
+               m = tmpsfi.code->m;
+
+               /* Skip builtin methods. */
+
+               if (m->flags & ACC_METHOD_BUILTIN)
+                       continue;
+
+               depth++;
+       }
+
+       return depth;
+}
+
+
+/* stacktrace_get **************************************************************
+
+   Builds and returns a stacktrace starting from the given stackframe
+   info and returns the stacktrace structure wrapped in a Java
+   byte-array to not confuse the GC.
+
+   IN:
+       sfi ... stackframe info to start stacktrace from
+
+   RETURN:
+       stacktrace as Java byte-array
+
+*******************************************************************************/
+
+java_handle_bytearray_t *stacktrace_get(stackframeinfo_t *sfi)
+{
+       stackframeinfo_t         tmpsfi;
+       int                      depth;
+       java_handle_bytearray_t *ba;
+       int32_t                  ba_size;
+       stacktrace_t            *st;
+       stacktrace_entry_t      *ste;
+       methodinfo              *m;
+       bool                     skip_fillInStackTrace;
+       bool                     skip_init;
+
+       CYCLES_STATS_DECLARE_AND_START_WITH_OVERHEAD
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackTrace)
+               log_println("[stacktrace_get]");
+#endif
+
+       skip_fillInStackTrace = true;
+       skip_init             = true;
+
+       depth = stacktrace_depth(sfi);
+
+       if (depth == 0)
+               return NULL;
+
+       /* Allocate memory from the GC heap and copy the stacktrace
+          buffer. */
+       /* ATTENTION: Use a Java byte-array for this to not confuse the
+          GC. */
+       /* FIXME: We waste some memory here as we skip some entries
+          later. */
+
+       ba_size = sizeof(stacktrace_t) + sizeof(stacktrace_entry_t) * depth;
+
+       ba = builtin_newarray_byte(ba_size);
+
+       if (ba == NULL)
+               goto return_NULL;
+
+       /* Get a stacktrace entry pointer. */
+       /* ATTENTION: We need a critical section here because we use the
+          byte-array data pointer directly. */
+
+       LLNI_CRITICAL_START;
+
+       st = (stacktrace_t *) LLNI_array_data(ba);
+
+       ste = st->entries;
+
+       /* Iterate over the whole stack. */
+
+       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
+                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
+                stacktrace_stackframeinfo_next(&tmpsfi)) {
+               /* Get the methodinfo. */
+
+               m = tmpsfi.code->m;
+
+               /* Skip builtin methods. */
+
+               if (m->flags & ACC_METHOD_BUILTIN)
+                       continue;
+
+               /* This logic is taken from
+                  hotspot/src/share/vm/classfile/javaClasses.cpp
+                  (java_lang_Throwable::fill_in_stack_trace). */
+
+               if (skip_fillInStackTrace == true) {
+                       /* Check "fillInStackTrace" only once, so we negate the
+                          flag after the first time check. */
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+                       /* For GNU Classpath we also need to skip
+                          VMThrowable.fillInStackTrace(). */
+
+                       if ((m->clazz == class_java_lang_VMThrowable) &&
+                               (m->name  == utf_fillInStackTrace))
+                               continue;
+#endif
+
+                       skip_fillInStackTrace = false;
+
+                       if (m->name == utf_fillInStackTrace)
+                               continue;
+               }
+
+               /* Skip <init> methods of the exceptions klass.  If there is
+                  <init> methods that belongs to a superclass of the
+                  exception we are going to skipping them in stack trace. */
+
+               if (skip_init == true) {
+                       if ((m->name == utf_init) &&
+                               (class_issubclass(m->clazz, class_java_lang_Throwable))) {
+                               continue;
+                       }
+                       else {
+                               /* If no "Throwable.init()" method found, we stop
+                                  checking it next time. */
+
+                               skip_init = false;
+                       }
+               }
+
+               /* Store the stacktrace entry and increment the pointer. */
+
+               ste->code = tmpsfi.code;
+               ste->pc   = tmpsfi.xpc;
+
+               ste++;
+       }
+
+       /* Store the number of entries in the stacktrace structure. */
+
+       st->length = ste - st->entries;
+
+       LLNI_CRITICAL_END;
+
+       /* release dump memory */
+
+/*     dump_release(dumpsize); */
+
+       CYCLES_STATS_END_WITH_OVERHEAD(stacktrace_fillInStackTrace,
+                                                                  stacktrace_overhead)
+       return ba;
+
+return_NULL:
+/*     dump_release(dumpsize); */
+
+       CYCLES_STATS_END_WITH_OVERHEAD(stacktrace_fillInStackTrace,
+                                                                  stacktrace_overhead)
+
+       return NULL;
+}
+
+
+/* stacktrace_get_current ******************************************************
+
+   Builds and returns a stacktrace from the current thread and returns
+   the stacktrace structure wrapped in a Java byte-array to not
+   confuse the GC.
+
+   RETURN:
+       stacktrace as Java byte-array
+
+*******************************************************************************/
+
+java_handle_bytearray_t *stacktrace_get_current(void)
+{
+       stackframeinfo_t        *sfi;
+       java_handle_bytearray_t *ba;
+
+       sfi = threads_get_current_stackframeinfo();
+       ba  = stacktrace_get(sfi);
+
+       return ba;
+}
+
+
+/* stacktrace_get_caller_class *************************************************
+
+   Get the class on the stack at the given depth.  This function skips
+   various special classes or methods.
+
+   ARGUMENTS:
+       depth ... depth to get caller class of
+
+   RETURN:
+       caller class
+
+*******************************************************************************/
+
+#if defined(ENABLE_JAVASE)
+classinfo *stacktrace_get_caller_class(int depth)
+{
+       stackframeinfo_t *sfi;
+       stackframeinfo_t  tmpsfi;
+       methodinfo       *m;
+       classinfo        *c;
+       int               i;
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackTrace)
+               log_println("[stacktrace_get_caller_class]");
+#endif
+
+       /* Get the stackframeinfo of the current thread. */
+
+       sfi = threads_get_current_stackframeinfo();
+
+       /* Iterate over the whole stack until we reached the requested
+          depth. */
+
+       i = 0;
+
+       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
+                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
+                stacktrace_stackframeinfo_next(&tmpsfi)) {
+
+               m = tmpsfi.code->m;
+               c = m->clazz;
+
+               /* Skip builtin methods. */
+
+               if (m->flags & ACC_METHOD_BUILTIN)
+                       continue;
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+               /* NOTE: See hotspot/src/share/vm/runtime/vframe.cpp
+                  (vframeStreamCommon::security_get_caller_frame). */
+
+               /* This is java.lang.reflect.Method.invoke(), skip it. */
+
+               if (m == method_java_lang_reflect_Method_invoke)
+                       continue;
+
+               /* This is an auxiliary frame, skip it. */
+
+               if (class_issubclass(c, class_sun_reflect_MagicAccessorImpl))
+                       continue;
+#endif
+
+               /* We reached the requested depth. */
+
+               if (i >= depth)
+                       return c;
+
+               i++;
+       }
+
+       return NULL;
+}
+#endif
+
+
+/* stacktrace_first_nonnull_classloader ****************************************
+
+   Returns the first non-null (user-defined) classloader on the stack.
+   If none is found NULL is returned.
+
+   RETURN:
+       classloader
+
+*******************************************************************************/
+
+classloader_t *stacktrace_first_nonnull_classloader(void)
+{
+       stackframeinfo_t *sfi;
+       stackframeinfo_t  tmpsfi;
+       methodinfo       *m;
+       classloader_t    *cl;
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackTrace)
+               log_println("[stacktrace_first_nonnull_classloader]");
+#endif
+
+       /* Get the stackframeinfo of the current thread. */
+
+       sfi = threads_get_current_stackframeinfo();
+
+       /* Iterate over the whole stack. */
+
+       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
+                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
+                stacktrace_stackframeinfo_next(&tmpsfi)) {
+
+               m  = tmpsfi.code->m;
+               cl = class_get_classloader(m->clazz);
+
+               if (cl != NULL)
+                       return cl;
+       }
+
+       return NULL;
+}
+
+
+/* stacktrace_getClassContext **************************************************
+
+   Creates a Class context array.
+
+   RETURN VALUE:
+      the array of java.lang.Class objects, or
+         NULL if an exception has been thrown
+
+*******************************************************************************/
+
+java_handle_objectarray_t *stacktrace_getClassContext(void)
+{
+       stackframeinfo_t           *sfi;
+       stackframeinfo_t            tmpsfi;
+       int                         depth;
+       java_handle_objectarray_t  *oa;
+       java_object_t             **data;
+       int                         i;
+       methodinfo                 *m;
+
+       CYCLES_STATS_DECLARE_AND_START
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackTrace)
+               log_println("[stacktrace_getClassContext]");
+#endif
+
+       sfi = threads_get_current_stackframeinfo();
+
+       /* Get the depth of the current stack. */
+
+       depth = stacktrace_depth(sfi);
+
+       /* The first stackframe corresponds to the method whose
+          implementation calls this native function.  We remove that
+          entry. */
+
+       depth--;
+       stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
+       stacktrace_stackframeinfo_next(&tmpsfi);
+
+       /* Allocate the Class array. */
+
+       oa = builtin_anewarray(depth, class_java_lang_Class);
+
+       if (oa == NULL) {
+               CYCLES_STATS_END(stacktrace_getClassContext);
+
+               return NULL;
+       }
+
+       /* Fill the Class array from the stacktrace list. */
+
+       LLNI_CRITICAL_START;
+
+       data = LLNI_array_data(oa);
+
+       /* Iterate over the whole stack. */
+
+       i = 0;
+
+       for (;
+                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
+                stacktrace_stackframeinfo_next(&tmpsfi)) {
+               /* Get methodinfo. */
+
+               m = tmpsfi.code->m;
+
+               /* Skip builtin methods. */
+
+               if (m->flags & ACC_METHOD_BUILTIN)
+                       continue;
+
+               /* Store the class in the array. */
+
+               data[i] = (java_object_t *) m->clazz;
+
+               i++;
+       }
+
+       LLNI_CRITICAL_END;
+
+       CYCLES_STATS_END(stacktrace_getClassContext)
+
+       return oa;
+}
+
+
+/* stacktrace_getCurrentClass **************************************************
+
+   Find the current class by walking the stack trace.
+
+   Quote from the JNI documentation:
+        
+   In the Java 2 Platform, FindClass locates the class loader
+   associated with the current native method.  If the native code
+   belongs to a system class, no class loader will be
+   involved. Otherwise, the proper class loader will be invoked to
+   load and link the named class. When FindClass is called through the
+   Invocation Interface, there is no current native method or its
+   associated class loader. In that case, the result of
+   ClassLoader.getBaseClassLoader is used."
+
+*******************************************************************************/
+
+#if defined(ENABLE_JAVASE)
+classinfo *stacktrace_get_current_class(void)
+{
+       stackframeinfo_t *sfi;
+       stackframeinfo_t  tmpsfi;
+       methodinfo       *m;
+
+       CYCLES_STATS_DECLARE_AND_START;
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackTrace)
+               log_println("[stacktrace_get_current_class]");
+#endif
+
+       /* Get the stackframeinfo of the current thread. */
+
+       sfi = threads_get_current_stackframeinfo();
+
+       /* If the stackframeinfo is NULL then FindClass is called through
+          the Invocation Interface and we return NULL */
+
+       if (sfi == NULL) {
+               CYCLES_STATS_END(stacktrace_getCurrentClass);
+
+               return NULL;
+       }
+
+       /* Iterate over the whole stack. */
+
+       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
+                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
+                stacktrace_stackframeinfo_next(&tmpsfi)) {
+               /* Get the methodinfo. */
+
+               m = tmpsfi.code->m;
+
+               if (m->clazz == class_java_security_PrivilegedAction) {
+                       CYCLES_STATS_END(stacktrace_getCurrentClass);
+
+                       return NULL;
+               }
+
+               if (m->clazz != NULL) {
+                       CYCLES_STATS_END(stacktrace_getCurrentClass);
+
+                       return m->clazz;
+               }
+       }
+
+       /* No Java method found on the stack. */
+
+       CYCLES_STATS_END(stacktrace_getCurrentClass);
+
+       return NULL;
+}
+#endif /* ENABLE_JAVASE */
+
+
+/* stacktrace_get_stack ********************************************************
+
+   Create a 2-dimensional array for java.security.VMAccessControler.
+
+   RETURN VALUE:
+      the arrary, or
+         NULL if an exception has been thrown
+
+*******************************************************************************/
+
+#if defined(ENABLE_JAVASE) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+java_handle_objectarray_t *stacktrace_get_stack(void)
+{
+       stackframeinfo_t          *sfi;
+       stackframeinfo_t           tmpsfi;
+       int                        depth;
+       java_handle_objectarray_t *oa;
+       java_handle_objectarray_t *classes;
+       java_handle_objectarray_t *methodnames;
+       methodinfo                *m;
+       java_handle_t             *string;
+       int                        i;
+
+       CYCLES_STATS_DECLARE_AND_START
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackTrace)
+               log_println("[stacktrace_get_stack]");
+#endif
+
+       /* Get the stackframeinfo of the current thread. */
+
+       sfi = threads_get_current_stackframeinfo();
+
+       /* Get the depth of the current stack. */
+
+       depth = stacktrace_depth(sfi);
+
+       if (depth == 0)
+               return NULL;
+
+       /* Allocate the required arrays. */
+
+       oa = builtin_anewarray(2, arrayclass_java_lang_Object);
+
+       if (oa == NULL)
+               goto return_NULL;
+
+       classes = builtin_anewarray(depth, class_java_lang_Class);
+
+       if (classes == NULL)
+               goto return_NULL;
+
+       methodnames = builtin_anewarray(depth, class_java_lang_String);
+
+       if (methodnames == NULL)
+               goto return_NULL;
+
+       /* Set up the 2-dimensional array. */
+
+       array_objectarray_element_set(oa, 0, (java_handle_t *) classes);
+       array_objectarray_element_set(oa, 1, (java_handle_t *) methodnames);
+
+       /* Iterate over the whole stack. */
+       /* TODO We should use a critical section here to speed things
+          up. */
+
+       i = 0;
+
+       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
+                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
+                stacktrace_stackframeinfo_next(&tmpsfi)) {
+               /* Get the methodinfo. */
+
+               m = tmpsfi.code->m;
+
+               /* Skip builtin methods. */
+
+               if (m->flags & ACC_METHOD_BUILTIN)
+                       continue;
+
+               /* Store the class in the array. */
+               /* NOTE: We use a LLNI-macro here, because a classinfo is not
+                  a handle. */
+
+               LLNI_array_direct(classes, i) = (java_object_t *) m->clazz;
+
+               /* Store the name in the array. */
+
+               string = javastring_new(m->name);
+
+               if (string == NULL)
+                       goto return_NULL;
+
+               array_objectarray_element_set(methodnames, i, string);
+
+               i++;
+       }
+
+       CYCLES_STATS_END(stacktrace_get_stack)
+
+       return oa;
+
+return_NULL:
+       CYCLES_STATS_END(stacktrace_get_stack)
+
+       return NULL;
+}
+#endif
+
+
+/* stacktrace_print_entry ****************************************************
+
+   Print line for a stacktrace entry.
+
+   ARGUMENTS:
+       m ............ methodinfo of the entry
+       linenumber ... linenumber of the entry
+
+*******************************************************************************/
+
+static void stacktrace_print_entry(methodinfo *m, int32_t linenumber)
+{
+       /* Sanity check. */
+
+       assert(m != NULL);
+
+       printf("\tat ");
+
+       if (m->flags & ACC_METHOD_BUILTIN)
+               printf("NULL");
+       else
+               utf_display_printable_ascii_classname(m->clazz->name);
+
+       printf(".");
+       utf_display_printable_ascii(m->name);
+       utf_display_printable_ascii(m->descriptor);
+
+       if (m->flags & ACC_NATIVE) {
+               puts("(Native Method)");
+       }
+       else {
+               if (m->flags & ACC_METHOD_BUILTIN) {
+                       puts("(builtin)");
+               }
+               else {
+                       printf("(");
+                       utf_display_printable_ascii(m->clazz->sourcefile);
+                       printf(":%d)\n", linenumber);
+               }
+       }
+
+       fflush(stdout);
+}
+
+
+/* stacktrace_print ************************************************************
+
+   Print the given stacktrace with CACAO intern methods only (no Java
+   code required).
+
+   This method is used by stacktrace_dump_trace and
+   builtin_trace_exception.
+
+   IN:
+       st ... stacktrace to print
+
+*******************************************************************************/
+
+void stacktrace_print(stacktrace_t *st)
+{
+       stacktrace_entry_t *ste;
+       methodinfo         *m;
+       int32_t             linenumber;
+       int                 i;
+
+       ste = &(st->entries[0]);
+
+       for (i = 0; i < st->length; i++, ste++) {
+               m = ste->code->m;
+
+               /* Get the line number. */
+
+               linenumber = linenumbertable_linenumber_for_pc(&m, ste->code, ste->pc);
+
+               stacktrace_print_entry(m, linenumber);
+       }
+}
+
+
+/* stacktrace_print_current ****************************************************
+
+   Print the current stacktrace of the current thread.
+
+   NOTE: This function prints all frames of the stacktrace and does
+   not skip frames like stacktrace_get.
+
+*******************************************************************************/
+
+void stacktrace_print_current(void)
+{
+       stackframeinfo_t *sfi;
+       stackframeinfo_t  tmpsfi;
+       codeinfo         *code;
+       methodinfo       *m;
+       int32_t           linenumber;
+
+       sfi = threads_get_current_stackframeinfo();
+
+       if (sfi == NULL) {
+               puts("\t<<No stacktrace available>>");
+               fflush(stdout);
+               return;
+       }
+
+       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
+                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
+                stacktrace_stackframeinfo_next(&tmpsfi)) {
+               /* Get the methodinfo. */
+
+               code = tmpsfi.code;
+               m    = code->m;
+
+               /* Get the line number. */
+
+               linenumber = linenumbertable_linenumber_for_pc(&m, code, tmpsfi.xpc);
+
+               stacktrace_print_entry(m, linenumber);
+       }
+}
+
+
+/* stacktrace_print_of_thread **************************************************
+
+   Print the current stacktrace of the given thread.
+
+   ARGUMENTS:
+       t ... thread
+
+*******************************************************************************/
+
+#if defined(ENABLE_THREADS)
+void stacktrace_print_of_thread(threadobject *t)
+{
+       stackframeinfo_t *sfi;
+       stackframeinfo_t  tmpsfi;
+       codeinfo         *code;
+       methodinfo       *m;
+       int32_t           linenumber;
+
+       /* Build a stacktrace for the passed thread. */
+
+       sfi = t->_stackframeinfo;
+       
+       if (sfi == NULL) {
+               puts("\t<<No stacktrace available>>");
+               fflush(stdout);
+               return;
+       }
+
+       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
+                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
+                stacktrace_stackframeinfo_next(&tmpsfi)) {
+               /* Get the methodinfo. */
+
+               code = tmpsfi.code;
+               m    = code->m;
+
+               /* Get the line number. */
+
+               linenumber = linenumbertable_linenumber_for_pc(&m, code, tmpsfi.xpc);
+
+               stacktrace_print_entry(m, linenumber);
+       }
+}
+#endif
+
+
+/* stacktrace_print_exception **************************************************
+
+   Print the stacktrace of a given exception (more or less a wrapper
+   to stacktrace_print).
+
+   IN:
+       h ... handle of exception to print
+
+*******************************************************************************/
+
+void stacktrace_print_exception(java_handle_t *h)
+{
+       java_lang_Throwable     *o;
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+       java_lang_VMThrowable   *vmt;
+#endif
+
+       java_lang_Object        *backtrace;
+       java_handle_bytearray_t *ba;
+       stacktrace_t            *st;
+
+       o = (java_lang_Throwable *) h;
+
+       if (o == NULL)
+               return;
+
+       /* now print the stacktrace */
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+       LLNI_field_get_ref(o,   vmState, vmt);
+       LLNI_field_get_ref(vmt, vmdata,  backtrace);
+
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
+
+       LLNI_field_get_ref(o, backtrace, backtrace);
+
+#else
+# error unknown classpath configuration
+#endif
+
+       ba = (java_handle_bytearray_t *) backtrace;
+
+       /* Sanity check. */
+
+       assert(ba != NULL);
+
+       /* We need a critical section here as we use the byte-array data
+          pointer directly. */
+
+       LLNI_CRITICAL_START;
+       
+       st = (stacktrace_t *) LLNI_array_data(ba);
+
+       stacktrace_print(st);
+
+       LLNI_CRITICAL_END;
+}
+
+
+#if defined(ENABLE_CYCLES_STATS)
+void stacktrace_print_cycles_stats(FILE *file)
+{
+       CYCLES_STATS_PRINT_OVERHEAD(stacktrace_overhead, file);
+       CYCLES_STATS_PRINT(stacktrace_get,               file);
+       CYCLES_STATS_PRINT(stacktrace_getClassContext ,  file);
+       CYCLES_STATS_PRINT(stacktrace_getCurrentClass ,  file);
+       CYCLES_STATS_PRINT(stacktrace_get_stack,         file);
+}
+#endif
+
+} // extern "C"
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/vm/jit/stacktrace.h b/src/vm/jit/stacktrace.h
deleted file mode 100644 (file)
index e21c348..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-/* src/vm/jit/stacktrace.h - header file for stacktrace generation
-
-   Copyright (C) 1996-2005, 2006, 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   This file is part of CACAO.
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2, or (at
-   your option) any later version.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-*/
-
-
-#ifndef _STACKTRACE_H
-#define _STACKTRACE_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct stackframeinfo_t   stackframeinfo_t;
-typedef struct stacktrace_entry_t stacktrace_entry_t;
-typedef struct stacktrace_t       stacktrace_t;
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "vm/types.h"
-
-#include "md-abi.h"
-
-#include "threads/thread.h"
-
-#include "vm/global.h"
-
-#include "vm/jit/code.h"
-
-#include "vmcore/class.h"
-
-
-/* stackframeinfo **************************************************************
-
-   ATTENTION: Keep the number of elements of this structure even, to
-   make sure that the stack keeps aligned (e.g. 16-bytes for x86_64).
-
-*******************************************************************************/
-
-struct stackframeinfo_t {
-       stackframeinfo_t *prev;             /* pointer to prev stackframeinfo     */
-       codeinfo         *code;             /* codeinfo of current method         */
-       u1               *pv;               /* PV of current function             */
-       u1               *sp;               /* SP of parent Java function         */
-       u1               *ra;               /* RA to parent Java function         */
-       u1               *xpc;              /* XPC (for inline stubs)             */
-#if defined(ENABLE_GC_CACAO)
-       /* 
-        * The exact GC needs to be able to recover saved registers, so the
-        * native-stub saves these registers here
-        */
-# if defined(HAS_ADDRESS_REGISTER_FILE)
-       uintptr_t         adrregs[ADR_SAV_CNT];
-# else
-       uintptr_t         intregs[INT_SAV_CNT];
-# endif
-#endif
-};
-
-
-/* stacktrace_entry_t *********************************************************/
-
-struct stacktrace_entry_t {
-       codeinfo *code;                     /* codeinfo pointer of this method    */
-       void     *pc;                       /* PC in this method                  */
-};
-
-
-/* stacktrace_t ***************************************************************/
-
-struct stacktrace_t {
-       int32_t            length;          /* length of the entries array        */
-       stacktrace_entry_t entries[1];      /* stacktrace entries                 */
-};
-
-
-/* function prototypes ********************************************************/
-
-void                       stacktrace_stackframeinfo_add(stackframeinfo_t *sfi, u1 *pv, u1 *sp, u1 *ra, u1 *xpc);
-void                       stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi);
-
-java_handle_bytearray_t   *stacktrace_get(stackframeinfo_t *sfi);
-java_handle_bytearray_t   *stacktrace_get_current(void);
-
-#if defined(ENABLE_JAVASE)
-classinfo                 *stacktrace_get_caller_class(int depth);
-classloader_t             *stacktrace_first_nonnull_classloader(void);
-java_handle_objectarray_t *stacktrace_getClassContext(void);
-classinfo                 *stacktrace_get_current_class(void);
-java_handle_objectarray_t *stacktrace_get_stack(void);
-#endif
-
-void                       stacktrace_print(stacktrace_t *st);
-void                       stacktrace_print_current(void);
-
-#if defined(ENABLE_THREADS)
-void                       stacktrace_print_of_thread(threadobject *t);
-#endif
-
-void                       stacktrace_print_exception(java_handle_t *h);
-
-/* machine dependent functions (code in ARCH_DIR/md.c) */
-
-#if defined(ENABLE_JIT)
-# if defined(__SPARC_64__)
-u1 *md_get_framepointer(u1 *sp);
-u1 *md_get_pv_from_stackframe(u1 *sp);
-# endif
-#endif
-
-#if defined(ENABLE_INTRP)
-u1 *intrp_md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
-#endif
-
-#if defined(ENABLE_CYCLES_STATS)
-void stacktrace_print_cycles_stats(FILE *file);
-#endif
-
-#endif /* _STACKTRACE_H */
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
diff --git a/src/vm/jit/stacktrace.hpp b/src/vm/jit/stacktrace.hpp
new file mode 100644 (file)
index 0000000..f233ecf
--- /dev/null
@@ -0,0 +1,162 @@
+/* src/vm/jit/stacktrace.hpp - header file for stacktrace generation
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#ifndef _STACKTRACE_HPP
+#define _STACKTRACE_HPP
+
+// FIXME Use C-linkage for now.
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* forward typedefs ***********************************************************/
+
+typedef struct stackframeinfo_t   stackframeinfo_t;
+typedef struct stacktrace_entry_t stacktrace_entry_t;
+typedef struct stacktrace_t       stacktrace_t;
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "vm/types.h"
+
+#include "md-abi.h"
+
+#include "threads/thread.h"
+
+#include "vm/global.h"
+
+#include "vm/jit/code.h"
+
+#include "vmcore/class.h"
+
+
+/* stackframeinfo **************************************************************
+
+   ATTENTION: Keep the number of elements of this structure even, to
+   make sure that the stack keeps aligned (e.g. 16-bytes for x86_64).
+
+*******************************************************************************/
+
+struct stackframeinfo_t {
+       stackframeinfo_t *prev;             /* pointer to prev stackframeinfo     */
+       codeinfo         *code;             /* codeinfo of current method         */
+       void             *pv;               /* PV of current function             */
+       void             *sp;               /* SP of parent Java function         */
+       void             *ra;               /* RA to parent Java function         */
+       void             *xpc;              /* XPC (for inline stubs)             */
+#if defined(ENABLE_GC_CACAO)
+       /* 
+        * The exact GC needs to be able to recover saved registers, so the
+        * native-stub saves these registers here
+        */
+# if defined(HAS_ADDRESS_REGISTER_FILE)
+       uintptr_t         adrregs[ADR_SAV_CNT];
+# else
+       uintptr_t         intregs[INT_SAV_CNT];
+# endif
+#endif
+};
+
+
+/* stacktrace_entry_t *********************************************************/
+
+struct stacktrace_entry_t {
+       codeinfo *code;                     /* codeinfo pointer of this method    */
+       void     *pc;                       /* PC in this method                  */
+};
+
+
+/* stacktrace_t ***************************************************************/
+
+struct stacktrace_t {
+       int32_t            length;          /* length of the entries array        */
+       stacktrace_entry_t entries[1];      /* stacktrace entries                 */
+};
+
+
+/* function prototypes ********************************************************/
+
+void                       stacktrace_stackframeinfo_add(stackframeinfo_t* sfi, void* pv, void* sp, void* ra, void* xpc);
+void                       stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi);
+
+java_handle_bytearray_t   *stacktrace_get(stackframeinfo_t *sfi);
+java_handle_bytearray_t   *stacktrace_get_current(void);
+
+#if defined(ENABLE_JAVASE)
+classinfo                 *stacktrace_get_caller_class(int depth);
+classloader_t             *stacktrace_first_nonnull_classloader(void);
+java_handle_objectarray_t *stacktrace_getClassContext(void);
+classinfo                 *stacktrace_get_current_class(void);
+java_handle_objectarray_t *stacktrace_get_stack(void);
+#endif
+
+void                       stacktrace_print(stacktrace_t *st);
+void                       stacktrace_print_current(void);
+
+#if defined(ENABLE_THREADS)
+void                       stacktrace_print_of_thread(threadobject *t);
+#endif
+
+void                       stacktrace_print_exception(java_handle_t *h);
+
+/* machine dependent functions (code in ARCH_DIR/md.c) */
+
+#if defined(ENABLE_JIT)
+# if defined(__SPARC_64__)
+u1 *md_get_framepointer(u1 *sp);
+u1 *md_get_pv_from_stackframe(u1 *sp);
+# endif
+#endif
+
+#if defined(ENABLE_INTRP)
+u1 *intrp_md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
+#endif
+
+#if defined(ENABLE_CYCLES_STATS)
+void stacktrace_print_cycles_stats(FILE *file);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _STACKTRACE_HPP
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
index a3400d2bffeb5d84de8bf52e3dd9131673a41ba8..db04a216e1ba64f5dc787daf273bcd0c6cd1d473 100644 (file)
@@ -46,7 +46,7 @@
 #include "vm/jit/methodtree.h"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 #include "vmcore/options.h"
 #include "vmcore/system.h"
index 985d07fea50397e73304407e9069ee730d52a1df..003a8b8ae9b97787ebfa264d0e05cb26fa861abe 100644 (file)
@@ -65,7 +65,7 @@
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 #if defined(ENABLE_LSRA)
index 593956e69df858f051a464a147d0f14db0a13704..7850ea9d81cccc6d7026c4b6ebc862d65bc3094b 100644 (file)
@@ -34,7 +34,7 @@
 #include "vm/signallocal.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 
 /* md_signal_handler_sigsegv ***************************************************
index fa5d6755b0f21cc78c42b06abf231ea12a2ff439..ce372761badd3d09c6fd7fe26d792e9533ce49b3 100644 (file)
@@ -45,7 +45,7 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
 #include "vm/jit/trap.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 
 /* md_signal_handler_sigsegv ***************************************************
index be30afa3759f0711b57cb8b7fbf489d81480707f..34c36b74840650589bd8a9ee296ca410e2040d0b 100644 (file)
@@ -40,7 +40,6 @@
 #include "vm/initialize.h"
 
 #include "vm/jit/patcher-common.h"
-#include "vm/jit/stacktrace.h"
 
 #include "vmcore/class.h"
 #include "vmcore/field.h"
index 805a08c4acd09c0bc1033ef35a21c17fae7aab5f..a8f6a5990b6a1b9ecb56221e25cf93a4a9e1b2c1 100644 (file)
@@ -43,7 +43,7 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
 #include "vm/jit/trap.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 
 /* md_signal_handler_sigsegv ***************************************************