major rework of jvmti. now we have three processes in jvmti mode. there are still...
[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    $Id: cacao.c,v 3.165 2006/01/03 23:44:38 twisti Exp $
33
34 */
35
36 #ifndef _CACAODBG_H
37 #define _CACAODBG_H
38
39 #include "threads/native/threads.h"
40 #include "native/jvmti/jvmti.h"
41
42 #define MSGQEVENT        1
43 #define MSGQPTRACEREQ    2
44 #define MSGQPTRACEANS    3
45
46 typedef struct {
47         jvmtiEvent ev;
48         jvmtiEnv *jvmti_env;
49         jthread thread;
50         jmethodID method;
51         jlocation location;
52         jclass klass;
53         jobject object;
54         jfieldID field;
55         char signature_type;
56         jvalue value;
57         jboolean b;
58         void* address;
59         void** new_address_ptr;
60         jmethodID catch_method;
61         jlocation catch_location;
62         char* name;
63         jobject protection_domain;
64         jint jint1;
65         jint jint2;
66         unsigned char* class_data;
67         jint* new_class_data_len;
68         unsigned char** new_class_data;
69         jvmtiAddrLocationMap* map;
70         void* compile_info;
71         jlong jlong;
72 } genericEventData;
73
74 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
75 struct _jrawMonitorID {
76     java_lang_String *name;
77 };
78
79 struct _threadmap {
80         pthread_t tid;
81         threadobject* cacaothreadobj;   
82 };
83
84 struct threadmap {
85         struct _threadmap* map;
86         int num;
87         int size;
88 };
89
90 struct threadmap thmap;
91 #endif
92
93
94 /* constants where system breakpoints are stored in the breakpoint table     */
95 #define HEREWEGOBRK           0 /* used for suspend VM on startup            */
96 #define SETTHREADOBJECTBRK    1 /* used for EVENT_THREAD_START               */
97 #define BEGINUSERBRK          2 /* here is where the first user breakpoint is 
98                                                                    stored                                    */
99 struct _brkpt {
100     jmethodID method;
101     jlocation location;
102     void* addr;
103     long orig; /* original memory content */
104 };
105
106
107 struct brkpts {
108         struct _brkpt* brk;
109         int num;
110         int size;
111 };
112
113 struct brkpts jvmtibrkpt;
114
115 bool jdwp;                  /* debugger via jdwp                              */
116 bool jvmti;                 /* jvmti agent                                    */
117 bool dbgprocess;            /* ture if debugger else debuggee process         */
118 pid_t debuggee;             /* PID of debuggee                                */
119
120 char *transport, *agentarg; /* arguments for jdwp transport and agent load    */
121 bool suspend;               /* should the virtual machine suspend on startup? */
122
123
124 bool cacaodbgfork();
125 void cacaodbglisten(char* transport);
126 jvmtiEnv* new_jvmtienv();
127 void set_jvmti_phase(jvmtiPhase p);
128 bool contdebuggee(int signal);
129 void stopdebuggee();
130 void fireEvent(genericEventData* data);
131 bool VMjdwpInit(jvmtiEnv *jvmti_env);
132 jvmtiEnv* remotedbgjvmtienv;
133 jvmtiEventCallbacks jvmti_jdwp_EventCallbacks;
134 void agentload(char* opt_arg);
135 void agentunload();
136
137 void getchildproc (char **ptr, void* addr, int count);
138 void addbrkpt(void* addr, jmethodID method, jlocation location);
139 void setsysbrkpt(int sysbrk, void* addr);
140 jthread threadobject2jthread(threadobject* thread);
141 jvmtiError allthreads (jint * threads_count_ptr, threadobject ** threads_ptr);
142 jthread getcurrentthread();
143
144 void ipcrm();
145
146 #endif
147
148 /*
149  * These are local overrides for various environment variables in Emacs.
150  * Please do not remove this and leave it at the end of the file, where
151  * Emacs will automagically detect them.
152  * ---------------------------------------------------------------------
153  * Local variables:
154  * mode: c
155  * indent-tabs-mode: t
156  * c-basic-offset: 4
157  * tab-width: 4
158  * End:
159  */