Changes:
- $Id: stacktrace.h 2985 2005-07-11 18:55:35Z twisti $
+ $Id: stacktrace.h 3741 2005-11-22 23:07:41Z twisti $
*/
/* forward typedefs ***********************************************************/
+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"
-/* stackframeinfo *************************************************************/
+/* exceptionentry **************************************************************
+
+ 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 {
- void *oldThreadspecificHeadValue;
- void **addressOfThreadspecificHead;
- methodinfo *method; /* methodinfo of current function */
- u1 *pv; /* PV of current function */
- u1 *sp; /* SP of parent Java function */
- functionptr ra; /* RA to parent Java function */
- functionptr xpc; /* XPC (for inline stubs) */
- void *padding; /* multiple of 16-byte padding */
+ 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
/* function prototypes ********************************************************/
+#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, functionptr ra,
- functionptr xpc);
+ 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, functionptr ra);
+ u1 *sp, u1 *ra);
void stacktrace_remove_stackframeinfo(stackframeinfo *sfi);
-/* exception creating functions */
-java_objectheader *stacktrace_new_arithmeticexception(u1 *pv, u1 *sp,
- functionptr ra,
- functionptr xpc);
+/* 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_new_arrayindexoutofboundsexception(u1 *pv,
- u1 *sp,
- functionptr ra,
- functionptr xpc,
- s4 index);
+java_objectheader *stacktrace_inline_classcastexception(u1 *pv, u1 *sp, u1 *ra,
+ u1 *xpc);
-java_objectheader *stacktrace_new_arraystoreexception(u1 *pv, u1 *sp,
- functionptr ra,
- functionptr xpc);
+java_objectheader *stacktrace_inline_nullpointerexception(u1 *pv, u1 *sp,
+ u1 *ra, u1 *xpc);
-java_objectheader *stacktrace_new_classcastexception(u1 *pv, u1 *sp,
- functionptr ra,
- functionptr xpc);
-java_objectheader *stacktrace_new_negativearraysizeexception(u1 *pv, u1 *sp,
- functionptr ra,
- functionptr xpc);
+/* hardware exception creating functions */
+java_objectheader *stacktrace_hardware_arithmeticexception(u1 *pv, u1 *sp,
+ u1 *ra, u1 *xpc);
-java_objectheader *stacktrace_new_nullpointerexception(u1 *pv, u1 *sp,
- functionptr ra,
- functionptr xpc);
+java_objectheader *stacktrace_hardware_nullpointerexception(u1 *pv, u1 *sp,
+ u1 *ra, u1 *xpc);
-java_objectheader *stacktrace_fillInStackTrace(u1 *pv, u1 *sp, functionptr ra,
- functionptr xpc);
+/* refill the stacktrace of an existing exception */
+java_objectheader *stacktrace_inline_fillInStackTrace(u1 *pv, u1 *sp, u1 *ra,
+ u1 *xpc);
-void cacao_stacktrace_NormalTrace(void **target);
+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 */