* src/vm/jit/i386/asmpart.S: Rewritten for PIC code.
[cacao.git] / src / vm / jit / stacktrace.h
index c65e2b17f12860fb1bf80ad9272eaae5de155975..b009acf16b04a7ec2fe193355c11001643c389c8 100644 (file)
@@ -1,9 +1,9 @@
 /* src/vm/jit/stacktrace.h - header file for stacktrace generation
 
-   Copyright (C) 1996-2005 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 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
 
    This file is part of CACAO.
 
 
    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., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
 
-   Contact: cacao@complang.tuwien.ac.at
+   Contact: cacao@cacaojvm.org
 
    Authors: Christian Thalinger
 
    Changes:
 
-   $Id: stacktrace.h 3244 2005-09-21 14:58:47Z twisti $
+   $Id: stacktrace.h 4533 2006-02-21 09:25:16Z twisti $
 
 */
 
 
 /* forward typedefs ***********************************************************/
 
-typedef struct exceptionentry exceptionentry;
 typedef struct stackframeinfo stackframeinfo;
-typedef struct stackTraceBuffer stackTraceBuffer;
-typedef struct stacktraceelement stacktraceelement;
+typedef struct stacktracebuffer stacktracebuffer;
+typedef struct stacktrace_entry stacktrace_entry;
 
 #include "config.h"
 #include "vm/types.h"
@@ -49,21 +48,6 @@ typedef struct stacktraceelement stacktraceelement;
 #include "vm/method.h"
 
 
-/* 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
@@ -76,12 +60,22 @@ struct stackframeinfo {
        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)             */
+       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
+
+
+/* stacktrace_entry ***********************************************************/
 
-struct stacktraceelement {
+struct stacktrace_entry {
 #if SIZEOF_VOID_P == 8
        u8          linenumber;
 #else
@@ -91,85 +85,85 @@ struct stacktraceelement {
 };
 
 
-struct stackTraceBuffer {
-       s4                 needsFree;
-       stacktraceelement *start;
-       s4                 size;
-       s4                 full;
+/* stacktracebuffer ***********************************************************/
+
+#define STACKTRACE_CAPACITY_DEFAULT      80
+#define STACKTRACE_CAPACITY_INCREMENT    80
+
+struct stacktracebuffer {
+       s4                capacity;         /* size of the buffer                 */
+       s4                used;             /* current entries in the buffer      */
+       stacktrace_entry *entries;          /* the actual entries                 */
 };
 
 
 /* function prototypes ********************************************************/
 
 #if defined(ENABLE_INTRP)
-void stacktrace_create_stackframeinfo(stackframeinfo *sfi, u1 *pv,
-                                                                         u1 *sp, functionptr ra);
+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, functionptr ra,
-                                                                                        functionptr xpc);
+                                                                                        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);
 
 /* inline exception creating functions */
-java_objectheader *stacktrace_inline_arithmeticexception(u1 *pv, u1 *sp,
-                                                                                                                functionptr ra,
-                                                                                                                functionptr xpc);
+java_objectheader *stacktrace_inline_arithmeticexception(u1 *pv, u1 *sp, u1 *ra,
+                                                                                                                u1 *xpc);
 
 java_objectheader *stacktrace_inline_arrayindexoutofboundsexception(u1 *pv,
                                                                                                                                        u1 *sp,
-                                                                                                                                       functionptr ra,
-                                                                                                                                       functionptr xpc,
+                                                                                                                                       u1 *ra,
+                                                                                                                                       u1 *xpc,
                                                                                                                                        s4 index);
 
-java_objectheader *stacktrace_inline_arraystoreexception(u1 *pv, u1 *sp,
-                                                                                                                functionptr ra,
-                                                                                                                functionptr xpc);
-
-java_objectheader *stacktrace_inline_classcastexception(u1 *pv, u1 *sp,
-                                                                                                               functionptr ra,
-                                                                                                               functionptr xpc);
+java_objectheader *stacktrace_inline_arraystoreexception(u1 *pv, u1 *sp, u1 *ra,
+                                                                                                                u1 *xpc);
 
-java_objectheader *stacktrace_inline_negativearraysizeexception(u1 *pv, u1 *sp,
-                                                                                                                               functionptr ra,
-                                                                                                                               functionptr xpc);
+java_objectheader *stacktrace_inline_classcastexception(u1 *pv, u1 *sp, u1 *ra,
+                                                                                                               u1 *xpc);
 
 java_objectheader *stacktrace_inline_nullpointerexception(u1 *pv, u1 *sp,
-                                                                                                                 functionptr ra,
-                                                                                                                 functionptr xpc);
+                                                                                                                 u1 *ra, u1 *xpc);
 
 
 /* hardware exception creating functions */
 java_objectheader *stacktrace_hardware_arithmeticexception(u1 *pv, u1 *sp,
-                                                                                                                  functionptr ra,
-                                                                                                                  functionptr xpc);
+                                                                                                                  u1 *ra, u1 *xpc);
 
 java_objectheader *stacktrace_hardware_nullpointerexception(u1 *pv, u1 *sp,
-                                                                                                                       functionptr ra,
-                                                                                                                       functionptr xpc);
+                                                                                                                       u1 *ra, u1 *xpc);
 
 /* refill the stacktrace of an existing exception */
-java_objectheader *stacktrace_inline_fillInStackTrace(u1 *pv, u1 *sp,
-                                                                                                         functionptr ra,
-                                                                                                         functionptr 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);
+java_objectheader *stacktrace_inline_fillInStackTrace(u1 *pv, u1 *sp, u1 *ra,
+                                                                                                         u1 *xpc);
+
+stacktracebuffer  *stacktrace_fillInStackTrace(void);
+java_objectarray  *stacktrace_getClassContext(void);
+classinfo         *stacktrace_getCurrentClass(void);
+java_objectarray  *stacktrace_getStack(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);
+
+#if defined(ENABLE_JIT)
+u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
+#endif
+
+#if defined(ENABLE_INTRP)
+u1 *intrp_md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
+#endif
 
 #endif /* _STACKTRACE_H */