コード例 #1
0
ファイル: mono-filemap.c プロジェクト: AnthonyTruchet/mono
guint64 
mono_file_map_size (MonoFileMap *fmap)
{
	struct stat stat_buf;
	if (fstat (mono_file_map_fd (fmap), &stat_buf) < 0)
		return 0;
	return stat_buf.st_size;
}
コード例 #2
0
ファイル: mono-filemap.c プロジェクト: AnthonyTruchet/mono
int 
mono_file_map_close (MonoFileMap *fmap)
{
#ifdef WIN32
	return fclose ((FILE*)fmap);
#else
	return close (mono_file_map_fd (fmap));
#endif
}
コード例 #3
0
MonoSymbolFile *
mono_debug_open_mono_symbols (MonoDebugHandle *handle, const uint8_t *raw_contents,
                              int size, gboolean in_the_debugger)
{
    MonoSymbolFile *symfile;

    mono_debugger_lock ();
    symfile = g_new0 (MonoSymbolFile, 1);

    if (raw_contents != NULL) {
        unsigned char *p;
        symfile->raw_contents_size = size;
        symfile->raw_contents = p = g_malloc (size);
        memcpy (p, raw_contents, size);
        symfile->filename = g_strdup_printf ("LoadedFromMemory");
        symfile->was_loaded_from_memory = TRUE;
    } else {
        MonoFileMap *f;
        symfile->filename = g_strdup_printf ("%s.mdb", mono_image_get_filename (handle->image));
        symfile->was_loaded_from_memory = FALSE;
        if ((f = mono_file_map_open (symfile->filename))) {
            symfile->raw_contents_size = mono_file_map_size (f);
            if (symfile->raw_contents_size == 0) {
                if (!in_the_debugger)
                    g_warning ("stat of %s failed: %s",
                               symfile->filename,  g_strerror (errno));
            } else {
                symfile->raw_contents = mono_file_map (symfile->raw_contents_size, MONO_MMAP_READ|MONO_MMAP_PRIVATE, mono_file_map_fd (f), 0, &symfile->raw_contents_handle);
            }

            mono_file_map_close (f);
        }
    }

    if (load_symfile (handle, symfile, in_the_debugger)) {
        mono_debugger_unlock ();
        return symfile;
    } else if (!in_the_debugger) {
        mono_debug_close_mono_symbol_file (symfile);
        mono_debugger_unlock ();
        return NULL;
    }

    mono_debugger_unlock ();
    return symfile;
}