1 /* src/vm/jit/stacktrace.hpp - 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
26 #ifndef _STACKTRACE_HPP
27 #define _STACKTRACE_HPP
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.hpp"
46 #include "vm/global.h"
48 #include "vm/jit/code.hpp"
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_t {
59 stackframeinfo_t *prev; /* pointer to prev stackframeinfo */
60 codeinfo *code; /* codeinfo of current method */
61 void *pv; /* PV of current function */
62 void *sp; /* SP of parent Java function */
63 void *ra; /* RA to parent Java function */
64 void *xpc; /* XPC (for inline stubs) */
65 #if defined(ENABLE_GC_CACAO)
67 * The exact GC needs to be able to recover saved registers, so the
68 * native-stub saves these registers here
70 # if defined(HAS_ADDRESS_REGISTER_FILE)
71 uintptr_t adrregs[ADR_SAV_CNT];
73 uintptr_t intregs[INT_SAV_CNT];
79 /* stacktrace_entry_t *********************************************************/
81 struct stacktrace_entry_t {
82 codeinfo *code; /* codeinfo pointer of this method */
83 void *pc; /* PC in this method */
87 /* stacktrace_t ***************************************************************/
90 int32_t length; /* length of the entries array */
91 stacktrace_entry_t entries[1]; /* stacktrace entries */
95 /* function prototypes ********************************************************/
97 // FIXME Use C-linkage for now.
102 void stacktrace_stackframeinfo_add(stackframeinfo_t* sfi, void* pv, void* sp, void* ra, void* xpc);
103 void stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi);
105 java_handle_bytearray_t *stacktrace_get(stackframeinfo_t *sfi);
106 java_handle_bytearray_t *stacktrace_get_current(void);
108 #if defined(ENABLE_JAVASE)
109 classinfo *stacktrace_get_caller_class(int depth);
110 classloader_t *stacktrace_first_nonnull_classloader(void);
111 java_handle_objectarray_t *stacktrace_getClassContext(void);
112 classinfo *stacktrace_get_current_class(void);
113 java_handle_objectarray_t *stacktrace_get_stack(void);
116 void stacktrace_print(stacktrace_t *st);
117 void stacktrace_print_current(void);
119 #if defined(ENABLE_THREADS)
120 void stacktrace_print_of_thread(threadobject *t);
123 void stacktrace_print_exception(java_handle_t *h);
125 /* machine dependent functions (code in ARCH_DIR/md.c) */
127 #if defined(ENABLE_JIT)
128 # if defined(__SPARC_64__)
129 u1 *md_get_framepointer(u1 *sp);
130 u1 *md_get_pv_from_stackframe(u1 *sp);
134 #if defined(ENABLE_INTRP)
135 void* intrp_md_stacktrace_get_returnaddress(void* sp, int32_t framesize);
138 #if defined(ENABLE_CYCLES_STATS)
139 void stacktrace_print_cycles_stats(FILE *file);
146 #endif // _STACKTRACE_HPP
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
160 * vim:noexpandtab:sw=4:ts=4: