Make the thread dump code safe by doing only async safe operations when a thread...
[mono.git] / mono / metadata / mono-debug.c
index 4c130898b9435691ad563bc3f9dfbe0f5f414042..42c980214eb53a73ef54cd57c7e3af979dd362d0 100644 (file)
@@ -262,7 +262,7 @@ mono_debug_open_image (MonoImage *image, const guint8 *raw_contents, int size)
        mono_image_addref (image);
 
        /* Try a ppdb file first */
-       handle->ppdb = mono_ppdb_load_file (handle->image);
+       handle->ppdb = mono_ppdb_load_file (handle->image, raw_contents, size);
 
        if (!handle->ppdb)
                handle->symfile = mono_debug_open_mono_symbols (handle, raw_contents, size, FALSE);
@@ -779,7 +779,7 @@ mono_debug_lookup_source_location (MonoMethod *method, guint32 address, MonoDoma
  * mono_debug_lookup_locals:
  *
  *   Return information about the local variables of MINFO.
- * The result should be freed using mono_debug_symfile_free_locals ().
+ * The result should be freed using mono_debug_free_locals ().
  */
 MonoDebugLocalsInfo*
 mono_debug_lookup_locals (MonoMethod *method)
@@ -792,17 +792,41 @@ mono_debug_lookup_locals (MonoMethod *method)
 
        mono_debugger_lock ();
        minfo = mono_debug_lookup_method_internal (method);
-       if (!minfo || !minfo->handle || !minfo->handle->symfile || !mono_debug_symfile_is_loaded (minfo->handle->symfile)) {
+       if (!minfo || !minfo->handle) {
                mono_debugger_unlock ();
                return NULL;
        }
 
-       res = mono_debug_symfile_lookup_locals (minfo);
+       if (minfo->handle->ppdb) {
+               res = mono_ppdb_lookup_locals (minfo);
+       } else {
+               if (!minfo->handle->symfile || !mono_debug_symfile_is_loaded (minfo->handle->symfile))
+                       res = NULL;
+               else
+                       res = mono_debug_symfile_lookup_locals (minfo);
+       }
        mono_debugger_unlock ();
 
        return res;
 }
 
+/*
+ * mono_debug_free_locals:
+ *
+ *   Free all the data allocated by mono_debug_lookup_locals ().
+ */
+void
+mono_debug_free_locals (MonoDebugLocalsInfo *info)
+{
+       int i;
+
+       for (i = 0; i < info->num_locals; ++i)
+               g_free (info->locals [i].name);
+       g_free (info->locals);
+       g_free (info->code_blocks);
+       g_free (info);
+}
+
 /**
  * mono_debug_free_source_location:
  * @location: A `MonoDebugSourceLocation'.
@@ -947,5 +971,8 @@ mono_debug_enabled (void)
 void
 mono_debug_get_seq_points (MonoDebugMethodInfo *minfo, char **source_file, GPtrArray **source_file_list, int **source_files, MonoSymSeqPoint **seq_points, int *n_seq_points)
 {
-       mono_debug_symfile_get_seq_points (minfo, source_file, source_file_list, source_files, seq_points, n_seq_points);
+       if (minfo->handle->ppdb)
+               mono_ppdb_get_seq_points (minfo, source_file, source_file_list, source_files, seq_points, n_seq_points);
+       else
+               mono_debug_symfile_get_seq_points (minfo, source_file, source_file_list, source_files, seq_points, n_seq_points);
 }