* src/vm/jit/powerpc/codegen.c (codegen_emit): Removed variable a,
[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
5    This file is part of CACAO.
6
7    This program is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License as
9    published by the Free Software Foundation; either version 2, or (at
10    your option) any later version.
11
12    This program is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20    02110-1301, USA.
21
22 */
23
24
25 #ifndef _STACKTRACE_H
26 #define _STACKTRACE_H
27
28 /* forward typedefs ***********************************************************/
29
30 typedef struct stackframeinfo_t   stackframeinfo_t;
31 typedef struct stacktrace_entry_t stacktrace_entry_t;
32 typedef struct stacktrace_t       stacktrace_t;
33
34 #include "config.h"
35
36 #include <stdint.h>
37
38 #include "vm/types.h"
39
40 #include "md-abi.h"
41
42 #include "vm/global.h"
43
44 #include "vm/jit/code.h"
45
46 #include "vmcore/class.h"
47
48
49 /* stackframeinfo **************************************************************
50
51    ATTENTION: Keep the number of elements of this structure even, to
52    make sure that the stack keeps aligned (e.g. 16-bytes for x86_64).
53
54 *******************************************************************************/
55
56 struct stackframeinfo_t {
57         stackframeinfo_t *prev;             /* pointer to prev stackframeinfo     */
58         codeinfo         *code;             /* codeinfo of current method         */
59         u1               *pv;               /* PV of current function             */
60         u1               *sp;               /* SP of parent Java function         */
61         u1               *ra;               /* RA to parent Java function         */
62         u1               *xpc;              /* XPC (for inline stubs)             */
63 #if defined(ENABLE_GC_CACAO)
64         /* 
65          * The exact GC needs to be able to recover saved registers, so the
66          * native-stub saves these registers here
67          */
68 # if defined(HAS_ADDRESS_REGISTER_FILE)
69         uintptr_t         adrregs[ADR_SAV_CNT];
70 # else
71         uintptr_t         intregs[INT_SAV_CNT];
72 # endif
73 #endif
74 };
75
76
77 /* stacktrace_entry_t *********************************************************/
78
79 struct stacktrace_entry_t {
80         codeinfo *code;                     /* codeinfo pointer of this method    */
81         void     *pc;                       /* PC in this method                  */
82 };
83
84
85 /* stacktrace_t ***************************************************************/
86
87 struct stacktrace_t {
88         int32_t            length;          /* length of the entries array        */
89         stacktrace_entry_t entries[1];      /* stacktrace entries                 */
90 };
91
92
93 /* function prototypes ********************************************************/
94
95 void                       stacktrace_stackframeinfo_add(stackframeinfo_t *sfi, u1 *pv, u1 *sp, u1 *ra, u1 *xpc);
96 void                       stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi);
97
98 java_handle_bytearray_t   *stacktrace_get(stackframeinfo_t *sfi);
99 java_handle_bytearray_t   *stacktrace_get_current(void);
100
101 #if defined(ENABLE_JAVASE)
102 classloader               *stacktrace_first_nonnull_classloader(void);
103 java_handle_objectarray_t *stacktrace_getClassContext(void);
104 classinfo                 *stacktrace_get_current_class(void);
105 java_handle_objectarray_t *stacktrace_get_stack(void);
106 #endif
107
108 void                       stacktrace_print(stacktrace_t *st);
109 void                       stacktrace_print_exception(java_handle_t *h);
110
111 /* machine dependent functions (code in ARCH_DIR/md.c) */
112
113 #if defined(ENABLE_JIT)
114 # if defined(__SPARC_64__)
115 u1 *md_get_framepointer(u1 *sp);
116 u1 *md_get_pv_from_stackframe(u1 *sp);
117 # endif
118 #endif
119
120 #if defined(ENABLE_INTRP)
121 u1 *intrp_md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
122 #endif
123
124 #if defined(ENABLE_CYCLES_STATS)
125 void stacktrace_print_cycles_stats(FILE *file);
126 #endif
127
128 #endif /* _STACKTRACE_H */
129
130
131 /*
132  * These are local overrides for various environment variables in Emacs.
133  * Please do not remove this and leave it at the end of the file, where
134  * Emacs will automagically detect them.
135  * ---------------------------------------------------------------------
136  * Local variables:
137  * mode: c
138  * indent-tabs-mode: t
139  * c-basic-offset: 4
140  * tab-width: 4
141  * End:
142  * vim:noexpandtab:sw=4:ts=4:
143  */