2002-03-23 Martin Baulig <martin@gnome.org>
authorMartin Baulig <martin@novell.com>
Sat, 23 Mar 2002 10:42:54 +0000 (10:42 -0000)
committerMartin Baulig <martin@novell.com>
Sat, 23 Mar 2002 10:42:54 +0000 (10:42 -0000)
* rawbuffer.c (mono_raw_buffer_load_mmap): Use MAP_SHARED when
is_writeable is set.
(mono_raw_buffer_update): New function to write the modified map
back to disk.

* debug-symfile.h (MonoDebugSymbolFile): Added `raw_contents_size'.

* debug-symfile.c (mono_debug_update_symbol_file): Call
mono_raw_buffer_update() when done writing.

svn path=/trunk/mono/; revision=3280

mono/metadata/ChangeLog
mono/metadata/debug-symfile.c
mono/metadata/debug-symfile.h
mono/metadata/rawbuffer.c
mono/metadata/rawbuffer.h

index 099ef1a3a2b9a0a594b9defd4ffe986cc1503244..e0e3b773387c651f6ab03b50523b89b040d0017f 100644 (file)
@@ -1,3 +1,15 @@
+2002-03-23  Martin Baulig  <martin@gnome.org>
+
+       * rawbuffer.c (mono_raw_buffer_load_mmap): Use MAP_SHARED when
+       is_writeable is set.
+       (mono_raw_buffer_update): New function to write the modified map
+       back to disk.
+
+       * debug-symfile.h (MonoDebugSymbolFile): Added `raw_contents_size'.
+
+       * debug-symfile.c (mono_debug_update_symbol_file): Call
+       mono_raw_buffer_update() when done writing.
+
 2002-03-23  Martin Baulig  <martin@gnome.org>
 
        * debug-symfile.h (MONO_DEBUG_SYMBOL_FILE_VERSION): Increased to 5.
index 0c4d509cede2fed3a796ad225bfe2ab3b9bf0234..a296d0dc904ca9f50894c1b6f132158f5ff02792 100644 (file)
@@ -154,6 +154,7 @@ mono_debug_open_symbol_file (MonoImage *image, const char *filename, gboolean em
        symfile->file_name = g_strdup (filename);
        symfile->image = image;
        symfile->raw_contents = ptr;
+       symfile->raw_contents_size = file_size;
 
        if (!get_sections (symfile, emit_warnings)) {
                mono_debug_close_symbol_file (symfile);
@@ -372,4 +373,6 @@ mono_debug_update_symbol_file (MonoDebugSymbolFile *symfile,
                        break;
                }
        }
+
+       mono_raw_buffer_update (symfile->raw_contents, symfile->raw_contents_size);
 }
index 9e07cdbcd80d149b6a05f34c40a21697a89c98dd..0252ece00eebf2886c9696f06f34186ccaf165eb 100644 (file)
@@ -37,6 +37,7 @@ struct MonoDebugSymbolFile {
        MonoImage *image;
        /* Pointer to the mmap()ed contents of the file. */
        void *raw_contents;
+       size_t raw_contents_size;
        /* Array of MONO_DEBUG_SYMBOL_SECTION_MAX elements. */
        MonoDebugSymbolFileSection *section_offsets;
        gpointer user_data;
index 833721accbe2db94e9ed7d1d5dff3d6b59afb85a..b8d75b97a57d931c029e20b26398245a9d2aabb3 100644 (file)
@@ -124,8 +124,10 @@ mono_raw_buffer_load_mmap (int fd, int is_writable, guint32 base, size_t size)
 
        if (is_writable){
                prot |= PROT_WRITE;
+               flags = MAP_SHARED;
+       } else {
+               flags = MAP_PRIVATE;
        }
-       flags = MAP_PRIVATE;
 
        ptr = mmap (0, end - start, prot, flags, fd, start);
 
@@ -156,6 +158,16 @@ mono_raw_buffer_free_mmap (void *base)
 #endif
 }
 
+static void
+mono_raw_buffer_update_mmap (void *base, size_t size)
+{
+#ifdef USE_WIN32_API
+       FlushViewOfFile (base, size);
+#else
+       msync (base, size, MS_SYNC);
+#endif
+}
+
 void *
 mono_raw_buffer_load (int fd, int is_writable, guint32 base, size_t size)
 {
@@ -168,6 +180,17 @@ mono_raw_buffer_load (int fd, int is_writable, guint32 base, size_t size)
        return ptr;
 }
 
+void
+mono_raw_buffer_update (void *buffer, size_t size)
+{
+       char *mmap_base;
+
+       mmap_base = GINT_TO_POINTER (ROUND_DOWN (GPOINTER_TO_INT (buffer), alignment));
+       
+       if (mmap_map && g_hash_table_lookup (mmap_map, mmap_base))
+               mono_raw_buffer_update_mmap (mmap_base, size);
+}
+
 void
 mono_raw_buffer_free (void *buffer)
 {
index 12f1a05a3365a2b12f0e6d93afe5e4db3c77d4a7..47232a2639f32325c14feecd0ce9eebee6a90d63 100644 (file)
@@ -1,3 +1,4 @@
 
 void *mono_raw_buffer_load (int fd, int writable, guint32 base, size_t size);
+void mono_raw_buffer_update (void *buffer, size_t size);
 void  mono_raw_buffer_free (void *buffer);