Add mono_register_symfile_for_assembly() for bundles.
authorMartin Baulig <martin@novell.com>
Wed, 3 Nov 2010 19:40:03 +0000 (20:40 +0100)
committerMartin Baulig <martin@novell.com>
Wed, 3 Nov 2010 19:41:38 +0000 (20:41 +0100)
2010-11-03  Martin Baulig  <martin@ximian.com>

* mono-debug.c (mono_register_symfile_for_assembly): New method.
This is used together with mono_register_bundled_assemblies() and
mono_register_config_for_assembly() to support bundles.

mono/metadata/ChangeLog
mono/metadata/assembly.h
mono/metadata/mono-debug.c

index 5594580a9f676777a571b39168976bcbc83a317b..71269ceb5d89f068e5825450ec476f24cb20acc4 100644 (file)
@@ -1,3 +1,9 @@
+2010-11-03  Martin Baulig  <martin@ximian.com>
+
+       * mono-debug.c (mono_register_symfile_for_assembly): New method.
+       This is used together with mono_register_bundled_assemblies() and
+       mono_register_config_for_assembly() to support bundles.
+
 2010-07-30  Mark Probst  <mark.probst@gmail.com>
 
        * sgen-archdep.h (ARCH_COPY_SIGCTX_REGS): Add casts to fix
index ff06e2002295d3914f77cc964c50d46e1ee0df8a..0b8fd8dab8fb4b1f38de5d8e89ddd40665730c34 100644 (file)
@@ -99,6 +99,7 @@ typedef struct {
 
 void          mono_register_bundled_assemblies (const MonoBundledAssembly **assemblies);
 void          mono_register_config_for_assembly (const char* assembly_name, const char* config_xml);
+void          mono_register_symfile_for_assembly (const char* assembly_name, const mono_byte *raw_contents, int size);
 void         mono_register_machine_config (const char *config_xml);
 
 void          mono_set_rootdir (void);
index dcb48c5e088d24284aef52c5507e7fe89a013aaa..0c66d7e9729134459be8b11d8c8425ab1197e0f4 100644 (file)
@@ -123,6 +123,8 @@ static void                 mono_debug_add_assembly    (MonoAssembly *assembly,
                                                        gpointer user_data);
 static void                 mono_debug_add_type        (MonoClass *klass);
 
+static MonoDebugHandle     *open_symfile_from_bundle   (MonoImage *image);
+
 void _mono_debug_init_corlib (MonoDomain *domain);
 
 extern void (*mono_debugger_class_init_func) (MonoClass *klass);
@@ -429,8 +431,14 @@ mono_debug_open_image (MonoImage *image, const guint8 *raw_contents, int size)
 static void
 mono_debug_add_assembly (MonoAssembly *assembly, gpointer user_data)
 {
+       MonoDebugHandle *handle;
+       MonoImage *image;
+
        mono_debugger_lock ();
-       mono_debug_open_image (mono_assembly_get_image (assembly), NULL, 0);
+       image = mono_assembly_get_image (assembly);
+       handle = open_symfile_from_bundle (image);
+       if (!handle)
+               mono_debug_open_image (image, NULL, 0);
        mono_debugger_unlock ();
 }
 
@@ -1188,3 +1196,45 @@ mono_is_debugger_attached (void)
        return is_attached;
 }
 
+/*
+ * Bundles
+ */
+
+typedef struct _BundledSymfile BundledSymfile;
+
+struct _BundledSymfile {
+       BundledSymfile *next;
+       const char *aname;
+       const mono_byte *raw_contents;
+       int size;
+};
+
+static BundledSymfile *bundled_symfiles = NULL;
+
+void
+mono_register_symfile_for_assembly (const char *assembly_name, const mono_byte *raw_contents, int size)
+{
+       BundledSymfile *bsymfile;
+
+       bsymfile = g_new0 (BundledSymfile, 1);
+       bsymfile->aname = assembly_name;
+       bsymfile->raw_contents = raw_contents;
+       bsymfile->size = size;
+       bsymfile->next = bundled_symfiles;
+       bundled_symfiles = bsymfile;
+}
+
+static MonoDebugHandle *
+open_symfile_from_bundle (MonoImage *image)
+{
+       BundledSymfile *bsymfile;
+
+       for (bsymfile = bundled_symfiles; bsymfile; bsymfile = bsymfile->next) {
+               if (strcmp (bsymfile->aname, image->module_name))
+                       continue;
+
+               return mono_debug_open_image (image, bsymfile->raw_contents, bsymfile->size);
+       }
+
+       return NULL;
+}