#include <mono/metadata/mono-debug.h>
#include <mono/metadata/mono-debug-debugger.h>
#include <mono/metadata/debug-mono-symfile.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/environment.h>
#include <mono/metadata/threads-types.h>
#include <mono/metadata/threadpool-ms.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/runtime.h>
#include <mono/metadata/verify-internals.h>
-#include <mono/utils/mono-semaphore.h>
+#include <mono/utils/mono-coop-mutex.h>
+#include <mono/utils/mono-coop-semaphore.h>
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/mono-stack-unwinding.h>
#include <mono/utils/mono-time.h>
#ifndef DISABLE_DEBUGGER_AGENT
-#include <mono/utils/mono-mutex.h>
+#include <mono/utils/mono-os-mutex.h>
#define THREAD_TO_INTERNAL(thread) (thread)->internal_thread
static gboolean debugger_thread_exited;
/* Cond variable used to wait for debugger_thread_exited becoming true */
-static mono_cond_t debugger_thread_exited_cond;
+static MonoCoopCond debugger_thread_exited_cond;
/* Mutex for the cond var above */
-static mono_mutex_t debugger_thread_exited_mutex;
+static MonoCoopMutex debugger_thread_exited_mutex;
static DebuggerProfiler debugger_profiler;
static ReplyPacket reply_packets [128];
int nreply_packets;
-#define dbg_lock() do { \
- MONO_TRY_BLOCKING; \
- mono_mutex_lock (&debug_mutex); \
- MONO_FINISH_TRY_BLOCKING; \
-} while (0)
-
-#define dbg_unlock() mono_mutex_unlock (&debug_mutex)
-static mono_mutex_t debug_mutex;
+#define dbg_lock() mono_coop_mutex_lock (&debug_mutex)
+#define dbg_unlock() mono_coop_mutex_unlock (&debug_mutex)
+static MonoCoopMutex debug_mutex;
static void transport_init (void);
static void transport_connect (const char *address);
if (pos == NULL || pos == address)
return 1;
- *host = g_malloc (pos - address + 1);
+ *host = (char *)g_malloc (pos - address + 1);
strncpy (*host, address, pos - address);
(*host) [pos - address] = '\0';
void
mono_debugger_agent_init (void)
{
- mono_mutex_init_recursive (&debug_mutex);
+ mono_coop_mutex_init_recursive (&debug_mutex);
if (!agent_config.enabled)
return;
event_requests = g_ptr_array_new ();
- mono_mutex_init (&debugger_thread_exited_mutex);
- mono_cond_init (&debugger_thread_exited_cond, 0);
+ mono_coop_mutex_init (&debugger_thread_exited_mutex);
+ mono_coop_cond_init (&debugger_thread_exited_cond);
mono_profiler_install ((MonoProfiler*)&debugger_profiler, runtime_shutdown);
- mono_profiler_set_events (MONO_PROFILE_APPDOMAIN_EVENTS | MONO_PROFILE_THREADS | MONO_PROFILE_ASSEMBLY_EVENTS | MONO_PROFILE_JIT_COMPILATION | MONO_PROFILE_METHOD_EVENTS);
+ mono_profiler_set_events ((MonoProfileFlags)(MONO_PROFILE_APPDOMAIN_EVENTS | MONO_PROFILE_THREADS | MONO_PROFILE_ASSEMBLY_EVENTS | MONO_PROFILE_JIT_COMPILATION | MONO_PROFILE_METHOD_EVENTS));
mono_profiler_install_runtime_initialized (runtime_initialized);
mono_profiler_install_appdomain (NULL, appdomain_load, appdomain_start_unload, appdomain_unload);
mono_profiler_install_thread (thread_startup, thread_end);
argv [2] = agent_config.address;
argv [3] = NULL;
- res = g_spawn_async_with_pipes (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ res = g_spawn_async_with_pipes (NULL, argv, NULL, (GSpawnFlags)0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
if (!res) {
fprintf (stderr, "Failed to execute '%s'.\n", agent_config.launch);
exit (1);
breakpoints_cleanup ();
objrefs_cleanup ();
ids_cleanup ();
-
- mono_mutex_destroy (&debugger_thread_exited_mutex);
- mono_cond_destroy (&debugger_thread_exited_cond);
}
/*
/* Write handshake message */
sprintf (handshake_msg, "DWP-Handshake");
/* Must use try blocking as this can nest into code that runs blocking */
- MONO_TRY_BLOCKING;
+ MONO_PREPARE_BLOCKING;
do {
res = transport_send (handshake_msg, strlen (handshake_msg));
} while (res == -1 && get_last_sock_error () == MONO_EINTR);
- MONO_FINISH_TRY_BLOCKING;
+ MONO_FINISH_BLOCKING;
g_assert (res != -1);
/* Read answer */
- MONO_TRY_BLOCKING;
+ MONO_PREPARE_BLOCKING;
res = transport_recv (buf, strlen (handshake_msg));
- MONO_FINISH_TRY_BLOCKING;
+ MONO_FINISH_BLOCKING;
if ((res != strlen (handshake_msg)) || (memcmp (buf, handshake_msg, strlen (handshake_msg)) != 0)) {
fprintf (stderr, "debugger-agent: DWP handshake failed.\n");
return FALSE;
*/
if (!is_debugger_thread ()) {
do {
- MONO_TRY_BLOCKING;
- mono_mutex_lock (&debugger_thread_exited_mutex);
+ mono_coop_mutex_lock (&debugger_thread_exited_mutex);
if (!debugger_thread_exited)
- mono_cond_wait (&debugger_thread_exited_cond, &debugger_thread_exited_mutex);
- mono_mutex_unlock (&debugger_thread_exited_mutex);
- MONO_FINISH_TRY_BLOCKING;
+ mono_coop_cond_wait (&debugger_thread_exited_cond, &debugger_thread_exited_mutex);
+ mono_coop_mutex_unlock (&debugger_thread_exited_mutex);
} while (!debugger_thread_exited);
}
return NULL;
}
- s = g_malloc (len + 1);
+ s = (char *)g_malloc (len + 1);
g_assert (s);
memcpy (s, buf, len);
static inline void
buffer_init (Buffer *buf, int size)
{
- buf->buf = g_malloc (size);
+ buf->buf = (guint8 *)g_malloc (size);
buf->p = buf->buf;
buf->end = buf->buf + size;
}
{
if (buf->end - buf->p < size) {
int new_size = buf->end - buf->buf + size + 32;
- guint8 *p = g_realloc (buf->buf, new_size);
+ guint8 *p = (guint8 *)g_realloc (buf->buf, new_size);
size = buf->p - buf->buf;
buf->buf = p;
buf->p = p + size;
static void
free_objref (gpointer value)
{
- ObjRef *o = value;
+ ObjRef *o = (ObjRef *)value;
mono_gchandle_free (o->handle);
*/
hash = mono_object_hash (obj);
- reflist = g_hash_table_lookup (obj_to_objref, GINT_TO_POINTER (hash));
+ reflist = (GSList *)g_hash_table_lookup (obj_to_objref, GINT_TO_POINTER (hash));
for (l = reflist; l; l = l->next) {
- ref = l->data;
+ ref = (ObjRef *)l->data;
if (ref && mono_gchandle_get_target (ref->handle) == obj) {
mono_loader_unlock ();
return ref;
}
} else {
/* Use a hash table with masked pointers to internalize object references */
- ref = g_hash_table_lookup (obj_to_objref, GINT_TO_POINTER (~((gsize)obj)));
+ ref = (ObjRef *)g_hash_table_lookup (obj_to_objref, GINT_TO_POINTER (~((gsize)obj)));
/* ref might refer to a different object with the same addr which was GCd */
if (ref && mono_gchandle_get_target (ref->handle) == obj) {
mono_loader_unlock ();
if (objid == 0) {
*obj = NULL;
- return 0;
+ return ERR_NONE;
}
if (!objrefs)
mono_loader_lock ();
- ref = g_hash_table_lookup (objrefs, GINT_TO_POINTER (objid));
+ ref = (ObjRef *)g_hash_table_lookup (objrefs, GINT_TO_POINTER (objid));
if (ref) {
*obj = mono_gchandle_get_target (ref->handle);
mono_loader_unlock ();
if (!(*obj))
return ERR_INVALID_OBJECT;
- return 0;
+ return ERR_NONE;
} else {
mono_loader_unlock ();
return ERR_INVALID_OBJECT;
static ErrorCode
get_object (int objid, MonoObject **obj)
{
- int err = get_object_allow_null (objid, obj);
+ ErrorCode err = get_object_allow_null (objid, obj);
- if (err)
+ if (err != ERR_NONE)
return err;
if (!(*obj))
return ERR_INVALID_OBJECT;
- return 0;
+ return ERR_NONE;
}
static inline int
void
mono_debugger_agent_free_domain_info (MonoDomain *domain)
{
- AgentDomainInfo *info = domain_jit_info (domain)->agent_info;
+ AgentDomainInfo *info = (AgentDomainInfo *)domain_jit_info (domain)->agent_info;
int i, j;
GHashTableIter iter;
GPtrArray *file_names;
for (i = 0; i < ID_NUM; ++i) {
if (ids [i]) {
for (j = 0; j < ids [i]->len; ++j) {
- Id *id = g_ptr_array_index (ids [i], j);
+ Id *id = (Id *)g_ptr_array_index (ids [i], j);
if (id->domain == domain)
id->domain = NULL;
}
mono_domain_lock (domain);
- info = domain_jit_info (domain)->agent_info;
+ info = (AgentDomainInfo *)domain_jit_info (domain)->agent_info;
if (!info) {
- info = domain_jit_info (domain)->agent_info = g_new0 (AgentDomainInfo, 1);
+ info = g_new0 (AgentDomainInfo, 1);
+ domain_jit_info (domain)->agent_info = info;
info->loaded_classes = g_hash_table_new (mono_aligned_addr_hash, NULL);
info->source_files = g_hash_table_new (mono_aligned_addr_hash, NULL);
info->source_file_to_class = g_hash_table_new (g_str_hash, g_str_equal);
if (info->val_to_id [type] == NULL)
info->val_to_id [type] = g_hash_table_new (mono_aligned_addr_hash, NULL);
- id = g_hash_table_lookup (info->val_to_id [type], val);
+ id = (Id *)g_hash_table_lookup (info->val_to_id [type], val);
if (id) {
dbg_unlock ();
return id->id;
}
static inline gpointer
-decode_ptr_id (guint8 *buf, guint8 **endbuf, guint8 *limit, IdType type, MonoDomain **domain, int *err)
+decode_ptr_id (guint8 *buf, guint8 **endbuf, guint8 *limit, IdType type, MonoDomain **domain, ErrorCode *err)
{
Id *res;
int id = decode_id (buf, endbuf, limit);
- *err = 0;
+ *err = ERR_NONE;
if (domain)
*domain = NULL;
dbg_lock ();
g_assert (id > 0 && id <= ids [type]->len);
- res = g_ptr_array_index (ids [type], GPOINTER_TO_INT (id - 1));
+ res = (Id *)g_ptr_array_index (ids [type], GPOINTER_TO_INT (id - 1));
dbg_unlock ();
if (res->domain == NULL) {
}
static inline MonoClass*
-decode_typeid (guint8 *buf, guint8 **endbuf, guint8 *limit, MonoDomain **domain, int *err)
+decode_typeid (guint8 *buf, guint8 **endbuf, guint8 *limit, MonoDomain **domain, ErrorCode *err)
{
MonoClass *klass;
- klass = decode_ptr_id (buf, endbuf, limit, ID_TYPE, domain, err);
+ klass = (MonoClass *)decode_ptr_id (buf, endbuf, limit, ID_TYPE, domain, err);
if (G_UNLIKELY (log_level >= 2) && klass) {
char *s;
}
static inline MonoAssembly*
-decode_assemblyid (guint8 *buf, guint8 **endbuf, guint8 *limit, MonoDomain **domain, int *err)
+decode_assemblyid (guint8 *buf, guint8 **endbuf, guint8 *limit, MonoDomain **domain, ErrorCode *err)
{
- return decode_ptr_id (buf, endbuf, limit, ID_ASSEMBLY, domain, err);
+ return (MonoAssembly *)decode_ptr_id (buf, endbuf, limit, ID_ASSEMBLY, domain, err);
}
static inline MonoImage*
-decode_moduleid (guint8 *buf, guint8 **endbuf, guint8 *limit, MonoDomain **domain, int *err)
+decode_moduleid (guint8 *buf, guint8 **endbuf, guint8 *limit, MonoDomain **domain, ErrorCode *err)
{
- return decode_ptr_id (buf, endbuf, limit, ID_MODULE, domain, err);
+ return (MonoImage *)decode_ptr_id (buf, endbuf, limit, ID_MODULE, domain, err);
}
static inline MonoMethod*
-decode_methodid (guint8 *buf, guint8 **endbuf, guint8 *limit, MonoDomain **domain, int *err)
+decode_methodid (guint8 *buf, guint8 **endbuf, guint8 *limit, MonoDomain **domain, ErrorCode *err)
{
MonoMethod *m;
- m = decode_ptr_id (buf, endbuf, limit, ID_METHOD, domain, err);
+ m = (MonoMethod *)decode_ptr_id (buf, endbuf, limit, ID_METHOD, domain, err);
if (G_UNLIKELY (log_level >= 2) && m) {
char *s;
}
static inline MonoClassField*
-decode_fieldid (guint8 *buf, guint8 **endbuf, guint8 *limit, MonoDomain **domain, int *err)
+decode_fieldid (guint8 *buf, guint8 **endbuf, guint8 *limit, MonoDomain **domain, ErrorCode *err)
{
- return decode_ptr_id (buf, endbuf, limit, ID_FIELD, domain, err);
+ return (MonoClassField *)decode_ptr_id (buf, endbuf, limit, ID_FIELD, domain, err);
}
static inline MonoDomain*
-decode_domainid (guint8 *buf, guint8 **endbuf, guint8 *limit, MonoDomain **domain, int *err)
+decode_domainid (guint8 *buf, guint8 **endbuf, guint8 *limit, MonoDomain **domain, ErrorCode *err)
{
- return decode_ptr_id (buf, endbuf, limit, ID_DOMAIN, domain, err);
+ return (MonoDomain *)decode_ptr_id (buf, endbuf, limit, ID_DOMAIN, domain, err);
}
static inline MonoProperty*
-decode_propertyid (guint8 *buf, guint8 **endbuf, guint8 *limit, MonoDomain **domain, int *err)
+decode_propertyid (guint8 *buf, guint8 **endbuf, guint8 *limit, MonoDomain **domain, ErrorCode *err)
{
- return decode_ptr_id (buf, endbuf, limit, ID_PROPERTY, domain, err);
+ return (MonoProperty *)decode_ptr_id (buf, endbuf, limit, ID_PROPERTY, domain, err);
}
static inline void
if (is_debugger_thread ())
DEBUG_PRINTF (2, "[dbg] send class [%s]\n", s);
else
- DEBUG_PRINTF (2, "[%p] send class [%s]\n", (gpointer)mono_native_thread_id_get (), s);
+ DEBUG_PRINTF (2, "[%p] send class [%s]\n", (gpointer) (gsize) mono_native_thread_id_get (), s);
g_free (s);
}
}
{
DebuggerTlsData *tls;
- tls = mono_native_tls_get_value (debugger_tls_id);
+ tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
g_assert (tls);
if (ctx)
*/
static gint32 threads_suspend_count;
-static mono_mutex_t suspend_mutex;
+static MonoCoopMutex suspend_mutex;
/* Cond variable used to wait for suspend_count becoming 0 */
-static mono_cond_t suspend_cond;
+static MonoCoopCond suspend_cond;
/* Semaphore used to wait for a thread becoming suspended */
-static MonoSemType suspend_sem;
+static MonoCoopSem suspend_sem;
static void
suspend_init (void)
{
- mono_mutex_init (&suspend_mutex);
- mono_cond_init (&suspend_cond, 0);
- MONO_SEM_INIT (&suspend_sem, 0);
+ mono_coop_mutex_init (&suspend_mutex);
+ mono_coop_cond_init (&suspend_cond);
+ mono_coop_sem_init (&suspend_sem, 0);
}
typedef struct
static gboolean
get_last_frame (StackFrameInfo *info, MonoContext *ctx, gpointer user_data)
{
- GetLastFrameUserData *data = user_data;
+ GetLastFrameUserData *data = (GetLastFrameUserData *)user_data;
if (info->type == FRAME_TYPE_MANAGED_TO_NATIVE || info->type == FRAME_TYPE_TRAMPOLINE)
return FALSE;
mono_memory_barrier ();
tls->suspended = TRUE;
- MONO_SEM_POST (&suspend_sem);
+ mono_coop_sem_post (&suspend_sem);
}
}
}
static void
reset_native_thread_suspend_state (gpointer key, gpointer value, gpointer user_data)
{
- DebuggerTlsData *tls = value;
+ DebuggerTlsData *tls = (DebuggerTlsData *)value;
if (!tls->really_suspended && tls->suspended) {
tls->suspended = FALSE;
static SuspendThreadResult
debugger_interrupt_critical (MonoThreadInfo *info, gpointer user_data)
{
- InterruptData *data = user_data;
+ InterruptData *data = (InterruptData *)user_data;
MonoJitInfo *ji;
data->valid_info = TRUE;
ji = mono_jit_info_table_find_internal (
- mono_thread_info_get_suspend_state (info)->unwind_data [MONO_UNWIND_DATA_DOMAIN],
- MONO_CONTEXT_GET_IP (&mono_thread_info_get_suspend_state (info)->ctx),
+ (MonoDomain *)mono_thread_info_get_suspend_state (info)->unwind_data [MONO_UNWIND_DATA_DOMAIN],
+ (char *)MONO_CONTEXT_GET_IP (&mono_thread_info_get_suspend_state (info)->ctx),
TRUE,
TRUE);
static void
notify_thread (gpointer key, gpointer value, gpointer user_data)
{
- MonoInternalThread *thread = key;
- DebuggerTlsData *tls = value;
+ MonoInternalThread *thread = (MonoInternalThread *)key;
+ DebuggerTlsData *tls = (DebuggerTlsData *)value;
MonoNativeThreadId tid = MONO_UINT_TO_NATIVE_THREAD_ID (thread->tid);
if (mono_native_thread_id_equals (mono_native_thread_id_get (), tid) || tls->terminated)
return;
- DEBUG_PRINTF (1, "[%p] Interrupting %p...\n", (gpointer)mono_native_thread_id_get (), (gpointer)tid);
+ DEBUG_PRINTF (1, "[%p] Interrupting %p...\n", (gpointer) (gsize) mono_native_thread_id_get (), (gpointer)tid);
/* This is _not_ equivalent to ves_icall_System_Threading_Thread_Abort () */
InterruptData interrupt_data = { 0 };
mono_thread_info_safe_suspend_and_run ((MonoNativeThreadId)(gpointer)(gsize)thread->tid, FALSE, debugger_interrupt_critical, &interrupt_data);
if (!interrupt_data.valid_info) {
- DEBUG_PRINTF (1, "[%p] mono_thread_info_suspend_sync () failed for %p...\n", (gpointer)mono_native_thread_id_get (), (gpointer)tid);
+ DEBUG_PRINTF (1, "[%p] mono_thread_info_suspend_sync () failed for %p...\n", (gpointer) (gsize) mono_native_thread_id_get (), (gpointer)tid);
/*
* Attached thread which died without detaching.
*/
static void
process_suspend (DebuggerTlsData *tls, MonoContext *ctx)
{
- guint8 *ip = MONO_CONTEXT_GET_IP (ctx);
+ guint8 *ip = (guint8 *)MONO_CONTEXT_GET_IP (ctx);
MonoJitInfo *ji;
MonoMethod *method;
if (suspend_count - tls->resume_count > 0)
tls->suspending = TRUE;
- DEBUG_PRINTF (1, "[%p] Received single step event for suspending.\n", (gpointer)mono_native_thread_id_get ());
+ DEBUG_PRINTF (1, "[%p] Received single step event for suspending.\n", (gpointer) (gsize) mono_native_thread_id_get ());
if (suspend_count - tls->resume_count == 0) {
/*
* suspending is still active.
* FIXME: This slows down single threaded invokes.
*/
- DEBUG_PRINTF (1, "[%p] Ignored during single threaded invoke.\n", (gpointer)mono_native_thread_id_get ());
+ DEBUG_PRINTF (1, "[%p] Ignored during single threaded invoke.\n", (gpointer) (gsize) mono_native_thread_id_get ());
return;
}
{
mono_loader_lock ();
- MONO_TRY_BLOCKING;
- mono_mutex_lock (&suspend_mutex);
- MONO_FINISH_TRY_BLOCKING;
+ mono_coop_mutex_lock (&suspend_mutex);
suspend_count ++;
- DEBUG_PRINTF (1, "[%p] Suspending vm...\n", (gpointer)mono_native_thread_id_get ());
+ DEBUG_PRINTF (1, "[%p] Suspending vm...\n", (gpointer) (gsize) mono_native_thread_id_get ());
if (suspend_count == 1) {
// FIXME: Is it safe to call this inside the lock ?
mono_g_hash_table_foreach (thread_to_tls, notify_thread, NULL);
}
- mono_mutex_unlock (&suspend_mutex);
+ mono_coop_mutex_unlock (&suspend_mutex);
if (suspend_count == 1)
/*
mono_loader_lock ();
- MONO_TRY_BLOCKING;
- mono_mutex_lock (&suspend_mutex);
- MONO_FINISH_TRY_BLOCKING;
+ mono_coop_mutex_lock (&suspend_mutex);
g_assert (suspend_count > 0);
suspend_count --;
- DEBUG_PRINTF (1, "[%p] Resuming vm, suspend count=%d...\n", (gpointer)mono_native_thread_id_get (), suspend_count);
+ DEBUG_PRINTF (1, "[%p] Resuming vm, suspend count=%d...\n", (gpointer) (gsize) mono_native_thread_id_get (), suspend_count);
if (suspend_count == 0) {
// FIXME: Is it safe to call this inside the lock ?
}
/* Signal this even when suspend_count > 0, since some threads might have resume_count > 0 */
- err = mono_cond_broadcast (&suspend_cond);
+ err = mono_coop_cond_broadcast (&suspend_cond);
g_assert (err == 0);
- mono_mutex_unlock (&suspend_mutex);
+ mono_coop_mutex_unlock (&suspend_mutex);
//g_assert (err == 0);
if (suspend_count == 0)
mono_loader_lock ();
- tls = mono_g_hash_table_lookup (thread_to_tls, thread);
+ tls = (DebuggerTlsData *)mono_g_hash_table_lookup (thread_to_tls, thread);
g_assert (tls);
-
- MONO_TRY_BLOCKING;
- mono_mutex_lock (&suspend_mutex);
- MONO_FINISH_TRY_BLOCKING;
+
+ mono_coop_mutex_lock (&suspend_mutex);
g_assert (suspend_count > 0);
* Signal suspend_count without decreasing suspend_count, the threads will wake up
* but only the one whose resume_count field is > 0 will be resumed.
*/
- err = mono_cond_broadcast (&suspend_cond);
+ err = mono_coop_cond_broadcast (&suspend_cond);
g_assert (err == 0);
- mono_mutex_unlock (&suspend_mutex);
+ mono_coop_mutex_unlock (&suspend_mutex);
//g_assert (err == 0);
mono_loader_unlock ();
invalidate_frames (DebuggerTlsData *tls)
{
if (!tls)
- tls = mono_native_tls_get_value (debugger_tls_id);
+ tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
g_assert (tls);
free_frames (tls->frames, tls->frame_count);
return;
}
- tls = mono_native_tls_get_value (debugger_tls_id);
+ tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
g_assert (tls);
- MONO_TRY_BLOCKING;
- mono_mutex_lock (&suspend_mutex);
- MONO_FINISH_TRY_BLOCKING;
+ mono_coop_mutex_lock (&suspend_mutex);
tls->suspending = FALSE;
tls->really_suspended = TRUE;
if (!tls->suspended) {
tls->suspended = TRUE;
- MONO_SEM_POST (&suspend_sem);
+ mono_coop_sem_post (&suspend_sem);
}
- DEBUG_PRINTF (1, "[%p] Suspended.\n", (gpointer)mono_native_thread_id_get ());
+ DEBUG_PRINTF (1, "[%p] Suspended.\n", (gpointer) (gsize) mono_native_thread_id_get ());
- MONO_TRY_BLOCKING;
while (suspend_count - tls->resume_count > 0) {
- err = mono_cond_wait (&suspend_cond, &suspend_mutex);
+ err = mono_coop_cond_wait (&suspend_cond, &suspend_mutex);
g_assert (err == 0);
}
- MONO_FINISH_TRY_BLOCKING;
tls->suspended = FALSE;
tls->really_suspended = FALSE;
threads_suspend_count --;
- mono_mutex_unlock (&suspend_mutex);
+ mono_coop_mutex_unlock (&suspend_mutex);
- DEBUG_PRINTF (1, "[%p] Resumed.\n", (gpointer)mono_native_thread_id_get ());
+ DEBUG_PRINTF (1, "[%p] Resumed.\n", (gpointer) (gsize) mono_native_thread_id_get ());
if (tls->pending_invoke) {
/* Save the original context */
static void
count_thread (gpointer key, gpointer value, gpointer user_data)
{
- DebuggerTlsData *tls = value;
+ DebuggerTlsData *tls = (DebuggerTlsData *)value;
if (!tls->suspended && !tls->terminated)
*(int*)user_data = *(int*)user_data + 1;
nwait = count_threads_to_wait_for ();
if (nwait) {
DEBUG_PRINTF (1, "Waiting for %d(%d) threads to suspend...\n", nwait, nthreads);
- err = MONO_SEM_WAIT (&suspend_sem);
+ err = mono_coop_sem_wait (&suspend_sem, MONO_SEM_FLAGS_NONE);
g_assert (err == 0);
waited = TRUE;
} else {
static gboolean
process_frame (StackFrameInfo *info, MonoContext *ctx, gpointer user_data)
{
- ComputeFramesUserData *ud = user_data;
+ ComputeFramesUserData *ud = (ComputeFramesUserData *)user_data;
StackFrame *frame;
MonoMethod *method, *actual_method, *api_method;
SeqPoint sp;
static gboolean
process_filter_frame (StackFrameInfo *info, MonoContext *ctx, gpointer user_data)
{
- ComputeFramesUserData *ud = user_data;
+ ComputeFramesUserData *ud = (ComputeFramesUserData *)user_data;
/*
* 'tls->filter_ctx' is the location of the throw site.
compute_frame_info_from (MonoInternalThread *thread, DebuggerTlsData *tls, MonoThreadUnwindState *state, int *out_nframes)
{
ComputeFramesUserData user_data;
- MonoUnwindOptions opts = MONO_UNWIND_DEFAULT|MONO_UNWIND_REG_LOCATIONS;
+ MonoUnwindOptions opts = (MonoUnwindOptions)(MONO_UNWIND_DEFAULT | MONO_UNWIND_REG_LOCATIONS);
StackFrame **res;
int i, nframes;
GSList *l;
res = g_new0 (StackFrame*, nframes);
l = user_data.frames;
for (i = 0; i < nframes; ++i) {
- res [i] = l->data;
+ res [i] = (StackFrame *)l->data;
l = l->next;
}
*out_nframes = nframes;
GSList *tmp;
int i, findex, new_frame_count;
StackFrame **new_frames, *f;
- MonoUnwindOptions opts = MONO_UNWIND_DEFAULT|MONO_UNWIND_REG_LOCATIONS;
+ MonoUnwindOptions opts = (MonoUnwindOptions)(MONO_UNWIND_DEFAULT | MONO_UNWIND_REG_LOCATIONS);
// FIXME: Locking on tls
if (tls->frames && tls->frames_up_to_date)
new_frames = g_new0 (StackFrame*, new_frame_count);
findex = 0;
for (tmp = user_data.frames; tmp; tmp = tmp->next) {
- f = tmp->data;
+ f = (StackFrame *)tmp->data;
/*
* Reuse the id for already existing stack frames, so invokes don't invalidate
emit_appdomain_load (gpointer key, gpointer value, gpointer user_data)
{
process_profiler_event (EVENT_KIND_APPDOMAIN_CREATE, value);
- g_hash_table_foreach (get_agent_domain_info (value)->loaded_classes, emit_type_load, NULL);
+ g_hash_table_foreach (get_agent_domain_info ((MonoDomain *)value)->loaded_classes, emit_type_load, NULL);
}
/*
return NULL;
for (i = 0; i < reqs->len; ++i) {
- EventRequest *req = g_ptr_array_index (reqs, i);
+ EventRequest *req = (EventRequest *)g_ptr_array_index (reqs, i);
if (req->event_kind == event) {
gboolean filtered = FALSE;
if (minfo) {
mono_debug_get_seq_points (minfo, &source_file, &source_file_list, NULL, NULL, NULL);
for (i = 0; i < source_file_list->len; ++i) {
- sinfo = g_ptr_array_index (source_file_list, i);
+ sinfo = (MonoDebugSourceInfo *)g_ptr_array_index (source_file_list, i);
/*
* Do a case-insesitive match by converting the file name to
* lowercase.
thread = mono_thread_current ();
if (event == EVENT_KIND_VM_START && arg != NULL)
- thread = arg;
+ thread = (MonoThread *)arg;
buffer_add_objid (&buf, (MonoObject*)thread); // thread
break;
case EVENT_KIND_APPDOMAIN_CREATE:
case EVENT_KIND_APPDOMAIN_UNLOAD:
- buffer_add_domainid (&buf, arg);
+ buffer_add_domainid (&buf, (MonoDomain *)arg);
break;
case EVENT_KIND_METHOD_ENTRY:
case EVENT_KIND_METHOD_EXIT:
- buffer_add_methodid (&buf, domain, arg);
+ buffer_add_methodid (&buf, domain, (MonoMethod *)arg);
break;
case EVENT_KIND_ASSEMBLY_LOAD:
- buffer_add_assemblyid (&buf, domain, arg);
+ buffer_add_assemblyid (&buf, domain, (MonoAssembly *)arg);
break;
case EVENT_KIND_ASSEMBLY_UNLOAD: {
DebuggerTlsData *tls;
/* The domain the assembly belonged to is not equal to the current domain */
- tls = mono_native_tls_get_value (debugger_tls_id);
+ tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
g_assert (tls);
g_assert (tls->domain_unloading);
- buffer_add_assemblyid (&buf, tls->domain_unloading, arg);
+ buffer_add_assemblyid (&buf, tls->domain_unloading, (MonoAssembly *)arg);
break;
}
case EVENT_KIND_TYPE_LOAD:
- buffer_add_typeid (&buf, domain, arg);
+ buffer_add_typeid (&buf, domain, (MonoClass *)arg);
break;
case EVENT_KIND_BREAKPOINT:
case EVENT_KIND_STEP:
- buffer_add_methodid (&buf, domain, arg);
+ buffer_add_methodid (&buf, domain, (MonoMethod *)arg);
buffer_add_long (&buf, il_offset);
break;
case EVENT_KIND_VM_START:
buffer_add_int (&buf, mono_environment_exitcode_get ());
break;
case EVENT_KIND_EXCEPTION: {
- EventInfo *ei = arg;
+ EventInfo *ei = (EventInfo *)arg;
buffer_add_objid (&buf, ei->exc);
/*
* We are not yet suspending, so get_objref () will not keep this object alive. So we need to do it
case EVENT_KIND_USER_BREAK:
break;
case EVENT_KIND_USER_LOG: {
- EventInfo *ei = arg;
+ EventInfo *ei = (EventInfo *)arg;
buffer_add_int (&buf, ei->level);
buffer_add_string (&buf, ei->category ? ei->category : "");
buffer_add_string (&buf, ei->message ? ei->message : "");
vm_start_event_sent = TRUE;
}
- DEBUG_PRINTF (1, "[%p] Sent %d events %s(%d), suspend=%d.\n", (gpointer)mono_native_thread_id_get (), nevents, event_to_string (event), ecount, suspend_policy);
+ DEBUG_PRINTF (1, "[%p] Sent %d events %s(%d), suspend=%d.\n", (gpointer) (gsize) mono_native_thread_id_get (), nevents, event_to_string (event), ecount, suspend_policy);
switch (suspend_policy) {
case SUSPEND_POLICY_NONE:
EventInfo ei, *ei_arg = NULL;
if (event == EVENT_KIND_TYPE_LOAD) {
- ei.klass = arg;
+ ei.klass = (MonoClass *)arg;
ei_arg = &ei;
}
g_assert (mono_native_thread_id_equals (MONO_UINT_TO_NATIVE_THREAD_ID (tid), MONO_UINT_TO_NATIVE_THREAD_ID (thread->tid)));
mono_loader_lock ();
- old_thread = mono_g_hash_table_lookup (tid_to_thread, GUINT_TO_POINTER (tid));
+ old_thread = (MonoInternalThread *)mono_g_hash_table_lookup (tid_to_thread, GUINT_TO_POINTER (tid));
mono_loader_unlock ();
if (old_thread) {
if (thread == old_thread) {
}
}
- tls = mono_native_tls_get_value (debugger_tls_id);
+ tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
g_assert (!tls);
// FIXME: Free this somewhere
tls = g_new0 (DebuggerTlsData, 1);
DebuggerTlsData *tls = NULL;
mono_loader_lock ();
- thread = mono_g_hash_table_lookup (tid_to_thread, GUINT_TO_POINTER (tid));
+ thread = (MonoInternalThread *)mono_g_hash_table_lookup (tid_to_thread, GUINT_TO_POINTER (tid));
if (thread) {
mono_g_hash_table_remove (tid_to_thread_obj, GUINT_TO_POINTER (tid));
- tls = mono_g_hash_table_lookup (thread_to_tls, thread);
+ tls = (DebuggerTlsData *)mono_g_hash_table_lookup (thread_to_tls, thread);
if (tls) {
/* FIXME: Maybe we need to free this instead, but some code can't handle that */
tls->terminated = TRUE;
* Remember the currently unloading appdomain as it is needed to generate
* proper ids for unloading assemblies.
*/
- tls = mono_native_tls_get_value (debugger_tls_id);
+ tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
g_assert (tls);
tls->domain_unloading = domain;
}
if (is_debugger_thread ())
return;
- tls = mono_native_tls_get_value (debugger_tls_id);
+ tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
g_assert (tls);
tls->domain_unloading = NULL;
static void
invalidate_each_thread (gpointer key, gpointer value, gpointer user_data)
{
- invalidate_frames (value);
+ invalidate_frames ((DebuggerTlsData *)value);
}
static void
// FIXME: Maybe store this in TLS so the thread of the event is correct ?
dbg_lock ();
if (pending_assembly_loads->len > 0) {
- assembly = g_ptr_array_index (pending_assembly_loads, 0);
+ assembly = (MonoAssembly *)g_ptr_array_index (pending_assembly_loads, 0);
g_ptr_array_remove_index (pending_assembly_loads, 0);
}
dbg_unlock ();
mono_loader_lock ();
for (i = 0; i < breakpoints->len; ++i) {
- MonoBreakpoint *bp = g_ptr_array_index (breakpoints, i);
+ MonoBreakpoint *bp = (MonoBreakpoint *)g_ptr_array_index (breakpoints, i);
gboolean found = FALSE;
if (!bp_matches_method (bp, method))
continue;
for (j = 0; j < bp->children->len; ++j) {
- BreakpointInstance *inst = g_ptr_array_index (bp->children, j);
+ BreakpointInstance *inst = (BreakpointInstance *)g_ptr_array_index (bp->children, j);
if (inst->ji == ji)
found = TRUE;
declaring = mono_method_get_declaring_generic_method (jmethod);
mono_domain_lock (domain);
- seq_points = g_hash_table_lookup (domain_jit_info (domain)->seq_points, jmethod);
+ seq_points = (MonoSeqPointInfo *)g_hash_table_lookup (domain_jit_info (domain)->seq_points, jmethod);
if (!seq_points && declaring)
- seq_points = g_hash_table_lookup (domain_jit_info (domain)->seq_points, declaring);
+ seq_points = (MonoSeqPointInfo *)g_hash_table_lookup (domain_jit_info (domain)->seq_points, declaring);
mono_domain_unlock (domain);
if (!seq_points)
/* Could be AOT code */
/* Might be AOTed code */
code = mono_aot_get_method (domain, method);
g_assert (code);
- ji = mono_jit_info_table_find (domain, code);
+ ji = mono_jit_info_table_find (domain, (char *)code);
g_assert (ji);
}
g_assert (code);
}
for (i = 0; i < methods->len; ++i) {
- m = g_ptr_array_index (methods, i);
- domain = g_ptr_array_index (method_domains, i);
- seq_points = g_ptr_array_index (method_seq_points, i);
+ m = (MonoMethod *)g_ptr_array_index (methods, i);
+ domain = (MonoDomain *)g_ptr_array_index (method_domains, i);
+ seq_points = (MonoSeqPointInfo *)g_ptr_array_index (method_seq_points, i);
set_bp_in_method (domain, m, seq_points, bp, error);
}
// FIXME: locking, races
for (i = 0; i < bp->children->len; ++i) {
- BreakpointInstance *inst = g_ptr_array_index (bp->children, i);
+ BreakpointInstance *inst = (BreakpointInstance *)g_ptr_array_index (bp->children, i);
remove_breakpoint (inst);
mono_loader_lock ();
i = 0;
while (i < event_requests->len) {
- EventRequest *req = g_ptr_array_index (event_requests, i);
+ EventRequest *req = (EventRequest *)g_ptr_array_index (event_requests, i);
if (req->event_kind == EVENT_KIND_BREAKPOINT) {
- clear_breakpoint (req->info);
+ clear_breakpoint ((MonoBreakpoint *)req->info);
g_ptr_array_remove_index_fast (event_requests, i);
g_free (req);
} else {
mono_loader_lock ();
for (i = 0; i < breakpoints->len; ++i) {
- MonoBreakpoint *bp = g_ptr_array_index (breakpoints, i);
+ MonoBreakpoint *bp = (MonoBreakpoint *)g_ptr_array_index (breakpoints, i);
j = 0;
while (j < bp->children->len) {
- BreakpointInstance *inst = g_ptr_array_index (bp->children, j);
+ BreakpointInstance *inst = (BreakpointInstance *)g_ptr_array_index (bp->children, j);
if (inst->domain == domain) {
remove_breakpoint (inst);
/*
* These seq points are inserted by the JIT after calls, step over needs to skip them.
*/
- DEBUG_PRINTF (1, "[%p] Seq point at nonempty stack %x while stepping over, continuing single stepping.\n", (gpointer)mono_native_thread_id_get (), sp->il_offset);
+ DEBUG_PRINTF (1, "[%p] Seq point at nonempty stack %x while stepping over, continuing single stepping.\n", (gpointer) (gsize) mono_native_thread_id_get (), sp->il_offset);
return FALSE;
}
compute_frame_info (tls->thread, tls);
if (req->nframes && tls->frame_count && tls->frame_count > req->nframes) {
/* Hit the breakpoint in a recursive call */
- DEBUG_PRINTF (1, "[%p] Breakpoint at lower frame while stepping over, continuing single stepping.\n", (gpointer)mono_native_thread_id_get ());
+ DEBUG_PRINTF (1, "[%p] Breakpoint at lower frame while stepping over, continuing single stepping.\n", (gpointer) (gsize) mono_native_thread_id_get ());
return FALSE;
}
}
mono_thread_state_init_from_monoctx (&tls->context, ctx);
compute_frame_info (tls->thread, tls);
if (ss_req->start_method == method && req->nframes && tls->frame_count == req->nframes) {//Check also frame count(could be recursion)
- DEBUG_PRINTF (1, "[%p] Seq point at nonempty stack %x while stepping in, continuing single stepping.\n", (gpointer)mono_native_thread_id_get (), sp->il_offset);
+ DEBUG_PRINTF (1, "[%p] Seq point at nonempty stack %x while stepping in, continuing single stepping.\n", (gpointer) (gsize) mono_native_thread_id_get (), sp->il_offset);
return FALSE;
}
}
minfo = mono_debug_lookup_method (method);
if (minfo)
- loc = mono_debug_symfile_lookup_location (minfo, sp->il_offset);
+ loc = mono_debug_method_lookup_location (minfo, sp->il_offset);
if (!loc) {
- DEBUG_PRINTF (1, "[%p] No line number info for il offset %x, continuing single stepping.\n", (gpointer)mono_native_thread_id_get (), sp->il_offset);
+ DEBUG_PRINTF (1, "[%p] No line number info for il offset %x, continuing single stepping.\n", (gpointer) (gsize) mono_native_thread_id_get (), sp->il_offset);
ss_req->last_method = method;
hit = FALSE;
} else if (loc && method == ss_req->last_method && loc->row == ss_req->last_line) {
- DEBUG_PRINTF (1, "[%p] Same source line (%d), continuing single stepping.\n", (gpointer)mono_native_thread_id_get (), loc->row);
+ DEBUG_PRINTF (1, "[%p] Same source line (%d), continuing single stepping.\n", (gpointer) (gsize) mono_native_thread_id_get (), loc->row);
hit = FALSE;
}
// FIXME: Speed this up
- ip = MONO_CONTEXT_GET_IP (ctx);
+ ip = (guint8 *)MONO_CONTEXT_GET_IP (ctx);
ji = mini_jit_info_table_find (mono_domain_get (), (char*)ip, NULL);
g_assert (ji && !ji->is_trampoline);
method = jinfo_get_method (ji);
g_assert (found_sp);
- DEBUG_PRINTF (1, "[%p] Breakpoint hit, method=%s, ip=%p, [il=0x%x,native=0x%x].\n", (gpointer)mono_native_thread_id_get (), method->name, ip, sp.il_offset, native_offset);
+ DEBUG_PRINTF (1, "[%p] Breakpoint hit, method=%s, ip=%p, [il=0x%x,native=0x%x].\n", (gpointer) (gsize) mono_native_thread_id_get (), method->name, ip, sp.il_offset, native_offset);
bp = NULL;
for (i = 0; i < breakpoints->len; ++i) {
- bp = g_ptr_array_index (breakpoints, i);
+ bp = (MonoBreakpoint *)g_ptr_array_index (breakpoints, i);
if (!bp->method)
continue;
for (j = 0; j < bp->children->len; ++j) {
- inst = g_ptr_array_index (bp->children, j);
+ inst = (BreakpointInstance *)g_ptr_array_index (bp->children, j);
if (inst->ji == ji && inst->il_offset == sp.il_offset && inst->native_offset == sp.native_offset) {
if (bp->req->event_kind == EVENT_KIND_STEP) {
g_ptr_array_add (ss_reqs_orig, bp->req);
/* Process single step requests */
for (i = 0; i < ss_reqs_orig->len; ++i) {
- EventRequest *req = g_ptr_array_index (ss_reqs_orig, i);
- SingleStepReq *ss_req = req->info;
+ EventRequest *req = (EventRequest *)g_ptr_array_index (ss_reqs_orig, i);
+ SingleStepReq *ss_req = (SingleStepReq *)req->info;
gboolean hit;
if (mono_thread_internal_current () != ss_req->thread)
MonoThreadUnwindState orig_restore_state;
MonoContext ctx;
- tls = mono_native_tls_get_value (debugger_tls_id);
+ tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
/* Have to save/restore the restore_ctx as we can be called recursively during invokes etc. */
memcpy (&orig_restore_state, &tls->restore_state, sizeof (MonoThreadUnwindState));
mono_thread_state_init_from_monoctx (&tls->restore_state, &tls->handler_ctx);
/* Save the original context in TLS */
// FIXME: This might not work on an altstack ?
- tls = mono_native_tls_get_value (debugger_tls_id);
+ tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
if (!tls)
- fprintf (stderr, "Thread %p is not attached to the JIT.\n", (gpointer)mono_native_thread_id_get ());
+ fprintf (stderr, "Thread %p is not attached to the JIT.\n", (gpointer) (gsize) mono_native_thread_id_get ());
g_assert (tls);
// FIXME: MonoContext usually doesn't include the fp registers, so these are
/* Obtain a context */
MONO_CONTEXT_SET_IP (&ctx, NULL);
- mono_walk_stack_with_ctx (user_break_cb, NULL, 0, &ctx);
+ mono_walk_stack_with_ctx (user_break_cb, NULL, (MonoUnwindOptions)0, &ctx);
g_assert (MONO_CONTEXT_GET_IP (&ctx) != NULL);
mono_loader_lock ();
SeqPoint sp;
MonoSeqPointInfo *info;
- ip = MONO_CONTEXT_GET_IP (ctx);
+ ip = (guint8 *)MONO_CONTEXT_GET_IP (ctx);
/* Skip the instruction causing the single step */
if (from_signal)
if (log_level > 0) {
ji = mini_jit_info_table_find (mono_domain_get (), (char*)ip, &domain);
- DEBUG_PRINTF (1, "[%p] Single step event (depth=%s) at %s (%p)[0x%x], sp %p, last sp %p\n", (gpointer)mono_native_thread_id_get (), ss_depth_to_string (ss_req->depth), mono_method_full_name (jinfo_get_method (ji), TRUE), MONO_CONTEXT_GET_IP (ctx), (int)((guint8*)MONO_CONTEXT_GET_IP (ctx) - (guint8*)ji->code_start), MONO_CONTEXT_GET_SP (ctx), ss_req->last_sp);
+ DEBUG_PRINTF (1, "[%p] Single step event (depth=%s) at %s (%p)[0x%x], sp %p, last sp %p\n", (gpointer) (gsize) mono_native_thread_id_get (), ss_depth_to_string (ss_req->depth), mono_method_full_name (jinfo_get_method (ji), TRUE), MONO_CONTEXT_GET_IP (ctx), (int)((guint8*)MONO_CONTEXT_GET_IP (ctx) - (guint8*)ji->code_start), MONO_CONTEXT_GET_SP (ctx), ss_req->last_sp);
}
ji = mini_jit_info_table_find (mono_domain_get (), (char*)ip, &domain);
DebuggerTlsData *tls;
MonoThreadUnwindState orig_restore_state;
- tls = mono_native_tls_get_value (debugger_tls_id);
+ tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
/* Fastpath during invokes, see in process_suspend () */
if (tls && suspend_count && suspend_count - tls->resume_count == 0)
return;
if (is_debugger_thread ())
return;
- orig_ip = MONO_CONTEXT_GET_IP (ctx);
+ orig_ip = (guint8 *)MONO_CONTEXT_GET_IP (ctx);
MONO_CONTEXT_SET_IP (ctx, orig_ip - 1);
- tls = mono_native_tls_get_value (debugger_tls_id);
+ tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
g_assert (tls);
memcpy (&orig_restore_state, &tls->restore_state, sizeof (MonoThreadUnwindState));
mono_thread_state_init_from_monoctx (&tls->restore_state, ctx);
GSList *l;
for (l = ss_req->bps; l; l = l->next) {
- clear_breakpoint (l->data);
+ clear_breakpoint ((MonoBreakpoint *)l->data);
}
g_slist_free (ss_req->bps);
ss_req->bps = NULL;
req->info = ss_req;
mono_loader_lock ();
- tls = mono_g_hash_table_lookup (thread_to_tls, thread);
+ tls = (DebuggerTlsData *)mono_g_hash_table_lookup (thread_to_tls, thread);
mono_loader_unlock ();
g_assert (tls);
g_assert (tls->context.valid);
*/
/* Find the the jit info for the catch context */
- res = mono_find_jit_info_ext (tls->catch_state.unwind_data [MONO_UNWIND_DATA_DOMAIN], ((MonoThreadInfo*)thread->thread_info)->jit_data, NULL, &tls->catch_state.ctx, &new_ctx, NULL, &lmf, NULL, &frame);
+ res = mono_find_jit_info_ext (
+ (MonoDomain *)tls->catch_state.unwind_data [MONO_UNWIND_DATA_DOMAIN],
+ (MonoJitTlsData *)((MonoThreadInfo*)thread->thread_info)->jit_data,
+ NULL, &tls->catch_state.ctx, &new_ctx, NULL, &lmf, NULL, &frame);
g_assert (res);
g_assert (frame.type == FRAME_TYPE_MANAGED);
minfo = mono_debug_lookup_method (frame->method);
if (minfo && frame->il_offset != -1) {
- MonoDebugSourceLocation *loc = mono_debug_symfile_lookup_location (minfo, frame->il_offset);
+ MonoDebugSourceLocation *loc = mono_debug_method_lookup_location (minfo, frame->il_offset);
if (loc) {
ss_req->last_line = loc->row;
if (frames)
free_frames (frames, nframes);
- return 0;
+ return ERR_NONE;
}
static void
while (found) {
found = FALSE;
for (l = ss_req->bps; l; l = l->next) {
- if (breakpoint_matches_assembly (l->data, assembly)) {
- clear_breakpoint (l->data);
+ if (breakpoint_matches_assembly ((MonoBreakpoint *)l->data, assembly)) {
+ clear_breakpoint ((MonoBreakpoint *)l->data);
ss_req->bps = g_slist_delete_link (ss_req->bps, l);
found = TRUE;
break;
MonoInternalThread *thread = mono_thread_internal_current ();
mono_loader_lock ();
- tls = mono_g_hash_table_lookup (thread_to_tls, thread);
+ tls = (DebuggerTlsData *)mono_g_hash_table_lookup (thread_to_tls, thread);
mono_loader_unlock ();
if (tls && tls->abort_requested)
gboolean found = FALSE;
for (l = agent_config.onthrow; l; l = l->next) {
- char *ex_type = l->data;
+ char *ex_type = (char *)l->data;
char *f = mono_type_full_name (&exc->object.vtable->klass->byval_arg);
if (!strcmp (ex_type, "") || !strcmp (ex_type, f))
if (!inited)
return;
- ji = mini_jit_info_table_find (mono_domain_get (), MONO_CONTEXT_GET_IP (throw_ctx), NULL);
+ ji = mini_jit_info_table_find (mono_domain_get (), (char *)MONO_CONTEXT_GET_IP (throw_ctx), NULL);
if (catch_ctx)
- catch_ji = mini_jit_info_table_find (mono_domain_get (), MONO_CONTEXT_GET_IP (catch_ctx), NULL);
+ catch_ji = mini_jit_info_table_find (mono_domain_get (), (char *)MONO_CONTEXT_GET_IP (catch_ctx), NULL);
else
catch_ji = NULL;
/* Treat exceptions which are caught in non-user code as unhandled */
for (i = 0; i < event_requests->len; ++i) {
- EventRequest *req = g_ptr_array_index (event_requests, i);
+ EventRequest *req = (EventRequest *)g_ptr_array_index (event_requests, i);
if (req->event_kind != EVENT_KIND_EXCEPTION)
continue;
if (!inited)
return;
- tls = mono_native_tls_get_value (debugger_tls_id);
+ tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
if (!tls)
return;
if (!inited)
return;
- tls = mono_native_tls_get_value (debugger_tls_id);
+ tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
if (!tls)
return;
int nfields;
gpointer iter = NULL;
MonoDomain *d;
- int err;
+ ErrorCode err;
is_enum = decode_byte (buf, &buf, limit);
/* Enums are sent as a normal vtype */
if (is_enum)
return ERR_NOT_IMPLEMENTED;
klass = decode_typeid (buf, &buf, limit, &d, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
if (t && klass != mono_class_from_mono_type (t)) {
char *name = mono_type_full_name (t);
char *name2 = mono_type_full_name (&klass->byval_arg);
- DEBUG_PRINTF (1, "[%p] Expected value of type %s, got %s.\n", (gpointer)mono_native_thread_id_get (), name, name2);
+ DEBUG_PRINTF (1, "[%p] Expected value of type %s, got %s.\n", (gpointer) (gsize) mono_native_thread_id_get (), name, name2);
g_free (name);
g_free (name2);
return ERR_INVALID_ARGUMENT;
if (mono_field_is_deleted (f))
continue;
err = decode_value (f->type, domain, (guint8*)addr + f->offset - sizeof (MonoObject), buf, &buf, limit);
- if (err)
+ if (err != ERR_NONE)
return err;
nfields --;
}
*endbuf = buf;
- return 0;
+ return ERR_NONE;
}
static ErrorCode
decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr, guint8 *buf, guint8 **endbuf, guint8 *limit)
{
- int err;
+ ErrorCode err;
if (type != t->type && !MONO_TYPE_IS_REFERENCE (t) &&
!(t->type == MONO_TYPE_I && type == MONO_TYPE_VALUETYPE) &&
!(t->type == MONO_TYPE_GENERICINST && type == MONO_TYPE_VALUETYPE) &&
!(t->type == MONO_TYPE_VALUETYPE && type == MONO_TYPE_OBJECT)) {
char *name = mono_type_full_name (t);
- DEBUG_PRINTF (1, "[%p] Expected value of type %s, got 0x%0x.\n", (gpointer)mono_native_thread_id_get (), name, type);
+ DEBUG_PRINTF (1, "[%p] Expected value of type %s, got 0x%0x.\n", (gpointer) (gsize) mono_native_thread_id_get (), name, type);
g_free (name);
return ERR_INVALID_ARGUMENT;
}
if (type == MONO_TYPE_OBJECT) {
/* Boxed vtype */
int objid = decode_objid (buf, &buf, limit);
- int err;
+ ErrorCode err;
MonoObject *obj;
err = get_object (objid, (MonoObject**)&obj);
- if (err)
+ if (err != ERR_NONE)
return err;
if (!obj)
return ERR_INVALID_ARGUMENT;
memcpy (addr, mono_object_unbox (obj), mono_class_value_size (obj->vtable->klass, NULL));
} else {
err = decode_vtype (t, domain, addr, buf, &buf, limit);
- if (err)
+ if (err != ERR_NONE)
return err;
}
break;
if (MONO_TYPE_IS_REFERENCE (t)) {
if (type == MONO_TYPE_OBJECT) {
int objid = decode_objid (buf, &buf, limit);
- int err;
+ ErrorCode err;
MonoObject *obj;
err = get_object (objid, (MonoObject**)&obj);
- if (err)
+ if (err != ERR_NONE)
return err;
if (obj) {
if (is_enum)
return ERR_NOT_IMPLEMENTED;
klass = decode_typeid (buf, &buf, limit, &d, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
/* Decode the vtype into a temporary buffer, then box it. */
vtype_buf_size = mono_class_value_size (klass, NULL);
- vtype_buf = g_malloc0 (vtype_buf_size);
+ vtype_buf = (guint8 *)g_malloc0 (vtype_buf_size);
g_assert (vtype_buf);
buf = buf2;
err = decode_vtype (NULL, domain, vtype_buf, buf, &buf, limit);
- if (err) {
+ if (err != ERR_NONE) {
g_free (vtype_buf);
return err;
}
g_free (vtype_buf);
} else {
char *name = mono_type_full_name (t);
- DEBUG_PRINTF (1, "[%p] Expected value of type %s, got 0x%0x.\n", (gpointer)mono_native_thread_id_get (), name, type);
+ DEBUG_PRINTF (1, "[%p] Expected value of type %s, got 0x%0x.\n", (gpointer) (gsize) mono_native_thread_id_get (), name, type);
g_free (name);
return ERR_INVALID_ARGUMENT;
}
*endbuf = buf;
- return 0;
+ return ERR_NONE;
}
static ErrorCode
decode_value (MonoType *t, MonoDomain *domain, guint8 *addr, guint8 *buf, guint8 **endbuf, guint8 *limit)
{
- int err;
+ ErrorCode err;
int type = decode_byte (buf, &buf, limit);
if (t->type == MONO_TYPE_GENERICINST && mono_class_is_nullable (mono_class_from_mono_type (t))) {
* First try decoding it as a Nullable`1
*/
err = decode_value_internal (t, type, domain, addr, buf, endbuf, limit);
- if (!err)
+ if (err == ERR_NONE)
return err;
/*
* Then try decoding as a primitive value or null.
*/
if (targ->type == type) {
- nullable_buf = g_malloc (mono_class_instance_size (mono_class_from_mono_type (targ)));
+ nullable_buf = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (targ)));
err = decode_value_internal (targ, type, domain, nullable_buf, buf, endbuf, limit);
- if (err) {
+ if (err != ERR_NONE) {
g_free (nullable_buf);
return err;
}
buffer_add_value_full (buf, t, ®_val, domain, as_vtype, NULL);
break;
case MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET:
- addr = (gpointer)mono_arch_context_get_int_reg (ctx, reg);
+ addr = (guint8 *)mono_arch_context_get_int_reg (ctx, reg);
addr += (gint32)var->offset;
//printf ("[R%d+%d] = %p\n", reg, var->offset, addr);
case MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET_INDIR:
case MONO_DEBUG_VAR_ADDRESS_MODE_VTADDR:
/* Same as regoffset, but with an indirection */
- addr = (gpointer)mono_arch_context_get_int_reg (ctx, reg);
+ addr = (guint8 *)mono_arch_context_get_int_reg (ctx, reg);
addr += (gint32)var->offset;
- gaddr = *(gpointer*)addr;
+ gaddr = (guint8 *)*(gpointer*)addr;
g_assert (gaddr);
buffer_add_value_full (buf, t, gaddr, domain, as_vtype, NULL);
break;
flags = info_var->index & MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS;
reg = info_var->index & ~MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS;
if (flags == MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET) {
- addr = (gpointer)mono_arch_context_get_int_reg (ctx, reg);
+ addr = (guint8 *)mono_arch_context_get_int_reg (ctx, reg);
addr += (gint32)info_var->offset;
- info = *(gpointer*)addr;
+ info = (MonoGSharedVtMethodRuntimeInfo *)*(gpointer*)addr;
} else if (flags == MONO_DEBUG_VAR_ADDRESS_MODE_REGISTER) {
- info = (gpointer)mono_arch_context_get_int_reg (ctx, reg);
+ info = (MonoGSharedVtMethodRuntimeInfo *)mono_arch_context_get_int_reg (ctx, reg);
} else {
g_assert_not_reached ();
}
flags = locals_var->index & MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS;
reg = locals_var->index & ~MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS;
if (flags == MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET) {
- addr = (gpointer)mono_arch_context_get_int_reg (ctx, reg);
+ addr = (guint8 *)mono_arch_context_get_int_reg (ctx, reg);
addr += (gint32)locals_var->offset;
- locals = *(gpointer*)addr;
+ locals = (guint8 *)*(gpointer*)addr;
} else if (flags == MONO_DEBUG_VAR_ADDRESS_MODE_REGISTER) {
- locals = (gpointer)mono_arch_context_get_int_reg (ctx, reg);
+ locals = (guint8 *)mono_arch_context_get_int_reg (ctx, reg);
} else {
g_assert_not_reached ();
}
gboolean is_signed = FALSE;
if (t->byref) {
- addr = (gpointer)mono_arch_context_get_int_reg (ctx, reg);
+ addr = (guint8 *)mono_arch_context_get_int_reg (ctx, reg);
if (addr) {
// FIXME: Write barriers
break;
}
case MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET:
- addr = (gpointer)mono_arch_context_get_int_reg (ctx, reg);
+ addr = (guint8 *)mono_arch_context_get_int_reg (ctx, reg);
addr += (gint32)var->offset;
//printf ("[R%d+%d] = %p\n", reg, var->offset, addr);
break;
case MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET_INDIR:
/* Same as regoffset, but with an indirection */
- addr = (gpointer)mono_arch_context_get_int_reg (ctx, reg);
+ addr = (guint8 *)mono_arch_context_get_int_reg (ctx, reg);
addr += (gint32)var->offset;
- gaddr = *(gpointer*)addr;
+ gaddr = (guint8 *)*(gpointer*)addr;
g_assert (gaddr);
// FIXME: Write barriers
mono_gc_memmove_atomic (gaddr, val, size);
mono_loader_lock ();
for (i = 0; i < event_requests->len; ++i) {
- EventRequest *req = g_ptr_array_index (event_requests, i);
+ EventRequest *req = (EventRequest *)g_ptr_array_index (event_requests, i);
if (req->id == req_id && req->event_kind == etype) {
if (req->event_kind == EVENT_KIND_BREAKPOINT)
- clear_breakpoint (req->info);
+ clear_breakpoint ((MonoBreakpoint *)req->info);
if (req->event_kind == EVENT_KIND_STEP)
- ss_destroy (req->info);
+ ss_destroy ((SingleStepReq *)req->info);
if (req->event_kind == EVENT_KIND_METHOD_ENTRY)
- clear_breakpoint (req->info);
+ clear_breakpoint ((MonoBreakpoint *)req->info);
if (req->event_kind == EVENT_KIND_METHOD_EXIT)
- clear_breakpoint (req->info);
+ clear_breakpoint ((MonoBreakpoint *)req->info);
g_ptr_array_remove_index_fast (event_requests, i);
g_free (req);
break;
while (found) {
found = FALSE;
for (i = 0; i < event_requests->len; ++i) {
- EventRequest *req = g_ptr_array_index (event_requests, i);
+ EventRequest *req = (EventRequest *)g_ptr_array_index (event_requests, i);
clear_assembly_from_modifiers (req, assembly);
- if (req->event_kind == EVENT_KIND_BREAKPOINT && breakpoint_matches_assembly (req->info, assembly)) {
+ if (req->event_kind == EVENT_KIND_BREAKPOINT && breakpoint_matches_assembly ((MonoBreakpoint *)req->info, assembly)) {
clear_event_request (req->id, req->event_kind);
found = TRUE;
break;
}
if (req->event_kind == EVENT_KIND_STEP)
- ss_clear_for_assembly (req->info, assembly);
+ ss_clear_for_assembly ((SingleStepReq *)req->info, assembly);
}
}
mono_loader_unlock ();
static void
add_thread (gpointer key, gpointer value, gpointer user_data)
{
- MonoInternalThread *thread = value;
- Buffer *buf = user_data;
+ MonoInternalThread *thread = (MonoInternalThread *)value;
+ Buffer *buf = (Buffer *)user_data;
buffer_add_objid (buf, (MonoObject*)thread);
}
{
guint8 *end = invoke->endp;
MonoMethod *m;
- int i, err, nargs;
+ int i, nargs;
+ ErrorCode err;
MonoMethodSignature *sig;
guint8 **arg_buf;
void **args;
* Invoke this method directly, currently only Environment.Exit () is supported.
*/
this_arg = NULL;
- DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer)mono_native_thread_id_get (), mono_method_full_name (invoke->method, TRUE), this_arg ? this_arg->vtable->klass->name : "<null>");
+ DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (invoke->method, TRUE), this_arg ? this_arg->vtable->klass->name : "<null>");
mono_runtime_invoke (invoke->method, NULL, invoke->args, &exc);
g_assert_not_reached ();
}
m = decode_methodid (p, &p, end, &domain, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
sig = mono_method_signature (m);
if (m->klass->valuetype)
- this_buf = g_alloca (mono_class_instance_size (m->klass));
+ this_buf = (guint8 *)g_alloca (mono_class_instance_size (m->klass));
else
- this_buf = g_alloca (sizeof (MonoObject*));
+ this_buf = (guint8 *)g_alloca (sizeof (MonoObject*));
if (m->klass->valuetype && (m->flags & METHOD_ATTRIBUTE_STATIC)) {
/* Should be null */
int type = decode_byte (p, &p, end);
if (type != VALUE_TYPE_ID_NULL) {
- DEBUG_PRINTF (1, "[%p] Error: Static vtype method invoked with this argument.\n", (gpointer)mono_native_thread_id_get ());
+ DEBUG_PRINTF (1, "[%p] Error: Static vtype method invoked with this argument.\n", (gpointer) (gsize) mono_native_thread_id_get ());
return ERR_INVALID_ARGUMENT;
}
memset (this_buf, 0, mono_class_instance_size (m->klass));
p = tmp_p;
} else {
err = decode_value (&m->klass->byval_arg, domain, this_buf, p, &p, end);
- if (err)
+ if (err != ERR_NONE)
return err;
}
} else {
err = decode_value (&m->klass->byval_arg, domain, this_buf, p, &p, end);
- if (err)
+ if (err != ERR_NONE)
return err;
}
if (MONO_CLASS_IS_INTERFACE (m->klass)) {
if (!this_arg) {
- DEBUG_PRINTF (1, "[%p] Error: Interface method invoked without this argument.\n", (gpointer)mono_native_thread_id_get ());
+ DEBUG_PRINTF (1, "[%p] Error: Interface method invoked without this argument.\n", (gpointer) (gsize) mono_native_thread_id_get ());
return ERR_INVALID_ARGUMENT;
}
m = mono_object_get_virtual_method (this_arg, m);
/* Transform this to the format the rest of the code expects it to be */
if (m->klass->valuetype) {
- this_buf = g_alloca (mono_class_instance_size (m->klass));
+ this_buf = (guint8 *)g_alloca (mono_class_instance_size (m->klass));
memcpy (this_buf, mono_object_unbox (this_arg), mono_class_instance_size (m->klass));
}
} else if ((m->flags & METHOD_ATTRIBUTE_VIRTUAL) && !m->klass->valuetype && invoke->flags & INVOKE_FLAG_VIRTUAL) {
if (!this_arg) {
- DEBUG_PRINTF (1, "[%p] Error: invoke with INVOKE_FLAG_VIRTUAL flag set without this argument.\n", (gpointer)mono_native_thread_id_get ());
+ DEBUG_PRINTF (1, "[%p] Error: invoke with INVOKE_FLAG_VIRTUAL flag set without this argument.\n", (gpointer) (gsize) mono_native_thread_id_get ());
return ERR_INVALID_ARGUMENT;
}
m = mono_object_get_virtual_method (this_arg, m);
if (m->klass->valuetype) {
- this_buf = g_alloca (mono_class_instance_size (m->klass));
+ this_buf = (guint8 *)g_alloca (mono_class_instance_size (m->klass));
memcpy (this_buf, mono_object_unbox (this_arg), mono_class_instance_size (m->klass));
}
}
- DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer)mono_native_thread_id_get (), mono_method_full_name (m, TRUE), this_arg ? this_arg->vtable->klass->name : "<null>");
+ DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (m, TRUE), this_arg ? this_arg->vtable->klass->name : "<null>");
if (this_arg && this_arg->vtable->domain != domain)
NOT_IMPLEMENTED;
if (nargs != sig->param_count)
return ERR_INVALID_ARGUMENT;
/* Use alloca to get gc tracking */
- arg_buf = g_alloca (nargs * sizeof (gpointer));
+ arg_buf = (guint8 **)g_alloca (nargs * sizeof (gpointer));
memset (arg_buf, 0, nargs * sizeof (gpointer));
- args = g_alloca (nargs * sizeof (gpointer));
+ args = (gpointer *)g_alloca (nargs * sizeof (gpointer));
for (i = 0; i < nargs; ++i) {
if (MONO_TYPE_IS_REFERENCE (sig->params [i])) {
err = decode_value (sig->params [i], domain, (guint8*)&args [i], p, &p, end);
- if (err)
+ if (err != ERR_NONE)
break;
if (args [i] && ((MonoObject*)args [i])->vtable->domain != domain)
NOT_IMPLEMENTED;
if (sig->params [i]->byref) {
- arg_buf [i] = g_alloca (sizeof (mgreg_t));
+ arg_buf [i] = (guint8 *)g_alloca (sizeof (mgreg_t));
*(gpointer*)arg_buf [i] = args [i];
args [i] = arg_buf [i];
}
} else {
- arg_buf [i] = g_alloca (mono_class_instance_size (mono_class_from_mono_type (sig->params [i])));
+ arg_buf [i] = (guint8 *)g_alloca (mono_class_instance_size (mono_class_from_mono_type (sig->params [i])));
err = decode_value (sig->params [i], domain, arg_buf [i], p, &p, end);
- if (err)
+ if (err != ERR_NONE)
break;
args [i] = arg_buf [i];
}
else
res = mono_runtime_invoke (m, this_arg, args, &exc);
mono_stopwatch_stop (&watch);
- DEBUG_PRINTF (1, "[%p] Invoke result: %p, exc: %s, time: %ld ms.\n", (gpointer)mono_native_thread_id_get (), res, exc ? exc->vtable->klass->name : NULL, (long)mono_stopwatch_elapsed_ms (&watch));
+ DEBUG_PRINTF (1, "[%p] Invoke result: %p, exc: %s, time: %ld ms.\n", (gpointer) (gsize) mono_native_thread_id_get (), res, exc ? exc->vtable->klass->name : NULL, (long)mono_stopwatch_elapsed_ms (&watch));
if (exc) {
buffer_add_byte (buf, 0);
buffer_add_value (buf, &mono_defaults.object_class->byval_arg, &exc, domain);
} else if (mono_class_from_mono_type (sig->ret)->valuetype || sig->ret->type == MONO_TYPE_PTR || sig->ret->type == MONO_TYPE_FNPTR) {
if (mono_class_is_nullable (mono_class_from_mono_type (sig->ret))) {
MonoClass *k = mono_class_from_mono_type (sig->ret);
- guint8 *nullable_buf = g_alloca (mono_class_value_size (k, NULL));
+ guint8 *nullable_buf = (guint8 *)g_alloca (mono_class_value_size (k, NULL));
g_assert (nullable_buf);
mono_nullable_init (nullable_buf, res, k);
#ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED
if (invoke->has_ctx)
- mono_set_lmf ((gpointer)(((gssize)ext.lmf.previous_lmf) & ~3));
+ mono_set_lmf ((MonoLMF *)(((gssize)ext.lmf.previous_lmf) & ~3));
#endif
*endp = p;
DebuggerTlsData *tls;
InvokeData *invoke;
int id;
- int i, err, mindex;
+ int i, mindex;
+ ErrorCode err;
Buffer buf;
MonoContext restore_ctx;
guint8 *p;
- tls = mono_native_tls_get_value (debugger_tls_id);
+ tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
g_assert (tls);
/*
id = invoke->id;
p = invoke->p;
- err = 0;
+ err = ERR_NONE;
for (mindex = 0; mindex < invoke->nmethods; ++mindex) {
buffer_init (&buf, 128);
tls->resume_count -= invoke->suspend_count;
}
- DEBUG_PRINTF (1, "[%p] Invoke finished (%d), resume_count = %d.\n", (gpointer)mono_native_thread_id_get (), err, tls->resume_count);
+ DEBUG_PRINTF (1, "[%p] Invoke finished (%d), resume_count = %d.\n", (gpointer) (gsize) mono_native_thread_id_get (), err, tls->resume_count);
/*
* Take the loader lock to avoid race conditions with CMD_VM_ABORT_INVOKE:
static gboolean
is_really_suspended (gpointer key, gpointer value, gpointer user_data)
{
- MonoThread *thread = value;
+ MonoThread *thread = (MonoThread *)value;
DebuggerTlsData *tls;
gboolean res;
mono_loader_lock ();
- tls = mono_g_hash_table_lookup (thread_to_tls, thread);
+ tls = (DebuggerTlsData *)mono_g_hash_table_lookup (thread_to_tls, thread);
g_assert (tls);
res = tls->really_suspended;
mono_loader_unlock ();
if (minfo) {
mono_debug_get_seq_points (minfo, NULL, &source_file_list, NULL, NULL, NULL);
for (j = 0; j < source_file_list->len; ++j) {
- sinfo = g_ptr_array_index (source_file_list, j);
+ sinfo = (MonoDebugSourceInfo *)g_ptr_array_index (source_file_list, j);
for (i = 0; i < files->len; ++i)
if (!strcmp (g_ptr_array_index (files, i), sinfo->source_file))
break;
/* Clear all event requests */
mono_loader_lock ();
while (event_requests->len > 0) {
- EventRequest *req = g_ptr_array_index (event_requests, 0);
+ EventRequest *req = (EventRequest *)g_ptr_array_index (event_requests, 0);
clear_event_request (req->id, req->event_kind);
}
/* Clear all event requests */
mono_loader_lock ();
while (event_requests->len > 0) {
- EventRequest *req = g_ptr_array_index (event_requests, 0);
+ EventRequest *req = (EventRequest *)g_ptr_array_index (event_requests, 0);
clear_event_request (req->id, req->event_kind);
}
#endif
mono_loader_lock ();
- thread = mono_g_hash_table_find (tid_to_thread, is_really_suspended, NULL);
+ thread = (MonoInternalThread *)mono_g_hash_table_find (tid_to_thread, is_really_suspended, NULL);
mono_loader_unlock ();
if (thread && exit_method) {
mono_loader_lock ();
- tls = mono_g_hash_table_lookup (thread_to_tls, thread);
+ tls = (DebuggerTlsData *)mono_g_hash_table_lookup (thread_to_tls, thread);
mono_loader_unlock ();
args = g_new0 (gpointer, 1);
int objid = decode_objid (p, &p, end);
MonoThread *thread;
DebuggerTlsData *tls;
- int i, count, err, flags, nmethods;
+ int i, count, flags, nmethods;
+ ErrorCode err;
err = get_object (objid, (MonoObject**)&thread);
- if (err)
+ if (err != ERR_NONE)
return err;
flags = decode_int (p, &p, end);
return ERR_NOT_SUSPENDED;
mono_loader_lock ();
- tls = mono_g_hash_table_lookup (thread_to_tls, THREAD_TO_INTERNAL (thread));
+ tls = (DebuggerTlsData *)mono_g_hash_table_lookup (thread_to_tls, THREAD_TO_INTERNAL (thread));
mono_loader_unlock ();
g_assert (tls);
tls->pending_invoke = g_new0 (InvokeData, 1);
tls->pending_invoke->id = id;
tls->pending_invoke->flags = flags;
- tls->pending_invoke->p = g_malloc (end - p);
+ tls->pending_invoke->p = (guint8 *)g_malloc (end - p);
memcpy (tls->pending_invoke->p, p, end - p);
tls->pending_invoke->endp = tls->pending_invoke->p + (end - p);
tls->pending_invoke->suspend_count = suspend_count;
int objid = decode_objid (p, &p, end);
MonoThread *thread;
DebuggerTlsData *tls;
- int invoke_id, err;
+ int invoke_id;
+ ErrorCode err;
err = get_object (objid, (MonoObject**)&thread);
- if (err)
+ if (err != ERR_NONE)
return err;
invoke_id = decode_int (p, &p, end);
mono_loader_lock ();
- tls = mono_g_hash_table_lookup (thread_to_tls, THREAD_TO_INTERNAL (thread));
+ tls = (DebuggerTlsData *)mono_g_hash_table_lookup (thread_to_tls, THREAD_TO_INTERNAL (thread));
g_assert (tls);
if (tls->abort_requested) {
mono_loader_lock ();
g_hash_table_iter_init (&iter, domains);
while (g_hash_table_iter_next (&iter, NULL, (void**)&domain)) {
- AgentDomainInfo *info = domain_jit_info (domain)->agent_info;
+ AgentDomainInfo *info = (AgentDomainInfo *)domain_jit_info (domain)->agent_info;
/* Update 'source_file_to_class' cache */
g_hash_table_iter_init (&kiter, info->loaded_classes);
g_hash_table_insert (info->source_files, klass, files);
for (i = 0; i < files->len; ++i) {
- char *s = g_ptr_array_index (files, i);
+ char *s = (char *)g_ptr_array_index (files, i);
char *s2 = dbg_path_get_basename (s);
char *s3;
- class_list = g_hash_table_lookup (info->source_file_to_class, s2);
+ class_list = (GSList *)g_hash_table_lookup (info->source_file_to_class, s2);
if (!class_list) {
class_list = g_slist_prepend (class_list, klass);
g_hash_table_insert (info->source_file_to_class, g_strdup (s2), class_list);
/* The _ignorecase hash contains the lowercase path */
s3 = strdup_tolower (s2);
- class_list = g_hash_table_lookup (info->source_file_to_class_ignorecase, s3);
+ class_list = (GSList *)g_hash_table_lookup (info->source_file_to_class_ignorecase, s3);
if (!class_list) {
class_list = g_slist_prepend (class_list, klass);
g_hash_table_insert (info->source_file_to_class_ignorecase, g_strdup (s3), class_list);
char *s;
s = strdup_tolower (basename);
- class_list = g_hash_table_lookup (info->source_file_to_class_ignorecase, s);
+ class_list = (GSList *)g_hash_table_lookup (info->source_file_to_class_ignorecase, s);
g_free (s);
} else {
- class_list = g_hash_table_lookup (info->source_file_to_class, basename);
+ class_list = (GSList *)g_hash_table_lookup (info->source_file_to_class, basename);
}
for (l = class_list; l; l = l->next) {
- klass = l->data;
+ klass = (MonoClass *)l->data;
g_ptr_array_add (res_classes, klass);
g_ptr_array_add (res_domains, domain);
buffer_add_int (buf, res_classes->len);
for (i = 0; i < res_classes->len; ++i)
- buffer_add_typeid (buf, g_ptr_array_index (res_domains, i), g_ptr_array_index (res_classes, i));
+ buffer_add_typeid (buf, (MonoDomain *)g_ptr_array_index (res_domains, i), (MonoClass *)g_ptr_array_index (res_classes, i));
g_ptr_array_free (res_classes, TRUE);
g_ptr_array_free (res_domains, TRUE);
break;
mono_domain_assemblies_lock (domain);
for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) {
- ass = tmp->data;
+ ass = (MonoAssembly *)tmp->data;
if (ass->image) {
type_resolve = TRUE;
buffer_add_int (buf, res_classes->len);
for (i = 0; i < res_classes->len; ++i)
- buffer_add_typeid (buf, g_ptr_array_index (res_domains, i), g_ptr_array_index (res_classes, i));
+ buffer_add_typeid (buf, (MonoDomain *)g_ptr_array_index (res_domains, i), (MonoClass *)g_ptr_array_index (res_classes, i));
g_ptr_array_free (res_classes, TRUE);
g_ptr_array_free (res_domains, TRUE);
break;
static ErrorCode
event_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
{
- int err;
+ ErrorCode err;
MonoError error;
switch (command) {
case CMD_EVENT_REQUEST_SET: {
EventRequest *req;
- int i, event_kind, suspend_policy, nmodifiers, mod;
+ int i, event_kind, suspend_policy, nmodifiers;
+ ModifierKind mod;
MonoMethod *method;
long location = 0;
MonoThread *step_thread;
- int size = 0, depth = 0, filter = 0, step_thread_id = 0;
+ int step_thread_id = 0;
+ StepDepth depth = STEP_DEPTH_INTO;
+ StepSize size = STEP_SIZE_MIN;
+ StepFilter filter = STEP_FILTER_NONE;
MonoDomain *domain;
Modifier *modifier;
suspend_policy = decode_byte (p, &p, end);
nmodifiers = decode_byte (p, &p, end);
- req = g_malloc0 (sizeof (EventRequest) + (nmodifiers * sizeof (Modifier)));
+ req = (EventRequest *)g_malloc0 (sizeof (EventRequest) + (nmodifiers * sizeof (Modifier)));
req->id = InterlockedIncrement (&event_request_id);
req->event_kind = event_kind;
req->suspend_policy = suspend_policy;
method = NULL;
for (i = 0; i < nmodifiers; ++i) {
- mod = decode_byte (p, &p, end);
+ mod = (ModifierKind)decode_byte (p, &p, end);
req->modifiers [i].kind = mod;
if (mod == MOD_KIND_COUNT) {
req->modifiers [i].data.count = decode_int (p, &p, end);
} else if (mod == MOD_KIND_LOCATION_ONLY) {
method = decode_methodid (p, &p, end, &domain, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
location = decode_long (p, &p, end);
} else if (mod == MOD_KIND_STEP) {
step_thread_id = decode_id (p, &p, end);
- size = decode_int (p, &p, end);
- depth = decode_int (p, &p, end);
+ size = (StepSize)decode_int (p, &p, end);
+ depth = (StepDepth)decode_int (p, &p, end);
if (CHECK_PROTOCOL_VERSION (2, 16))
- filter = decode_int (p, &p, end);
+ filter = (StepFilter)decode_int (p, &p, end);
req->modifiers [i].data.filter = filter;
if (!CHECK_PROTOCOL_VERSION (2, 26) && (req->modifiers [i].data.filter & STEP_FILTER_DEBUGGER_HIDDEN))
/* Treat STEP_THOUGH the same as HIDDEN */
- req->modifiers [i].data.filter |= STEP_FILTER_DEBUGGER_STEP_THROUGH;
+ req->modifiers [i].data.filter = (StepFilter)(req->modifiers [i].data.filter | STEP_FILTER_DEBUGGER_STEP_THROUGH);
} else if (mod == MOD_KIND_THREAD_ONLY) {
int id = decode_id (p, &p, end);
err = get_object (id, (MonoObject**)&req->modifiers [i].data.thread);
- if (err) {
+ if (err != ERR_NONE) {
g_free (req);
return err;
}
} else if (mod == MOD_KIND_EXCEPTION_ONLY) {
MonoClass *exc_class = decode_typeid (p, &p, end, &domain, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
req->modifiers [i].caught = decode_byte (p, &p, end);
req->modifiers [i].uncaught = decode_byte (p, &p, end);
req->modifiers [i].data.assemblies = g_new0 (MonoAssembly*, n);
for (j = 0; j < n; ++j) {
req->modifiers [i].data.assemblies [j] = decode_assemblyid (p, &p, end, &domain, &err);
- if (err) {
+ if (err != ERR_NONE) {
g_free (req->modifiers [i].data.assemblies);
return err;
}
g_assert (step_thread_id);
err = get_object (step_thread_id, (MonoObject**)&step_thread);
- if (err) {
+ if (err != ERR_NONE) {
g_free (req);
return err;
}
err = ss_create (THREAD_TO_INTERNAL (step_thread), size, depth, filter, req);
- if (err) {
+ if (err != ERR_NONE) {
g_free (req);
return err;
}
mono_loader_lock ();
i = 0;
while (i < event_requests->len) {
- EventRequest *req = g_ptr_array_index (event_requests, i);
+ EventRequest *req = (EventRequest *)g_ptr_array_index (event_requests, i);
if (req->event_kind == EVENT_KIND_BREAKPOINT) {
- clear_breakpoint (req->info);
+ clear_breakpoint ((MonoBreakpoint *)req->info);
g_ptr_array_remove_index_fast (event_requests, i);
g_free (req);
static ErrorCode
domain_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
{
- int err;
+ ErrorCode err;
MonoDomain *domain;
switch (command) {
}
case CMD_APPDOMAIN_GET_FRIENDLY_NAME: {
domain = decode_domainid (p, &p, end, NULL, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
buffer_add_string (buf, domain->friendly_name);
break;
int count;
domain = decode_domainid (p, &p, end, NULL, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
mono_loader_lock ();
count = 0;
}
buffer_add_int (buf, count);
for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) {
- ass = tmp->data;
+ ass = (MonoAssembly *)tmp->data;
buffer_add_assemblyid (buf, domain, ass);
}
mono_loader_unlock ();
}
case CMD_APPDOMAIN_GET_ENTRY_ASSEMBLY: {
domain = decode_domainid (p, &p, end, NULL, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
buffer_add_assemblyid (buf, domain, domain->entry_assembly);
}
case CMD_APPDOMAIN_GET_CORLIB: {
domain = decode_domainid (p, &p, end, NULL, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
buffer_add_assemblyid (buf, domain, domain->domain->mbr.obj.vtable->klass->image->assembly);
MonoString *o;
domain = decode_domainid (p, &p, end, NULL, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
s = decode_string (p, &p, end);
MonoObject *o;
domain = decode_domainid (p, &p, end, NULL, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
klass = decode_typeid (p, &p, end, &domain2, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
// FIXME:
o = mono_object_new (domain, klass);
- err = decode_value (&klass->byval_arg, domain, mono_object_unbox (o), p, &p, end);
- if (err)
+ err = decode_value (&klass->byval_arg, domain, (guint8 *)mono_object_unbox (o), p, &p, end);
+ if (err != ERR_NONE)
return err;
buffer_add_objid (buf, o);
static ErrorCode
assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
{
- int err;
+ ErrorCode err;
MonoAssembly *ass;
MonoDomain *domain;
ass = decode_assemblyid (p, &p, end, &domain, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
switch (command) {
static ErrorCode
module_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
{
- int err;
+ ErrorCode err;
MonoDomain *domain;
switch (command) {
static ErrorCode
field_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
{
- int err;
+ ErrorCode err;
MonoDomain *domain;
switch (command) {
buffer_add_value (buf, t, mono_object_unbox (val), domain);
}
-static int
+static ErrorCode
buffer_add_cattrs (Buffer *buf, MonoDomain *domain, MonoImage *image, MonoClass *attr_klass, MonoCustomAttrInfo *cinfo)
{
int i, j;
MonoType *type;
gpointer iter;
guint8 b;
- int err, nnested;
+ int nnested;
+ ErrorCode err;
char *name;
switch (command) {
count = container->type_argc;
buffer_add_int (buf, count);
for (i = 0; i < count; i++) {
- pklass = mono_class_from_generic_parameter (mono_generic_container_get_param (container, i), klass->image, FALSE);
+ pklass = mono_class_from_generic_parameter_internal (mono_generic_container_get_param (container, i));
buffer_add_typeid (buf, domain, pklass);
}
} else {
attr_klass = decode_typeid (p, &p, end, NULL, &err);
/* attr_klass can be NULL */
- if (err)
+ if (err != ERR_NONE)
return err;
cinfo = mono_custom_attrs_from_class (klass);
err = buffer_add_cattrs (buf, domain, klass->image, attr_klass, cinfo);
- if (err)
+ if (err != ERR_NONE)
return err;
break;
}
MonoClassField *field;
field = decode_fieldid (p, &p, end, NULL, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
attr_klass = decode_typeid (p, &p, end, NULL, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
cinfo = mono_custom_attrs_from_field (klass, field);
err = buffer_add_cattrs (buf, domain, klass->image, attr_klass, cinfo);
- if (err)
+ if (err != ERR_NONE)
return err;
break;
}
MonoProperty *prop;
prop = decode_propertyid (p, &p, end, NULL, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
attr_klass = decode_typeid (p, &p, end, NULL, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
cinfo = mono_custom_attrs_from_property (klass, prop);
err = buffer_add_cattrs (buf, domain, klass->image, attr_klass, cinfo);
- if (err)
+ if (err != ERR_NONE)
return err;
break;
}
if (command == CMD_TYPE_GET_VALUES_2) {
int objid = decode_objid (p, &p, end);
- int err;
+ ErrorCode err;
err = get_object (objid, (MonoObject**)&thread_obj);
- if (err)
+ if (err != ERR_NONE)
return err;
thread = THREAD_TO_INTERNAL (thread_obj);
len = decode_int (p, &p, end);
for (i = 0; i < len; ++i) {
f = decode_fieldid (p, &p, end, NULL, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
if (!(f->type->attrs & FIELD_ATTRIBUTE_STATIC))
return ERR_INVALID_FIELDID;
vtable = mono_class_vtable (domain, f->parent);
- val = g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type)));
+ val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type)));
mono_field_static_get_value_for_thread (thread ? thread : mono_thread_internal_current (), vtable, f, val);
buffer_add_value (buf, f->type, val, domain);
g_free (val);
len = decode_int (p, &p, end);
for (i = 0; i < len; ++i) {
f = decode_fieldid (p, &p, end, NULL, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
if (!(f->type->attrs & FIELD_ATTRIBUTE_STATIC))
// FIXME: Check for literal/const
vtable = mono_class_vtable (domain, f->parent);
- val = g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type)));
+ val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type)));
err = decode_value (f->type, domain, val, p, &p, end);
- if (err) {
+ if (err != ERR_NONE) {
g_free (val);
return err;
}
buffer_add_int (buf, files->len);
for (i = 0; i < files->len; ++i) {
- source_file = g_ptr_array_index (files, i);
+ source_file = (char *)g_ptr_array_index (files, i);
if (command == CMD_TYPE_GET_SOURCE_FILES_2) {
buffer_add_string (buf, source_file);
} else {
case CMD_TYPE_IS_ASSIGNABLE_FROM: {
MonoClass *oklass = decode_typeid (p, &p, end, NULL, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
if (mono_class_is_assignable_from (klass, oklass))
buffer_add_byte (buf, 1);
return ERR_LOADER_ERROR;
buffer_add_int (buf, array->len);
for (i = 0; i < array->len; ++i) {
- MonoMethod *method = g_ptr_array_index (array, i);
+ MonoMethod *method = (MonoMethod *)g_ptr_array_index (array, i);
buffer_add_methodid (buf, domain, method);
}
for (tindex = 0; tindex < len; ++tindex) {
iclass = decode_typeid (p, &p, end, NULL, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
ioffset = mono_class_interface_offset_with_variance (klass, iclass, &variance_used);
MonoClass *klass;
MonoDomain *old_domain;
MonoDomain *domain;
- int err;
+ ErrorCode err;
klass = decode_typeid (p, &p, end, &domain, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
old_domain = mono_domain_get ();
method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, guint8 *p, guint8 *end, Buffer *buf)
{
MonoMethodHeader *header;
- int err;
+ ErrorCode err;
switch (command) {
case CMD_METHOD_GET_NAME: {
if (CHECK_PROTOCOL_VERSION (2, 13)) {
buffer_add_int (buf, source_file_list->len);
for (i = 0; i < source_file_list->len; ++i) {
- MonoDebugSourceInfo *sinfo = g_ptr_array_index (source_file_list, i);
+ MonoDebugSourceInfo *sinfo = (MonoDebugSourceInfo *)g_ptr_array_index (source_file_list, i);
buffer_add_string (buf, sinfo->source_file);
if (CHECK_PROTOCOL_VERSION (2, 14)) {
for (j = 0; j < 16; ++j)
const char *srcfile = "";
if (source_files [i] != -1) {
- MonoDebugSourceInfo *sinfo = g_ptr_array_index (source_file_list, source_files [i]);
+ MonoDebugSourceInfo *sinfo = (MonoDebugSourceInfo *)g_ptr_array_index (source_file_list, source_files [i]);
srcfile = sinfo->source_file;
}
DEBUG_PRINTF (10, "IL%x -> %s:%d %d %d %d\n", sp->il_offset, srcfile, sp->line, sp->column, sp->end_line, sp->end_column);
buffer_add_int (buf, count);
for (i = 0; i < count; i++) {
MonoGenericParam *param = mono_generic_container_get_param (container, i);
- MonoClass *pklass = mono_class_from_generic_parameter (param, method->klass->image, TRUE);
+ MonoClass *pklass = mono_class_from_generic_parameter_internal (param);
buffer_add_typeid (buf, domain, pklass);
}
} else {
if (method->wrapper_type == MONO_WRAPPER_DYNAMIC_METHOD) {
val = mono_method_get_wrapper_data (method, token);
- handle_class = mono_method_get_wrapper_data (method, token + 1);
+ handle_class = (MonoClass *)mono_method_get_wrapper_data (method, token + 1);
if (handle_class == NULL) {
// Can't figure out the token type
buffer_add_typeid (buf, domain, mono_class_from_mono_type ((MonoType*)val));
} else if (handle_class == mono_defaults.fieldhandle_class) {
buffer_add_byte (buf, TOKEN_TYPE_FIELD);
- buffer_add_fieldid (buf, domain, val);
+ buffer_add_fieldid (buf, domain, (MonoClassField *)val);
} else if (handle_class == mono_defaults.methodhandle_class) {
buffer_add_byte (buf, TOKEN_TYPE_METHOD);
- buffer_add_methodid (buf, domain, val);
+ buffer_add_methodid (buf, domain, (MonoMethod *)val);
} else if (handle_class == mono_defaults.string_class) {
char *s;
- s = mono_string_to_utf8 (val);
+ s = mono_string_to_utf8 ((MonoString *)val);
buffer_add_byte (buf, TOKEN_TYPE_STRING);
buffer_add_string (buf, s);
g_free (s);
attr_klass = decode_typeid (p, &p, end, NULL, &err);
/* attr_klass can be NULL */
- if (err)
+ if (err != ERR_NONE)
return err;
cinfo = mono_custom_attrs_from_method (method);
err = buffer_add_cattrs (buf, domain, method->klass->image, attr_klass, cinfo);
- if (err)
+ if (err != ERR_NONE)
return err;
break;
}
type_argv = g_new0 (MonoType*, type_argc);
for (i = 0; i < type_argc; ++i) {
klass = decode_typeid (p, &p, end, &d, &err);
- if (err) {
+ if (err != ERR_NONE) {
g_free (type_argv);
return err;
}
static ErrorCode
method_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
{
- int err;
+ ErrorCode err;
MonoDomain *old_domain;
MonoDomain *domain;
MonoMethod *method;
method = decode_methodid (p, &p, end, &domain, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
old_domain = mono_domain_get ();
thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
{
int objid = decode_objid (p, &p, end);
- int err;
+ ErrorCode err;
MonoThread *thread_obj;
MonoInternalThread *thread;
err = get_object (objid, (MonoObject**)&thread_obj);
- if (err)
+ if (err != ERR_NONE)
return err;
thread = THREAD_TO_INTERNAL (thread_obj);
return ERR_NOT_IMPLEMENTED;
mono_loader_lock ();
- tls = mono_g_hash_table_lookup (thread_to_tls, thread);
+ tls = (DebuggerTlsData *)mono_g_hash_table_lookup (thread_to_tls, thread);
mono_loader_unlock ();
g_assert (tls);
gint64 il_offset;
method = decode_methodid (p, &p, end, &domain, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
il_offset = decode_long (p, &p, end);
}
mono_loader_lock ();
- tls = mono_g_hash_table_lookup (thread_to_tls, thread);
+ tls = (DebuggerTlsData *)mono_g_hash_table_lookup (thread_to_tls, thread);
mono_loader_unlock ();
g_assert (tls);
frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
{
int objid;
- int err;
+ ErrorCode err;
MonoThread *thread_obj;
MonoInternalThread *thread;
int pos, i, len, frame_idx;
objid = decode_objid (p, &p, end);
err = get_object (objid, (MonoObject**)&thread_obj);
- if (err)
+ if (err != ERR_NONE)
return err;
thread = THREAD_TO_INTERNAL (thread_obj);
id = decode_id (p, &p, end);
mono_loader_lock ();
- tls = mono_g_hash_table_lookup (thread_to_tls, thread);
+ tls = (DebuggerTlsData *)mono_g_hash_table_lookup (thread_to_tls, thread);
mono_loader_unlock ();
g_assert (tls);
}
if (MONO_TYPE_IS_REFERENCE (t))
- val_buf = g_alloca (sizeof (MonoObject*));
+ val_buf = (guint8 *)g_alloca (sizeof (MonoObject*));
else
- val_buf = g_alloca (mono_class_instance_size (mono_class_from_mono_type (t)));
+ val_buf = (guint8 *)g_alloca (mono_class_instance_size (mono_class_from_mono_type (t)));
err = decode_value (t, frame->domain, val_buf, p, &p, end);
- if (err)
+ if (err != ERR_NONE)
return err;
set_var (t, var, &frame->ctx, frame->domain, val_buf, frame->reg_locations, &tls->restore_state.ctx);
array_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
{
MonoArray *arr;
- int objid, err, index, len, i, esize;
+ int objid, index, len, i, esize;
+ ErrorCode err;
gpointer elem;
objid = decode_objid (p, &p, end);
err = get_object (objid, (MonoObject**)&arr);
- if (err)
+ if (err != ERR_NONE)
return err;
switch (command) {
for (i = index; i < index + len; ++i) {
elem = (gpointer*)((char*)arr->vector + (i * esize));
- decode_value (&arr->obj.vtable->klass->element_class->byval_arg, arr->obj.vtable->domain, elem, p, &p, end);
+ decode_value (&arr->obj.vtable->klass->element_class->byval_arg, arr->obj.vtable->domain, (guint8 *)elem, p, &p, end);
}
break;
default:
static ErrorCode
string_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
{
- int objid, err;
+ int objid;
+ ErrorCode err;
MonoString *str;
char *s;
int i, index, length;
objid = decode_objid (p, &p, end);
err = get_object (objid, (MonoObject**)&str);
- if (err)
+ if (err != ERR_NONE)
return err;
switch (command) {
static ErrorCode
object_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
{
- int objid, err;
+ int objid;
+ ErrorCode err;
MonoObject *obj;
int len, i;
MonoClassField *f;
if (command == CMD_OBJECT_REF_IS_COLLECTED) {
objid = decode_objid (p, &p, end);
err = get_object (objid, &obj);
- if (err)
+ if (err != ERR_NONE)
buffer_add_int (buf, 1);
else
buffer_add_int (buf, 0);
- return 0;
+ return ERR_NONE;
}
objid = decode_objid (p, &p, end);
err = get_object (objid, &obj);
- if (err)
+ if (err != ERR_NONE)
return err;
MonoClass *obj_type;
+ gboolean remote_obj = FALSE;
obj_type = obj->vtable->klass;
- if (mono_class_is_transparent_proxy (obj_type))
+ if (mono_class_is_transparent_proxy (obj_type)) {
obj_type = ((MonoTransparentProxy *)obj)->remote_class->proxy_class;
+ remote_obj = TRUE;
+ }
g_assert (obj_type);
for (i = 0; i < len; ++i) {
MonoClassField *f = decode_fieldid (p, &p, end, NULL, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
/* Check that the field belongs to the object */
g_assert (f->type->attrs & FIELD_ATTRIBUTE_STATIC);
vtable = mono_class_vtable (obj->vtable->domain, f->parent);
- val = g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type)));
+ val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type)));
mono_field_static_get_value (vtable, f, val);
buffer_add_value (buf, f->type, val, obj->vtable->domain);
g_free (val);
} else {
- buffer_add_value (buf, f->type, (guint8*)obj + f->offset, obj->vtable->domain);
+ guint8 *field_value = NULL;
+ void *field_storage = NULL;
+
+ if (remote_obj) {
+ field_value = mono_load_remote_field(obj, obj_type, f, &field_storage);
+ } else
+ field_value = (guint8*)obj + f->offset;
+
+ buffer_add_value (buf, f->type, field_value, obj->vtable->domain);
}
}
break;
for (i = 0; i < len; ++i) {
f = decode_fieldid (p, &p, end, NULL, &err);
- if (err)
+ if (err != ERR_NONE)
return err;
/* Check that the field belongs to the object */
g_assert (f->type->attrs & FIELD_ATTRIBUTE_STATIC);
vtable = mono_class_vtable (obj->vtable->domain, f->parent);
- val = g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type)));
+ val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type)));
err = decode_value (f->type, obj->vtable->domain, val, p, &p, end);
- if (err) {
+ if (err != ERR_NONE) {
g_free (val);
return err;
}
g_free (val);
} else {
err = decode_value (f->type, obj->vtable->domain, (guint8*)obj + f->offset, p, &p, end);
- if (err)
+ if (err != ERR_NONE)
return err;
}
}
static guint32 WINAPI
debugger_thread (void *arg)
{
- int res, len, id, flags, command_set = 0, command = 0;
+ int res, len, id, flags, command = 0;
+ CommandSet command_set = (CommandSet)0;
guint8 header [HEADER_LENGTH];
guint8 *data, *p, *end;
Buffer buf;
gboolean no_reply;
gboolean attach_failed = FALSE;
- DEBUG_PRINTF (1, "[dbg] Agent thread started, pid=%p\n", (gpointer)mono_native_thread_id_get ());
+ DEBUG_PRINTF (1, "[dbg] Agent thread started, pid=%p\n", (gpointer) (gsize) mono_native_thread_id_get ());
debugger_thread_id = mono_native_thread_id_get ();
len = decode_int (p, &p, end);
id = decode_int (p, &p, end);
flags = decode_byte (p, &p, end);
- command_set = decode_byte (p, &p, end);
+ command_set = (CommandSet)decode_byte (p, &p, end);
command = decode_byte (p, &p, end);
g_assert (flags == 0);
DEBUG_PRINTF (1, "[dbg] Command %s(%s) [%d][at=%lx].\n", command_set_to_string (command_set), cmd_str, id, (long)mono_100ns_ticks () / 10000);
}
- data = g_malloc (len - HEADER_LENGTH);
+ data = (guint8 *)g_malloc (len - HEADER_LENGTH);
if (len - HEADER_LENGTH > 0)
{
MONO_PREPARE_BLOCKING;
switch (command_set) {
case CMD_SET_VM:
err = vm_commands (command, id, p, end, &buf);
- if (!err && command == CMD_VM_INVOKE_METHOD)
+ if (err == ERR_NONE && command == CMD_VM_INVOKE_METHOD)
/* Sent after the invoke is complete */
no_reply = TRUE;
break;
}
}
- if (!err && command_set == CMD_SET_VM && command == CMD_VM_STOP_BUFFERING) {
+ if (err == ERR_NONE && command_set == CMD_SET_VM && command == CMD_VM_STOP_BUFFERING) {
send_buffered_reply_packets ();
buffer_replies = FALSE;
}
}
mono_set_is_debugger_attached (FALSE);
-
- MONO_TRY_BLOCKING;
- mono_mutex_lock (&debugger_thread_exited_mutex);
+
+ mono_coop_mutex_lock (&debugger_thread_exited_mutex);
debugger_thread_exited = TRUE;
- mono_cond_signal (&debugger_thread_exited_cond);
- mono_mutex_unlock (&debugger_thread_exited_mutex);
- MONO_FINISH_TRY_BLOCKING;
+ mono_coop_cond_signal (&debugger_thread_exited_cond);
+ mono_coop_mutex_unlock (&debugger_thread_exited_mutex);
DEBUG_PRINTF (1, "[dbg] Debugger thread exited.\n");