Merge pull request #1455 from esdrubal/caching
[mono.git] / mono / metadata / mono-debug.c
index 1cfc8cf65f4c7be36104774704accb98545064ac..a5f964737ea9d3919642e62d050805b0d2d17eb8 100644 (file)
@@ -337,6 +337,42 @@ mono_debug_lookup_method (MonoMethod *method)
        return minfo;
 }
 
+typedef struct
+{
+       gboolean found;
+       MonoImage *image;
+} LookupImageData;
+
+static void
+lookup_image_func (gpointer key, gpointer value, gpointer user_data)
+{
+       MonoDebugHandle *handle = (MonoDebugHandle *) value;
+       LookupImageData *data = (LookupImageData *) user_data;
+
+       if (data->found)
+               return;
+
+       if (handle->image == data->image)
+               data->found = TRUE;
+}
+
+gboolean
+mono_debug_image_has_debug_info (MonoImage *image)
+{
+       LookupImageData data;
+
+       if (!mono_debug_handles)
+               return FALSE;
+
+       memset (&data, 0, sizeof (data));
+       data.image = image;
+
+       mono_debugger_lock ();
+       g_hash_table_foreach (mono_debug_handles, lookup_image_func, &data);
+       mono_debugger_unlock ();
+       return data.found;
+}
+
 static inline void
 write_leb128 (guint32 value, guint8 *ptr, guint8 **rptr)
 {