* gen_inst: Use lastmcodeptr instead of last_compiled.
[cacao.git] / src / vm / jit / stacktrace.h
index cfe2f8126aff113c99270e731f8f53ddbc903cca..490f3775c443ae00ee5c558d167130f2cd467e28 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: stacktrace.h 2660 2005-06-13 14:16:26Z twisti $
+   $Id: stacktrace.h 3741 2005-11-22 23:07:41Z twisti $
 
 */
 
 
 /* forward typedefs ***********************************************************/
 
-typedef struct native_stackframeinfo native_stackframeinfo;
+typedef struct exceptionentry exceptionentry;
+typedef struct stackframeinfo stackframeinfo;
 typedef struct stackTraceBuffer stackTraceBuffer;
 typedef struct stacktraceelement stacktraceelement;
 
+#include "config.h"
+#include "vm/types.h"
 
-#include "types.h"
-#include "arch.h"
 #include "vm/method.h"
 
 
-struct native_stackframeinfo {
-       void *oldThreadspecificHeadValue;
-       void **addressOfThreadspecificHead;
-       methodinfo *method;
-#ifdef __ALPHA__
-       void *savedpv;
-#endif
-       void *beginOfJavaStackframe; /*only used if != 0*/ /* on i386 and x86_64 this points to the return addres stored directly below the stackframe*/
-       functionptr returnToFromNative;
+/* exceptionentry **************************************************************
 
-#if 0
-       void *returnFromNative;
-       void *addrReturnFromNative;
-       methodinfo *method;
-       native_stackframeinfo *next;
-       native_stackframeinfo *prev;
-#endif
+   Datastructure which represents an exception entry in the exception
+   table residing in the data segment.
+
+*******************************************************************************/
+
+struct exceptionentry {
+       classinfo *catchtype;
+       void      *handlerpc;
+       void      *endpc;
+       void      *startpc;
 };
 
 
+/* 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 {
+       stackframeinfo *prev;               /* pointer to prev stackframeinfo     */
+       methodinfo     *method;             /* methodinfo of current function     */
+       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(USE_THREADS)
+#define STACKFRAMEINFO    (stackframeinfo **) (&THREADINFO->_stackframeinfo)
+#else
+extern stackframeinfo *_no_threads_stackframeinfo;
+
+#define STACKFRAMEINFO    (&_no_threads_stackframeinfo)
+#endif
+
+
 struct stacktraceelement {
 #if SIZEOF_VOID_P == 8
        u8          linenumber;
@@ -88,11 +109,74 @@ struct stackTraceBuffer {
 
 /* function prototypes ********************************************************/
 
-void cacao_stacktrace_NormalTrace(void **target);
-java_objectarray *cacao_createClassContextArray();
-java_objectheader *cacao_currentClassLoader();
-methodinfo* cacao_callingMethod();
-java_objectarray *cacao_getStackForVMAccessController();
+#if defined(ENABLE_INTRP)
+void stacktrace_create_stackframeinfo(stackframeinfo *sfi, u1 *pv, u1 *sp,
+                                                                         u1 *ra);
+#endif
+
+void stacktrace_create_inline_stackframeinfo(stackframeinfo *sfi, u1 *pv,
+                                                                                        u1 *sp, u1 *ra, u1 *xpc);
+
+void stacktrace_create_extern_stackframeinfo(stackframeinfo *sfi, u1 *pv,
+                                                                                        u1 *sp, u1 *ra, u1 *xpc);
+
+void stacktrace_create_native_stackframeinfo(stackframeinfo *sfi, u1 *pv,
+                                                                                        u1 *sp, u1 *ra);
+
+void stacktrace_remove_stackframeinfo(stackframeinfo *sfi);
+
+/* inline exception creating functions */
+java_objectheader *stacktrace_inline_arithmeticexception(u1 *pv, u1 *sp, u1 *ra,
+                                                                                                                u1 *xpc);
+
+java_objectheader *stacktrace_inline_arrayindexoutofboundsexception(u1 *pv,
+                                                                                                                                       u1 *sp,
+                                                                                                                                       u1 *ra,
+                                                                                                                                       u1 *xpc,
+                                                                                                                                       s4 index);
+
+java_objectheader *stacktrace_inline_arraystoreexception(u1 *pv, u1 *sp, u1 *ra,
+                                                                                                                u1 *xpc);
+
+java_objectheader *stacktrace_inline_classcastexception(u1 *pv, u1 *sp, u1 *ra,
+                                                                                                               u1 *xpc);
+
+java_objectheader *stacktrace_inline_nullpointerexception(u1 *pv, u1 *sp,
+                                                                                                                 u1 *ra, u1 *xpc);
+
+
+/* hardware exception creating functions */
+java_objectheader *stacktrace_hardware_arithmeticexception(u1 *pv, u1 *sp,
+                                                                                                                  u1 *ra, u1 *xpc);
+
+java_objectheader *stacktrace_hardware_nullpointerexception(u1 *pv, u1 *sp,
+                                                                                                                       u1 *ra, u1 *xpc);
+
+/* refill the stacktrace of an existing exception */
+java_objectheader *stacktrace_inline_fillInStackTrace(u1 *pv, u1 *sp, u1 *ra,
+                                                                                                         u1 *xpc);
+
+bool cacao_stacktrace_NormalTrace(void **target);
+java_objectarray *cacao_createClassContextArray(void);
+java_objectheader *cacao_currentClassLoader(void);
+java_objectarray *cacao_getStackForVMAccessController(void);
+
+void stacktrace_dump_trace(void);
+void stacktrace_print_trace(java_objectheader *xptr);
+
+/* machine dependent functions (code in ARCH_DIR/md.c) */
+u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
+
+#ifdef ENABLE_JVMTI
+typedef bool(*CacaoStackTraceCollector)(void **, stackTraceBuffer*);
+
+bool cacao_stacktrace_fillInStackTrace(void **target,
+                                                                          CacaoStackTraceCollector coll,
+                                                                          threadobject* thread);
+
+bool stackTraceCollector(void **target, stackTraceBuffer *buffer);
+#endif
+
 #endif /* _STACKTRACE_H */