* gen_inst: Use lastmcodeptr instead of last_compiled.
[cacao.git] / src / vm / jit / stacktrace.h
index 8440bda4ae1cf696d8e5b039c47a46ceb5680882..490f3775c443ae00ee5c558d167130f2cd467e28 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: stacktrace.h 2914 2005-07-05 13:39:44Z 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 "types.h"
+#include "vm/types.h"
 
 #include "vm/method.h"
 
 
-struct native_stackframeinfo {
-       void        *oldThreadspecificHeadValue;
-       void       **addressOfThreadspecificHead;
-       methodinfo  *method;
-#if defined(__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
@@ -88,15 +109,73 @@ struct stackTraceBuffer {
 
 /* function prototypes ********************************************************/
 
-void cacao_stacktrace_NormalTrace(void **target);
+#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);
-methodinfo* cacao_callingMethod(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) */
-functionptr md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
+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 */