* src/vmcore/linker.c (build_display): Removed superfluous recursion; return
[cacao.git] / src / vm / jit / stacktrace.h
1 /* src/vm/jit/stacktrace.h - header file for stacktrace generation
2
3    Copyright (C) 1996-2005, 2006, 2007, 2008
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_H
27 #define _STACKTRACE_H
28
29 /* forward typedefs ***********************************************************/
30
31 typedef struct stackframeinfo_t   stackframeinfo_t;
32 typedef struct stacktrace_entry_t stacktrace_entry_t;
33 typedef struct stacktrace_t       stacktrace_t;
34
35 #include "config.h"
36
37 #include <stdint.h>
38
39 #include "vm/types.h"
40
41 #include "md-abi.h"
42
43 #include "threads/thread.h"
44
45 #include "vm/global.h"
46
47 #include "vm/jit/code.h"
48
49 #include "vmcore/class.h"
50
51
52 /* stackframeinfo **************************************************************
53
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).
56
57 *******************************************************************************/
58
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)
67         /* 
68          * The exact GC needs to be able to recover saved registers, so the
69          * native-stub saves these registers here
70          */
71 # if defined(HAS_ADDRESS_REGISTER_FILE)
72         uintptr_t         adrregs[ADR_SAV_CNT];
73 # else
74         uintptr_t         intregs[INT_SAV_CNT];
75 # endif
76 #endif
77 };
78
79
80 /* stacktrace_entry_t *********************************************************/
81
82 struct stacktrace_entry_t {
83         codeinfo *code;                     /* codeinfo pointer of this method    */
84         void     *pc;                       /* PC in this method                  */
85 };
86
87
88 /* stacktrace_t ***************************************************************/
89
90 struct stacktrace_t {
91         int32_t            length;          /* length of the entries array        */
92         stacktrace_entry_t entries[1];      /* stacktrace entries                 */
93 };
94
95
96 /* function prototypes ********************************************************/
97
98 void                       stacktrace_stackframeinfo_add(stackframeinfo_t *sfi, u1 *pv, u1 *sp, u1 *ra, u1 *xpc);
99 void                       stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi);
100
101 java_handle_bytearray_t   *stacktrace_get(stackframeinfo_t *sfi);
102 java_handle_bytearray_t   *stacktrace_get_current(void);
103
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);
110 #endif
111
112 void                       stacktrace_print(stacktrace_t *st);
113 void                       stacktrace_print_current(void);
114
115 #if defined(ENABLE_THREADS)
116 void                       stacktrace_print_of_thread(threadobject *t);
117 #endif
118
119 void                       stacktrace_print_exception(java_handle_t *h);
120
121 /* machine dependent functions (code in ARCH_DIR/md.c) */
122
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);
127 # endif
128 #endif
129
130 #if defined(ENABLE_INTRP)
131 u1 *intrp_md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
132 #endif
133
134 #if defined(ENABLE_CYCLES_STATS)
135 void stacktrace_print_cycles_stats(FILE *file);
136 #endif
137
138 #endif /* _STACKTRACE_H */
139
140
141 /*
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  * ---------------------------------------------------------------------
146  * Local variables:
147  * mode: c
148  * indent-tabs-mode: t
149  * c-basic-offset: 4
150  * tab-width: 4
151  * End:
152  * vim:noexpandtab:sw=4:ts=4:
153  */