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 6248 2006-12-27 22:39:39Z twisti $
39 /* forward typedefs ***********************************************************/
41 typedef struct stackframeinfo stackframeinfo;
42 typedef struct stacktracebuffer stacktracebuffer;
43 typedef struct stacktrace_entry stacktrace_entry;
48 #if defined(ENABLE_THREADS)
49 # include "threads/native/threads.h"
51 # include "threads/none/threads.h"
54 #include "vm/method.h"
57 /* stackframeinfo **************************************************************
59 ATTENTION: Keep the number of elements of this structure even, to
60 make sure that the stack keeps aligned (e.g. 16-bytes for x86_64).
62 *******************************************************************************/
64 struct stackframeinfo {
65 stackframeinfo *prev; /* pointer to prev stackframeinfo */
66 methodinfo *method; /* methodinfo of current function */
67 u1 *pv; /* PV of current function */
68 u1 *sp; /* SP of parent Java function */
69 u1 *ra; /* RA to parent Java function */
70 u1 *xpc; /* XPC (for inline stubs) */
73 #if defined(ENABLE_THREADS)
74 #define STACKFRAMEINFO (&(THREADOBJECT->_stackframeinfo))
76 extern stackframeinfo *_no_threads_stackframeinfo;
78 #define STACKFRAMEINFO (&_no_threads_stackframeinfo)
82 /* stacktrace_entry ***********************************************************/
84 struct stacktrace_entry {
85 #if SIZEOF_VOID_P == 8
94 /* stacktracebuffer ***********************************************************/
96 #define STACKTRACE_CAPACITY_DEFAULT 80
97 #define STACKTRACE_CAPACITY_INCREMENT 80
99 struct stacktracebuffer {
100 s4 capacity; /* size of the buffer */
101 s4 used; /* current entries in the buffer */
102 stacktrace_entry *entries; /* the actual entries */
106 /* stacktracecontainer ********************************************************
108 ATTENTION: Use the stacktracecontainer to place a stacktrace onto the heap
109 with stacktrace_fillInStackTrace() so that the GC does not get confused.
111 *******************************************************************************/
113 typedef struct stacktracecontainer {
114 java_arrayheader header; /* default array header for the GC */
115 struct stacktracebuffer stb; /* let entries point to data below */
116 stacktrace_entry data[1]; /* the actual array of entries */
117 } stacktracecontainer;
120 /* function prototypes ********************************************************/
122 #if defined(ENABLE_INTRP)
123 void stacktrace_create_stackframeinfo(stackframeinfo *sfi, u1 *pv, u1 *sp,
127 void stacktrace_create_inline_stackframeinfo(stackframeinfo *sfi, u1 *pv,
128 u1 *sp, u1 *ra, u1 *xpc);
130 void stacktrace_create_extern_stackframeinfo(stackframeinfo *sfi, u1 *pv,
131 u1 *sp, u1 *ra, u1 *xpc);
133 void stacktrace_create_native_stackframeinfo(stackframeinfo *sfi, u1 *pv,
136 void stacktrace_remove_stackframeinfo(stackframeinfo *sfi);
138 /* inline exception creating functions */
139 java_objectheader *stacktrace_inline_arithmeticexception(u1 *pv, u1 *sp, u1 *ra,
141 #define STACKTRACE_inline_arithmeticexception \
142 (functionptr) stacktrace_inline_arithmeticexception
145 java_objectheader *stacktrace_inline_arrayindexoutofboundsexception(u1 *pv,
150 #define STACKTRACE_inline_arrayindexoutofboundsexception \
151 (functionptr) stacktrace_inline_arrayindexoutofboundsexception
153 java_objectheader *stacktrace_inline_arraystoreexception(u1 *pv, u1 *sp, u1 *ra,
155 #define STACKTRACE_inline_arraystoreexception \
156 (functionptr) stacktrace_inline_arraystoreexception
158 java_objectheader *stacktrace_inline_classcastexception(u1 *pv, u1 *sp, u1 *ra,
160 java_objectheader *o);
161 #define STACKTRACE_inline_classcastexception \
162 (functionptr) stacktrace_inline_classcastexception
164 java_objectheader *stacktrace_inline_nullpointerexception(u1 *pv, u1 *sp,
166 #define STACKTRACE_inline_nullpointerexception \
167 (functionptr) stacktrace_inline_nullpointerexception
169 /* refill the stacktrace of an existing exception */
170 java_objectheader *stacktrace_inline_fillInStackTrace(u1 *pv, u1 *sp, u1 *ra,
172 #define STACKTRACE_inline_fillInStackTrace \
173 (functionptr) stacktrace_inline_fillInStackTrace
176 /* hardware exception creating functions */
177 java_objectheader *stacktrace_hardware_arithmeticexception(u1 *pv, u1 *sp,
180 java_objectheader *stacktrace_hardware_nullpointerexception(u1 *pv, u1 *sp,
184 stacktracecontainer *stacktrace_fillInStackTrace(void);
186 #if defined(ENABLE_JAVASE)
187 java_objectarray *stacktrace_getClassContext(void);
188 classinfo *stacktrace_getCurrentClass(void);
189 java_objectarray *stacktrace_getStack(void);
192 void stacktrace_dump_trace(threadobject *thread);
193 void stacktrace_print_trace(java_objectheader *xptr);
196 /* machine dependent functions (code in ARCH_DIR/md.c) */
198 #if defined(ENABLE_JIT)
199 u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
202 #if defined(ENABLE_INTRP)
203 u1 *intrp_md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
206 #if defined(ENABLE_CYCLES_STATS)
207 void stacktrace_print_cycles_stats(FILE *file);
210 #endif /* _STACKTRACE_H */
214 * These are local overrides for various environment variables in Emacs.
215 * Please do not remove this and leave it at the end of the file, where
216 * Emacs will automagically detect them.
217 * ---------------------------------------------------------------------
220 * indent-tabs-mode: t