annotate src/dumper.c @ 793:e38acbeb1cae

[xemacs-hg @ 2002-03-29 04:46:17 by ben] lots o' fixes etc/ChangeLog: New file. Separated out all entries for etc/ into their own ChangeLog. Includes entries for the following files: etc/BABYL, etc/BETA, etc/CHARSETS, etc/DISTRIB, etc/Emacs.ad, etc/FTP, etc/GNUS-NEWS, etc/GOATS, etc/HELLO, etc/INSTALL, etc/MACHINES, etc/MAILINGLISTS, etc/MSDOS, etc/MYTHOLOGY, etc/NEWS, etc/OXYMORONS, etc/PACKAGES, etc/README, etc/TUTORIAL, etc/TUTORIAL.de, etc/TUTORIAL.ja, etc/TUTORIAL.ko, etc/TUTORIAL.se, etc/aliases.ksh, etc/altrasoft-logo.xpm, etc/check_cygwin_setup.sh, etc/custom/example-themes/europe-theme.el, etc/custom/example-themes/ex-custom-file, etc/custom/example-themes/example-theme.el, etc/e/eterm.ti, etc/edt-user.doc, etc/enriched.doc, etc/etags.1, etc/gnuserv.1, etc/gnuserv.README, etc/package-index.LATEST.gpg, etc/package-index.LATEST.pgp, etc/photos/jan.png, etc/recycle.xpm, etc/refcard.tex, etc/sample.Xdefaults, etc/sample.emacs, etc/sgml/CATALOG, etc/sgml/HTML32.dtd, etc/skk/SKK.tut.E, etc/smilies/Face_ase.xbm, etc/smilies/Face_ase2.xbm, etc/smilies/Face_ase3.xbm, etc/smilies/Face_smile.xbm, etc/smilies/Face_weep.xbm, etc/sounds, etc/toolbar, etc/toolbar/workshop-cap-up.xpm, etc/xemacs-ja.1, etc/xemacs.1, etc/yow.lines, etc\BETA, etc\NEWS, etc\README, etc\TUTORIAL, etc\TUTORIAL.de, etc\check_cygwin_setup.sh, etc\sample.init.el, etc\unicode\README, etc\unicode\mule-ucs\*, etc\unicode\other\* unicode/unicode-consortium/8859-16.TXT: New file. mule/english.el: Define this charset now, since a bug was fixed that formerly prevented it. mule/ethio-util.el: Fix compile errors involving Unicode `characters', which should be integers. Makefile.in.in: Always include gui.c, to fix compile error when TTY-only. EmacsFrame.c, abbrev.c, alloc.c, buffer.c, buffer.h, bytecode.c, bytecode.h, callint.c, callproc.c, casetab.c, casetab.h, charset.h, chartab.c, chartab.h, cmds.c, console-msw.c, console-msw.h, console-tty.c, console-x.c, console-x.h, console.c, console.h, data.c, database.c, device-gtk.c, device-msw.c, device-x.c, device.c, device.h, dialog-msw.c, doc.c, doprnt.c, dumper.c, dynarr.c, editfns.c, eldap.c, eldap.h, elhash.c, elhash.h, emacs.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-tty.c, event-unixoid.c, events.c, events.h, extents.c, extents.h, faces.c, faces.h, file-coding.c, file-coding.h, fileio.c, filelock.c, fns.c, frame-gtk.c, frame-msw.c, frame-tty.c, frame-x.c, frame.c, frame.h, free-hook.c, general-slots.h, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gtk-xemacs.c, gui-msw.c, gui-x.c, gui-x.h, gui.c, gui.h, gutter.c, gutter.h, indent.c, input-method-xlib.c, insdel.c, keymap.c, keymap.h, lisp-disunion.h, lisp-union.h, lisp.h, lread.c, lrecord.h, lstream.c, lstream.h, marker.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, mule-canna.c, mule-ccl.c, mule-charset.c, mule-wnnfns.c, native-gtk-toolbar.c, objects-msw.c, objects-tty.c, objects-x.c, objects.c, objects.h, opaque.c, opaque.h, postgresql.c, postgresql.h, print.c, process-unix.c, process.c, process.h, rangetab.c, rangetab.h, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-tty.c, redisplay-x.c, redisplay.c, scrollbar-gtk.c, scrollbar-msw.c, scrollbar-x.c, scrollbar.c, scrollbar.h, search.c, select-gtk.c, select-x.c, sound.c, specifier.c, specifier.h, strftime.c, symbols.c, symeval.h, syntax.h, text.c, text.h, toolbar-common.c, toolbar-msw.c, toolbar.c, toolbar.h, tooltalk.c, tooltalk.h, ui-gtk.c, ui-gtk.h, undo.c, vm-limit.c, window.c, window.h: Eliminate XSETFOO. Replace all usages with wrap_foo(). Make symbol->name a Lisp_Object, not Lisp_String *. Eliminate nearly all uses of Lisp_String * in favor of Lisp_Object, and correct macros so most of them favor Lisp_Object. Create new error-behavior ERROR_ME_DEBUG_WARN -- output warnings, but at level `debug' (usually ignored). Use it when instantiating specifiers, so problems can be debugged. Move log-warning-minimum-level into C so that we can optimize ERROR_ME_DEBUG_WARN. Fix warning levels consistent with new definitions. Add default_ and parent fields to char table; not yet implemented. New fun Dynarr_verify(); use for further error checking on Dynarrs. Rearrange code at top of lisp.h in conjunction with dynarr changes. Fix eifree(). Use Eistrings in various places (format_event_object(), where_is_to_char(), and callers thereof) to avoid fixed-size strings buffers. New fun write_eistring(). Reindent and fix GPM code to follow standards. Set default MS Windows font to Lucida Console (same size as Courier New but less interline spacing, so more lines fit). Increase default frame size on Windows to 50 lines. (If that's too big for the workspace, the frame will be shrunk as necessary.) Fix problem with text files with no newlines (). (Change `convert-eol' coding system to use `nil' for autodetect, consistent with make-coding-system.) Correct compile warnings in vm-limit.c. Fix handling of reverse-direction charsets to avoid errors when opening (e.g.) mule-ucs/lisp/reldata/uiso8859-6.el. Recode some object printing methods to use write_fmt_string() instead of a fixed buffer and sprintf. Turn on display of png comments as warnings (level `info'), now that they're unobtrusive. Revamped the sound documentation. Fixed bug in redisplay w.r.t. hscroll/truncation/continuation glyphs causing jumping up and down of the lines, since they're bigger than the line size. (It was seen most obviously when there's a horizontal scroll bar, e.g. do C-h a glyph or something like that.) The problem was that the glyph-contrib-p setting on glyphs was ignored even if it was set properly, which it wasn't until now.
author ben
date Fri, 29 Mar 2002 04:49:13 +0000
parents 943eaba38521
children a5954632b187
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1 /* Portable data dumper for XEmacs.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
2 Copyright (C) 1999-2000 Olivier Galibert
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
3 Copyright (C) 2001 Martin Buchholz
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
4 Copyright (C) 2001 Ben Wing.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
5
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
6 This file is part of XEmacs.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
7
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
8 XEmacs is free software; you can redistribute it and/or modify it
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
10 Free Software Foundation; either version 2, or (at your option) any
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
11 later version.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
12
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
16 for more details.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
17
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
19 along with XEmacs; see the file COPYING. If not, write to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
21 Boston, MA 02111-1307, USA. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
22
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
23 /* Synched up with: Not in FSF. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
24
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
25 #include <config.h>
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
26 #include "lisp.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
27
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
28 #include "specifier.h"
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
29 #include "file-coding.h"
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
30 #include "elhash.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
31 #include "sysfile.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
32 #include "console-stream.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
33 #include "dumper.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
34
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
35 #ifdef WIN32_NATIVE
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
36 #include "syswindows.h"
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
37 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
38 #ifdef HAVE_MMAP
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
39 #include <sys/mman.h>
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
40 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
41 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
42
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
43 typedef struct
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
44 {
545
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 462
diff changeset
45 const void *varaddress;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
46 Bytecount size;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
47 } pdump_opaque;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
48
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
49 typedef struct
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
50 {
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
51 Dynarr_declare (pdump_opaque);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
52 } pdump_opaque_dynarr;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
53
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
54 typedef struct
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
55 {
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
56 void **ptraddress;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
57 const struct struct_description *desc;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
58 } pdump_root_struct_ptr;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
59
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
60 typedef struct
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
61 {
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
62 Dynarr_declare (pdump_root_struct_ptr);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
63 } pdump_root_struct_ptr_dynarr;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
64
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
65 typedef struct
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
66 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
67 Lisp_Object *address;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
68 Lisp_Object value;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
69 } pdump_static_Lisp_Object;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
70
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
71 typedef struct
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
72 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
73 char **address; /* char * for ease of doing relocation */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
74 char * value;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
75 } pdump_static_pointer;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
76
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
77 static pdump_opaque_dynarr *pdump_opaques;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
78 static pdump_root_struct_ptr_dynarr *pdump_root_struct_ptrs;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
79 static Lisp_Object_ptr_dynarr *pdump_root_objects;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
80 static Lisp_Object_ptr_dynarr *pdump_weak_object_chains;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
81
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
82 /* Mark SIZE bytes at non-heap address VARADDRESS for dumping as is,
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
83 without any bit-twiddling. */
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
84 void
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
85 dump_add_opaque (const void *varaddress, Bytecount size)
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
86 {
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
87 pdump_opaque info;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
88 info.varaddress = varaddress;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
89 info.size = size;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
90 if (pdump_opaques == NULL)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
91 pdump_opaques = Dynarr_new (pdump_opaque);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
92 Dynarr_add (pdump_opaques, info);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
93 }
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
94
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
95 /* Mark the struct described by DESC and pointed to by the pointer at
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
96 non-heap address VARADDRESS for dumping.
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
97 All the objects reachable from this pointer will also be dumped. */
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
98 void
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
99 dump_add_root_struct_ptr (void *ptraddress,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
100 const struct struct_description *desc)
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
101 {
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
102 pdump_root_struct_ptr info;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
103 info.ptraddress = (void **) ptraddress;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
104 info.desc = desc;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
105 if (pdump_root_struct_ptrs == NULL)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
106 pdump_root_struct_ptrs = Dynarr_new (pdump_root_struct_ptr);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
107 Dynarr_add (pdump_root_struct_ptrs, info);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
108 }
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
109
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
110 /* Mark the Lisp_Object at non-heap address VARADDRESS for dumping.
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
111 All the objects reachable from this var will also be dumped. */
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
112 void
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
113 dump_add_root_object (Lisp_Object *varaddress)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
114 {
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
115 if (pdump_root_objects == NULL)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
116 pdump_root_objects = Dynarr_new2 (Lisp_Object_ptr_dynarr, Lisp_Object *);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
117 Dynarr_add (pdump_root_objects, varaddress);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
118 }
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
119
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
120 /* Mark the list pointed to by the Lisp_Object at VARADDRESS for dumping. */
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
121 void
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
122 dump_add_weak_object_chain (Lisp_Object *varaddress)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
123 {
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
124 if (pdump_weak_object_chains == NULL)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
125 pdump_weak_object_chains = Dynarr_new2 (Lisp_Object_ptr_dynarr, Lisp_Object *);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
126 Dynarr_add (pdump_weak_object_chains, varaddress);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
127 }
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
128
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
129
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
130 inline static void
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
131 pdump_align_stream (FILE *stream, Bytecount alignment)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
132 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
133 long offset = ftell (stream);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
134 long adjustment = ALIGN_SIZE (offset, alignment) - offset;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
135 if (adjustment)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
136 fseek (stream, adjustment, SEEK_CUR);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
137 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
138
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
139 #define PDUMP_ALIGN_OUTPUT(type) pdump_align_stream (pdump_out, ALIGNOF (type))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
140
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
141 #define PDUMP_WRITE(type, object) \
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
142 retry_fwrite (&object, sizeof (object), 1, pdump_out);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
143
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
144 #define PDUMP_WRITE_ALIGNED(type, object) do { \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
145 PDUMP_ALIGN_OUTPUT (type); \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
146 PDUMP_WRITE (type, object); \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
147 } while (0)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
148
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
149 #define PDUMP_READ(ptr, type) \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
150 (((type *) (ptr = (char*) (((type *) ptr) + 1)))[-1])
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
151
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
152 #define PDUMP_READ_ALIGNED(ptr, type) \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
153 ((ptr = (char *) ALIGN_PTR (ptr, ALIGNOF (type))), PDUMP_READ (ptr, type))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
154
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
155
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
156
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
157 typedef struct
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
158 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
159 const struct lrecord_description *desc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
160 int count;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
161 } pdump_reloc_table;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
162
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
163 static char *pdump_rt_list = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
164
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
165 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
166 pdump_objects_unmark (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
167 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
168 int i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
169 char *p = pdump_rt_list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
170 if (p)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
171 for (;;)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
172 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
173 pdump_reloc_table *rt = (pdump_reloc_table *)p;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
174 p += sizeof (pdump_reloc_table);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
175 if (rt->desc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
176 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
177 for (i=0; i<rt->count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
178 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
179 struct lrecord_header *lh = * (struct lrecord_header **) p;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
180 if (! C_READONLY_RECORD_HEADER_P (lh))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
181 UNMARK_RECORD_HEADER (lh);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
182 p += sizeof (EMACS_INT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
183 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
184 } else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
185 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
186 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
187 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
188
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
189
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
190 /* The structure of the file
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
191 0 - header
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
192 - dumped objects
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
193 stab_offset - nb_root_struct_ptrs*pair(void *, adr)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
194 for pointers to structures
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
195 - nb_opaques*pair(void *, size) for raw bits to restore
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
196 - relocation table
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
197 - root lisp object address/value couples with the count
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
198 preceding the list
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
199 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
200
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
201
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
202 #define PDUMP_SIGNATURE "XEmacsDP"
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
203 #define PDUMP_SIGNATURE_LEN (sizeof (PDUMP_SIGNATURE) - 1)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
204
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
205 typedef struct
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
206 {
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
207 char signature[PDUMP_SIGNATURE_LEN];
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
208 unsigned int id;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
209 EMACS_UINT stab_offset;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
210 EMACS_UINT reloc_address;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
211 int nb_root_struct_ptrs;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
212 int nb_opaques;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
213 } pdump_header;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
214
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
215 char *pdump_start;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
216 char *pdump_end;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
217 static Bytecount pdump_length;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
218
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
219 #ifdef WIN32_NATIVE
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
220 /* Handle for the dump file */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
221 static HANDLE pdump_hFile = INVALID_HANDLE_VALUE;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
222 /* Handle for the file mapping object for the dump file */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
223 static HANDLE pdump_hMap = INVALID_HANDLE_VALUE;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
224 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
225
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
226 static void (*pdump_free) (void);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
227
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
228 static unsigned char pdump_align_table[] =
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
229 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
230 64, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1,
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
231 16, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1,
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
232 32, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1,
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
233 16, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
234 };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
235
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 619
diff changeset
236 static inline int
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
237 pdump_size_to_align (Bytecount size)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
238 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
239 return pdump_align_table[size % countof (pdump_align_table)];
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
240 }
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
241
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
242 typedef struct pdump_entry_list_elt
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
243 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
244 struct pdump_entry_list_elt *next;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
245 const void *obj;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
246 Bytecount size;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
247 int count;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
248 EMACS_INT save_offset;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
249 } pdump_entry_list_elt;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
250
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
251 typedef struct
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
252 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
253 pdump_entry_list_elt *first;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
254 int align;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
255 int count;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
256 } pdump_entry_list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
257
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
258 typedef struct pdump_struct_list_elt
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
259 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
260 pdump_entry_list list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
261 const struct struct_description *sdesc;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
262 } pdump_struct_list_elt;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
263
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
264 typedef struct
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
265 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
266 pdump_struct_list_elt *list;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
267 int count;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
268 int size;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
269 } pdump_struct_list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
270
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
271 static pdump_entry_list *pdump_object_table;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
272 static pdump_entry_list pdump_opaque_data_list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
273 static pdump_struct_list pdump_struct_table;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
274
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
275 static int *pdump_alert_undump_object;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
276
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
277 static unsigned long cur_offset;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
278 static Bytecount max_size;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
279 static int pdump_fd;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
280 static void *pdump_buf;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
281 static FILE *pdump_out;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
282
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
283 #define PDUMP_HASHSIZE 200001
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
284
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
285 static pdump_entry_list_elt **pdump_hash;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
286
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
287 /* Since most pointers are eight bytes aligned, the >>3 allows for a better hash */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
288 static int
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
289 pdump_make_hash (const void *obj)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
290 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
291 return ((unsigned long)(obj)>>3) % PDUMP_HASHSIZE;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
292 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
293
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
294 static pdump_entry_list_elt *
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
295 pdump_get_entry (const void *obj)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
296 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
297 int pos = pdump_make_hash (obj);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
298 pdump_entry_list_elt *e;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
299
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
300 assert (obj != 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
301
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
302 while ((e = pdump_hash[pos]) != 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
303 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
304 if (e->obj == obj)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
305 return e;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
306
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
307 pos++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
308 if (pos == PDUMP_HASHSIZE)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
309 pos = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
310 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
311 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
312 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
313
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
314 static void
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
315 pdump_add_entry (pdump_entry_list *list, const void *obj, Bytecount size,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
316 int count)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
317 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
318 pdump_entry_list_elt *e;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
319 int pos = pdump_make_hash (obj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
320
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
321 while ((e = pdump_hash[pos]) != 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
322 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
323 if (e->obj == obj)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
324 return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
325
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
326 pos++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
327 if (pos == PDUMP_HASHSIZE)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
328 pos = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
329 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
330
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
331 e = xnew (pdump_entry_list_elt);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
332
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
333 e->next = list->first;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
334 e->obj = obj;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
335 e->size = size;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
336 e->count = count;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
337 list->first = e;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
338
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
339 list->count += count;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
340 pdump_hash[pos] = e;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
341
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
342 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
343 int align = pdump_size_to_align (size);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
344
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
345 if (align < list->align)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
346 list->align = align;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
347 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
348 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
349
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
350 static pdump_entry_list *
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
351 pdump_get_entry_list (const struct struct_description *sdesc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
352 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
353 int i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
354 for (i=0; i<pdump_struct_table.count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
355 if (pdump_struct_table.list[i].sdesc == sdesc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
356 return &pdump_struct_table.list[i].list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
357
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
358 if (pdump_struct_table.size <= pdump_struct_table.count)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
359 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
360 if (pdump_struct_table.size == -1)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
361 pdump_struct_table.size = 10;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
362 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
363 pdump_struct_table.size = pdump_struct_table.size * 2;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
364 pdump_struct_table.list = (pdump_struct_list_elt *)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
365 xrealloc (pdump_struct_table.list,
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
366 pdump_struct_table.size * sizeof (pdump_struct_list_elt));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
367 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
368 pdump_struct_table.list[pdump_struct_table.count].list.first = 0;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
369 pdump_struct_table.list[pdump_struct_table.count].list.align = ALIGNOF (max_align_t);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
370 pdump_struct_table.list[pdump_struct_table.count].list.count = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
371 pdump_struct_table.list[pdump_struct_table.count].sdesc = sdesc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
372
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
373 return &pdump_struct_table.list[pdump_struct_table.count++].list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
374 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
375
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
376 static struct
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
377 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
378 struct lrecord_header *obj;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
379 int position;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
380 int offset;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
381 } backtrace[65536];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
382
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
383 static int depth;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
384
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
385 static void
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
386 pdump_backtrace (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
387 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
388 int i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
389 stderr_out ("pdump backtrace :\n");
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
390 for (i = 0; i < depth; i++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
391 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
392 if (!backtrace[i].obj)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
393 stderr_out (" - ind. (%d, %d)\n",
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
394 backtrace[i].position,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
395 backtrace[i].offset);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
396 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
397 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
398 stderr_out (" - %s (%d, %d)\n",
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
399 LHEADER_IMPLEMENTATION (backtrace[i].obj)->name,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
400 backtrace[i].position,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
401 backtrace[i].offset);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
402 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
403 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
404 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
405
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
406 static void pdump_register_object (Lisp_Object obj);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
407 static void pdump_register_struct_contents (const void *data,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
408 const struct struct_description *
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
409 sdesc,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
410 int count);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
411 static void pdump_register_struct (const void *data,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
412 const struct struct_description *sdesc,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
413 int count);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
414
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
415 static EMACS_INT
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
416 pdump_get_indirect_count (EMACS_INT code,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
417 const struct lrecord_description *idesc,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
418 const void *idata)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
419 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
420 EMACS_INT count;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
421 const void *irdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
422
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
423 int line = XD_INDIRECT_VAL (code);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
424 int delta = XD_INDIRECT_DELTA (code);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
425
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
426 irdata = ((char *)idata) + idesc[line].offset;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
427 switch (idesc[line].type)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
428 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
429 case XD_BYTECOUNT:
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
430 count = *(Bytecount *)irdata;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 619
diff changeset
431 break;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
432 case XD_ELEMCOUNT:
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
433 count = *(Elemcount *)irdata;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 619
diff changeset
434 break;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
435 case XD_HASHCODE:
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
436 count = *(Hashcode *)irdata;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
437 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
438 case XD_INT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
439 count = *(int *)irdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
440 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
441 case XD_LONG:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
442 count = *(long *)irdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
443 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
444 default:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
445 stderr_out ("Unsupported count type : %d (line = %d, code=%ld)\n",
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
446 idesc[line].type, line, (long)code);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
447 pdump_backtrace ();
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 619
diff changeset
448 count = 0; /* warning suppression */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
449 abort ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
450 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
451 count += delta;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
452 return count;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
453 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
454
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
455 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
456 pdump_register_sub (const void *data, const struct lrecord_description *desc, int me)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
457 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
458 int pos;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
459
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
460 restart:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
461 for (pos = 0; desc[pos].type != XD_END; pos++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
462 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
463 const void *rdata = (const char *)data + desc[pos].offset;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
464
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
465 backtrace[me].position = pos;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
466 backtrace[me].offset = desc[pos].offset;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
467
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
468 switch (desc[pos].type)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
469 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
470 case XD_SPECIFIER_END:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
471 pos = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
472 desc = ((const Lisp_Specifier *)data)->methods->extra_description;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
473 goto restart;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
474 case XD_CODING_SYSTEM_END:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
475 pos = 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
476 desc =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
477 ((const Lisp_Coding_System *)data)->methods->extra_description;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
478 goto restart;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
479 case XD_BYTECOUNT:
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
480 case XD_ELEMCOUNT:
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
481 case XD_HASHCODE:
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
482 case XD_INT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
483 case XD_LONG:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
484 case XD_INT_RESET:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
485 case XD_LO_LINK:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
486 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
487 case XD_OPAQUE_DATA_PTR:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
488 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
489 EMACS_INT count = desc[pos].data1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
490 if (XD_IS_INDIRECT (count))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
491 count = pdump_get_indirect_count (count, desc, data);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
492
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
493 pdump_add_entry (&pdump_opaque_data_list,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
494 *(void **)rdata, count, 1);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
495 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
496 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
497 case XD_C_STRING:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
498 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
499 const char *str = *(const char **)rdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
500 if (str)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
501 pdump_add_entry (&pdump_opaque_data_list, str, strlen (str)+1, 1);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
502 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
503 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
504 case XD_DOC_STRING:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
505 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
506 const char *str = *(const char **)rdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
507 if ((EMACS_INT)str > 0)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
508 pdump_add_entry (&pdump_opaque_data_list, str, strlen (str)+1, 1);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
509 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
510 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
511 case XD_LISP_OBJECT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
512 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
513 const Lisp_Object *pobj = (const Lisp_Object *)rdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
514
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
515 assert (desc[pos].data1 == 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
516
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
517 backtrace[me].offset = (const char *)pobj - (const char *)data;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
518 pdump_register_object (*pobj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
519 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
520 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
521 case XD_LISP_OBJECT_ARRAY:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
522 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
523 int i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
524 EMACS_INT count = desc[pos].data1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
525 if (XD_IS_INDIRECT (count))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
526 count = pdump_get_indirect_count (count, desc, data);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
527
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
528 for (i = 0; i < count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
529 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
530 const Lisp_Object *pobj = ((const Lisp_Object *)rdata) + i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
531 Lisp_Object dobj = *pobj;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
532
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
533 backtrace[me].offset = (const char *)pobj - (const char *)data;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
534 pdump_register_object (dobj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
535 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
536 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
537 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
538 case XD_STRUCT_PTR:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
539 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
540 EMACS_INT count = desc[pos].data1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
541 const struct struct_description *sdesc = desc[pos].data2;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
542 const char *dobj = *(const char **)rdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
543 if (dobj)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
544 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
545 if (XD_IS_INDIRECT (count))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
546 count = pdump_get_indirect_count (count, desc, data);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
547
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
548 pdump_register_struct (dobj, sdesc, count);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
549 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
550 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
551 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
552 case XD_STRUCT_ARRAY:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
553 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
554 EMACS_INT count = desc[pos].data1;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
555 const struct struct_description *sdesc = desc[pos].data2;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
556
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
557 if (XD_IS_INDIRECT (count))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
558 count = pdump_get_indirect_count (count, desc, data);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
559
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
560 pdump_register_struct_contents (rdata, sdesc, count);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
561 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
562 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
563 case XD_UNION:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
564 abort (); /* #### IMPLEMENT ME! NEEDED FOR UNICODE SUPPORT */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
565
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
566 default:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
567 stderr_out ("Unsupported dump type : %d\n", desc[pos].type);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
568 pdump_backtrace ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
569 abort ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
570 };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
571 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
572 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
573
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
574 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
575 pdump_register_object (Lisp_Object obj)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
576 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
577 struct lrecord_header *objh;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
578 const struct lrecord_implementation *imp;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
579
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
580 if (!POINTER_TYPE_P (XTYPE (obj)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
581 return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
582
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
583 objh = XRECORD_LHEADER (obj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
584 if (!objh)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
585 return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
586
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
587 if (pdump_get_entry (objh))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
588 return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
589
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
590 imp = LHEADER_IMPLEMENTATION (objh);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
591
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
592 if (imp->description)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
593 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
594 int me = depth++;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
595 if (me > 65536)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
596 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
597 stderr_out ("Backtrace overflow, loop ?\n");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
598 abort ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
599 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
600 backtrace[me].obj = objh;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
601 backtrace[me].position = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
602 backtrace[me].offset = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
603
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
604 pdump_add_entry (pdump_object_table + objh->type,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
605 objh,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
606 imp->static_size ?
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
607 imp->static_size :
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
608 imp->size_in_bytes_method (objh),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
609 1);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
610 pdump_register_sub (objh, imp->description, me);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
611 --depth;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
612 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
613 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
614 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
615 pdump_alert_undump_object[objh->type]++;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
616 stderr_out ("Undumpable object type : %s\n", imp->name);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
617 pdump_backtrace ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
618 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
619 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
620
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
621 /* Return the size of the memory block (NOT necessarily a structure!)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
622 described by SDESC and pointed to by OBJ. If SDESC records an
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
623 explicit size (i.e. non-zero), it is simply returned; otherwise,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
624 the size is calculated by the maximum offset and the size of the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
625 object at that offset, rounded up to the maximum alignment. In
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
626 this case, we may need the object, for example when retrieving an
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
627 "indirect count" of an inlined array (the count is not constant,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
628 but is specified by one of the elements of the memory block). (It
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
629 is generally not a problem if we return an overly large size -- we
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
630 will simply end up reserving more space than necessary; but if the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
631 size is too small we could be in serious trouble, in particular
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
632 with nested inlined structures, where there may be alignment
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
633 padding in the middle of a block. #### In fact there is an (at
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
634 least theoretical) problem with an overly large size -- we may
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
635 trigger a protection fault when reading from invalid memory. We
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
636 need to handle this -- perhaps in a stupid but dependable way,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
637 i.e. by trapping SIGSEGV and SIGBUS.) */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
638
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
639 static Bytecount
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
640 pdump_structure_size (const void *obj, const struct struct_description *sdesc)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
641 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
642 int max_offset = -1;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
643 int max_offset_pos = -1;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
644 int size_at_max = 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
645 int pos;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
646 const struct lrecord_description *desc;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
647 void *rdata;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
648
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
649 if (sdesc->size)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
650 return sdesc->size;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
651
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
652 desc = sdesc->description;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
653
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
654 for (pos = 0; desc[pos].type != XD_END; pos++)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
655 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
656 if (desc[pos].offset == max_offset)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
657 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
658 stderr_out ("Two relocatable elements at same offset?\n");
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
659 abort ();
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
660 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
661 else if (desc[pos].offset > max_offset)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
662 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
663 max_offset = desc[pos].offset;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
664 max_offset_pos = pos;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
665 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
666 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
667
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
668 if (max_offset_pos < 0)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
669 return 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
670
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
671 pos = max_offset_pos;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
672 rdata = (char *) obj + desc[pos].offset;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
673
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
674 switch (desc[pos].type)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
675 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
676 case XD_LISP_OBJECT_ARRAY:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
677 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
678 EMACS_INT val = desc[pos].data1;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
679 if (XD_IS_INDIRECT (val))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
680 val = pdump_get_indirect_count (val, desc, obj);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
681 size_at_max = val * sizeof (Lisp_Object);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
682 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
683 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
684 case XD_LISP_OBJECT:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
685 case XD_LO_LINK:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
686 size_at_max = sizeof (Lisp_Object);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
687 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
688 case XD_OPAQUE_PTR:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
689 size_at_max = sizeof (void *);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
690 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
691 case XD_STRUCT_PTR:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
692 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
693 EMACS_INT val = desc[pos].data1;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
694 if (XD_IS_INDIRECT (val))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
695 val = pdump_get_indirect_count (val, desc, obj);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
696 size_at_max = val * sizeof (void *);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
697 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
698 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
699 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
700 case XD_STRUCT_ARRAY:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
701 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
702 EMACS_INT val = desc[pos].data1;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
703
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
704 if (XD_IS_INDIRECT (val))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
705 val = pdump_get_indirect_count (val, desc, obj);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
706
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
707 size_at_max = val * pdump_structure_size (rdata, desc[pos].data2);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
708 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
709 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
710 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
711 case XD_OPAQUE_DATA_PTR:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
712 size_at_max = sizeof (void *);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
713 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
714 case XD_UNION:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
715 abort (); /* #### IMPLEMENT ME! NEEDED FOR UNICODE
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
716 SUPPORT */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
717 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
718 case XD_C_STRING:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
719 size_at_max = sizeof (void *);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
720 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
721 case XD_DOC_STRING:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
722 size_at_max = sizeof (void *);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
723 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
724 case XD_INT_RESET:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
725 size_at_max = sizeof (int);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
726 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
727 case XD_BYTECOUNT:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
728 size_at_max = sizeof (Bytecount);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
729 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
730 case XD_ELEMCOUNT:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
731 size_at_max = sizeof (Elemcount);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
732 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
733 case XD_HASHCODE:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
734 size_at_max = sizeof (Hashcode);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
735 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
736 case XD_INT:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
737 size_at_max = sizeof (int);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
738 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
739 case XD_LONG:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
740 size_at_max = sizeof (long);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
741 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
742 case XD_SPECIFIER_END:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
743 case XD_CODING_SYSTEM_END:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
744 stderr_out
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
745 ("Should not be seeing XD_SPECIFIER_END or\n"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
746 "XD_CODING_SYSTEM_END outside of struct Lisp_Specifier\n"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
747 "and struct Lisp_Coding_System.\n");
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
748 abort ();
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
749 default:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
750 stderr_out ("Unsupported dump type : %d\n", desc[pos].type);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
751 abort ();
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
752 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
753
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
754 /* We have no way of knowing the required alignment for this structure,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
755 so just max it maximally aligned. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
756 return ALIGN_SIZE (max_offset + size_at_max, ALIGNOF (max_align_t));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
757 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
758
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
759 /* Register the referenced objects in the array of COUNT objects of
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
760 located at DATA; each object is described by SDESC. "Object" here
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
761 simply means any block of memory; it need not actually be a C
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
762 "struct". It could be a single integer or Lisp_Object, for
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
763 example, as long as the description is accurate.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
764
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
765 This does not register the block of memory itself; it may, for
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
766 example, be an array of structures inlined in another memory block
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
767 and thus should not be registered. See pdump_register_struct(),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
768 which does register the memory block. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
769
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
770 static void
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
771 pdump_register_struct_contents (const void *data,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
772 const struct struct_description *sdesc,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
773 int count)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
774
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
775 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
776 int me = depth++;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
777 int i;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
778 Bytecount elsize;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
779
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
780 if (me>65536)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
781 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
782 stderr_out ("Backtrace overflow, loop ?\n");
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
783 abort ();
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
784 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
785 backtrace[me].obj = 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
786 backtrace[me].position = 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
787 backtrace[me].offset = 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
788
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
789 elsize = pdump_structure_size (data, sdesc);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
790
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
791 for (i = 0; i < count; i++)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
792 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
793 pdump_register_sub (((char *) data) + elsize * i,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
794 sdesc->description,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
795 me);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
796 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
797 --depth;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
798 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
799
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
800 /* Register the array of COUNT objects of located at DATA; each object is
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
801 described by SDESC. "Object" here simply means any block of memory;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
802 it need not actually be a C "struct". It could be a single integer
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
803 or Lisp_Object, for example, as long as the description is accurate.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
804
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
805 This is like pdump_register_struct_contents() but also registers
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
806 the memory block itself. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
807
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
808 static void
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
809 pdump_register_struct (const void *data,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
810 const struct struct_description *sdesc,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
811 int count)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
812 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
813 if (data && !pdump_get_entry (data))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
814 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
815 pdump_add_entry (pdump_get_entry_list (sdesc), data,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
816 pdump_structure_size (data, sdesc), count);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
817
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
818 pdump_register_struct_contents (data, sdesc, count);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
819 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
820 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
821
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
822 /* Store the already-calculated new pointer offsets for all pointers
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
823 in the COUNT contiguous blocks of memory, each described by DESC
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
824 and of size SIZE, whose original is located at ORIG_DATA and the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
825 modifiable copy at DATA.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
826
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
827 This is done just before writing the modified block of memory to
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
828 the dump file. The new pointer offsets have been carefully
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
829 calculated so that the data being pointed gets written at that
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
830 offset in the dump file. That way, the dump file is a correct
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
831 memory image except perhaps for a constant that needs to be added
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
832 to all pointers. (#### In fact, we SHOULD be starting up a dumped
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
833 XEmacs, seeing where the dumped file gets loaded into memory, and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
834 then rewriting the dumped file after relocating all the pointers
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
835 relative to this memory location. That way, if the file gets
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
836 loaded again at the same location, which will be common, we don't
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
837 have to do any relocating, which is both faster at startup and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
838 allows the read-only part of the dumped data to be shared read-only
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
839 between different invocations of XEmacs.)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
840
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
841 #### Do we distinguish between read-only and writable dumped data?
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
842 Should we? It's tricky because the dumped data, once loaded again,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
843 cannot really be free()d or garbage collected since it's all stored
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
844 in one contiguous block of data with no malloc() headers, and we
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
845 don't keep track of the pointers used internally in malloc() and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
846 the Lisp allocator to track allocated blocks of memory. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
847
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
848 static void
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
849 pdump_store_new_pointer_offsets (int count, void *data, const void *orig_data,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
850 const struct lrecord_description *desc,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
851 int size)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
852 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
853 int pos, i;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
854 /* Process each block one by one */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
855 for (i = 0; i < count; i++)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
856 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
857 /* CUR points to the beginning of each block in the new data. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
858 char *cur = ((char *)data) + i*size;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
859 restart:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
860 /* Scan each line of the description for relocatable pointers */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
861 for (pos = 0; desc[pos].type != XD_END; pos++)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
862 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
863 /* RDATA points to the beginning of each element in the new data. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
864 void *rdata = cur + desc[pos].offset;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
865 switch (desc[pos].type)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
866 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
867 case XD_SPECIFIER_END:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
868 desc = ((const Lisp_Specifier *)(orig_data))->
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
869 methods->extra_description;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
870 goto restart;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
871 case XD_CODING_SYSTEM_END:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
872 desc = ((const Lisp_Coding_System *)(orig_data))->
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
873 methods->extra_description;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
874 goto restart;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
875 case XD_BYTECOUNT:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
876 case XD_ELEMCOUNT:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
877 case XD_HASHCODE:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
878 case XD_INT:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
879 case XD_LONG:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
880 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
881 case XD_INT_RESET:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
882 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
883 EMACS_INT val = desc[pos].data1;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
884 if (XD_IS_INDIRECT (val))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
885 val = pdump_get_indirect_count (val, desc, orig_data);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
886 * (int *) rdata = val;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
887 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
888 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
889 case XD_OPAQUE_DATA_PTR:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
890 case XD_C_STRING:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
891 case XD_STRUCT_PTR:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
892 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
893 void *ptr = * (void **) rdata;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
894 if (ptr)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
895 * (EMACS_INT *) rdata = pdump_get_entry (ptr)->save_offset;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
896 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
897 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
898 case XD_LO_LINK:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
899 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
900 /* As described in lrecord.h, this is a weak link.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
901 Thus, we need to link this object not (necessarily)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
902 to the object directly pointed to, but to the next
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
903 referenced object in the chain. None of the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
904 intermediate objects will be written out, so we
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
905 traverse down the chain of objects until we find a
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
906 referenced one. (The Qnil or Qunbound that ends the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
907 chain will always be a referenced object.) */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
908 Lisp_Object obj = * (Lisp_Object *) rdata;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
909 pdump_entry_list_elt *elt1;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
910 for (;;)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
911 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
912 elt1 = pdump_get_entry (XRECORD_LHEADER (obj));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
913 if (elt1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
914 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
915 obj = * (Lisp_Object *) (desc[pos].offset +
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
916 (char *)(XRECORD_LHEADER (obj)));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
917 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
918 * (EMACS_INT *) rdata = elt1->save_offset;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
919 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
920 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
921 case XD_LISP_OBJECT:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
922 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
923 Lisp_Object *pobj = (Lisp_Object *) rdata;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
924
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
925 assert (desc[pos].data1 == 0);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
926
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
927 if (POINTER_TYPE_P (XTYPE (*pobj)) && XRECORD_LHEADER (*pobj))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
928 * (EMACS_INT *) pobj =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
929 pdump_get_entry (XRECORD_LHEADER (*pobj))->save_offset;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
930 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
931 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
932 case XD_LISP_OBJECT_ARRAY:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
933 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
934 EMACS_INT num = desc[pos].data1;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
935 int j;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
936 if (XD_IS_INDIRECT (num))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
937 num = pdump_get_indirect_count (num, desc, orig_data);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
938
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
939 for (j = 0; j < num; j++)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
940 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
941 Lisp_Object *pobj = ((Lisp_Object *) rdata) + j;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
942 if (POINTER_TYPE_P (XTYPE (*pobj)) &&
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
943 XRECORD_LHEADER (*pobj))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
944 * (EMACS_INT *) pobj =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
945 pdump_get_entry (XRECORD_LHEADER (*pobj))->save_offset;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
946 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
947 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
948 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
949 case XD_DOC_STRING:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
950 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
951 EMACS_INT str = *(EMACS_INT *)rdata;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
952 if (str > 0)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
953 * (EMACS_INT *) rdata =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
954 pdump_get_entry ((void *)str)->save_offset;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
955 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
956 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
957 case XD_STRUCT_ARRAY:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
958 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
959 EMACS_INT num = desc[pos].data1;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
960 if (XD_IS_INDIRECT (num))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
961 num = pdump_get_indirect_count (num, desc, orig_data);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
962
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
963 pdump_store_new_pointer_offsets
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
964 (num, rdata,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
965 ((char *) rdata - (char *) data) + (char *) orig_data,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
966 desc[pos].data2->description,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
967 pdump_structure_size
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
968 (((char *) rdata - (char *) data) + (char *) orig_data,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
969 desc[pos].data2));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
970 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
971 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
972 case XD_UNION:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
973 abort (); /* #### IMPLEMENT ME! NEEDED FOR UNICODE
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
974 SUPPORT */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
975
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
976 default:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
977 stderr_out ("Unsupported dump type : %d\n", desc[pos].type);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
978 abort ();
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
979 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
980 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
981 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
982 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
983
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
984 /* Write out to global file descriptor PDUMP_OUT the element (one or
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
985 more contiguous blocks of identical size/description) recorded in
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
986 ELT and described by DESC. The element is first copied to a buffer
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
987 and then all pointers (this includes Lisp_Objects other than
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
988 integer/character) are relocated to the (pre-computed) offset in
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
989 the dump file. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
990
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
991 static void
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
992 pdump_dump_data (pdump_entry_list_elt *elt,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
993 const struct lrecord_description *desc)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
994 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
995 Bytecount size = elt->size;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
996 int count = elt->count;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
997 if (desc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
998 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
999 /* Copy to temporary buffer */
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1000 memcpy (pdump_buf, elt->obj, size*count);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1001
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1002 /* Store new offsets into all pointers in block */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1003 pdump_store_new_pointer_offsets (count, pdump_buf, elt->obj, desc, size);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1004 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1005 retry_fwrite (desc ? pdump_buf : elt->obj, size, count, pdump_out);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1006 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1007
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1008 /* Relocate a single memory block at DATA, described by DESC, from its
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1009 assumed load location to its actual one by adding DELTA to all
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1010 pointers in the block. Does not recursively relocate any other
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1011 memory blocks pointed to. (We already have a list of all memory
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1012 blocks in the dump file.) */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1013
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1014 static void
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1015 pdump_reloc_one (void *data, EMACS_INT delta,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1016 const struct lrecord_description *desc)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1017 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1018 int pos;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1019
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1020 restart:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1021 for (pos = 0; desc[pos].type != XD_END; pos++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1022 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1023 void *rdata = (char *)data + desc[pos].offset;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1024 switch (desc[pos].type)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1025 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1026 case XD_SPECIFIER_END:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1027 pos = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1028 desc = ((const Lisp_Specifier *)data)->methods->extra_description;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1029 goto restart;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1030 case XD_CODING_SYSTEM_END:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1031 pos = 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1032 desc =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1033 ((const Lisp_Coding_System *)data)->methods->extra_description;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1034 goto restart;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
1035 case XD_BYTECOUNT:
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
1036 case XD_ELEMCOUNT:
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
1037 case XD_HASHCODE:
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1038 case XD_INT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1039 case XD_LONG:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1040 case XD_INT_RESET:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1041 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1042 case XD_OPAQUE_DATA_PTR:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1043 case XD_C_STRING:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1044 case XD_STRUCT_PTR:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1045 case XD_LO_LINK:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1046 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1047 EMACS_INT ptr = *(EMACS_INT *)rdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1048 if (ptr)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1049 *(EMACS_INT *)rdata = ptr+delta;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1050 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1051 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1052 case XD_LISP_OBJECT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1053 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1054 Lisp_Object *pobj = (Lisp_Object *) rdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1055
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1056 assert (desc[pos].data1 == 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1057
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1058 if (POINTER_TYPE_P (XTYPE (*pobj))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1059 && ! EQ (*pobj, Qnull_pointer))
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1060 *pobj = wrap_pointer_1 ((char *) XPNTR (*pobj) + delta);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1061
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1062 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1063 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1064 case XD_LISP_OBJECT_ARRAY:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1065 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1066 EMACS_INT num = desc[pos].data1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1067 int j;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1068 if (XD_IS_INDIRECT (num))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1069 num = pdump_get_indirect_count (num, desc, data);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1070
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1071 for (j=0; j<num; j++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1072 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1073 Lisp_Object *pobj = (Lisp_Object *) rdata + j;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1074
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1075 if (POINTER_TYPE_P (XTYPE (*pobj))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1076 && ! EQ (*pobj, Qnull_pointer))
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1077 *pobj = wrap_pointer_1 ((char *) XPNTR (*pobj) + delta);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1078 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1079 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1080 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1081 case XD_DOC_STRING:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1082 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1083 EMACS_INT str = *(EMACS_INT *)rdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1084 if (str > 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1085 *(EMACS_INT *)rdata = str + delta;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1086 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1087 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1088 case XD_STRUCT_ARRAY:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1089 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1090 EMACS_INT num = desc[pos].data1;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1091 int j;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1092 const struct struct_description *sdesc = desc[pos].data2;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1093 Bytecount size = pdump_structure_size (rdata, sdesc);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1094
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1095 if (XD_IS_INDIRECT (num))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1096 num = pdump_get_indirect_count (num, desc, data);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1097 /* Note: We are recursing over data in the block itself */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1098 for (j = 0; j < num; j++)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1099 pdump_reloc_one ((char *) rdata + j * size, delta,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1100 sdesc->description);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1101
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1102 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1103 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1104
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1105 case XD_UNION:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1106 abort (); /* #### IMPLEMENT ME! NEEDED FOR UNICODE SUPPORT */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1107 default:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1108 stderr_out ("Unsupported dump type : %d\n", desc[pos].type);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1109 abort ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1110 };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1111 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1112 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1113
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1114 static void
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1115 pdump_allocate_offset (pdump_entry_list_elt *elt,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1116 const struct lrecord_description *desc)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1117 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
1118 Bytecount size = elt->count * elt->size;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1119 elt->save_offset = cur_offset;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1120 if (size>max_size)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1121 max_size = size;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1122 cur_offset += size;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1123 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1124
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1125 static void
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1126 pdump_scan_by_alignment (void (*f)(pdump_entry_list_elt *,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1127 const struct lrecord_description *))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1128 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1129 int align;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1130
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1131 for (align = ALIGNOF (max_align_t); align; align>>=1)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1132 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1133 int i;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1134 pdump_entry_list_elt *elt;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1135
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1136 for (i=0; i<lrecord_type_count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1137 if (pdump_object_table[i].align == align)
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1138 for (elt = pdump_object_table[i].first; elt; elt = elt->next)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1139 f (elt, lrecord_implementations_table[i]->description);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1140
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1141 for (i=0; i<pdump_struct_table.count; i++)
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1142 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1143 pdump_struct_list_elt list = pdump_struct_table.list[i];
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1144 if (list.list.align == align)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1145 for (elt = list.list.first; elt; elt = elt->next)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1146 f (elt, list.sdesc->description);
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1147 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1148
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1149 for (elt = pdump_opaque_data_list.first; elt; elt = elt->next)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1150 if (pdump_size_to_align (elt->size) == align)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1151 f (elt, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1152 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1153 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1154
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1155 static void
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1156 pdump_dump_root_struct_ptrs (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1157 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1158 int i;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
1159 Elemcount count = Dynarr_length (pdump_root_struct_ptrs);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1160 pdump_static_pointer *data = alloca_array (pdump_static_pointer, count);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1161 for (i = 0; i < count; i++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1162 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1163 data[i].address = (char **) Dynarr_atp (pdump_root_struct_ptrs, i)->ptraddress;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1164 data[i].value = (char *) pdump_get_entry (* data[i].address)->save_offset;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1165 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1166 PDUMP_ALIGN_OUTPUT (pdump_static_pointer);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1167 retry_fwrite (data, sizeof (pdump_static_pointer), count, pdump_out);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1168 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1169
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1170 static void
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1171 pdump_dump_opaques (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1172 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1173 int i;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1174 for (i = 0; i < Dynarr_length (pdump_opaques); i++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1175 {
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1176 pdump_opaque *info = Dynarr_atp (pdump_opaques, i);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1177 PDUMP_WRITE_ALIGNED (pdump_opaque, *info);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1178 retry_fwrite (info->varaddress, info->size, 1, pdump_out);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1179 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1180 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1181
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1182 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1183 pdump_dump_rtables (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1184 {
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1185 int i;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1186 pdump_entry_list_elt *elt;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1187 pdump_reloc_table rt;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1188
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1189 for (i=0; i<lrecord_type_count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1190 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1191 elt = pdump_object_table[i].first;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1192 if (!elt)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1193 continue;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1194 rt.desc = lrecord_implementations_table[i]->description;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1195 rt.count = pdump_object_table[i].count;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1196 PDUMP_WRITE_ALIGNED (pdump_reloc_table, rt);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1197 while (elt)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1198 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1199 EMACS_INT rdata = pdump_get_entry (elt->obj)->save_offset;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1200 PDUMP_WRITE_ALIGNED (EMACS_INT, rdata);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1201 elt = elt->next;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1202 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1203 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1204
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1205 rt.desc = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1206 rt.count = 0;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1207 PDUMP_WRITE_ALIGNED (pdump_reloc_table, rt);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1208
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1209 for (i=0; i<pdump_struct_table.count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1210 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1211 elt = pdump_struct_table.list[i].list.first;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1212 rt.desc = pdump_struct_table.list[i].sdesc->description;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1213 rt.count = pdump_struct_table.list[i].list.count;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1214 PDUMP_WRITE_ALIGNED (pdump_reloc_table, rt);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1215 while (elt)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1216 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1217 EMACS_INT rdata = pdump_get_entry (elt->obj)->save_offset;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1218 int j;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1219 for (j=0; j<elt->count; j++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1220 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1221 PDUMP_WRITE_ALIGNED (EMACS_INT, rdata);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1222 rdata += elt->size;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1223 }
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1224 elt = elt->next;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1225 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1226 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1227 rt.desc = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1228 rt.count = 0;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1229 PDUMP_WRITE_ALIGNED (pdump_reloc_table, rt);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1230 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1231
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1232 static void
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1233 pdump_dump_root_objects (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1234 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
1235 Elemcount count = (Dynarr_length (pdump_root_objects) +
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 619
diff changeset
1236 Dynarr_length (pdump_weak_object_chains));
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
1237 Elemcount i;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1238
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
1239 PDUMP_WRITE_ALIGNED (Elemcount, count);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1240 PDUMP_ALIGN_OUTPUT (pdump_static_Lisp_Object);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1241
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 619
diff changeset
1242 for (i = 0; i < Dynarr_length (pdump_root_objects); i++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1243 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1244 pdump_static_Lisp_Object obj;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1245 obj.address = Dynarr_at (pdump_root_objects, i);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1246 obj.value = * obj.address;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1247
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1248 if (POINTER_TYPE_P (XTYPE (obj.value)))
619
8d7292eb4a18 [xemacs-hg @ 2001-06-19 01:35:35 by ben]
ben
parents: 617
diff changeset
1249 obj.value =
8d7292eb4a18 [xemacs-hg @ 2001-06-19 01:35:35 by ben]
ben
parents: 617
diff changeset
1250 wrap_pointer_1 ((void *) pdump_get_entry (XRECORD_LHEADER
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 545
diff changeset
1251 (obj.value))->save_offset);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1252
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1253 PDUMP_WRITE (pdump_static_Lisp_Object, obj);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1254 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1255
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1256 for (i=0; i<Dynarr_length (pdump_weak_object_chains); i++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1257 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1258 pdump_entry_list_elt *elt;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1259 pdump_static_Lisp_Object obj;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1260
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1261 obj.address = Dynarr_at (pdump_weak_object_chains, i);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1262 obj.value = * obj.address;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1263
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1264 for (;;)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1265 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1266 const struct lrecord_description *desc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1267 int pos;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1268 elt = pdump_get_entry (XRECORD_LHEADER (obj.value));
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1269 if (elt)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1270 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1271 desc = XRECORD_LHEADER_IMPLEMENTATION (obj.value)->description;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1272 for (pos = 0; desc[pos].type != XD_LO_LINK; pos++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1273 assert (desc[pos].type != XD_END);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1274
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1275 obj.value = *(Lisp_Object *)(desc[pos].offset + (char *)(XRECORD_LHEADER (obj.value)));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1276 }
619
8d7292eb4a18 [xemacs-hg @ 2001-06-19 01:35:35 by ben]
ben
parents: 617
diff changeset
1277 obj.value = wrap_pointer_1 ((void *) elt->save_offset);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1278
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1279 PDUMP_WRITE (pdump_static_Lisp_Object, obj);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1280 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1281 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1282
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1283 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1284 pdump (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1285 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1286 int i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1287 Lisp_Object t_console, t_device, t_frame;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1288 int none;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1289 pdump_header header;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1290
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1291 pdump_object_table = xnew_array (pdump_entry_list, lrecord_type_count);
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1292 pdump_alert_undump_object = xnew_array (int, lrecord_type_count);
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1293
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1294 assert (ALIGNOF (max_align_t) <= pdump_align_table[0]);
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1295
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1296 for (i = 0; i < countof (pdump_align_table); i++)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1297 if (pdump_align_table[i] > ALIGNOF (max_align_t))
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1298 pdump_align_table[i] = ALIGNOF (max_align_t);
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1299
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1300 flush_all_buffer_local_cache ();
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1301
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1302 /* These appear in a DEFVAR_LISP, which does a staticpro() */
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1303 t_console = Vterminal_console; Vterminal_console = Qnil;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1304 t_frame = Vterminal_frame; Vterminal_frame = Qnil;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1305 t_device = Vterminal_device; Vterminal_device = Qnil;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1306
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1307 dump_add_opaque (&lrecord_implementations_table,
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1308 lrecord_type_count * sizeof (lrecord_implementations_table[0]));
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1309 dump_add_opaque (&lrecord_markers,
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1310 lrecord_type_count * sizeof (lrecord_markers[0]));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1311
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1312 pdump_hash = xnew_array_and_zero (pdump_entry_list_elt *, PDUMP_HASHSIZE);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1313
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1314 for (i=0; i<lrecord_type_count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1315 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1316 pdump_object_table[i].first = 0;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1317 pdump_object_table[i].align = ALIGNOF (max_align_t);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1318 pdump_object_table[i].count = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1319 pdump_alert_undump_object[i] = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1320 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1321 pdump_struct_table.count = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1322 pdump_struct_table.size = -1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1323
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1324 pdump_opaque_data_list.first = 0;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1325 pdump_opaque_data_list.align = ALIGNOF (max_align_t);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1326 pdump_opaque_data_list.count = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1327 depth = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1328
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1329 for (i=0; i<Dynarr_length (pdump_root_objects); i++)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1330 pdump_register_object (* Dynarr_at (pdump_root_objects, i));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1331
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1332 none = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1333 for (i=0; i<lrecord_type_count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1334 if (pdump_alert_undump_object[i])
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1335 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1336 if (none)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1337 printf ("Undumpable types list :\n");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1338 none = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1339 printf (" - %s (%d)\n", lrecord_implementations_table[i]->name, pdump_alert_undump_object[i]);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1340 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1341 if (!none)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1342 return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1343
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1344 for (i=0; i<Dynarr_length (pdump_root_struct_ptrs); i++)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1345 {
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1346 pdump_root_struct_ptr info = Dynarr_at (pdump_root_struct_ptrs, i);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1347 pdump_register_struct (*(info.ptraddress), info.desc, 1);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1348 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1349
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1350 memcpy (header.signature, PDUMP_SIGNATURE, PDUMP_SIGNATURE_LEN);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1351 header.id = dump_id;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1352 header.reloc_address = 0;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1353 header.nb_root_struct_ptrs = Dynarr_length (pdump_root_struct_ptrs);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1354 header.nb_opaques = Dynarr_length (pdump_opaques);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1355
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1356 cur_offset = ALIGN_SIZE (sizeof (header), ALIGNOF (max_align_t));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1357 max_size = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1358
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1359 pdump_scan_by_alignment (pdump_allocate_offset);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1360 cur_offset = ALIGN_SIZE (cur_offset, ALIGNOF (max_align_t));
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1361 header.stab_offset = cur_offset;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1362
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1363 pdump_buf = xmalloc (max_size);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1364 pdump_fd = open (EMACS_PROGNAME ".dmp",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1365 O_WRONLY | O_CREAT | O_TRUNC | OPEN_BINARY, 0666);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1366 if (pdump_fd < 0)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1367 report_file_error ("Unable to open dump file",
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1368 build_string (EMACS_PROGNAME ".dmp"));
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1369 pdump_out = fdopen (pdump_fd, "w");
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1370 if (pdump_out < 0)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1371 report_file_error ("Unable to open dump file for writing",
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1372 build_string (EMACS_PROGNAME ".dmp"));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1373
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1374 retry_fwrite (&header, sizeof (header), 1, pdump_out);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1375 PDUMP_ALIGN_OUTPUT (max_align_t);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1376
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1377 pdump_scan_by_alignment (pdump_dump_data);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1378
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1379 fseek (pdump_out, header.stab_offset, SEEK_SET);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1380
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1381 pdump_dump_root_struct_ptrs ();
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1382 pdump_dump_opaques ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1383 pdump_dump_rtables ();
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1384 pdump_dump_root_objects ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1385
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1386 retry_fclose (pdump_out);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1387 retry_close (pdump_fd);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1388
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1389 free (pdump_buf);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1390
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1391 free (pdump_hash);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1392
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1393 Vterminal_console = t_console;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1394 Vterminal_frame = t_frame;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1395 Vterminal_device = t_device;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1396 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1397
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1398 static int
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1399 pdump_load_check (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1400 {
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1401 return (!memcmp (((pdump_header *)pdump_start)->signature,
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1402 PDUMP_SIGNATURE, PDUMP_SIGNATURE_LEN)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1403 && ((pdump_header *)pdump_start)->id == dump_id);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1404 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1405
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1406 /*----------------------------------------------------------------------*/
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1407 /* Reading the dump file */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1408 /*----------------------------------------------------------------------*/
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1409 static int
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1410 pdump_load_finish (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1411 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1412 int i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1413 char *p;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1414 EMACS_INT delta;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1415 EMACS_INT count;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1416 pdump_header *header = (pdump_header *)pdump_start;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1417
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1418 pdump_end = pdump_start + pdump_length;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1419
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1420 delta = ((EMACS_INT)pdump_start) - header->reloc_address;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1421 p = pdump_start + header->stab_offset;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1422
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1423 /* Put back the pdump_root_struct_ptrs */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1424 p = (char *) ALIGN_PTR (p, ALIGNOF (pdump_static_pointer));
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1425 for (i=0; i<header->nb_root_struct_ptrs; i++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1426 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1427 pdump_static_pointer ptr = PDUMP_READ (p, pdump_static_pointer);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1428 (* ptr.address) = ptr.value + delta;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1429 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1430
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1431 /* Put back the pdump_opaques */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1432 for (i=0; i<header->nb_opaques; i++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1433 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1434 pdump_opaque info = PDUMP_READ_ALIGNED (p, pdump_opaque);
545
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 462
diff changeset
1435 memcpy ((void*)info.varaddress, p, info.size);
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1436 p += info.size;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1437 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1438
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1439 /* Do the relocations */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1440 pdump_rt_list = p;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1441 count = 2;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1442 for (;;)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1443 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1444 pdump_reloc_table rt = PDUMP_READ_ALIGNED (p, pdump_reloc_table);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1445 p = (char *) ALIGN_PTR (p, ALIGNOF (char *));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1446 if (rt.desc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1447 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1448 char **reloc = (char **)p;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1449 for (i=0; i < rt.count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1450 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1451 reloc[i] += delta;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1452 pdump_reloc_one (reloc[i], delta, rt.desc);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1453 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1454 p += rt.count * sizeof (char *);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1455 } else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1456 if (!(--count))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1457 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1458 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1459
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1460 /* Put the pdump_root_objects variables in place */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
1461 i = PDUMP_READ_ALIGNED (p, Elemcount);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1462 p = (char *) ALIGN_PTR (p, ALIGNOF (pdump_static_Lisp_Object));
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1463 while (i--)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1464 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1465 pdump_static_Lisp_Object obj = PDUMP_READ (p, pdump_static_Lisp_Object);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1466
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1467 if (POINTER_TYPE_P (XTYPE (obj.value)))
619
8d7292eb4a18 [xemacs-hg @ 2001-06-19 01:35:35 by ben]
ben
parents: 617
diff changeset
1468 obj.value = wrap_pointer_1 ((char *) XPNTR (obj.value) + delta);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1469
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1470 (* obj.address) = obj.value;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1471 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1472
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1473 /* Final cleanups */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1474 /* reorganize hash tables */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1475 p = pdump_rt_list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1476 for (;;)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1477 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1478 pdump_reloc_table rt = PDUMP_READ_ALIGNED (p, pdump_reloc_table);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1479 p = (char *) ALIGN_PTR (p, ALIGNOF (Lisp_Object));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1480 if (!rt.desc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1481 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1482 if (rt.desc == hash_table_description)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1483 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1484 for (i=0; i < rt.count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1485 pdump_reorganize_hash_table (PDUMP_READ (p, Lisp_Object));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1486 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1487 } else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1488 p += sizeof (Lisp_Object) * rt.count;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1489 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1490
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1491 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1492 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1493
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1494 #ifdef WIN32_NATIVE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1495 /* Free the mapped file if we decide we don't want it after all */
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1496 static void
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1497 pdump_file_unmap (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1498 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1499 UnmapViewOfFile (pdump_start);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1500 CloseHandle (pdump_hFile);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1501 CloseHandle (pdump_hMap);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1502 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1503
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1504 static int
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1505 pdump_file_get (const char *path)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1506 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1507
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1508 pdump_hFile = CreateFile (path,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1509 GENERIC_READ + GENERIC_WRITE, /* Required for copy on write */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1510 0, /* Not shared */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1511 NULL, /* Not inheritable */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1512 OPEN_EXISTING,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1513 FILE_ATTRIBUTE_NORMAL,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1514 NULL); /* No template file */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1515 if (pdump_hFile == INVALID_HANDLE_VALUE)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1516 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1517
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1518 pdump_length = GetFileSize (pdump_hFile, NULL);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1519 pdump_hMap = CreateFileMapping (pdump_hFile,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1520 NULL, /* No security attributes */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1521 PAGE_WRITECOPY, /* Copy on write */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1522 0, /* Max size, high half */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1523 0, /* Max size, low half */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1524 NULL); /* Unnamed */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1525 if (pdump_hMap == INVALID_HANDLE_VALUE)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1526 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1527
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1528 pdump_start = MapViewOfFile (pdump_hMap,
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1529 FILE_MAP_COPY, /* Copy on write */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1530 0, /* Start at zero */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1531 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1532 0); /* Map all of it */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1533 pdump_free = pdump_file_unmap;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1534 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1535 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1536
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1537 /* pdump_resource_free is called (via the pdump_free pointer) to release
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1538 any resources allocated by pdump_resource_get. Since the Windows API
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1539 specs specifically state that you don't need to (and shouldn't) free the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1540 resources allocated by FindResource, LoadResource, and LockResource this
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1541 routine does nothing. */
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1542 static void
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1543 pdump_resource_free (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1544 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1545 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1546
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1547 static int
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1548 pdump_resource_get (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1549 {
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1550 HRSRC hRes; /* Handle to dump resource */
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1551 HRSRC hResLoad; /* Handle to loaded dump resource */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1552
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1553 /* See Q126630 which describes how Windows NT and 95 trap writes to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1554 resource sections and duplicate the page to allow the write to proceed.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1555 It also describes how to make the resource section read/write (and hence
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1556 private to each process). Doing this avoids the exceptions and related
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1557 overhead, but causes the resource section to be private to each process
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1558 that is running XEmacs. Since the resource section contains little
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1559 other than the dumped data, which should be private to each process, we
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1560 make the whole resource section read/write so we don't have to copy it. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1561
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1562 hRes = FindResource (NULL, MAKEINTRESOURCE(101), "DUMP");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1563 if (hRes == NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1564 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1565
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1566 /* Found it, use the data in the resource */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1567 hResLoad = LoadResource (NULL, hRes);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1568 if (hResLoad == NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1569 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1570
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1571 pdump_start = LockResource (hResLoad);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1572 if (pdump_start == NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1573 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1574
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1575 pdump_free = pdump_resource_free;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1576 pdump_length = SizeofResource (NULL, hRes);
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
1577 if (pdump_length <= (Bytecount) sizeof (pdump_header))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1578 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1579 pdump_start = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1580 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1581 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1582
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1583 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1584 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1585
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1586 #else /* !WIN32_NATIVE */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1587
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1588 static void
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1589 pdump_file_free (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1590 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1591 xfree (pdump_start);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1592 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1593
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1594 #ifdef HAVE_MMAP
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1595 static void
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1596 pdump_file_unmap (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1597 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1598 munmap (pdump_start, pdump_length);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1599 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1600 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1601
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1602 static int
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1603 pdump_file_get (const char *path)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1604 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1605 int fd = open (path, O_RDONLY | OPEN_BINARY);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1606 if (fd<0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1607 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1608
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1609 pdump_length = lseek (fd, 0, SEEK_END);
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
1610 if (pdump_length < (Bytecount) sizeof (pdump_header))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1611 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1612 retry_close (fd);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1613 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1614 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1615
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1616 lseek (fd, 0, SEEK_SET);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1617
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1618 #ifdef HAVE_MMAP
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 452
diff changeset
1619 /* Unix 98 requires that sys/mman.h define MAP_FAILED,
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 452
diff changeset
1620 but many earlier implementations don't. */
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 452
diff changeset
1621 # ifndef MAP_FAILED
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 452
diff changeset
1622 # define MAP_FAILED ((void *) -1L)
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 452
diff changeset
1623 # endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1624 pdump_start = (char *) mmap (0, pdump_length, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1625 if (pdump_start != (char *) MAP_FAILED)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1626 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1627 pdump_free = pdump_file_unmap;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1628 retry_close (fd);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1629 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1630 }
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 452
diff changeset
1631 #endif /* HAVE_MMAP */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1632
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1633 pdump_start = xnew_array (char, pdump_length);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1634 pdump_free = pdump_file_free;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1635 retry_read (fd, pdump_start, pdump_length);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1636
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1637 retry_close (fd);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1638 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1639 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1640 #endif /* !WIN32_NATIVE */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1641
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1642
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1643 static int
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1644 pdump_file_try (char *exe_path)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1645 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1646 char *w = exe_path + strlen (exe_path);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1647
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1648 do
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1649 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1650 sprintf (w, "-%s-%08x.dmp", EMACS_VERSION, dump_id);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1651 if (pdump_file_get (exe_path))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1652 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1653 if (pdump_load_check ())
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1654 return 1;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1655 pdump_free ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1656 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1657
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1658 sprintf (w, "-%08x.dmp", dump_id);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1659 if (pdump_file_get (exe_path))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1660 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1661 if (pdump_load_check ())
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1662 return 1;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1663 pdump_free ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1664 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1665
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1666 sprintf (w, ".dmp");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1667 if (pdump_file_get (exe_path))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1668 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1669 if (pdump_load_check ())
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1670 return 1;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1671 pdump_free ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1672 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1673
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1674 do
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1675 w--;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1676 while (w>exe_path && !IS_DIRECTORY_SEP (*w) && (*w != '-') && (*w != '.'));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1677 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1678 while (w>exe_path && !IS_DIRECTORY_SEP (*w));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1679 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1680 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1681
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1682 int
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1683 pdump_load (const Extbyte *argv0)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1684 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1685 Extbyte exe_path[PATH_MAX];
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1686 #ifdef WIN32_NATIVE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1687 GetModuleFileName (NULL, exe_path, PATH_MAX);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1688 #else /* !WIN32_NATIVE */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1689 Extbyte *w;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1690 const Extbyte *dir, *p;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1691
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1692 dir = argv0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1693 if (dir[0] == '-')
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1694 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1695 /* XEmacs as a login shell, oh goody! */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1696 dir = getenv ("SHELL"); /* not egetenv -- not yet initialized */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1697 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1698
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1699 p = dir + strlen (dir);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1700 while (p != dir && !IS_ANY_SEP (p[-1])) p--;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1701
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1702 if (p != dir)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1703 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1704 /* invocation-name includes a directory component -- presumably it
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1705 is relative to cwd, not $PATH */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1706 strcpy (exe_path, dir);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1707 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1708 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1709 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1710 const Extbyte *path = getenv ("PATH"); /* not egetenv -- not yet init. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1711 const Extbyte *name = p;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1712 for (;;)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1713 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1714 p = path;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1715 while (*p && *p != SEPCHAR)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1716 p++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1717 if (p == path)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1718 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1719 exe_path[0] = '.';
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1720 w = exe_path + 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1721 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1722 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1723 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1724 memcpy (exe_path, path, p - path);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1725 w = exe_path + (p - path);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1726 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1727 if (!IS_DIRECTORY_SEP (w[-1]))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1728 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1729 *w++ = '/';
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1730 }
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1731 strcpy (w, name);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1732
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1733 if (!access (exe_path, X_OK))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1734 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1735 if (!*p)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1736 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1737 /* Oh well, let's have some kind of default */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1738 sprintf (exe_path, "./%s", name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1739 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1740 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1741 path = p+1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1742 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1743 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1744 #endif /* WIN32_NATIVE */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1745
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1746 if (pdump_file_try (exe_path))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1747 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1748 pdump_load_finish ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1749 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1750 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1751
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1752 #ifdef WIN32_NATIVE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1753 if (pdump_resource_get ())
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1754 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1755 if (pdump_load_check ())
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1756 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1757 pdump_load_finish ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1758 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1759 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1760 pdump_free ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1761 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1762 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1763
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1764 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1765 }