CACAO
stacktrace.hpp
Go to the documentation of this file.
1 /* src/vm/jit/stacktrace.hpp - header file for stacktrace generation
2 
3  Copyright (C) 1996-2013
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
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.
12 
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.
17 
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
21  02110-1301, USA.
22 
23 */
24 
25 
26 #ifndef STACKTRACE_HPP_
27 #define STACKTRACE_HPP_ 1
28 
29 #include <stdint.h> // for int32_t
30 #include "config.h" // for ENABLE_JAVASE, ENABLE_JIT, etc
31 #include "vm/global.hpp" // for java_handle_objectarray_t, etc
32 #include "vm/loader.hpp" // for classloader_t
33 
34 #include "vm/types.hpp"
35 #include "md-abi.hpp"
36 
37 struct classinfo;
38 struct codeinfo;
39 struct threadobject;
40 
41 /* stackframeinfo **************************************************************
42 
43  ATTENTION: Keep the number of elements of this structure even, to
44  make sure that the stack keeps aligned (e.g. 16-bytes for x86_64).
45 
46 *******************************************************************************/
47 
49  stackframeinfo_t *prev; /* pointer to prev stackframeinfo */
50  codeinfo *code; /* codeinfo of current method */
51  void *pv; /* PV of current function */
52  void *sp; /* SP of parent Java function */
53  void *ra; /* RA to parent Java function */
54  void *xpc; /* XPC (for inline stubs) */
55 #if defined(ENABLE_GC_CACAO)
56  /*
57  * The exact GC needs to be able to recover saved registers, so the
58  * native-stub saves these registers here
59  */
60  uintptr_t intregs[INT_SAV_CNT];
61 #endif
62 };
63 
64 
65 /* stacktrace_entry_t *********************************************************/
66 
68  codeinfo *code; /* codeinfo pointer of this method */
69  void *pc; /* PC in this method */
70 };
71 
72 
73 /* stacktrace_t ***************************************************************/
74 
75 struct stacktrace_t {
76  int32_t length; /* length of the entries array */
77  stacktrace_entry_t entries[1]; /* stacktrace entries */
78 };
79 
80 
81 /* function prototypes ********************************************************/
82 
83 void stacktrace_stackframeinfo_add(stackframeinfo_t* sfi, void* pv, void* sp, void* ra, void* xpc);
85 
88 
89 #if defined(ENABLE_JAVASE)
98 #endif
99 
101 void stacktrace_print_current(void);
102 
105 
107 
108 /* machine dependent functions (code in ARCH_DIR/md.c) */
109 
110 #if defined(ENABLE_JIT)
111 # if defined(__SPARC_64__)
114 # endif
115 #endif
116 
117 #if defined(ENABLE_INTRP)
118 void* intrp_md_stacktrace_get_returnaddress(void* sp, int32_t framesize);
119 #endif
120 
121 #if defined(ENABLE_CYCLES_STATS)
122 void stacktrace_print_cycles_stats(FILE *file);
123 #endif
124 
125 #endif // STACKTRACE_HPP_
126 
127 
128 /*
129  * These are local overrides for various environment variables in Emacs.
130  * Please do not remove this and leave it at the end of the file, where
131  * Emacs will automagically detect them.
132  * ---------------------------------------------------------------------
133  * Local variables:
134  * mode: c++
135  * indent-tabs-mode: t
136  * c-basic-offset: 4
137  * tab-width: 4
138  * End:
139  * vim:noexpandtab:sw=4:ts=4:
140  */
std::size_t index
#define pv
Definition: md-asm.hpp:65
classinfo * stacktrace_get_caller_class(int depth)
Definition: stacktrace.cpp:784
codeinfo * code
Definition: stacktrace.hpp:50
#define ra
Definition: md-asm.hpp:62
void stacktrace_print_current(void)
classloader_t * stacktrace_first_nonsystem_classloader(void)
Returns the first non-system (user-defined) classloader on the stack.
Definition: stacktrace.cpp:926
stacktrace_entry_t entries[1]
Definition: stacktrace.hpp:77
classloader_t * stacktrace_first_nonnull_classloader(void)
Returns the first non-null (user-defined) classloader on the stack.
Definition: stacktrace.cpp:851
u1 * intrp_md_stacktrace_get_returnaddress(u1 *sp, u4 framesize)
Definition: md.c:86
static void * md_get_framepointer(void *sp)
Definition: md.hpp:79
uint8_t u1
Definition: types.hpp:40
void stacktrace_print_exception(java_handle_t *h)
void stacktrace_print(stacktrace_t *st)
java_handle_t * stacktrace_get_StackTraceElement(stacktrace_t *st, int32_t index)
Creates a java.lang.StackTraceElement for one element of the given stacktrace.
Definition: stacktrace.cpp:656
#define INT_SAV_CNT
Definition: md-abi.hpp:73
#define xpc
Definition: md-asm.hpp:51
java_handle_objectarray_t * stacktrace_get_StackTraceElements(stacktrace_t *st)
Creates a complete array of java.lang.StackTraceElement objects for the given stacktrace.
Definition: stacktrace.cpp:740
classinfo * stacktrace_get_current_class(void)
jlong jlong jlong jlong jint depth
Definition: jvmti.h:497
stacktrace_t * stacktrace_get_of_thread(threadobject *t)
Creates a stacktrace for the given thread.
codeinfo * code
Definition: stacktrace.hpp:68
int32_t length
Definition: stacktrace.hpp:76
java_handle_bytearray_t * stacktrace_get(stackframeinfo_t *sfi)
Definition: stacktrace.cpp:512
java_handle_objectarray_t * stacktrace_getClassContext(void)
Definition: stacktrace.cpp:978
void stacktrace_stackframeinfo_add(stackframeinfo_t *sfi, void *pv, void *sp, void *ra, void *xpc)
Definition: stacktrace.cpp:84
static void * md_get_pv_from_stackframe(void *sp)
Definition: md.hpp:91
void stacktrace_print_of_thread(threadobject *t)
#define sp
Definition: md-asm.hpp:81
void stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi)
Definition: stacktrace.cpp:204
stackframeinfo_t * prev
Definition: stacktrace.hpp:49
java_handle_objectarray_t * stacktrace_get_stack(void)
java_handle_bytearray_t * stacktrace_get_current(void)
Definition: stacktrace.cpp:635
Definition: stacktrace.hpp:67
void * pc
Definition: stacktrace.hpp:69