1 /* src/vm/jit/stacktrace.h - header file for stacktrace generation
3 Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 Contact: cacao@cacaojvm.org
27 Authors: Christian Thalinger
31 $Id: stacktrace.h 4921 2006-05-15 14:24:36Z twisti $
39 /* forward typedefs ***********************************************************/
41 typedef struct stackframeinfo stackframeinfo;
42 typedef struct stacktracebuffer stacktracebuffer;
43 typedef struct stacktrace_entry stacktrace_entry;
48 #include "vm/method.h"
51 /* stackframeinfo **************************************************************
53 ATTENTION: Keep the number of elements of this structure even, to
54 make sure that the stack keeps aligned (e.g. 16-bytes for x86_64).
56 *******************************************************************************/
58 struct stackframeinfo {
59 stackframeinfo *prev; /* pointer to prev stackframeinfo */
60 methodinfo *method; /* methodinfo of current function */
61 u1 *pv; /* PV of current function */
62 u1 *sp; /* SP of parent Java function */
63 u1 *ra; /* RA to parent Java function */
64 u1 *xpc; /* XPC (for inline stubs) */
67 #if defined(ENABLE_THREADS)
68 #define STACKFRAMEINFO (&(THREADOBJECT->_stackframeinfo))
70 extern stackframeinfo *_no_threads_stackframeinfo;
72 #define STACKFRAMEINFO (&_no_threads_stackframeinfo)
76 /* stacktrace_entry ***********************************************************/
78 struct stacktrace_entry {
79 #if SIZEOF_VOID_P == 8
88 /* stacktracebuffer ***********************************************************/
90 #define STACKTRACE_CAPACITY_DEFAULT 80
91 #define STACKTRACE_CAPACITY_INCREMENT 80
93 struct stacktracebuffer {
94 s4 capacity; /* size of the buffer */
95 s4 used; /* current entries in the buffer */
96 stacktrace_entry *entries; /* the actual entries */
100 /* function prototypes ********************************************************/
102 #if defined(ENABLE_INTRP)
103 void stacktrace_create_stackframeinfo(stackframeinfo *sfi, u1 *pv, u1 *sp,
107 void stacktrace_create_inline_stackframeinfo(stackframeinfo *sfi, u1 *pv,
108 u1 *sp, u1 *ra, u1 *xpc);
110 void stacktrace_create_extern_stackframeinfo(stackframeinfo *sfi, u1 *pv,
111 u1 *sp, u1 *ra, u1 *xpc);
113 void stacktrace_create_native_stackframeinfo(stackframeinfo *sfi, u1 *pv,
116 void stacktrace_remove_stackframeinfo(stackframeinfo *sfi);
118 /* inline exception creating functions */
119 java_objectheader *stacktrace_inline_arithmeticexception(u1 *pv, u1 *sp, u1 *ra,
121 #define STACKTRACE_inline_arithmeticexception \
122 (functionptr) stacktrace_inline_arithmeticexception
125 java_objectheader *stacktrace_inline_arrayindexoutofboundsexception(u1 *pv,
130 #define STACKTRACE_inline_arrayindexoutofboundsexception \
131 (functionptr) stacktrace_inline_arrayindexoutofboundsexception
133 java_objectheader *stacktrace_inline_arraystoreexception(u1 *pv, u1 *sp, u1 *ra,
135 #define STACKTRACE_inline_arraystoreexception \
136 (functionptr) stacktrace_inline_arraystoreexception
138 java_objectheader *stacktrace_inline_classcastexception(u1 *pv, u1 *sp, u1 *ra,
140 #define STACKTRACE_inline_classcastexception \
141 (functionptr) stacktrace_inline_classcastexception
143 java_objectheader *stacktrace_inline_nullpointerexception(u1 *pv, u1 *sp,
145 #define STACKTRACE_inline_nullpointerexception \
146 (functionptr) stacktrace_inline_nullpointerexception
148 /* refill the stacktrace of an existing exception */
149 java_objectheader *stacktrace_inline_fillInStackTrace(u1 *pv, u1 *sp, u1 *ra,
151 #define STACKTRACE_inline_fillInStackTrace \
152 (functionptr) stacktrace_inline_fillInStackTrace
155 /* hardware exception creating functions */
156 java_objectheader *stacktrace_hardware_arithmeticexception(u1 *pv, u1 *sp,
159 java_objectheader *stacktrace_hardware_nullpointerexception(u1 *pv, u1 *sp,
163 stacktracebuffer *stacktrace_fillInStackTrace(void);
164 java_objectarray *stacktrace_getClassContext(void);
165 classinfo *stacktrace_getCurrentClass(void);
166 java_objectarray *stacktrace_getStack(void);
168 void stacktrace_dump_trace(void);
169 void stacktrace_print_trace(java_objectheader *xptr);
172 /* machine dependent functions (code in ARCH_DIR/md.c) */
174 #if defined(ENABLE_JIT)
175 u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
178 #if defined(ENABLE_INTRP)
179 u1 *intrp_md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
182 #if defined(ENABLE_CYCLES_STATS)
183 void stacktrace_print_cycles_stats(FILE *file);
186 #endif /* _STACKTRACE_H */
190 * These are local overrides for various environment variables in Emacs.
191 * Please do not remove this and leave it at the end of the file, where
192 * Emacs will automagically detect them.
193 * ---------------------------------------------------------------------
196 * indent-tabs-mode: t