442
|
1 /* Portable data dumper for XEmacs.
|
|
2 Copyright (C) 1999-2000 Olivier Galibert
|
458
|
3 Copyright (C) 2001 Martin Buchholz
|
826
|
4 Copyright (C) 2001, 2002 Ben Wing.
|
442
|
5
|
|
6 This file is part of XEmacs.
|
|
7
|
|
8 XEmacs is free software; you can redistribute it and/or modify it
|
|
9 under the terms of the GNU General Public License as published by the
|
|
10 Free Software Foundation; either version 2, or (at your option) any
|
|
11 later version.
|
|
12
|
|
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
16 for more details.
|
|
17
|
|
18 You should have received a copy of the GNU General Public License
|
|
19 along with XEmacs; see the file COPYING. If not, write to
|
|
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
21 Boston, MA 02111-1307, USA. */
|
|
22
|
|
23 /* Synched up with: Not in FSF. */
|
|
24
|
800
|
25 /* !!#### Not yet Mule-ized */
|
|
26
|
442
|
27 #include <config.h>
|
|
28 #include "lisp.h"
|
|
29
|
|
30 #include "specifier.h"
|
771
|
31 #include "file-coding.h"
|
442
|
32 #include "elhash.h"
|
1204
|
33 #include "lstream.h"
|
442
|
34 #include "sysfile.h"
|
|
35 #include "console-stream.h"
|
|
36
|
|
37 #ifdef WIN32_NATIVE
|
771
|
38 #include "syswindows.h"
|
442
|
39 #else
|
|
40 #ifdef HAVE_MMAP
|
|
41 #include <sys/mman.h>
|
|
42 #endif
|
|
43 #endif
|
|
44
|
|
45 typedef struct
|
|
46 {
|
545
|
47 const void *varaddress;
|
665
|
48 Bytecount size;
|
1204
|
49 const struct memory_description *desc;
|
|
50 } pdump_root_block;
|
452
|
51
|
|
52 typedef struct
|
|
53 {
|
1204
|
54 Dynarr_declare (pdump_root_block);
|
|
55 } pdump_root_block_dynarr;
|
452
|
56
|
|
57 typedef struct
|
|
58 {
|
|
59 void **ptraddress;
|
1204
|
60 const struct sized_memory_description *desc;
|
452
|
61 } pdump_root_struct_ptr;
|
|
62
|
|
63 typedef struct
|
|
64 {
|
|
65 Dynarr_declare (pdump_root_struct_ptr);
|
|
66 } pdump_root_struct_ptr_dynarr;
|
|
67
|
458
|
68 typedef struct
|
|
69 {
|
|
70 Lisp_Object *address;
|
|
71 Lisp_Object value;
|
|
72 } pdump_static_Lisp_Object;
|
|
73
|
|
74 typedef struct
|
|
75 {
|
|
76 char **address; /* char * for ease of doing relocation */
|
|
77 char * value;
|
|
78 } pdump_static_pointer;
|
|
79
|
1204
|
80 static pdump_root_block_dynarr *pdump_root_blocks;
|
452
|
81 static pdump_root_struct_ptr_dynarr *pdump_root_struct_ptrs;
|
1204
|
82 static Lisp_Object_ptr_dynarr *pdump_root_lisp_objects;
|
452
|
83 static Lisp_Object_ptr_dynarr *pdump_weak_object_chains;
|
|
84
|
1204
|
85 /* Mark SIZE bytes at non-heap address VARADDRESS for dumping, described
|
|
86 by DESC. */
|
452
|
87 void
|
1204
|
88 dump_add_root_block (const void *varaddress, Bytecount size,
|
|
89 const struct memory_description *desc)
|
452
|
90 {
|
1204
|
91 pdump_root_block info;
|
452
|
92 info.varaddress = varaddress;
|
|
93 info.size = size;
|
1204
|
94 info.desc = desc;
|
|
95 if (pdump_root_blocks == NULL)
|
|
96 pdump_root_blocks = Dynarr_new (pdump_root_block);
|
|
97 Dynarr_add (pdump_root_blocks, info);
|
452
|
98 }
|
|
99
|
|
100 /* Mark the struct described by DESC and pointed to by the pointer at
|
|
101 non-heap address VARADDRESS for dumping.
|
|
102 All the objects reachable from this pointer will also be dumped. */
|
|
103 void
|
771
|
104 dump_add_root_struct_ptr (void *ptraddress,
|
1204
|
105 const struct sized_memory_description *desc)
|
452
|
106 {
|
|
107 pdump_root_struct_ptr info;
|
|
108 info.ptraddress = (void **) ptraddress;
|
|
109 info.desc = desc;
|
|
110 if (pdump_root_struct_ptrs == NULL)
|
|
111 pdump_root_struct_ptrs = Dynarr_new (pdump_root_struct_ptr);
|
|
112 Dynarr_add (pdump_root_struct_ptrs, info);
|
|
113 }
|
|
114
|
|
115 /* Mark the Lisp_Object at non-heap address VARADDRESS for dumping.
|
|
116 All the objects reachable from this var will also be dumped. */
|
|
117 void
|
1204
|
118 dump_add_root_lisp_object (Lisp_Object *varaddress)
|
452
|
119 {
|
1204
|
120 if (pdump_root_lisp_objects == NULL)
|
|
121 pdump_root_lisp_objects = Dynarr_new2 (Lisp_Object_ptr_dynarr, Lisp_Object *);
|
|
122 Dynarr_add (pdump_root_lisp_objects, varaddress);
|
452
|
123 }
|
|
124
|
|
125 /* Mark the list pointed to by the Lisp_Object at VARADDRESS for dumping. */
|
|
126 void
|
|
127 dump_add_weak_object_chain (Lisp_Object *varaddress)
|
|
128 {
|
|
129 if (pdump_weak_object_chains == NULL)
|
|
130 pdump_weak_object_chains = Dynarr_new2 (Lisp_Object_ptr_dynarr, Lisp_Object *);
|
|
131 Dynarr_add (pdump_weak_object_chains, varaddress);
|
|
132 }
|
|
133
|
|
134
|
458
|
135 inline static void
|
665
|
136 pdump_align_stream (FILE *stream, Bytecount alignment)
|
458
|
137 {
|
|
138 long offset = ftell (stream);
|
|
139 long adjustment = ALIGN_SIZE (offset, alignment) - offset;
|
|
140 if (adjustment)
|
|
141 fseek (stream, adjustment, SEEK_CUR);
|
|
142 }
|
|
143
|
|
144 #define PDUMP_ALIGN_OUTPUT(type) pdump_align_stream (pdump_out, ALIGNOF (type))
|
|
145
|
|
146 #define PDUMP_WRITE(type, object) \
|
771
|
147 retry_fwrite (&object, sizeof (object), 1, pdump_out);
|
458
|
148
|
|
149 #define PDUMP_WRITE_ALIGNED(type, object) do { \
|
|
150 PDUMP_ALIGN_OUTPUT (type); \
|
|
151 PDUMP_WRITE (type, object); \
|
|
152 } while (0)
|
|
153
|
|
154 #define PDUMP_READ(ptr, type) \
|
|
155 (((type *) (ptr = (char*) (((type *) ptr) + 1)))[-1])
|
|
156
|
|
157 #define PDUMP_READ_ALIGNED(ptr, type) \
|
826
|
158 ((ptr = (char *) ALIGN_PTR (ptr, type)), PDUMP_READ (ptr, type))
|
458
|
159
|
|
160
|
|
161
|
452
|
162 typedef struct
|
|
163 {
|
1204
|
164 const struct memory_description *desc;
|
442
|
165 int count;
|
|
166 } pdump_reloc_table;
|
|
167
|
|
168 static char *pdump_rt_list = 0;
|
|
169
|
|
170 void
|
|
171 pdump_objects_unmark (void)
|
|
172 {
|
|
173 int i;
|
|
174 char *p = pdump_rt_list;
|
|
175 if (p)
|
|
176 for (;;)
|
|
177 {
|
|
178 pdump_reloc_table *rt = (pdump_reloc_table *)p;
|
|
179 p += sizeof (pdump_reloc_table);
|
|
180 if (rt->desc)
|
|
181 {
|
|
182 for (i=0; i<rt->count; i++)
|
|
183 {
|
|
184 struct lrecord_header *lh = * (struct lrecord_header **) p;
|
|
185 if (! C_READONLY_RECORD_HEADER_P (lh))
|
|
186 UNMARK_RECORD_HEADER (lh);
|
|
187 p += sizeof (EMACS_INT);
|
|
188 }
|
|
189 } else
|
|
190 break;
|
|
191 }
|
|
192 }
|
|
193
|
|
194
|
1204
|
195 /* The structure of the dump file looks like this:
|
458
|
196 0 - header
|
|
197 - dumped objects
|
1204
|
198 stab_offset - nb_root_struct_ptrs*struct(void *, adr)
|
|
199 for global pointers to structures
|
|
200 - nb_root_blocks*struct(void *, size, info) for global
|
|
201 objects to restore
|
458
|
202 - relocation table
|
|
203 - root lisp object address/value couples with the count
|
|
204 preceding the list
|
442
|
205 */
|
|
206
|
|
207
|
452
|
208 #define PDUMP_SIGNATURE "XEmacsDP"
|
|
209 #define PDUMP_SIGNATURE_LEN (sizeof (PDUMP_SIGNATURE) - 1)
|
442
|
210
|
|
211 typedef struct
|
|
212 {
|
452
|
213 char signature[PDUMP_SIGNATURE_LEN];
|
442
|
214 unsigned int id;
|
|
215 EMACS_UINT stab_offset;
|
|
216 EMACS_UINT reloc_address;
|
452
|
217 int nb_root_struct_ptrs;
|
1204
|
218 int nb_root_blocks;
|
452
|
219 } pdump_header;
|
442
|
220
|
458
|
221 char *pdump_start;
|
|
222 char *pdump_end;
|
665
|
223 static Bytecount pdump_length;
|
442
|
224
|
|
225 #ifdef WIN32_NATIVE
|
452
|
226 /* Handle for the dump file */
|
458
|
227 static HANDLE pdump_hFile = INVALID_HANDLE_VALUE;
|
452
|
228 /* Handle for the file mapping object for the dump file */
|
458
|
229 static HANDLE pdump_hMap = INVALID_HANDLE_VALUE;
|
442
|
230 #endif
|
|
231
|
458
|
232 static void (*pdump_free) (void);
|
442
|
233
|
460
|
234 static unsigned char pdump_align_table[] =
|
442
|
235 {
|
460
|
236 64, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1,
|
|
237 16, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1,
|
|
238 32, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1,
|
|
239 16, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1
|
442
|
240 };
|
|
241
|
647
|
242 static inline int
|
665
|
243 pdump_size_to_align (Bytecount size)
|
442
|
244 {
|
460
|
245 return pdump_align_table[size % countof (pdump_align_table)];
|
|
246 }
|
|
247
|
|
248 typedef struct pdump_entry_list_elt
|
|
249 {
|
|
250 struct pdump_entry_list_elt *next;
|
442
|
251 const void *obj;
|
665
|
252 Bytecount size;
|
442
|
253 int count;
|
|
254 EMACS_INT save_offset;
|
460
|
255 } pdump_entry_list_elt;
|
442
|
256
|
|
257 typedef struct
|
|
258 {
|
460
|
259 pdump_entry_list_elt *first;
|
442
|
260 int align;
|
|
261 int count;
|
|
262 } pdump_entry_list;
|
|
263
|
460
|
264 typedef struct pdump_struct_list_elt
|
442
|
265 {
|
|
266 pdump_entry_list list;
|
1204
|
267 const struct memory_description *desc;
|
460
|
268 } pdump_struct_list_elt;
|
442
|
269
|
|
270 typedef struct
|
|
271 {
|
460
|
272 pdump_struct_list_elt *list;
|
442
|
273 int count;
|
|
274 int size;
|
|
275 } pdump_struct_list;
|
|
276
|
460
|
277 static pdump_entry_list *pdump_object_table;
|
442
|
278 static pdump_entry_list pdump_opaque_data_list;
|
|
279 static pdump_struct_list pdump_struct_table;
|
|
280
|
460
|
281 static int *pdump_alert_undump_object;
|
442
|
282
|
|
283 static unsigned long cur_offset;
|
665
|
284 static Bytecount max_size;
|
442
|
285 static int pdump_fd;
|
|
286 static void *pdump_buf;
|
458
|
287 static FILE *pdump_out;
|
442
|
288
|
|
289 #define PDUMP_HASHSIZE 200001
|
|
290
|
460
|
291 static pdump_entry_list_elt **pdump_hash;
|
442
|
292
|
|
293 /* Since most pointers are eight bytes aligned, the >>3 allows for a better hash */
|
|
294 static int
|
|
295 pdump_make_hash (const void *obj)
|
|
296 {
|
|
297 return ((unsigned long)(obj)>>3) % PDUMP_HASHSIZE;
|
|
298 }
|
|
299
|
460
|
300 static pdump_entry_list_elt *
|
442
|
301 pdump_get_entry (const void *obj)
|
|
302 {
|
|
303 int pos = pdump_make_hash (obj);
|
460
|
304 pdump_entry_list_elt *e;
|
442
|
305
|
|
306 assert (obj != 0);
|
|
307
|
|
308 while ((e = pdump_hash[pos]) != 0)
|
|
309 {
|
|
310 if (e->obj == obj)
|
|
311 return e;
|
|
312
|
|
313 pos++;
|
|
314 if (pos == PDUMP_HASHSIZE)
|
|
315 pos = 0;
|
|
316 }
|
|
317 return 0;
|
|
318 }
|
|
319
|
|
320 static void
|
665
|
321 pdump_add_entry (pdump_entry_list *list, const void *obj, Bytecount size,
|
458
|
322 int count)
|
442
|
323 {
|
460
|
324 pdump_entry_list_elt *e;
|
442
|
325 int pos = pdump_make_hash (obj);
|
|
326
|
|
327 while ((e = pdump_hash[pos]) != 0)
|
|
328 {
|
|
329 if (e->obj == obj)
|
|
330 return;
|
|
331
|
|
332 pos++;
|
|
333 if (pos == PDUMP_HASHSIZE)
|
|
334 pos = 0;
|
|
335 }
|
|
336
|
460
|
337 e = xnew (pdump_entry_list_elt);
|
442
|
338
|
|
339 e->next = list->first;
|
|
340 e->obj = obj;
|
|
341 e->size = size;
|
|
342 e->count = count;
|
|
343 list->first = e;
|
|
344
|
|
345 list->count += count;
|
|
346 pdump_hash[pos] = e;
|
|
347
|
460
|
348 {
|
|
349 int align = pdump_size_to_align (size);
|
442
|
350
|
460
|
351 if (align < list->align)
|
|
352 list->align = align;
|
|
353 }
|
442
|
354 }
|
|
355
|
|
356 static pdump_entry_list *
|
1204
|
357 pdump_get_entry_list (const struct memory_description *desc)
|
442
|
358 {
|
|
359 int i;
|
|
360 for (i=0; i<pdump_struct_table.count; i++)
|
1204
|
361 if (pdump_struct_table.list[i].desc == desc)
|
442
|
362 return &pdump_struct_table.list[i].list;
|
|
363
|
|
364 if (pdump_struct_table.size <= pdump_struct_table.count)
|
|
365 {
|
|
366 if (pdump_struct_table.size == -1)
|
|
367 pdump_struct_table.size = 10;
|
|
368 else
|
|
369 pdump_struct_table.size = pdump_struct_table.size * 2;
|
460
|
370 pdump_struct_table.list = (pdump_struct_list_elt *)
|
442
|
371 xrealloc (pdump_struct_table.list,
|
460
|
372 pdump_struct_table.size * sizeof (pdump_struct_list_elt));
|
442
|
373 }
|
|
374 pdump_struct_table.list[pdump_struct_table.count].list.first = 0;
|
460
|
375 pdump_struct_table.list[pdump_struct_table.count].list.align = ALIGNOF (max_align_t);
|
442
|
376 pdump_struct_table.list[pdump_struct_table.count].list.count = 0;
|
1204
|
377 pdump_struct_table.list[pdump_struct_table.count].desc = desc;
|
442
|
378
|
|
379 return &pdump_struct_table.list[pdump_struct_table.count++].list;
|
|
380 }
|
|
381
|
|
382 static struct
|
|
383 {
|
|
384 struct lrecord_header *obj;
|
|
385 int position;
|
|
386 int offset;
|
|
387 } backtrace[65536];
|
|
388
|
1204
|
389 static int pdump_depth;
|
442
|
390
|
1204
|
391 void
|
452
|
392 pdump_backtrace (void)
|
442
|
393 {
|
|
394 int i;
|
|
395 stderr_out ("pdump backtrace :\n");
|
1204
|
396 for (i = 0; i < pdump_depth; i++)
|
442
|
397 {
|
|
398 if (!backtrace[i].obj)
|
458
|
399 stderr_out (" - ind. (%d, %d)\n",
|
|
400 backtrace[i].position,
|
|
401 backtrace[i].offset);
|
442
|
402 else
|
|
403 {
|
|
404 stderr_out (" - %s (%d, %d)\n",
|
1204
|
405 LHEADER_IMPLEMENTATION (backtrace[i].obj)->name,
|
|
406 backtrace[i].position,
|
|
407 backtrace[i].offset);
|
442
|
408 }
|
|
409 }
|
|
410 }
|
|
411
|
1204
|
412 static void
|
|
413 pdump_bump_depth (void)
|
|
414 {
|
|
415 int me = pdump_depth++;
|
|
416 if (me > 65536)
|
|
417 {
|
|
418 stderr_out ("Backtrace overflow, loop ?\n");
|
|
419 abort ();
|
|
420 }
|
|
421 backtrace[me].obj = 0;
|
|
422 backtrace[me].position = 0;
|
|
423 backtrace[me].offset = 0;
|
|
424 }
|
|
425
|
442
|
426 static void pdump_register_object (Lisp_Object obj);
|
771
|
427 static void pdump_register_struct_contents (const void *data,
|
1204
|
428 const struct sized_memory_description *
|
771
|
429 sdesc,
|
|
430 int count);
|
458
|
431 static void pdump_register_struct (const void *data,
|
1204
|
432 const struct sized_memory_description *sdesc,
|
458
|
433 int count);
|
442
|
434
|
|
435 static void
|
1204
|
436 pdump_register_sub (const void *data, const struct memory_description *desc)
|
442
|
437 {
|
|
438 int pos;
|
1204
|
439 int me = pdump_depth - 1;
|
442
|
440
|
|
441 for (pos = 0; desc[pos].type != XD_END; pos++)
|
|
442 {
|
1204
|
443 const struct memory_description *desc1 = &desc[pos];
|
|
444 EMACS_INT offset = lispdesc_indirect_count (desc1->offset, desc,
|
|
445 data);
|
|
446 const void *rdata = (const char *) data + offset;
|
442
|
447
|
|
448 backtrace[me].position = pos;
|
1204
|
449 backtrace[me].offset = offset;
|
|
450
|
|
451 union_switcheroo:
|
442
|
452
|
1204
|
453 /* If the flag says don't dump, then don't dump. */
|
|
454 if ((desc1->flags) & XD_FLAG_NO_PDUMP)
|
|
455 continue;
|
|
456
|
|
457 switch (desc1->type)
|
442
|
458 {
|
665
|
459 case XD_BYTECOUNT:
|
|
460 case XD_ELEMCOUNT:
|
|
461 case XD_HASHCODE:
|
442
|
462 case XD_INT:
|
|
463 case XD_LONG:
|
|
464 case XD_INT_RESET:
|
|
465 case XD_LO_LINK:
|
|
466 break;
|
|
467 case XD_OPAQUE_DATA_PTR:
|
|
468 {
|
1204
|
469 EMACS_INT count = lispdesc_indirect_count (desc1->data1, desc,
|
|
470 data);
|
442
|
471
|
|
472 pdump_add_entry (&pdump_opaque_data_list,
|
458
|
473 *(void **)rdata, count, 1);
|
442
|
474 break;
|
|
475 }
|
|
476 case XD_C_STRING:
|
|
477 {
|
1204
|
478 const char *str = * (const char **) rdata;
|
442
|
479 if (str)
|
1204
|
480 pdump_add_entry (&pdump_opaque_data_list, str, strlen (str) + 1,
|
|
481 1);
|
442
|
482 break;
|
|
483 }
|
|
484 case XD_DOC_STRING:
|
|
485 {
|
1204
|
486 const char *str = * (const char **) rdata;
|
|
487 if ((EMACS_INT) str > 0)
|
|
488 pdump_add_entry (&pdump_opaque_data_list, str, strlen (str) + 1,
|
|
489 1);
|
442
|
490 break;
|
|
491 }
|
|
492 case XD_LISP_OBJECT:
|
|
493 {
|
1204
|
494 const Lisp_Object *pobj = (const Lisp_Object *) rdata;
|
442
|
495
|
1204
|
496 assert (desc1->data1 == 0);
|
442
|
497
|
1204
|
498 backtrace[me].offset = (const char *) pobj - (const char *) data;
|
442
|
499 pdump_register_object (*pobj);
|
|
500 break;
|
|
501 }
|
|
502 case XD_LISP_OBJECT_ARRAY:
|
|
503 {
|
|
504 int i;
|
1204
|
505 EMACS_INT count = lispdesc_indirect_count (desc1->data1, desc,
|
|
506 data);
|
442
|
507
|
|
508 for (i = 0; i < count; i++)
|
|
509 {
|
1204
|
510 const Lisp_Object *pobj = ((const Lisp_Object *) rdata) + i;
|
442
|
511 Lisp_Object dobj = *pobj;
|
|
512
|
1204
|
513 backtrace[me].offset =
|
|
514 (const char *) pobj - (const char *) data;
|
442
|
515 pdump_register_object (dobj);
|
|
516 }
|
|
517 break;
|
|
518 }
|
|
519 case XD_STRUCT_PTR:
|
|
520 {
|
1204
|
521 EMACS_INT count = lispdesc_indirect_count (desc1->data1, desc,
|
|
522 data);
|
|
523 const struct sized_memory_description *sdesc =
|
|
524 lispdesc_indirect_description (data, desc1->data2);
|
442
|
525 const char *dobj = *(const char **)rdata;
|
|
526 if (dobj)
|
1204
|
527 pdump_register_struct (dobj, sdesc, count);
|
442
|
528 break;
|
|
529 }
|
771
|
530 case XD_STRUCT_ARRAY:
|
|
531 {
|
1204
|
532 EMACS_INT count = lispdesc_indirect_count (desc1->data1, desc,
|
|
533 data);
|
|
534 const struct sized_memory_description *sdesc =
|
|
535 lispdesc_indirect_description (data, desc1->data2);
|
771
|
536
|
|
537 pdump_register_struct_contents (rdata, sdesc, count);
|
|
538 break;
|
|
539 }
|
|
540 case XD_UNION:
|
1204
|
541 case XD_UNION_DYNAMIC_SIZE:
|
|
542 desc1 = lispdesc_process_xd_union (desc1, desc, data);
|
|
543 if (desc1)
|
|
544 goto union_switcheroo;
|
|
545 break;
|
771
|
546
|
442
|
547 default:
|
1204
|
548 stderr_out ("Unsupported dump type : %d\n", desc1->type);
|
442
|
549 pdump_backtrace ();
|
|
550 abort ();
|
1204
|
551 }
|
442
|
552 }
|
|
553 }
|
|
554
|
|
555 static void
|
|
556 pdump_register_object (Lisp_Object obj)
|
|
557 {
|
|
558 struct lrecord_header *objh;
|
458
|
559 const struct lrecord_implementation *imp;
|
442
|
560
|
|
561 if (!POINTER_TYPE_P (XTYPE (obj)))
|
|
562 return;
|
|
563
|
|
564 objh = XRECORD_LHEADER (obj);
|
|
565 if (!objh)
|
|
566 return;
|
|
567
|
|
568 if (pdump_get_entry (objh))
|
|
569 return;
|
|
570
|
458
|
571 imp = LHEADER_IMPLEMENTATION (objh);
|
|
572
|
934
|
573 if (imp->description
|
1204
|
574 && RECORD_DUMPABLE (objh))
|
442
|
575 {
|
1204
|
576 pdump_bump_depth ();
|
|
577 backtrace[pdump_depth - 1].obj = objh;
|
442
|
578 pdump_add_entry (pdump_object_table + objh->type,
|
1204
|
579 objh, detagged_lisp_object_size (objh), 1);
|
|
580 pdump_register_sub (objh, imp->description);
|
|
581 --pdump_depth;
|
442
|
582 }
|
|
583 else
|
|
584 {
|
|
585 pdump_alert_undump_object[objh->type]++;
|
458
|
586 stderr_out ("Undumpable object type : %s\n", imp->name);
|
442
|
587 pdump_backtrace ();
|
|
588 }
|
|
589 }
|
|
590
|
771
|
591 /* Register the referenced objects in the array of COUNT objects of
|
|
592 located at DATA; each object is described by SDESC. "Object" here
|
|
593 simply means any block of memory; it need not actually be a C
|
|
594 "struct". It could be a single integer or Lisp_Object, for
|
|
595 example, as long as the description is accurate.
|
|
596
|
|
597 This does not register the block of memory itself; it may, for
|
|
598 example, be an array of structures inlined in another memory block
|
|
599 and thus should not be registered. See pdump_register_struct(),
|
|
600 which does register the memory block. */
|
|
601
|
|
602 static void
|
|
603 pdump_register_struct_contents (const void *data,
|
1204
|
604 const struct sized_memory_description *sdesc,
|
771
|
605 int count)
|
|
606
|
|
607 {
|
|
608 int i;
|
|
609 Bytecount elsize;
|
|
610
|
1204
|
611 pdump_bump_depth ();
|
|
612 elsize = lispdesc_structure_size (data, sdesc);
|
771
|
613 for (i = 0; i < count; i++)
|
|
614 {
|
1204
|
615 pdump_register_sub (((char *) data) + elsize * i, sdesc->description);
|
771
|
616 }
|
1204
|
617 --pdump_depth;
|
771
|
618 }
|
|
619
|
|
620 /* Register the array of COUNT objects of located at DATA; each object is
|
|
621 described by SDESC. "Object" here simply means any block of memory;
|
|
622 it need not actually be a C "struct". It could be a single integer
|
|
623 or Lisp_Object, for example, as long as the description is accurate.
|
|
624
|
|
625 This is like pdump_register_struct_contents() but also registers
|
|
626 the memory block itself. */
|
|
627
|
442
|
628 static void
|
458
|
629 pdump_register_struct (const void *data,
|
1204
|
630 const struct sized_memory_description *sdesc,
|
458
|
631 int count)
|
442
|
632 {
|
|
633 if (data && !pdump_get_entry (data))
|
|
634 {
|
1204
|
635 pdump_add_entry (pdump_get_entry_list (sdesc->description), data,
|
|
636 lispdesc_structure_size (data, sdesc), count);
|
442
|
637
|
771
|
638 pdump_register_struct_contents (data, sdesc, count);
|
442
|
639 }
|
|
640 }
|
|
641
|
1204
|
642 /* Store the already-calculated new pointer offsets for all pointers in the
|
|
643 COUNT contiguous blocks of memory, each described by DESC and of size
|
|
644 SIZE, whose original is located at ORIG_DATA and the modifiable copy at
|
|
645 DATA. We examine the description to figure out where the pointers are,
|
|
646 and then look up the replacement values using pdump_get_entry().
|
771
|
647
|
1204
|
648 This is done just before writing the modified block of memory to the
|
|
649 dump file. The new pointer offsets have been carefully calculated so
|
|
650 that the data being pointed gets written at that offset in the dump
|
|
651 file. That way, the dump file is a correct memory image except perhaps
|
|
652 for a constant that needs to be added to all pointers. (#### In fact, we
|
|
653 SHOULD be starting up a dumped XEmacs, seeing where the dumped file gets
|
|
654 loaded into memory, and then rewriting the dumped file after relocating
|
|
655 all the pointers relative to this memory location. That way, if the
|
|
656 file gets loaded again at the same location, which will be common, we
|
|
657 don't have to do any relocating, which is both faster at startup and
|
771
|
658 allows the read-only part of the dumped data to be shared read-only
|
|
659 between different invocations of XEmacs.)
|
|
660
|
|
661 #### Do we distinguish between read-only and writable dumped data?
|
|
662 Should we? It's tricky because the dumped data, once loaded again,
|
1204
|
663 cannot really be free()d or garbage collected since it's all stored in
|
|
664 one contiguous block of data with no malloc() headers, and we don't keep
|
|
665 track of the pointers used internally in malloc() and the Lisp allocator
|
|
666 to track allocated blocks of memory. */
|
771
|
667
|
|
668 static void
|
|
669 pdump_store_new_pointer_offsets (int count, void *data, const void *orig_data,
|
1204
|
670 const struct memory_description *desc,
|
771
|
671 int size)
|
|
672 {
|
|
673 int pos, i;
|
|
674 /* Process each block one by one */
|
|
675 for (i = 0; i < count; i++)
|
|
676 {
|
|
677 /* CUR points to the beginning of each block in the new data. */
|
|
678 char *cur = ((char *)data) + i*size;
|
|
679 /* Scan each line of the description for relocatable pointers */
|
|
680 for (pos = 0; desc[pos].type != XD_END; pos++)
|
|
681 {
|
|
682 /* RDATA points to the beginning of each element in the new data. */
|
1204
|
683 const struct memory_description *desc1 = &desc[pos];
|
|
684 /* #### Change ORIG_DATA to DATA. See below. */
|
|
685 void *rdata = cur + lispdesc_indirect_count (desc1->offset, desc,
|
|
686 orig_data);
|
|
687 union_switcheroo:
|
|
688
|
|
689 /* If the flag says don't dump, then don't dump. */
|
|
690 if ((desc1->flags) & XD_FLAG_NO_PDUMP)
|
|
691 continue;
|
|
692
|
|
693 switch (desc1->type)
|
771
|
694 {
|
|
695 case XD_BYTECOUNT:
|
|
696 case XD_ELEMCOUNT:
|
|
697 case XD_HASHCODE:
|
|
698 case XD_INT:
|
|
699 case XD_LONG:
|
|
700 break;
|
|
701 case XD_INT_RESET:
|
|
702 {
|
1204
|
703 EMACS_INT val = lispdesc_indirect_count (desc1->data1, desc,
|
|
704 orig_data);
|
771
|
705 * (int *) rdata = val;
|
|
706 break;
|
|
707 }
|
|
708 case XD_OPAQUE_DATA_PTR:
|
|
709 case XD_C_STRING:
|
|
710 case XD_STRUCT_PTR:
|
|
711 {
|
|
712 void *ptr = * (void **) rdata;
|
|
713 if (ptr)
|
|
714 * (EMACS_INT *) rdata = pdump_get_entry (ptr)->save_offset;
|
|
715 break;
|
|
716 }
|
|
717 case XD_LO_LINK:
|
|
718 {
|
|
719 /* As described in lrecord.h, this is a weak link.
|
|
720 Thus, we need to link this object not (necessarily)
|
|
721 to the object directly pointed to, but to the next
|
|
722 referenced object in the chain. None of the
|
|
723 intermediate objects will be written out, so we
|
|
724 traverse down the chain of objects until we find a
|
|
725 referenced one. (The Qnil or Qunbound that ends the
|
|
726 chain will always be a referenced object.) */
|
|
727 Lisp_Object obj = * (Lisp_Object *) rdata;
|
|
728 pdump_entry_list_elt *elt1;
|
1204
|
729 /* #### Figure out how to handle indirect offsets here.
|
|
730 #### In general, when computing indirect counts, do we
|
|
731 really need to use the orig_data pointer? Why not just
|
|
732 use the new stuff?
|
|
733
|
|
734 No, we don't usually need orig_data. We only need it
|
|
735 when fetching pointers out of the data, not integers.
|
|
736 This currently occurs only with description maps. We
|
|
737 should change the other places to DATA to emphasize
|
|
738 this. */
|
|
739 assert (!XD_IS_INDIRECT (desc1->offset));
|
771
|
740 for (;;)
|
|
741 {
|
|
742 elt1 = pdump_get_entry (XRECORD_LHEADER (obj));
|
|
743 if (elt1)
|
|
744 break;
|
1204
|
745 obj = * (Lisp_Object *) (desc1->offset +
|
771
|
746 (char *)(XRECORD_LHEADER (obj)));
|
|
747 }
|
|
748 * (EMACS_INT *) rdata = elt1->save_offset;
|
|
749 break;
|
|
750 }
|
|
751 case XD_LISP_OBJECT:
|
|
752 {
|
|
753 Lisp_Object *pobj = (Lisp_Object *) rdata;
|
|
754
|
1204
|
755 assert (desc1->data1 == 0);
|
771
|
756
|
|
757 if (POINTER_TYPE_P (XTYPE (*pobj)) && XRECORD_LHEADER (*pobj))
|
|
758 * (EMACS_INT *) pobj =
|
|
759 pdump_get_entry (XRECORD_LHEADER (*pobj))->save_offset;
|
|
760 break;
|
|
761 }
|
|
762 case XD_LISP_OBJECT_ARRAY:
|
|
763 {
|
1204
|
764 EMACS_INT num = lispdesc_indirect_count (desc1->data1, desc,
|
|
765 orig_data);
|
771
|
766 int j;
|
|
767
|
|
768 for (j = 0; j < num; j++)
|
|
769 {
|
|
770 Lisp_Object *pobj = ((Lisp_Object *) rdata) + j;
|
|
771 if (POINTER_TYPE_P (XTYPE (*pobj)) &&
|
|
772 XRECORD_LHEADER (*pobj))
|
|
773 * (EMACS_INT *) pobj =
|
|
774 pdump_get_entry (XRECORD_LHEADER (*pobj))->save_offset;
|
|
775 }
|
|
776 break;
|
|
777 }
|
|
778 case XD_DOC_STRING:
|
|
779 {
|
|
780 EMACS_INT str = *(EMACS_INT *)rdata;
|
|
781 if (str > 0)
|
|
782 * (EMACS_INT *) rdata =
|
|
783 pdump_get_entry ((void *)str)->save_offset;
|
|
784 break;
|
|
785 }
|
|
786 case XD_STRUCT_ARRAY:
|
|
787 {
|
1204
|
788 EMACS_INT num = lispdesc_indirect_count (desc1->data1, desc,
|
|
789 orig_data);
|
|
790 const struct sized_memory_description *sdesc =
|
|
791 lispdesc_indirect_description (orig_data, desc1->data2);
|
771
|
792
|
|
793 pdump_store_new_pointer_offsets
|
|
794 (num, rdata,
|
|
795 ((char *) rdata - (char *) data) + (char *) orig_data,
|
1204
|
796 sdesc->description,
|
|
797 lispdesc_structure_size
|
771
|
798 (((char *) rdata - (char *) data) + (char *) orig_data,
|
1204
|
799 sdesc));
|
771
|
800 break;
|
|
801 }
|
|
802 case XD_UNION:
|
1204
|
803 case XD_UNION_DYNAMIC_SIZE:
|
|
804 desc1 = lispdesc_process_xd_union (desc1, desc, orig_data);
|
|
805 if (desc1)
|
|
806 goto union_switcheroo;
|
|
807 break;
|
771
|
808
|
|
809 default:
|
1204
|
810 stderr_out ("Unsupported dump type : %d\n", desc1->type);
|
771
|
811 abort ();
|
|
812 }
|
|
813 }
|
|
814 }
|
|
815 }
|
|
816
|
|
817 /* Write out to global file descriptor PDUMP_OUT the element (one or
|
|
818 more contiguous blocks of identical size/description) recorded in
|
|
819 ELT and described by DESC. The element is first copied to a buffer
|
|
820 and then all pointers (this includes Lisp_Objects other than
|
|
821 integer/character) are relocated to the (pre-computed) offset in
|
|
822 the dump file. */
|
|
823
|
442
|
824 static void
|
460
|
825 pdump_dump_data (pdump_entry_list_elt *elt,
|
1204
|
826 const struct memory_description *desc)
|
442
|
827 {
|
665
|
828 Bytecount size = elt->size;
|
460
|
829 int count = elt->count;
|
442
|
830 if (desc)
|
|
831 {
|
771
|
832 /* Copy to temporary buffer */
|
460
|
833 memcpy (pdump_buf, elt->obj, size*count);
|
442
|
834
|
771
|
835 /* Store new offsets into all pointers in block */
|
|
836 pdump_store_new_pointer_offsets (count, pdump_buf, elt->obj, desc, size);
|
|
837 }
|
|
838 retry_fwrite (desc ? pdump_buf : elt->obj, size, count, pdump_out);
|
|
839 }
|
442
|
840
|
771
|
841 /* Relocate a single memory block at DATA, described by DESC, from its
|
1204
|
842 assumed load location to its actual one by adding DELTA to all pointers
|
|
843 in the block. Does not recursively relocate any other memory blocks
|
|
844 pointed to. (We already have a list of all memory blocks in the dump
|
|
845 file.) This is used once the dump data has been loaded back in, both
|
|
846 for blocks sitting in the dumped data and in global data objects whose
|
|
847 contents have been restored from the dumped data. */
|
442
|
848
|
|
849 static void
|
458
|
850 pdump_reloc_one (void *data, EMACS_INT delta,
|
1204
|
851 const struct memory_description *desc)
|
442
|
852 {
|
|
853 int pos;
|
|
854
|
|
855 for (pos = 0; desc[pos].type != XD_END; pos++)
|
|
856 {
|
1204
|
857 const struct memory_description *desc1 = &desc[pos];
|
|
858 void *rdata = (char *) data + lispdesc_indirect_count (desc1->offset,
|
|
859 desc, data);
|
|
860
|
|
861 union_switcheroo:
|
|
862
|
|
863 /* If the flag says don't dump, then don't dump. */
|
|
864 if ((desc1->flags) & XD_FLAG_NO_PDUMP)
|
|
865 continue;
|
|
866
|
|
867 switch (desc1->type)
|
442
|
868 {
|
665
|
869 case XD_BYTECOUNT:
|
|
870 case XD_ELEMCOUNT:
|
|
871 case XD_HASHCODE:
|
442
|
872 case XD_INT:
|
|
873 case XD_LONG:
|
|
874 case XD_INT_RESET:
|
|
875 break;
|
|
876 case XD_OPAQUE_DATA_PTR:
|
|
877 case XD_C_STRING:
|
|
878 case XD_STRUCT_PTR:
|
|
879 case XD_LO_LINK:
|
|
880 {
|
|
881 EMACS_INT ptr = *(EMACS_INT *)rdata;
|
|
882 if (ptr)
|
|
883 *(EMACS_INT *)rdata = ptr+delta;
|
|
884 break;
|
|
885 }
|
|
886 case XD_LISP_OBJECT:
|
|
887 {
|
|
888 Lisp_Object *pobj = (Lisp_Object *) rdata;
|
|
889
|
1204
|
890 assert (desc1->data1 == 0);
|
442
|
891
|
|
892 if (POINTER_TYPE_P (XTYPE (*pobj))
|
|
893 && ! EQ (*pobj, Qnull_pointer))
|
793
|
894 *pobj = wrap_pointer_1 ((char *) XPNTR (*pobj) + delta);
|
442
|
895
|
|
896 break;
|
|
897 }
|
|
898 case XD_LISP_OBJECT_ARRAY:
|
|
899 {
|
1204
|
900 EMACS_INT num = lispdesc_indirect_count (desc1->data1, desc,
|
|
901 data);
|
442
|
902 int j;
|
|
903
|
|
904 for (j=0; j<num; j++)
|
|
905 {
|
|
906 Lisp_Object *pobj = (Lisp_Object *) rdata + j;
|
|
907
|
|
908 if (POINTER_TYPE_P (XTYPE (*pobj))
|
|
909 && ! EQ (*pobj, Qnull_pointer))
|
793
|
910 *pobj = wrap_pointer_1 ((char *) XPNTR (*pobj) + delta);
|
442
|
911 }
|
|
912 break;
|
|
913 }
|
|
914 case XD_DOC_STRING:
|
|
915 {
|
|
916 EMACS_INT str = *(EMACS_INT *)rdata;
|
|
917 if (str > 0)
|
|
918 *(EMACS_INT *)rdata = str + delta;
|
|
919 break;
|
|
920 }
|
771
|
921 case XD_STRUCT_ARRAY:
|
|
922 {
|
1204
|
923 EMACS_INT num = lispdesc_indirect_count (desc1->data1, desc,
|
|
924 data);
|
771
|
925 int j;
|
1204
|
926 const struct sized_memory_description *sdesc =
|
|
927 lispdesc_indirect_description (data, desc1->data2);
|
|
928 Bytecount size = lispdesc_structure_size (rdata, sdesc);
|
771
|
929
|
|
930 /* Note: We are recursing over data in the block itself */
|
|
931 for (j = 0; j < num; j++)
|
|
932 pdump_reloc_one ((char *) rdata + j * size, delta,
|
|
933 sdesc->description);
|
|
934
|
|
935 break;
|
|
936 }
|
1204
|
937 case XD_UNION:
|
|
938 case XD_UNION_DYNAMIC_SIZE:
|
|
939 desc1 = lispdesc_process_xd_union (desc1, desc, data);
|
|
940 if (desc1)
|
|
941 goto union_switcheroo;
|
|
942 break;
|
771
|
943
|
442
|
944 default:
|
1204
|
945 stderr_out ("Unsupported dump type : %d\n", desc1->type);
|
442
|
946 abort ();
|
1204
|
947 }
|
442
|
948 }
|
|
949 }
|
|
950
|
|
951 static void
|
460
|
952 pdump_allocate_offset (pdump_entry_list_elt *elt,
|
1204
|
953 const struct memory_description *desc)
|
442
|
954 {
|
665
|
955 Bytecount size = elt->count * elt->size;
|
460
|
956 elt->save_offset = cur_offset;
|
442
|
957 if (size>max_size)
|
|
958 max_size = size;
|
|
959 cur_offset += size;
|
|
960 }
|
|
961
|
|
962 static void
|
460
|
963 pdump_scan_by_alignment (void (*f)(pdump_entry_list_elt *,
|
1204
|
964 const struct memory_description *))
|
442
|
965 {
|
460
|
966 int align;
|
|
967
|
|
968 for (align = ALIGNOF (max_align_t); align; align>>=1)
|
442
|
969 {
|
460
|
970 int i;
|
|
971 pdump_entry_list_elt *elt;
|
|
972
|
442
|
973 for (i=0; i<lrecord_type_count; i++)
|
|
974 if (pdump_object_table[i].align == align)
|
460
|
975 for (elt = pdump_object_table[i].first; elt; elt = elt->next)
|
|
976 f (elt, lrecord_implementations_table[i]->description);
|
442
|
977
|
|
978 for (i=0; i<pdump_struct_table.count; i++)
|
460
|
979 {
|
|
980 pdump_struct_list_elt list = pdump_struct_table.list[i];
|
|
981 if (list.list.align == align)
|
|
982 for (elt = list.list.first; elt; elt = elt->next)
|
1204
|
983 f (elt, list.desc);
|
460
|
984 }
|
442
|
985
|
460
|
986 for (elt = pdump_opaque_data_list.first; elt; elt = elt->next)
|
|
987 if (pdump_size_to_align (elt->size) == align)
|
|
988 f (elt, 0);
|
442
|
989 }
|
|
990 }
|
|
991
|
|
992 static void
|
458
|
993 pdump_dump_root_struct_ptrs (void)
|
442
|
994 {
|
|
995 int i;
|
665
|
996 Elemcount count = Dynarr_length (pdump_root_struct_ptrs);
|
458
|
997 pdump_static_pointer *data = alloca_array (pdump_static_pointer, count);
|
|
998 for (i = 0; i < count; i++)
|
442
|
999 {
|
458
|
1000 data[i].address = (char **) Dynarr_atp (pdump_root_struct_ptrs, i)->ptraddress;
|
|
1001 data[i].value = (char *) pdump_get_entry (* data[i].address)->save_offset;
|
442
|
1002 }
|
458
|
1003 PDUMP_ALIGN_OUTPUT (pdump_static_pointer);
|
771
|
1004 retry_fwrite (data, sizeof (pdump_static_pointer), count, pdump_out);
|
442
|
1005 }
|
|
1006
|
|
1007 static void
|
1204
|
1008 pdump_dump_root_blocks (void)
|
442
|
1009 {
|
|
1010 int i;
|
1204
|
1011 for (i = 0; i < Dynarr_length (pdump_root_blocks); i++)
|
442
|
1012 {
|
1204
|
1013 pdump_root_block *info = Dynarr_atp (pdump_root_blocks, i);
|
|
1014 PDUMP_WRITE_ALIGNED (pdump_root_block, *info);
|
771
|
1015 retry_fwrite (info->varaddress, info->size, 1, pdump_out);
|
442
|
1016 }
|
|
1017 }
|
|
1018
|
|
1019 static void
|
|
1020 pdump_dump_rtables (void)
|
|
1021 {
|
452
|
1022 int i;
|
460
|
1023 pdump_entry_list_elt *elt;
|
442
|
1024 pdump_reloc_table rt;
|
|
1025
|
|
1026 for (i=0; i<lrecord_type_count; i++)
|
|
1027 {
|
460
|
1028 elt = pdump_object_table[i].first;
|
|
1029 if (!elt)
|
442
|
1030 continue;
|
|
1031 rt.desc = lrecord_implementations_table[i]->description;
|
|
1032 rt.count = pdump_object_table[i].count;
|
458
|
1033 PDUMP_WRITE_ALIGNED (pdump_reloc_table, rt);
|
460
|
1034 while (elt)
|
442
|
1035 {
|
460
|
1036 EMACS_INT rdata = pdump_get_entry (elt->obj)->save_offset;
|
458
|
1037 PDUMP_WRITE_ALIGNED (EMACS_INT, rdata);
|
460
|
1038 elt = elt->next;
|
442
|
1039 }
|
|
1040 }
|
|
1041
|
|
1042 rt.desc = 0;
|
|
1043 rt.count = 0;
|
458
|
1044 PDUMP_WRITE_ALIGNED (pdump_reloc_table, rt);
|
442
|
1045
|
|
1046 for (i=0; i<pdump_struct_table.count; i++)
|
|
1047 {
|
460
|
1048 elt = pdump_struct_table.list[i].list.first;
|
1204
|
1049 rt.desc = pdump_struct_table.list[i].desc;
|
442
|
1050 rt.count = pdump_struct_table.list[i].list.count;
|
458
|
1051 PDUMP_WRITE_ALIGNED (pdump_reloc_table, rt);
|
460
|
1052 while (elt)
|
442
|
1053 {
|
460
|
1054 EMACS_INT rdata = pdump_get_entry (elt->obj)->save_offset;
|
452
|
1055 int j;
|
460
|
1056 for (j=0; j<elt->count; j++)
|
442
|
1057 {
|
458
|
1058 PDUMP_WRITE_ALIGNED (EMACS_INT, rdata);
|
460
|
1059 rdata += elt->size;
|
442
|
1060 }
|
460
|
1061 elt = elt->next;
|
442
|
1062 }
|
|
1063 }
|
|
1064 rt.desc = 0;
|
|
1065 rt.count = 0;
|
458
|
1066 PDUMP_WRITE_ALIGNED (pdump_reloc_table, rt);
|
442
|
1067 }
|
|
1068
|
|
1069 static void
|
1204
|
1070 pdump_dump_root_lisp_objects (void)
|
442
|
1071 {
|
1204
|
1072 Elemcount count = (Dynarr_length (pdump_root_lisp_objects) +
|
647
|
1073 Dynarr_length (pdump_weak_object_chains));
|
665
|
1074 Elemcount i;
|
442
|
1075
|
665
|
1076 PDUMP_WRITE_ALIGNED (Elemcount, count);
|
458
|
1077 PDUMP_ALIGN_OUTPUT (pdump_static_Lisp_Object);
|
442
|
1078
|
1204
|
1079 for (i = 0; i < Dynarr_length (pdump_root_lisp_objects); i++)
|
442
|
1080 {
|
458
|
1081 pdump_static_Lisp_Object obj;
|
1204
|
1082 obj.address = Dynarr_at (pdump_root_lisp_objects, i);
|
458
|
1083 obj.value = * obj.address;
|
460
|
1084
|
458
|
1085 if (POINTER_TYPE_P (XTYPE (obj.value)))
|
619
|
1086 obj.value =
|
|
1087 wrap_pointer_1 ((void *) pdump_get_entry (XRECORD_LHEADER
|
617
|
1088 (obj.value))->save_offset);
|
460
|
1089
|
458
|
1090 PDUMP_WRITE (pdump_static_Lisp_Object, obj);
|
442
|
1091 }
|
|
1092
|
452
|
1093 for (i=0; i<Dynarr_length (pdump_weak_object_chains); i++)
|
442
|
1094 {
|
460
|
1095 pdump_entry_list_elt *elt;
|
458
|
1096 pdump_static_Lisp_Object obj;
|
442
|
1097
|
458
|
1098 obj.address = Dynarr_at (pdump_weak_object_chains, i);
|
|
1099 obj.value = * obj.address;
|
460
|
1100
|
442
|
1101 for (;;)
|
|
1102 {
|
1204
|
1103 const struct memory_description *desc;
|
442
|
1104 int pos;
|
460
|
1105 elt = pdump_get_entry (XRECORD_LHEADER (obj.value));
|
|
1106 if (elt)
|
442
|
1107 break;
|
458
|
1108 desc = XRECORD_LHEADER_IMPLEMENTATION (obj.value)->description;
|
442
|
1109 for (pos = 0; desc[pos].type != XD_LO_LINK; pos++)
|
|
1110 assert (desc[pos].type != XD_END);
|
|
1111
|
1204
|
1112 /* #### Figure out how to handle indirect offsets here. */
|
|
1113 assert (!XD_IS_INDIRECT (desc[pos].offset));
|
|
1114 obj.value =
|
|
1115 * (Lisp_Object *) (desc[pos].offset +
|
|
1116 (char *) (XRECORD_LHEADER (obj.value)));
|
442
|
1117 }
|
619
|
1118 obj.value = wrap_pointer_1 ((void *) elt->save_offset);
|
442
|
1119
|
458
|
1120 PDUMP_WRITE (pdump_static_Lisp_Object, obj);
|
442
|
1121 }
|
|
1122 }
|
|
1123
|
|
1124 void
|
|
1125 pdump (void)
|
|
1126 {
|
|
1127 int i;
|
|
1128 Lisp_Object t_console, t_device, t_frame;
|
|
1129 int none;
|
458
|
1130 pdump_header header;
|
442
|
1131
|
1204
|
1132 in_pdump = 1;
|
|
1133
|
460
|
1134 pdump_object_table = xnew_array (pdump_entry_list, lrecord_type_count);
|
|
1135 pdump_alert_undump_object = xnew_array (int, lrecord_type_count);
|
|
1136
|
|
1137 assert (ALIGNOF (max_align_t) <= pdump_align_table[0]);
|
|
1138
|
|
1139 for (i = 0; i < countof (pdump_align_table); i++)
|
|
1140 if (pdump_align_table[i] > ALIGNOF (max_align_t))
|
|
1141 pdump_align_table[i] = ALIGNOF (max_align_t);
|
|
1142
|
446
|
1143 flush_all_buffer_local_cache ();
|
|
1144
|
442
|
1145 /* These appear in a DEFVAR_LISP, which does a staticpro() */
|
452
|
1146 t_console = Vterminal_console; Vterminal_console = Qnil;
|
|
1147 t_frame = Vterminal_frame; Vterminal_frame = Qnil;
|
|
1148 t_device = Vterminal_device; Vterminal_device = Qnil;
|
442
|
1149
|
452
|
1150 dump_add_opaque (&lrecord_implementations_table,
|
1204
|
1151 lrecord_type_count *
|
|
1152 sizeof (lrecord_implementations_table[0]));
|
452
|
1153 dump_add_opaque (&lrecord_markers,
|
|
1154 lrecord_type_count * sizeof (lrecord_markers[0]));
|
442
|
1155
|
460
|
1156 pdump_hash = xnew_array_and_zero (pdump_entry_list_elt *, PDUMP_HASHSIZE);
|
442
|
1157
|
|
1158 for (i=0; i<lrecord_type_count; i++)
|
|
1159 {
|
|
1160 pdump_object_table[i].first = 0;
|
460
|
1161 pdump_object_table[i].align = ALIGNOF (max_align_t);
|
442
|
1162 pdump_object_table[i].count = 0;
|
|
1163 pdump_alert_undump_object[i] = 0;
|
|
1164 }
|
|
1165 pdump_struct_table.count = 0;
|
|
1166 pdump_struct_table.size = -1;
|
|
1167
|
|
1168 pdump_opaque_data_list.first = 0;
|
460
|
1169 pdump_opaque_data_list.align = ALIGNOF (max_align_t);
|
442
|
1170 pdump_opaque_data_list.count = 0;
|
1204
|
1171 pdump_depth = 0;
|
442
|
1172
|
1204
|
1173 for (i = 0; i < Dynarr_length (pdump_root_lisp_objects); i++)
|
|
1174 pdump_register_object (* Dynarr_at (pdump_root_lisp_objects, i));
|
442
|
1175
|
|
1176 none = 1;
|
|
1177 for (i=0; i<lrecord_type_count; i++)
|
|
1178 if (pdump_alert_undump_object[i])
|
|
1179 {
|
|
1180 if (none)
|
|
1181 printf ("Undumpable types list :\n");
|
|
1182 none = 0;
|
1204
|
1183 printf (" - %s (%d)\n", lrecord_implementations_table[i]->name,
|
|
1184 pdump_alert_undump_object[i]);
|
442
|
1185 }
|
|
1186 if (!none)
|
1204
|
1187 {
|
|
1188 in_pdump = 0;
|
|
1189 return;
|
|
1190 }
|
442
|
1191
|
452
|
1192 for (i=0; i<Dynarr_length (pdump_root_struct_ptrs); i++)
|
|
1193 {
|
|
1194 pdump_root_struct_ptr info = Dynarr_at (pdump_root_struct_ptrs, i);
|
|
1195 pdump_register_struct (*(info.ptraddress), info.desc, 1);
|
|
1196 }
|
442
|
1197
|
458
|
1198 memcpy (header.signature, PDUMP_SIGNATURE, PDUMP_SIGNATURE_LEN);
|
|
1199 header.id = dump_id;
|
|
1200 header.reloc_address = 0;
|
|
1201 header.nb_root_struct_ptrs = Dynarr_length (pdump_root_struct_ptrs);
|
1204
|
1202 header.nb_root_blocks = Dynarr_length (pdump_root_blocks);
|
442
|
1203
|
826
|
1204 cur_offset = MAX_ALIGN_SIZE (sizeof (header));
|
442
|
1205 max_size = 0;
|
|
1206
|
|
1207 pdump_scan_by_alignment (pdump_allocate_offset);
|
826
|
1208 cur_offset = MAX_ALIGN_SIZE (cur_offset);
|
458
|
1209 header.stab_offset = cur_offset;
|
442
|
1210
|
|
1211 pdump_buf = xmalloc (max_size);
|
|
1212 pdump_fd = open (EMACS_PROGNAME ".dmp",
|
|
1213 O_WRONLY | O_CREAT | O_TRUNC | OPEN_BINARY, 0666);
|
771
|
1214 if (pdump_fd < 0)
|
|
1215 report_file_error ("Unable to open dump file",
|
|
1216 build_string (EMACS_PROGNAME ".dmp"));
|
458
|
1217 pdump_out = fdopen (pdump_fd, "w");
|
771
|
1218 if (pdump_out < 0)
|
|
1219 report_file_error ("Unable to open dump file for writing",
|
|
1220 build_string (EMACS_PROGNAME ".dmp"));
|
442
|
1221
|
771
|
1222 retry_fwrite (&header, sizeof (header), 1, pdump_out);
|
458
|
1223 PDUMP_ALIGN_OUTPUT (max_align_t);
|
442
|
1224
|
|
1225 pdump_scan_by_alignment (pdump_dump_data);
|
|
1226
|
458
|
1227 fseek (pdump_out, header.stab_offset, SEEK_SET);
|
442
|
1228
|
458
|
1229 pdump_dump_root_struct_ptrs ();
|
1204
|
1230 pdump_dump_root_blocks ();
|
442
|
1231 pdump_dump_rtables ();
|
1204
|
1232 pdump_dump_root_lisp_objects ();
|
442
|
1233
|
771
|
1234 retry_fclose (pdump_out);
|
|
1235 retry_close (pdump_fd);
|
458
|
1236
|
442
|
1237 free (pdump_buf);
|
|
1238
|
|
1239 free (pdump_hash);
|
|
1240
|
|
1241 Vterminal_console = t_console;
|
|
1242 Vterminal_frame = t_frame;
|
|
1243 Vterminal_device = t_device;
|
1204
|
1244 in_pdump = 0;
|
442
|
1245 }
|
|
1246
|
452
|
1247 static int
|
|
1248 pdump_load_check (void)
|
442
|
1249 {
|
452
|
1250 return (!memcmp (((pdump_header *)pdump_start)->signature,
|
|
1251 PDUMP_SIGNATURE, PDUMP_SIGNATURE_LEN)
|
|
1252 && ((pdump_header *)pdump_start)->id == dump_id);
|
442
|
1253 }
|
|
1254
|
458
|
1255 /*----------------------------------------------------------------------*/
|
|
1256 /* Reading the dump file */
|
|
1257 /*----------------------------------------------------------------------*/
|
452
|
1258 static int
|
|
1259 pdump_load_finish (void)
|
442
|
1260 {
|
|
1261 int i;
|
|
1262 char *p;
|
|
1263 EMACS_INT delta;
|
|
1264 EMACS_INT count;
|
1204
|
1265 pdump_header *header = (pdump_header *) pdump_start;
|
442
|
1266
|
|
1267 pdump_end = pdump_start + pdump_length;
|
|
1268
|
1204
|
1269 delta = ((EMACS_INT) pdump_start) - header->reloc_address;
|
458
|
1270 p = pdump_start + header->stab_offset;
|
442
|
1271
|
452
|
1272 /* Put back the pdump_root_struct_ptrs */
|
826
|
1273 p = (char *) ALIGN_PTR (p, pdump_static_pointer);
|
1204
|
1274 for (i = 0; i < header->nb_root_struct_ptrs; i++)
|
442
|
1275 {
|
458
|
1276 pdump_static_pointer ptr = PDUMP_READ (p, pdump_static_pointer);
|
|
1277 (* ptr.address) = ptr.value + delta;
|
442
|
1278 }
|
|
1279
|
1204
|
1280 /* Put back the pdump_root_blocks and relocate */
|
|
1281 for (i = 0; i < header->nb_root_blocks; i++)
|
442
|
1282 {
|
1204
|
1283 pdump_root_block info = PDUMP_READ_ALIGNED (p, pdump_root_block);
|
|
1284 memcpy ((void *) info.varaddress, p, info.size);
|
|
1285 if (info.desc)
|
|
1286 pdump_reloc_one ((void *) info.varaddress, delta, info.desc);
|
452
|
1287 p += info.size;
|
442
|
1288 }
|
|
1289
|
1204
|
1290 /* Relocate the heap objects */
|
442
|
1291 pdump_rt_list = p;
|
|
1292 count = 2;
|
|
1293 for (;;)
|
|
1294 {
|
458
|
1295 pdump_reloc_table rt = PDUMP_READ_ALIGNED (p, pdump_reloc_table);
|
826
|
1296 p = (char *) ALIGN_PTR (p, char *);
|
442
|
1297 if (rt.desc)
|
|
1298 {
|
1204
|
1299 char **reloc = (char **) p;
|
|
1300 for (i = 0; i < rt.count; i++)
|
442
|
1301 {
|
458
|
1302 reloc[i] += delta;
|
|
1303 pdump_reloc_one (reloc[i], delta, rt.desc);
|
442
|
1304 }
|
458
|
1305 p += rt.count * sizeof (char *);
|
1204
|
1306 }
|
|
1307 else if (!(--count))
|
|
1308 break;
|
442
|
1309 }
|
|
1310
|
1204
|
1311 /* Put the pdump_root_lisp_objects variables in place */
|
665
|
1312 i = PDUMP_READ_ALIGNED (p, Elemcount);
|
826
|
1313 p = (char *) ALIGN_PTR (p, pdump_static_Lisp_Object);
|
458
|
1314 while (i--)
|
442
|
1315 {
|
458
|
1316 pdump_static_Lisp_Object obj = PDUMP_READ (p, pdump_static_Lisp_Object);
|
442
|
1317
|
458
|
1318 if (POINTER_TYPE_P (XTYPE (obj.value)))
|
619
|
1319 obj.value = wrap_pointer_1 ((char *) XPNTR (obj.value) + delta);
|
442
|
1320
|
458
|
1321 (* obj.address) = obj.value;
|
442
|
1322 }
|
|
1323
|
|
1324 /* Final cleanups */
|
|
1325 /* reorganize hash tables */
|
|
1326 p = pdump_rt_list;
|
|
1327 for (;;)
|
|
1328 {
|
458
|
1329 pdump_reloc_table rt = PDUMP_READ_ALIGNED (p, pdump_reloc_table);
|
826
|
1330 p = (char *) ALIGN_PTR (p, Lisp_Object);
|
442
|
1331 if (!rt.desc)
|
|
1332 break;
|
|
1333 if (rt.desc == hash_table_description)
|
|
1334 {
|
1204
|
1335 for (i = 0; i < rt.count; i++)
|
442
|
1336 pdump_reorganize_hash_table (PDUMP_READ (p, Lisp_Object));
|
|
1337 break;
|
1204
|
1338 }
|
|
1339 else
|
|
1340 p += sizeof (Lisp_Object) * rt.count;
|
442
|
1341 }
|
|
1342
|
|
1343 return 1;
|
|
1344 }
|
|
1345
|
|
1346 #ifdef WIN32_NATIVE
|
|
1347 /* Free the mapped file if we decide we don't want it after all */
|
452
|
1348 static void
|
|
1349 pdump_file_unmap (void)
|
442
|
1350 {
|
|
1351 UnmapViewOfFile (pdump_start);
|
|
1352 CloseHandle (pdump_hFile);
|
|
1353 CloseHandle (pdump_hMap);
|
|
1354 }
|
|
1355
|
452
|
1356 static int
|
|
1357 pdump_file_get (const char *path)
|
442
|
1358 {
|
|
1359
|
800
|
1360 pdump_hFile = CreateFileA (path,
|
442
|
1361 GENERIC_READ + GENERIC_WRITE, /* Required for copy on write */
|
|
1362 0, /* Not shared */
|
|
1363 NULL, /* Not inheritable */
|
|
1364 OPEN_EXISTING,
|
|
1365 FILE_ATTRIBUTE_NORMAL,
|
|
1366 NULL); /* No template file */
|
|
1367 if (pdump_hFile == INVALID_HANDLE_VALUE)
|
|
1368 return 0;
|
|
1369
|
|
1370 pdump_length = GetFileSize (pdump_hFile, NULL);
|
800
|
1371 pdump_hMap = CreateFileMappingA (pdump_hFile,
|
442
|
1372 NULL, /* No security attributes */
|
|
1373 PAGE_WRITECOPY, /* Copy on write */
|
|
1374 0, /* Max size, high half */
|
|
1375 0, /* Max size, low half */
|
|
1376 NULL); /* Unnamed */
|
|
1377 if (pdump_hMap == INVALID_HANDLE_VALUE)
|
|
1378 return 0;
|
|
1379
|
1204
|
1380 pdump_start = (char *) MapViewOfFile (pdump_hMap,
|
|
1381 FILE_MAP_COPY, /* Copy on write */
|
|
1382 0, /* Start at zero */
|
|
1383 0,
|
|
1384 0); /* Map all of it */
|
442
|
1385 pdump_free = pdump_file_unmap;
|
|
1386 return 1;
|
|
1387 }
|
|
1388
|
|
1389 /* pdump_resource_free is called (via the pdump_free pointer) to release
|
|
1390 any resources allocated by pdump_resource_get. Since the Windows API
|
|
1391 specs specifically state that you don't need to (and shouldn't) free the
|
|
1392 resources allocated by FindResource, LoadResource, and LockResource this
|
|
1393 routine does nothing. */
|
452
|
1394 static void
|
|
1395 pdump_resource_free (void)
|
442
|
1396 {
|
|
1397 }
|
|
1398
|
452
|
1399 static int
|
|
1400 pdump_resource_get (void)
|
442
|
1401 {
|
452
|
1402 HRSRC hRes; /* Handle to dump resource */
|
|
1403 HRSRC hResLoad; /* Handle to loaded dump resource */
|
442
|
1404
|
|
1405 /* See Q126630 which describes how Windows NT and 95 trap writes to
|
|
1406 resource sections and duplicate the page to allow the write to proceed.
|
|
1407 It also describes how to make the resource section read/write (and hence
|
|
1408 private to each process). Doing this avoids the exceptions and related
|
|
1409 overhead, but causes the resource section to be private to each process
|
|
1410 that is running XEmacs. Since the resource section contains little
|
|
1411 other than the dumped data, which should be private to each process, we
|
|
1412 make the whole resource section read/write so we don't have to copy it. */
|
|
1413
|
800
|
1414 hRes = FindResourceA (NULL, MAKEINTRESOURCE (101), "DUMP");
|
442
|
1415 if (hRes == NULL)
|
|
1416 return 0;
|
|
1417
|
|
1418 /* Found it, use the data in the resource */
|
1204
|
1419 hResLoad = (HRSRC) LoadResource (NULL, hRes);
|
442
|
1420 if (hResLoad == NULL)
|
|
1421 return 0;
|
|
1422
|
1204
|
1423 pdump_start = (char *) LockResource (hResLoad);
|
442
|
1424 if (pdump_start == NULL)
|
|
1425 return 0;
|
|
1426
|
|
1427 pdump_free = pdump_resource_free;
|
|
1428 pdump_length = SizeofResource (NULL, hRes);
|
665
|
1429 if (pdump_length <= (Bytecount) sizeof (pdump_header))
|
442
|
1430 {
|
|
1431 pdump_start = 0;
|
|
1432 return 0;
|
|
1433 }
|
|
1434
|
|
1435 return 1;
|
|
1436 }
|
|
1437
|
|
1438 #else /* !WIN32_NATIVE */
|
|
1439
|
452
|
1440 static void
|
|
1441 pdump_file_free (void)
|
442
|
1442 {
|
460
|
1443 xfree (pdump_start);
|
442
|
1444 }
|
|
1445
|
|
1446 #ifdef HAVE_MMAP
|
452
|
1447 static void
|
|
1448 pdump_file_unmap (void)
|
442
|
1449 {
|
|
1450 munmap (pdump_start, pdump_length);
|
|
1451 }
|
|
1452 #endif
|
|
1453
|
452
|
1454 static int
|
|
1455 pdump_file_get (const char *path)
|
442
|
1456 {
|
|
1457 int fd = open (path, O_RDONLY | OPEN_BINARY);
|
|
1458 if (fd<0)
|
|
1459 return 0;
|
|
1460
|
|
1461 pdump_length = lseek (fd, 0, SEEK_END);
|
665
|
1462 if (pdump_length < (Bytecount) sizeof (pdump_header))
|
442
|
1463 {
|
771
|
1464 retry_close (fd);
|
442
|
1465 return 0;
|
|
1466 }
|
|
1467
|
|
1468 lseek (fd, 0, SEEK_SET);
|
|
1469
|
|
1470 #ifdef HAVE_MMAP
|
456
|
1471 /* Unix 98 requires that sys/mman.h define MAP_FAILED,
|
|
1472 but many earlier implementations don't. */
|
|
1473 # ifndef MAP_FAILED
|
|
1474 # define MAP_FAILED ((void *) -1L)
|
|
1475 # endif
|
442
|
1476 pdump_start = (char *) mmap (0, pdump_length, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
|
452
|
1477 if (pdump_start != (char *) MAP_FAILED)
|
442
|
1478 {
|
|
1479 pdump_free = pdump_file_unmap;
|
771
|
1480 retry_close (fd);
|
442
|
1481 return 1;
|
|
1482 }
|
456
|
1483 #endif /* HAVE_MMAP */
|
442
|
1484
|
460
|
1485 pdump_start = xnew_array (char, pdump_length);
|
442
|
1486 pdump_free = pdump_file_free;
|
771
|
1487 retry_read (fd, pdump_start, pdump_length);
|
442
|
1488
|
771
|
1489 retry_close (fd);
|
442
|
1490 return 1;
|
|
1491 }
|
|
1492 #endif /* !WIN32_NATIVE */
|
|
1493
|
|
1494
|
452
|
1495 static int
|
|
1496 pdump_file_try (char *exe_path)
|
442
|
1497 {
|
460
|
1498 char *w = exe_path + strlen (exe_path);
|
442
|
1499
|
|
1500 do
|
|
1501 {
|
|
1502 sprintf (w, "-%s-%08x.dmp", EMACS_VERSION, dump_id);
|
|
1503 if (pdump_file_get (exe_path))
|
|
1504 {
|
|
1505 if (pdump_load_check ())
|
|
1506 return 1;
|
452
|
1507 pdump_free ();
|
442
|
1508 }
|
|
1509
|
|
1510 sprintf (w, "-%08x.dmp", dump_id);
|
|
1511 if (pdump_file_get (exe_path))
|
|
1512 {
|
|
1513 if (pdump_load_check ())
|
|
1514 return 1;
|
452
|
1515 pdump_free ();
|
442
|
1516 }
|
|
1517
|
|
1518 sprintf (w, ".dmp");
|
|
1519 if (pdump_file_get (exe_path))
|
|
1520 {
|
|
1521 if (pdump_load_check ())
|
|
1522 return 1;
|
452
|
1523 pdump_free ();
|
442
|
1524 }
|
|
1525
|
|
1526 do
|
|
1527 w--;
|
|
1528 while (w>exe_path && !IS_DIRECTORY_SEP (*w) && (*w != '-') && (*w != '.'));
|
|
1529 }
|
|
1530 while (w>exe_path && !IS_DIRECTORY_SEP (*w));
|
|
1531 return 0;
|
|
1532 }
|
|
1533
|
452
|
1534 int
|
771
|
1535 pdump_load (const Extbyte *argv0)
|
442
|
1536 {
|
771
|
1537 Extbyte exe_path[PATH_MAX];
|
442
|
1538 #ifdef WIN32_NATIVE
|
800
|
1539 GetModuleFileNameA (NULL, exe_path, PATH_MAX);
|
442
|
1540 #else /* !WIN32_NATIVE */
|
771
|
1541 Extbyte *w;
|
|
1542 const Extbyte *dir, *p;
|
442
|
1543
|
1204
|
1544 in_pdump = 1;
|
442
|
1545 dir = argv0;
|
|
1546 if (dir[0] == '-')
|
|
1547 {
|
|
1548 /* XEmacs as a login shell, oh goody! */
|
771
|
1549 dir = getenv ("SHELL"); /* not egetenv -- not yet initialized */
|
442
|
1550 }
|
|
1551
|
452
|
1552 p = dir + strlen (dir);
|
442
|
1553 while (p != dir && !IS_ANY_SEP (p[-1])) p--;
|
|
1554
|
|
1555 if (p != dir)
|
|
1556 {
|
|
1557 /* invocation-name includes a directory component -- presumably it
|
|
1558 is relative to cwd, not $PATH */
|
|
1559 strcpy (exe_path, dir);
|
|
1560 }
|
|
1561 else
|
|
1562 {
|
771
|
1563 const Extbyte *path = getenv ("PATH"); /* not egetenv -- not yet init. */
|
|
1564 const Extbyte *name = p;
|
442
|
1565 for (;;)
|
|
1566 {
|
|
1567 p = path;
|
|
1568 while (*p && *p != SEPCHAR)
|
|
1569 p++;
|
|
1570 if (p == path)
|
|
1571 {
|
|
1572 exe_path[0] = '.';
|
|
1573 w = exe_path + 1;
|
|
1574 }
|
|
1575 else
|
|
1576 {
|
|
1577 memcpy (exe_path, path, p - path);
|
|
1578 w = exe_path + (p - path);
|
|
1579 }
|
|
1580 if (!IS_DIRECTORY_SEP (w[-1]))
|
|
1581 {
|
|
1582 *w++ = '/';
|
|
1583 }
|
452
|
1584 strcpy (w, name);
|
442
|
1585
|
|
1586 if (!access (exe_path, X_OK))
|
|
1587 break;
|
|
1588 if (!*p)
|
|
1589 {
|
|
1590 /* Oh well, let's have some kind of default */
|
|
1591 sprintf (exe_path, "./%s", name);
|
|
1592 break;
|
|
1593 }
|
|
1594 path = p+1;
|
|
1595 }
|
|
1596 }
|
|
1597 #endif /* WIN32_NATIVE */
|
|
1598
|
|
1599 if (pdump_file_try (exe_path))
|
|
1600 {
|
|
1601 pdump_load_finish ();
|
1204
|
1602 in_pdump = 0;
|
442
|
1603 return 1;
|
|
1604 }
|
|
1605
|
|
1606 #ifdef WIN32_NATIVE
|
|
1607 if (pdump_resource_get ())
|
|
1608 {
|
|
1609 if (pdump_load_check ())
|
|
1610 {
|
|
1611 pdump_load_finish ();
|
1204
|
1612 in_pdump = 0;
|
442
|
1613 return 1;
|
|
1614 }
|
|
1615 pdump_free ();
|
|
1616 }
|
|
1617 #endif
|
|
1618
|
1204
|
1619 in_pdump = 0;
|
442
|
1620 return 0;
|
|
1621 }
|