* Removed all Id tags.
[cacao.git] / src / native / jvmti / cacaodbg.h
1 /* src/native/jvmti/cacaodbg.h - contains cacao specifics for debugging support
2
3    Copyright (C) 1996-2005, 2006 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., 59 Temple Place - Suite 330, Boston, MA
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Martin Platter
28
29    Changes:
30
31 */
32
33 #ifndef _CACAODBG_H
34 #define _CACAODBG_H
35
36 #include "threads/native/threads.h"
37 #include "native/jvmti/jvmti.h"
38 #include "native/include/java_lang_String.h"
39 #include <ltdl.h>
40
41
42
43 typedef struct {
44         jvmtiEvent ev;
45         jvmtiEnv *jvmti_env;
46         jthread thread;
47         jmethodID method;
48         jlocation location;
49         jclass klass;
50         jobject object;
51         jfieldID field;
52         char signature_type;
53         jvalue value;
54         jboolean b;
55         void* address;
56         void** new_address_ptr;
57         jmethodID catch_method;
58         jlocation catch_location;
59         char* name;
60         jobject protection_domain;
61         jint jint1;
62         jint jint2;
63         unsigned char* class_data;
64         jint* new_class_data_len;
65         unsigned char** new_class_data;
66         jvmtiAddrLocationMap* map;
67         void* compile_info;
68         jlong jlong;
69 } genericEventData;
70
71
72
73 #if defined(ENABLE_THREADS)
74 struct _jrawMonitorID {
75     java_lang_String *name;
76 };
77
78
79 #endif
80
81
82 /* constants where system breakpoints are stored in the breakpoint table       */
83 #define SETSYSBRKPT             0 /* used for setsysbrkpt calls                */
84 #define CACAODBGSERVERQUIT      1 
85 #define NOTHARDCODEDBRK         2 /* here is where the first not hard coded 
86                                                                      breakpoint is stored                      */
87 #define THREADSTARTBRK          2 
88 #define THREADENDBRK            3 
89 #define CLASSLOADBRK            4
90 #define CLASSPREPARERK          5
91 #define CLASSFILELOADHOOKBRK    6
92 #define COMPILEDMETHODLOADBRK   7
93 #define COMPILEDMETHODUNLOADBRK 8
94 #define BEGINUSERBRK            9 /* here is where the first user breakpoint  
95                                                                      is stored                                 */
96
97 struct _brkpt {
98     jmethodID method;
99     jlocation location;
100     void* addr; /* memory address          */
101         int count;
102 };
103
104
105 struct brkpts {
106         struct _brkpt* brk;
107         int num;
108         int size;
109 };
110
111
112 typedef struct {
113         int running;
114         bool addbrkpt;
115         void* brkaddr;
116         struct brkpts jvmtibrkpt;
117 } cacaodbgcommunication;
118
119 cacaodbgcommunication *dbgcom;
120
121 bool jvmti;                 /* jvmti agent  */
122
123 extern pthread_mutex_t dbgcomlock;
124
125 jvmtiEnv* jvmti_new_environment();
126 void jvmti_set_phase(jvmtiPhase p);
127 void jvmti_fireEvent(genericEventData* data);
128 void jvmti_agentload(char* opt_arg, bool agentbypath, 
129                                          lt_dlhandle  *handle, char **libname);
130 void jvmti_agentunload();
131 void jvmti_add_breakpoint(void* addr, jmethodID method, jlocation location);
132 void jvmti_set_system_breakpoint(int sysbrk, bool mode);
133 jvmtiError jvmti_get_all_threads (jint * threads_count_ptr, 
134                                                                   threadobject *** threads_ptr);
135 jthread jvmti_get_current_thread();
136 void jvmti_cacao_debug_init();
137 void jvmti_cacaodbgserver_quit();
138
139 void jvmti_ClassLoadPrepare(bool prepared, classinfo *c);
140 void jvmti_ClassFileLoadHook(utf* name, int class_data_len, 
141                                                          unsigned char* class_data, 
142                                                          java_objectheader* loader, 
143                                                          java_objectheader* protection_domain, 
144                                                          jint* new_class_data_len, 
145                                                          unsigned char** new_class_data);
146 void jvmti_MonitorContendedEntering(bool entered, jobject obj);
147 void jvmti_MonitorWaiting(bool wait, jobject obj, jlong timeout);
148 void jvmti_ThreadStartEnd(jvmtiEvent ev);
149 void jvmti_NativeMethodBind(jmethodID method, void* address, 
150                                                         void** new_address_ptr);
151 #endif
152
153 /*
154  * These are local overrides for various environment variables in Emacs.
155  * Please do not remove this and leave it at the end of the file, where
156  * Emacs will automagically detect them.
157  * ---------------------------------------------------------------------
158  * Local variables:
159  * mode: c
160  * indent-tabs-mode: t
161  * c-basic-offset: 4
162  * tab-width: 4
163  * End:
164  */