X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fdumper.c;h=640309dc7ad024865f97905054d3a8afd9638163;hb=44ea030ec31ae441e59974eb9f6b2a9404611cd8;hp=93083dac33641ebc61847cbfe6cbc516ec657ffb;hpb=82f6d62ee211b1d36e8f45fed3ee3edde82b6916;p=chise%2Fxemacs-chise.git.1 diff --git a/src/dumper.c b/src/dumper.c index 93083da..1bb3172 100644 --- a/src/dumper.c +++ b/src/dumper.c @@ -22,7 +22,6 @@ Boston, MA 02111-1307, USA. */ #include #include "lisp.h" - #include "dump-id.h" #include "specifier.h" #include "alloc.h" @@ -31,13 +30,9 @@ Boston, MA 02111-1307, USA. */ #include "console-stream.h" #include "dumper.h" -#ifdef WIN32_NATIVE -#include "nt.h" -#else #ifdef HAVE_MMAP #include #endif -#endif #ifndef SEPCHAR #define SEPCHAR ':' @@ -105,14 +100,6 @@ typedef struct char *pdump_start, *pdump_end; static size_t pdump_length; - -#ifdef WIN32_NATIVE -// Handle for the dump file -HANDLE pdump_hFile = INVALID_HANDLE_VALUE; -// Handle for the file mapping object for the dump file -HANDLE pdump_hMap = INVALID_HANDLE_VALUE; -#endif - void (*pdump_free) (void); static const unsigned char align_table[256] = @@ -168,6 +155,7 @@ typedef struct static pdump_entry_list pdump_object_table[256]; static pdump_entry_list pdump_opaque_data_list; static pdump_struct_list pdump_struct_table; +static pdump_entry_list_elmt *pdump_qnil; static int pdump_alert_undump_object[256]; @@ -356,6 +344,7 @@ pdump_register_sub (const void *data, const struct lrecord_description *desc, in case XD_INT: case XD_LONG: case XD_BYTECOUNT: + case XD_LO_RESET_NIL: case XD_INT_RESET: case XD_LO_LINK: break; @@ -540,6 +529,16 @@ pdump_dump_data (pdump_entry_list_elmt *elmt, const struct lrecord_description * case XD_LONG: case XD_BYTECOUNT: break; + case XD_LO_RESET_NIL: + { + EMACS_INT num = desc[pos].data1; + int j; + if (XD_IS_INDIRECT (num)) + num = pdump_get_indirect_count (num, desc, elmt->obj); + for (j=0; jsave_offset; + break; + } case XD_INT_RESET: { EMACS_INT val = desc[pos].data1; @@ -656,11 +655,12 @@ pdump_reloc_one (void *data, EMACS_INT delta, const struct lrecord_description * if (POINTER_TYPE_P (XTYPE (*pobj)) && ! EQ (*pobj, Qnull_pointer)) - XSETOBJ (*pobj, (char *) XPNTR (*pobj) + delta); + XSETOBJ (*pobj, XTYPE (*pobj), (char *) XPNTR (*pobj) + delta); break; } case XD_LISP_OBJECT_ARRAY: + case XD_LO_RESET_NIL: { EMACS_INT num = desc[pos].data1; int j; @@ -673,7 +673,7 @@ pdump_reloc_one (void *data, EMACS_INT delta, const struct lrecord_description * if (POINTER_TYPE_P (XTYPE (*pobj)) && ! EQ (*pobj, Qnull_pointer)) - XSETOBJ (*pobj, (char *) XPNTR (*pobj) + delta); + XSETOBJ (*pobj, XTYPE (*pobj), (char *) XPNTR (*pobj) + delta); } break; } @@ -892,8 +892,6 @@ pdump (void) int none; dump_header hd; - flush_all_buffer_local_cache (); - /* These appear in a DEFVAR_LISP, which does a staticpro() */ t_console = Vterminal_console; t_frame = Vterminal_frame; @@ -951,6 +949,7 @@ pdump (void) max_size = 0; pdump_scan_by_alignment (pdump_allocate_offset); + pdump_qnil = pdump_get_entry (XRECORD_LHEADER (Qnil)); pdump_buf = xmalloc (max_size); /* Avoid use of the `open' macro. We want the real function. */ @@ -1011,7 +1010,7 @@ static int pdump_load_finish (void) { Lisp_Object obj = PDUMP_READ (p, Lisp_Object); if (POINTER_TYPE_P (XTYPE (obj))) - XSETOBJ (obj, (char *) XPNTR (obj) + delta); + XSETOBJ (obj, XTYPE (obj), (char *) XPNTR (obj) + delta); *staticvec[i] = obj; } @@ -1069,7 +1068,7 @@ static int pdump_load_finish (void) Lisp_Object obj = PDUMP_READ (p, Lisp_Object); if (POINTER_TYPE_P (XTYPE (obj))) - XSETOBJ (obj, (char *) XPNTR (obj) + delta); + XSETOBJ (obj, XTYPE (obj), (char *) XPNTR (obj) + delta); *var = obj; } @@ -1091,42 +1090,43 @@ static int pdump_load_finish (void) p += sizeof (Lisp_Object) * rt.count; } + /* Put back noninteractive1 to its real value */ + noninteractive1 = noninteractive; + return 1; } -#ifdef WIN32_NATIVE -/* Free the mapped file if we decide we don't want it after all */ +#ifdef WINDOWSNT static void pdump_file_unmap(void) { - UnmapViewOfFile (pdump_start); - CloseHandle (pdump_hFile); - CloseHandle (pdump_hMap); } static int pdump_file_get(const char *path) { - - pdump_hFile = CreateFile (path, - GENERIC_READ + GENERIC_WRITE, /* Required for copy on write */ - 0, /* Not shared */ - NULL, /* Not inheritable */ - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); /* No template file */ - if (pdump_hFile == INVALID_HANDLE_VALUE) + HANDLE hFile; + HANDLE hMap; + + hFile = CreateFile (path, + GENERIC_READ + GENERIC_WRITE, /* Required for copy on write */ + 0, /* Not shared */ + NULL, /* Not inheritable */ + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); /* No template file */ + if (hFile == INVALID_HANDLE_VALUE) return 0; - pdump_length = GetFileSize (pdump_hFile, NULL); - pdump_hMap = CreateFileMapping (pdump_hFile, - NULL, /* No security attributes */ - PAGE_WRITECOPY, /* Copy on write */ - 0, /* Max size, high half */ - 0, /* Max size, low half */ - NULL); /* Unnamed */ - if (pdump_hMap == INVALID_HANDLE_VALUE) + pdump_length = GetFileSize (hFile, NULL); + hMap = CreateFileMapping (hFile, + NULL, /* No security attributes */ + PAGE_WRITECOPY, /* Copy on write */ + 0, /* Max size, high half */ + 0, /* Max size, low half */ + NULL); /* Unnamed */ + if (hMap == INVALID_HANDLE_VALUE) return 0; - pdump_start = MapViewOfFile (pdump_hMap, + pdump_start = MapViewOfFile (hMap, FILE_MAP_COPY, /* Copy on write */ 0, /* Start at zero */ 0, @@ -1135,15 +1135,7 @@ static int pdump_file_get(const char *path) return 1; } -/* pdump_resource_free is called (via the pdump_free pointer) to release - any resources allocated by pdump_resource_get. Since the Windows API - specs specifically state that you don't need to (and shouldn't) free the - resources allocated by FindResource, LoadResource, and LockResource this - routine does nothing. */ static void pdump_resource_free (void) -{ -} - static int pdump_resource_get (void) { HRSRC hRes; /* Handle to dump resource */ @@ -1182,7 +1174,7 @@ static int pdump_resource_get (void) return 1; } -#else /* !WIN32_NATIVE */ +#else /* !WINDOWSNT */ static void *pdump_mallocadr; @@ -1226,12 +1218,12 @@ static int pdump_file_get(const char *path) pdump_mallocadr = xmalloc(pdump_length+255); pdump_free = pdump_file_free; pdump_start = (char *)((255 + (unsigned long)pdump_mallocadr) & ~255); - read (fd, pdump_start, pdump_length); + read (pdump_fd, pdump_start, pdump_length); - close (fd); + close (pdump_fd); return 1; } -#endif /* !WIN32_NATIVE */ +#endif /* !WINDOWSNT */ static int pdump_file_try(char *exe_path) @@ -1248,7 +1240,7 @@ static int pdump_file_try(char *exe_path) return 1; pdump_free(); } - + sprintf (w, "-%08x.dmp", dump_id); if (pdump_file_get (exe_path)) { @@ -1256,7 +1248,7 @@ static int pdump_file_try(char *exe_path) return 1; pdump_free(); } - + sprintf (w, ".dmp"); if (pdump_file_get (exe_path)) { @@ -1264,10 +1256,10 @@ static int pdump_file_try(char *exe_path) return 1; pdump_free(); } - + do w--; - while (w>exe_path && !IS_DIRECTORY_SEP (*w) && (*w != '-') && (*w != '.')); + while (w>exe_path && !IS_DIRECTORY_SEP (*w) && (*w != '-') && (*w != '.')); } while (w>exe_path && !IS_DIRECTORY_SEP (*w)); return 0; @@ -1276,10 +1268,10 @@ static int pdump_file_try(char *exe_path) int pdump_load(const char *argv0) { char exe_path[PATH_MAX]; -#ifdef WIN32_NATIVE - GetModuleFileName (NULL, exe_path, PATH_MAX); -#else /* !WIN32_NATIVE */ char *w; +#ifdef WINDOWSNT + GetModuleFileName (NULL, exe_name, PATH_MAX); +#else /* !WINDOWSNT */ const char *dir, *p; dir = argv0; @@ -1291,7 +1283,7 @@ int pdump_load(const char *argv0) p = dir + strlen(dir); while (p != dir && !IS_ANY_SEP (p[-1])) p--; - + if (p != dir) { /* invocation-name includes a directory component -- presumably it @@ -1322,12 +1314,12 @@ int pdump_load(const char *argv0) *w++ = '/'; } strcpy(w, name); - + /* ### #$%$#^$^@%$^#%@$ ! */ #ifdef access #undef access #endif - + if (!access (exe_path, X_OK)) break; if (!*p) @@ -1336,10 +1328,10 @@ int pdump_load(const char *argv0) sprintf (exe_path, "./%s", name); break; } - path = p+1; + path = p+1; } } -#endif /* WIN32_NATIVE */ +#endif /* WINDOWSNT */ if (pdump_file_try (exe_path)) { @@ -1347,7 +1339,7 @@ int pdump_load(const char *argv0) return 1; } -#ifdef WIN32_NATIVE +#ifdef WINDOWSNT if (pdump_resource_get ()) { if (pdump_load_check ())