1 /* src/vm/jit/stacktrace.h - header file for stacktrace generation
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29 /* forward typedefs ***********************************************************/
31 typedef struct stackframeinfo_t stackframeinfo_t;
32 typedef struct stacktrace_entry_t stacktrace_entry_t;
33 typedef struct stacktrace_t stacktrace_t;
43 #include "threads/thread.h"
45 #include "vm/global.h"
47 #include "vm/jit/code.h"
49 #include "vmcore/class.h"
52 /* stackframeinfo **************************************************************
54 ATTENTION: Keep the number of elements of this structure even, to
55 make sure that the stack keeps aligned (e.g. 16-bytes for x86_64).
57 *******************************************************************************/
59 struct stackframeinfo_t {
60 stackframeinfo_t *prev; /* pointer to prev stackframeinfo */
61 codeinfo *code; /* codeinfo of current method */
62 u1 *pv; /* PV of current function */
63 u1 *sp; /* SP of parent Java function */
64 u1 *ra; /* RA to parent Java function */
65 u1 *xpc; /* XPC (for inline stubs) */
66 #if defined(ENABLE_GC_CACAO)
68 * The exact GC needs to be able to recover saved registers, so the
69 * native-stub saves these registers here
71 # if defined(HAS_ADDRESS_REGISTER_FILE)
72 uintptr_t adrregs[ADR_SAV_CNT];
74 uintptr_t intregs[INT_SAV_CNT];
80 /* stacktrace_entry_t *********************************************************/
82 struct stacktrace_entry_t {
83 codeinfo *code; /* codeinfo pointer of this method */
84 void *pc; /* PC in this method */
88 /* stacktrace_t ***************************************************************/
91 int32_t length; /* length of the entries array */
92 stacktrace_entry_t entries[1]; /* stacktrace entries */
96 /* function prototypes ********************************************************/
98 void stacktrace_stackframeinfo_add(stackframeinfo_t *sfi, u1 *pv, u1 *sp, u1 *ra, u1 *xpc);
99 void stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi);
101 java_handle_bytearray_t *stacktrace_get(stackframeinfo_t *sfi);
102 java_handle_bytearray_t *stacktrace_get_current(void);
104 #if defined(ENABLE_JAVASE)
105 classinfo *stacktrace_get_caller_class(int depth);
106 classloader_t *stacktrace_first_nonnull_classloader(void);
107 java_handle_objectarray_t *stacktrace_getClassContext(void);
108 classinfo *stacktrace_get_current_class(void);
109 java_handle_objectarray_t *stacktrace_get_stack(void);
112 void stacktrace_print(stacktrace_t *st);
113 void stacktrace_print_current(void);
115 #if defined(ENABLE_THREADS)
116 void stacktrace_print_of_thread(threadobject *t);
119 void stacktrace_print_exception(java_handle_t *h);
121 /* machine dependent functions (code in ARCH_DIR/md.c) */
123 #if defined(ENABLE_JIT)
124 # if defined(__SPARC_64__)
125 u1 *md_get_framepointer(u1 *sp);
126 u1 *md_get_pv_from_stackframe(u1 *sp);
130 #if defined(ENABLE_INTRP)
131 u1 *intrp_md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
134 #if defined(ENABLE_CYCLES_STATS)
135 void stacktrace_print_cycles_stats(FILE *file);
138 #endif /* _STACKTRACE_H */
142 * These are local overrides for various environment variables in Emacs.
143 * Please do not remove this and leave it at the end of the file, where
144 * Emacs will automagically detect them.
145 * ---------------------------------------------------------------------
148 * indent-tabs-mode: t
152 * vim:noexpandtab:sw=4:ts=4: