5 #ifndef __MONO_DEBUGGER_ENGINE_H__
6 #define __MONO_DEBUGGER_ENGINE_H__
9 #include <mono/metadata/seq-points-data.h>
10 #include <mono/mini/debugger-state-machine.h>
14 - Move EventKind back to debugger-agent.c as it contains sdb wire protocol constants.
15 This is complicated because EventRequest has an event_kind field.
20 EVENT_KIND_VM_START
= 0,
21 EVENT_KIND_VM_DEATH
= 1,
22 EVENT_KIND_THREAD_START
= 2,
23 EVENT_KIND_THREAD_DEATH
= 3,
24 EVENT_KIND_APPDOMAIN_CREATE
= 4,
25 EVENT_KIND_APPDOMAIN_UNLOAD
= 5,
26 EVENT_KIND_METHOD_ENTRY
= 6,
27 EVENT_KIND_METHOD_EXIT
= 7,
28 EVENT_KIND_ASSEMBLY_LOAD
= 8,
29 EVENT_KIND_ASSEMBLY_UNLOAD
= 9,
30 EVENT_KIND_BREAKPOINT
= 10,
32 EVENT_KIND_TYPE_LOAD
= 12,
33 EVENT_KIND_EXCEPTION
= 13,
34 EVENT_KIND_KEEPALIVE
= 14,
35 EVENT_KIND_USER_BREAK
= 15,
36 EVENT_KIND_USER_LOG
= 16,
42 MOD_KIND_THREAD_ONLY
= 3,
43 MOD_KIND_LOCATION_ONLY
= 7,
44 MOD_KIND_EXCEPTION_ONLY
= 8,
46 MOD_KIND_ASSEMBLY_ONLY
= 11,
47 MOD_KIND_SOURCE_FILE_ONLY
= 12,
48 MOD_KIND_TYPE_NAME_ONLY
= 13,
65 STEP_FILTER_STATIC_CTOR
= 1,
66 STEP_FILTER_DEBUGGER_HIDDEN
= 2,
67 STEP_FILTER_DEBUGGER_STEP_THROUGH
= 4,
68 STEP_FILTER_DEBUGGER_NON_USER_CODE
= 8
74 int count
; /* For kind == MOD_KIND_COUNT */
75 MonoInternalThread
*thread
; /* For kind == MOD_KIND_THREAD_ONLY */
76 MonoClass
*exc_class
; /* For kind == MONO_KIND_EXCEPTION_ONLY */
77 MonoAssembly
**assemblies
; /* For kind == MONO_KIND_ASSEMBLY_ONLY */
78 GHashTable
*source_files
; /* For kind == MONO_KIND_SOURCE_FILE_ONLY */
79 GHashTable
*type_names
; /* For kind == MONO_KIND_TYPE_NAME_ONLY */
80 StepFilter filter
; /* For kind == MOD_KIND_STEP */
82 gboolean caught
, uncaught
, subclasses
, not_filtered_feature
, everything_else
; /* For kind == MOD_KIND_EXCEPTION_ONLY */
91 Modifier modifiers
[MONO_ZERO_LEN_ARRAY
];
95 * Describes a single step request.
99 MonoInternalThread
*thread
;
105 MonoMethod
*start_method
;
106 MonoMethod
*last_method
;
108 /* Whenever single stepping is performed using start/stop_single_stepping () */
110 /* The list of breakpoints used to implement step-over */
112 /* The number of frames at the start of a step-over */
114 /* If set, don't stop in methods that are not part of user assemblies */
115 MonoAssembly
** user_assemblies
;
116 /* Used to distinguish stepping breakpoint hits in parallel tasks executions */
118 /* Used to know if we are in process of async step-out and distishing from exception breakpoints */
119 MonoMethod
* async_stepout_method
;
125 * Contains information about an inserted breakpoint.
128 long il_offset
, native_offset
;
132 } BreakpointInstance
;
135 * Contains generic information about a breakpoint.
139 * The method where the breakpoint is placed. Can be NULL in which case it
140 * is inserted into every method. This is used to implement method entry/
141 * exit events. Can be a generic method definition, in which case the
142 * breakpoint is inserted into every instance.
148 * A list of BreakpointInstance structures describing where the breakpoint
149 * was inserted. There could be more than one because of
150 * generics/appdomains/method entry/exit.
159 guint32 native_offset
;
160 } DbgEngineStackFrame
;
164 * Method where to start single stepping
169 * If ctx is set, tls must belong to the same thread.
175 * Stopped at a throw site
177 gboolean step_to_catch
;
180 * Sequence point to start from.
183 MonoSeqPointInfo
*info
;
186 * Frame data, will be freed at the end of ss_start if provided
188 DbgEngineStackFrame
**frames
;
197 * Represents an object accessible by the debugger client.
200 /* Unique id used in the wire protocol to refer to objects */
203 * A weakref gc handle pointing to the object. The gc handle is used to
204 * detect if the object was garbage collected.
210 void mono_debugger_free_objref (gpointer value
);
212 typedef int DbgEngineErrorCode
;
213 #define DE_ERR_NONE 0
214 // WARNING WARNING WARNING
215 // Error codes MUST match those of sdb for now
216 #define DE_ERR_NOT_IMPLEMENTED 100
219 mono_debugger_get_thread_states (void);
222 mono_debugger_is_disconnected (void);
225 mono_debugger_tls_thread_id (DebuggerTlsData
*debuggerTlsData
);
228 mono_debugger_set_thread_state (DebuggerTlsData
*ref
, MonoDebuggerThreadState expected
, MonoDebuggerThreadState set
);
230 MonoDebuggerThreadState
231 mono_debugger_get_thread_state (DebuggerTlsData
*ref
);
234 MonoContext
*(*tls_get_restore_state
) (void *tls
);
235 gboolean (*try_process_suspend
) (void *tls
, MonoContext
*ctx
);
236 gboolean (*begin_breakpoint_processing
) (void *tls
, MonoContext
*ctx
, MonoJitInfo
*ji
, gboolean from_signal
);
237 void (*begin_single_step_processing
) (MonoContext
*ctx
, gboolean from_signal
);
239 void (*ss_discard_frame_context
) (void *tls
);
240 void (*ss_calculate_framecount
) (void *tls
, MonoContext
*ctx
, gboolean force_use_ctx
, DbgEngineStackFrame
***frames
, int *nframes
);
241 gboolean (*ensure_jit
) (DbgEngineStackFrame
*frame
);
242 int (*ensure_runtime_is_suspended
) (void);
244 int (*get_this_async_id
) (DbgEngineStackFrame
*frame
);
246 void* (*create_breakpoint_events
) (GPtrArray
*ss_reqs
, GPtrArray
*bp_reqs
, MonoJitInfo
*ji
, EventKind kind
);
247 void (*process_breakpoint_events
) (void *_evts
, MonoMethod
*method
, MonoContext
*ctx
, int il_offset
);
249 gboolean (*set_set_notification_for_wait_completion_flag
) (DbgEngineStackFrame
*f
);
250 MonoMethod
* (*get_notify_debugger_of_wait_completion_method
)(void);
252 int (*ss_create_init_args
) (SingleStepReq
*ss_req
, SingleStepArgs
*args
);
253 void (*ss_args_destroy
) (SingleStepArgs
*ss_args
);
254 } DebuggerEngineCallbacks
;
257 void mono_de_init (DebuggerEngineCallbacks
*cbs
);
258 void mono_de_cleanup (void);
259 void mono_de_set_log_level (int level
, FILE *file
);
261 //locking - we expose the lock object from the debugging engine to ensure we keep the same locking semantics of sdb.
262 void mono_de_lock (void);
263 void mono_de_unlock (void);
266 void mono_de_foreach_domain (GHFunc func
, gpointer user_data
);
267 void mono_de_domain_add (MonoDomain
*domain
);
268 void mono_de_domain_remove (MonoDomain
*domain
);
271 void mono_de_clear_breakpoint (MonoBreakpoint
*bp
);
272 MonoBreakpoint
* mono_de_set_breakpoint (MonoMethod
*method
, long il_offset
, EventRequest
*req
, MonoError
*error
);
273 void mono_de_collect_breakpoints_by_sp (SeqPoint
*sp
, MonoJitInfo
*ji
, GPtrArray
*ss_reqs
, GPtrArray
*bp_reqs
);
274 void mono_de_clear_breakpoints_for_domain (MonoDomain
*domain
);
275 void mono_de_add_pending_breakpoints (MonoMethod
*method
, MonoJitInfo
*ji
);
276 void mono_de_clear_all_breakpoints (void);
277 MonoBreakpoint
* mono_de_get_breakpoint_by_id (int id
);
280 void mono_de_start_single_stepping (void);
281 void mono_de_stop_single_stepping (void);
283 void mono_de_process_breakpoint (void *tls
, gboolean from_signal
);
284 void mono_de_process_single_step (void *tls
, gboolean from_signal
);
285 DbgEngineErrorCode
mono_de_ss_create (MonoInternalThread
*thread
, StepSize size
, StepDepth depth
, StepFilter filter
, EventRequest
*req
);
286 void mono_de_cancel_ss (void);