* src/vm/jit/md.h: Removed.
[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 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25 */
26
27
28 #ifndef _STACKTRACE_H
29 #define _STACKTRACE_H
30
31 /* forward typedefs ***********************************************************/
32
33 typedef struct stackframeinfo_t stackframeinfo_t;
34 typedef struct stacktracebuffer stacktracebuffer;
35 typedef struct stacktrace_entry stacktrace_entry;
36
37 #include "config.h"
38
39 #include <stdint.h>
40
41 #include "vm/types.h"
42
43 #include "md-abi.h"
44
45 #include "vmcore/class.h"
46 #include "vmcore/method.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 ***********************************************************/
78
79 struct stacktrace_entry {
80 #if SIZEOF_VOID_P == 8
81         u8          linenumber;
82 #else
83         u4          linenumber;
84 #endif
85         methodinfo *method;
86 };
87
88
89 /* stacktracebuffer ***********************************************************/
90
91 #define STACKTRACE_CAPACITY_DEFAULT      80
92 #define STACKTRACE_CAPACITY_INCREMENT    80
93
94 struct stacktracebuffer {
95         s4               capacity;          /* size of the buffer                 */
96         s4               used;              /* current entries in the buffer      */
97         stacktrace_entry entries[80];       /* the actual entries                 */
98 };
99
100
101 /* function prototypes ********************************************************/
102
103 void stacktrace_stackframeinfo_add(stackframeinfo_t *sfi, u1 *pv, u1 *sp, u1 *ra, u1 *xpc);
104 void stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi);
105
106
107 stacktracebuffer *stacktrace_create(stackframeinfo_t *sfi);
108
109 java_handle_bytearray_t   *stacktrace_fillInStackTrace(void);
110
111 #if defined(ENABLE_JAVASE)
112 java_handle_objectarray_t *stacktrace_getClassContext(void);
113 classinfo                 *stacktrace_getCurrentClass(void);
114 java_handle_objectarray_t *stacktrace_getStack(void);
115 #endif
116
117 void stacktrace_print_trace_from_buffer(stacktracebuffer *stb);
118 void stacktrace_print_exception(java_handle_t *h);
119
120 /* machine dependent functions (code in ARCH_DIR/md.c) */
121
122 #if defined(ENABLE_JIT)
123 # if defined(__SPARC_64__)
124 u1 *md_get_framepointer(u1 *sp);
125 u1 *md_get_pv_from_stackframe(u1 *sp);
126 # endif
127 #endif
128
129 #if defined(ENABLE_INTRP)
130 u1 *intrp_md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
131 #endif
132
133 #if defined(ENABLE_CYCLES_STATS)
134 void stacktrace_print_cycles_stats(FILE *file);
135 #endif
136
137 #endif /* _STACKTRACE_H */
138
139
140 /*
141  * These are local overrides for various environment variables in Emacs.
142  * Please do not remove this and leave it at the end of the file, where
143  * Emacs will automagically detect them.
144  * ---------------------------------------------------------------------
145  * Local variables:
146  * mode: c
147  * indent-tabs-mode: t
148  * c-basic-offset: 4
149  * tab-width: 4
150  * End:
151  * vim:noexpandtab:sw=4:ts=4:
152  */