- symfile->filename = g_strdup_printf ("%s.mdb", mono_image_get_filename (handle->image));
-
- if (!g_file_get_contents (symfile->filename, (gchar **) &symfile->raw_contents,
- &symfile->raw_contents_size, NULL))
- symfile->raw_contents = NULL;
-
- if (load_symfile (handle, symfile)) {
- mono_loader_unlock ();
+ if (raw_contents != NULL) {
+ symfile->raw_contents_size = size;
+ symfile->raw_contents = g_malloc (size);
+ memcpy(symfile->raw_contents, raw_contents, size);
+ symfile->filename = g_strdup_printf ("LoadedFromMemory");
+ } else {
+ symfile->filename = g_strdup_printf ("%s.mdb", mono_image_get_filename (handle->image));
+
+ if ((f = fopen (symfile->filename, "rb"))) {
+ struct stat stat_buf;
+
+ if (fstat (fileno (f), &stat_buf) < 0) {
+ if (!in_the_debugger)
+ g_warning ("stat of %s failed: %s",
+ symfile->filename, g_strerror (errno));
+ } else {
+ symfile->raw_contents_size = stat_buf.st_size;
+ symfile->raw_contents = mono_raw_buffer_load (fileno (f), FALSE, 0, stat_buf.st_size);
+ }
+
+ fclose (f);
+ }
+ }
+
+ if (load_symfile (handle, symfile, in_the_debugger)) {
+ mono_debugger_unlock ();