#include <mono/metadata/debug-mono-symfile.h>
#include <mono/metadata/mono-endian.h>
#include <mono/metadata/metadata-internals.h>
+#include <mono/metadata/mono-debug-debugger.h>
#include <fcntl.h>
#include <unistd.h>
{
MonoSymbolFile *symfile;
+ mono_debugger_lock ();
symfile = g_new0 (MonoSymbolFile, 1);
symfile->filename = g_strdup_printf ("%s.mdb", mono_image_get_filename (handle->image));
&symfile->raw_contents_size, NULL))
symfile->raw_contents = NULL;
- if (load_symfile (handle, symfile))
+ if (load_symfile (handle, symfile)) {
+ mono_debugger_unlock ();
return symfile;
- else if (!create_symfile) {
+ } else if (!create_symfile) {
mono_debug_close_mono_symbol_file (symfile);
+ mono_debugger_unlock ();
return NULL;
}
+ mono_debugger_unlock ();
return symfile;
}
if (!symfile)
return;
+ mono_debugger_lock ();
if (symfile->method_hash)
g_hash_table_destroy (symfile->method_hash);
g_free (symfile);
+ mono_debugger_unlock ();
}
static int
const char *ptr;
int i;
- if (!symfile->method_hash)
+ mono_debugger_lock ();
+ if (!symfile->method_hash) {
+ mono_debugger_unlock ();
return NULL;
+ }
minfo = g_hash_table_lookup (symfile->method_hash, method);
- if (!minfo)
+ if (!minfo) {
+ mono_debugger_unlock ();
return NULL;
+ }
if (read32(&(minfo->entry->_source_index))) {
int offset = read32(&(symfile->offset_table->_source_table_offset)) +
if (line_number) {
*line_number = read32(&(lne->_row));
+ mono_debugger_unlock ();
if (source_file)
return source_file;
else
} else if (source_file) {
gchar *retval = g_strdup_printf ("%s:%d", source_file, read32(&(lne->_row)));
g_free (source_file);
+ mono_debugger_unlock ();
return retval;
- } else
- return g_strdup_printf ("%d", read32(&(lne->_row)));
+ } else {
+ gchar* retval = g_strdup_printf ("%d", read32(&(lne->_row)));
+ mono_debugger_unlock ();
+ return retval;
+ }
}
+ mono_debugger_unlock ();
return NULL;
}
if (handle->image != mono_class_get_image (mono_method_get_class (method)))
return NULL;
+ mono_debugger_lock ();
first_ie = (MonoSymbolFileMethodIndexEntry *)
(symfile->raw_contents + read32(&(symfile->offset_table->_method_table_offset)));
read32(&(symfile->offset_table->_method_count)),
sizeof (MonoSymbolFileMethodIndexEntry), compare_method);
- if (!ie)
+ if (!ie) {
+ mono_debugger_unlock ();
return NULL;
+ }
me = (MonoSymbolFileMethodEntry *) (symfile->raw_contents + read32(&(ie->_file_offset)));
g_hash_table_insert (symfile->method_hash, method, minfo);
+ mono_debugger_unlock ();
return minfo;
}
mono_debugger_start_class_init_func = mono_debug_start_add_type;
mono_debugger_class_init_func = mono_debug_add_type;
mono_install_assembly_load_hook (mono_debug_add_assembly, NULL);
+ mono_debugger_unlock ();
}
void
mono_debug_source_location_from_address (MonoMethod *method, guint32 address, guint32 *line_number,
MonoDomain *domain)
{
- MonoDebugMethodInfo *minfo = _mono_debug_lookup_method (method);
+ char *res;
+ MonoDebugMethodInfo *minfo;
MonoDebugDomainData *domain_data;
+ mono_debugger_lock ();
+ minfo = _mono_debug_lookup_method (method);
if (!minfo || !minfo->handle || !minfo->handle->symfile ||
- !minfo->handle->symfile->offset_table)
+ !minfo->handle->symfile->offset_table) {
+ mono_debugger_unlock ();
return NULL;
+ }
domain_data = mono_debug_get_domain_data (minfo->handle, domain);
- if (!domain_data->jit [minfo->index])
+ if (!domain_data->jit [minfo->index]) {
+ mono_debugger_unlock ();
return NULL;
+ }
if (minfo->handle && minfo->handle->symfile) {
gint32 offset = il_offset_from_address (domain_data->jit [minfo->index], address);
+ char *res = NULL;
- if (offset < 0)
- return NULL;
-
- return mono_debug_find_source_location (minfo->handle->symfile, method, offset, line_number);
+ if (offset >= 0)
+ res = mono_debug_find_source_location (minfo->handle->symfile, method, offset, line_number);
+ mono_debugger_unlock ();
+ return res;
}
+ mono_debugger_unlock ();
return NULL;
}
gchar *
mono_debug_source_location_from_il_offset (MonoMethod *method, guint32 offset, guint32 *line_number)
{
- MonoDebugMethodInfo *minfo = _mono_debug_lookup_method (method);
+ char *res;
+ MonoDebugMethodInfo *minfo;
- if (!minfo || !minfo->handle || !minfo->handle->symfile)
+ mono_debugger_lock ();
+ minfo = _mono_debug_lookup_method (method);
+ if (!minfo || !minfo->handle || !minfo->handle->symfile) {
+ mono_debugger_unlock ();
return NULL;
+ }
- return mono_debug_find_source_location (minfo->handle->symfile, method, offset, line_number);
+ res = mono_debug_find_source_location (minfo->handle->symfile, method, offset, line_number);
+ mono_debugger_unlock ();
+ return res;
}
/*
{
MonoDebugMethodInfo *minfo;
MonoDebugDomainData *domain_data;
+ gint32 res;
if (address < 0)
return -1;
+ mono_debugger_lock ();
minfo = _mono_debug_lookup_method (method);
if (!minfo || !minfo->il_offsets || !minfo->handle || !minfo->handle->symfile ||
- !minfo->handle->symfile->offset_table)
+ !minfo->handle->symfile->offset_table) {
+ mono_debugger_unlock ();
return -1;
+ }
domain_data = mono_debug_get_domain_data (minfo->handle, domain);
- return il_offset_from_address (domain_data->jit [minfo->index], address);
+ res = il_offset_from_address (domain_data->jit [minfo->index], address);
+ mono_debugger_unlock ();
+ return res;
}
/*
{
MonoDebugMethodInfo *minfo;
MonoDebugDomainData *domain_data;
+ gint32 res;
if (il_offset < 0)
return -1;
+ mono_debugger_lock ();
minfo = _mono_debug_lookup_method (method);
if (!minfo || !minfo->il_offsets || !minfo->handle || !minfo->handle->symfile ||
- !minfo->handle->symfile->offset_table)
+ !minfo->handle->symfile->offset_table) {
+ mono_debugger_unlock ();
return -1;
+ }
domain_data = mono_debug_get_domain_data (minfo->handle, domain);
- return _mono_debug_address_from_il_offset (domain_data->jit [minfo->index], il_offset);
+ res = _mono_debug_address_from_il_offset (domain_data->jit [minfo->index], il_offset);
+ mono_debugger_unlock ();
+ return res;
}
static MonoDebugDomainData *