1 /* src/vm/jit/stacktrace.h - header file for stacktrace generation
3 Copyright (C) 1996-2005, 2006, 2007 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
31 /* forward typedefs ***********************************************************/
33 typedef struct stackframeinfo stackframeinfo;
34 typedef struct stacktracebuffer stacktracebuffer;
35 typedef struct stacktrace_entry stacktrace_entry;
40 #include "vmcore/class.h"
41 #include "vmcore/method.h"
44 /* stackframeinfo **************************************************************
46 ATTENTION: Keep the number of elements of this structure even, to
47 make sure that the stack keeps aligned (e.g. 16-bytes for x86_64).
49 *******************************************************************************/
51 struct stackframeinfo {
52 stackframeinfo *prev; /* pointer to prev stackframeinfo */
53 methodinfo *method; /* methodinfo of current function */
54 u1 *pv; /* PV of current function */
55 u1 *sp; /* SP of parent Java function */
56 u1 *ra; /* RA to parent Java function */
57 u1 *xpc; /* XPC (for inline stubs) */
61 /* stacktrace_entry ***********************************************************/
63 struct stacktrace_entry {
64 #if SIZEOF_VOID_P == 8
73 /* stacktracebuffer ***********************************************************/
75 #define STACKTRACE_CAPACITY_DEFAULT 80
76 #define STACKTRACE_CAPACITY_INCREMENT 80
78 struct stacktracebuffer {
79 s4 capacity; /* size of the buffer */
80 s4 used; /* current entries in the buffer */
81 stacktrace_entry *entries; /* the actual entries */
85 /* stacktracecontainer ********************************************************
87 ATTENTION: Use the stacktracecontainer to place a stacktrace onto the heap
88 with stacktrace_fillInStackTrace() so that the GC does not get confused.
90 *******************************************************************************/
92 typedef struct stacktracecontainer {
93 java_array_t header; /* default array header for the GC */
94 struct stacktracebuffer stb; /* let entries point to data below */
95 stacktrace_entry data[1]; /* the actual array of entries */
96 } stacktracecontainer;
99 /* function prototypes ********************************************************/
101 #if defined(ENABLE_INTRP)
102 void stacktrace_create_stackframeinfo(stackframeinfo *sfi, u1 *pv, u1 *sp,
106 void stacktrace_create_extern_stackframeinfo(stackframeinfo *sfi, u1 *pv,
107 u1 *sp, u1 *ra, u1 *xpc);
109 void stacktrace_create_native_stackframeinfo(stackframeinfo *sfi, u1 *pv,
112 void stacktrace_remove_stackframeinfo(stackframeinfo *sfi);
115 stacktracebuffer *stacktrace_create(stackframeinfo *sfi);
117 stacktracecontainer *stacktrace_fillInStackTrace(void);
119 #if defined(ENABLE_JAVASE)
120 java_handle_objectarray_t *stacktrace_getClassContext(void);
121 classinfo *stacktrace_getCurrentClass(void);
122 java_handle_objectarray_t *stacktrace_getStack(void);
125 void stacktrace_print_trace_from_buffer(stacktracebuffer *stb);
126 void stacktrace_print_trace(java_handle_t *xptr);
128 /* machine dependent functions (code in ARCH_DIR/md.c) */
130 #if defined(ENABLE_JIT)
131 u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
132 # if defined(__SPARC_64__)
133 u1 *md_get_framepointer(u1 *sp);
134 u1 *md_get_pv_from_stackframe(u1 *sp);
138 #if defined(ENABLE_INTRP)
139 u1 *intrp_md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
142 #if defined(ENABLE_CYCLES_STATS)
143 void stacktrace_print_cycles_stats(FILE *file);
146 #endif /* _STACKTRACE_H */
150 * These are local overrides for various environment variables in Emacs.
151 * Please do not remove this and leave it at the end of the file, where
152 * Emacs will automagically detect them.
153 * ---------------------------------------------------------------------
156 * indent-tabs-mode: t