annotate src/dumper.c @ 665:fdefd0186b75

[xemacs-hg @ 2001-09-20 06:28:42 by ben] The great integral types renaming. The purpose of this is to rationalize the names used for various integral types, so that they match their intended uses and follow consist conventions, and eliminate types that were not semantically different from each other. The conventions are: -- All integral types that measure quantities of anything are signed. Some people disagree vociferously with this, but their arguments are mostly theoretical, and are vastly outweighed by the practical headaches of mixing signed and unsigned values, and more importantly by the far increased likelihood of inadvertent bugs: Because of the broken "viral" nature of unsigned quantities in C (operations involving mixed signed/unsigned are done unsigned, when exactly the opposite is nearly always wanted), even a single error in declaring a quantity unsigned that should be signed, or even the even more subtle error of comparing signed and unsigned values and forgetting the necessary cast, can be catastrophic, as comparisons will yield wrong results. -Wsign-compare is turned on specifically to catch this, but this tends to result in a great number of warnings when mixing signed and unsigned, and the casts are annoying. More has been written on this elsewhere. -- All such quantity types just mentioned boil down to EMACS_INT, which is 32 bits on 32-bit machines and 64 bits on 64-bit machines. This is guaranteed to be the same size as Lisp objects of type `int', and (as far as I can tell) of size_t (unsigned!) and ssize_t. The only type below that is not an EMACS_INT is Hashcode, which is an unsigned value of the same size as EMACS_INT. -- Type names should be relatively short (no more than 10 characters or so), with the first letter capitalized and no underscores if they can at all be avoided. -- "count" == a zero-based measurement of some quantity. Includes sizes, offsets, and indexes. -- "bpos" == a one-based measurement of a position in a buffer. "Charbpos" and "Bytebpos" count text in the buffer, rather than bytes in memory; thus Bytebpos does not directly correspond to the memory representation. Use "Membpos" for this. -- "Char" refers to internal-format characters, not to the C type "char", which is really a byte. -- For the actual name changes, see the script below. I ran the following script to do the conversion. (NOTE: This script is idempotent. You can safely run it multiple times and it will not screw up previous results -- in fact, it will do nothing if nothing has changed. Thus, it can be run repeatedly as necessary to handle patches coming in from old workspaces, or old branches.) There are two tags, just before and just after the change: `pre-integral-type-rename' and `post-integral-type-rename'. When merging code from the main trunk into a branch, the best thing to do is first merge up to `pre-integral-type-rename', then apply the script and associated changes, then merge from `post-integral-type-change' to the present. (Alternatively, just do the merging in one operation; but you may then have a lot of conflicts needing to be resolved by hand.) Script `fixtypes.sh' follows: ----------------------------------- cut ------------------------------------ files="*.[ch] s/*.h m/*.h config.h.in ../configure.in Makefile.in.in ../lib-src/*.[ch] ../lwlib/*.[ch]" gr Memory_Count Bytecount $files gr Lstream_Data_Count Bytecount $files gr Element_Count Elemcount $files gr Hash_Code Hashcode $files gr extcount bytecount $files gr bufpos charbpos $files gr bytind bytebpos $files gr memind membpos $files gr bufbyte intbyte $files gr Extcount Bytecount $files gr Bufpos Charbpos $files gr Bytind Bytebpos $files gr Memind Membpos $files gr Bufbyte Intbyte $files gr EXTCOUNT BYTECOUNT $files gr BUFPOS CHARBPOS $files gr BYTIND BYTEBPOS $files gr MEMIND MEMBPOS $files gr BUFBYTE INTBYTE $files gr MEMORY_COUNT BYTECOUNT $files gr LSTREAM_DATA_COUNT BYTECOUNT $files gr ELEMENT_COUNT ELEMCOUNT $files gr HASH_CODE HASHCODE $files ----------------------------------- cut ------------------------------------ `fixtypes.sh' is a Bourne-shell script; it uses 'gr': ----------------------------------- cut ------------------------------------ #!/bin/sh # Usage is like this: # gr FROM TO FILES ... # globally replace FROM with TO in FILES. FROM and TO are regular expressions. # backup files are stored in the `backup' directory. from="$1" to="$2" shift 2 echo ${1+"$@"} | xargs global-replace "s/$from/$to/g" ----------------------------------- cut ------------------------------------ `gr' in turn uses a Perl script to do its real work, `global-replace', which follows: ----------------------------------- cut ------------------------------------ : #-*- Perl -*- ### global-modify --- modify the contents of a file by a Perl expression ## Copyright (C) 1999 Martin Buchholz. ## Copyright (C) 2001 Ben Wing. ## Authors: Martin Buchholz <martin@xemacs.org>, Ben Wing <ben@xemacs.org> ## Maintainer: Ben Wing <ben@xemacs.org> ## Current Version: 1.0, May 5, 2001 # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with XEmacs; see the file COPYING. If not, write to the Free # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. eval 'exec perl -w -S $0 ${1+"$@"}' if 0; use strict; use FileHandle; use Carp; use Getopt::Long; use File::Basename; (my $myName = $0) =~ s@.*/@@; my $usage=" Usage: $myName [--help] [--backup-dir=DIR] [--line-mode] [--hunk-mode] PERLEXPR FILE ... Globally modify a file, either line by line or in one big hunk. Typical usage is like this: [with GNU print, GNU xargs: guaranteed to handle spaces, quotes, etc. in file names] find . -name '*.[ch]' -print0 | xargs -0 $0 's/\bCONST\b/const/g'\n [with non-GNU print, xargs] find . -name '*.[ch]' -print | xargs $0 's/\bCONST\b/const/g'\n The file is read in, either line by line (with --line-mode specified) or in one big hunk (with --hunk-mode specified; it's the default), and the Perl expression is then evalled with \$_ set to the line or hunk of text, including the terminating newline if there is one. It should destructively modify the value there, storing the changed result in \$_. Files in which any modifications are made are backed up to the directory specified using --backup-dir, or to `backup' by default. To disable this, use --backup-dir= with no argument. Hunk mode is the default because it is MUCH MUCH faster than line-by-line. Use line-by-line only when it matters, e.g. you want to do a replacement only once per line (the default without the `g' argument). Conversely, when using hunk mode, *ALWAYS* use `g'; otherwise, you will only make one replacement in the entire file! "; my %options = (); $Getopt::Long::ignorecase = 0; &GetOptions ( \%options, 'help', 'backup-dir=s', 'line-mode', 'hunk-mode', ); die $usage if $options{"help"} or @ARGV <= 1; my $code = shift; die $usage if grep (-d || ! -w, @ARGV); sub SafeOpen { open ((my $fh = new FileHandle), $_[0]); confess "Can't open $_[0]: $!" if ! defined $fh; return $fh; } sub SafeClose { close $_[0] or confess "Can't close $_[0]: $!"; } sub FileContents { my $fh = SafeOpen ("< $_[0]"); my $olddollarslash = $/; local $/ = undef; my $contents = <$fh>; $/ = $olddollarslash; return $contents; } sub WriteStringToFile { my $fh = SafeOpen ("> $_[0]"); binmode $fh; print $fh $_[1] or confess "$_[0]: $!\n"; SafeClose $fh; } foreach my $file (@ARGV) { my $changed_p = 0; my $new_contents = ""; if ($options{"line-mode"}) { my $fh = SafeOpen $file; while (<$fh>) { my $save_line = $_; eval $code; $changed_p = 1 if $save_line ne $_; $new_contents .= $_; } } else { my $orig_contents = $_ = FileContents $file; eval $code; if ($_ ne $orig_contents) { $changed_p = 1; $new_contents = $_; } } if ($changed_p) { my $backdir = $options{"backup-dir"}; $backdir = "backup" if !defined ($backdir); if ($backdir) { my ($name, $path, $suffix) = fileparse ($file, ""); my $backfulldir = $path . $backdir; my $backfile = "$backfulldir/$name"; mkdir $backfulldir, 0755 unless -d $backfulldir; print "modifying $file (original saved in $backfile)\n"; rename $file, $backfile; } WriteStringToFile ($file, $new_contents); } } ----------------------------------- cut ------------------------------------ In addition to those programs, I needed to fix up a few other things, particularly relating to the duplicate definitions of types, now that some types merged with others. Specifically: 1. in lisp.h, removed duplicate declarations of Bytecount. The changed code should now look like this: (In each code snippet below, the first and last lines are the same as the original, as are all lines outside of those lines. That allows you to locate the section to be replaced, and replace the stuff in that section, verifying that there isn't anything new added that would need to be kept.) --------------------------------- snip ------------------------------------- /* Counts of bytes or chars */ typedef EMACS_INT Bytecount; typedef EMACS_INT Charcount; /* Counts of elements */ typedef EMACS_INT Elemcount; /* Hash codes */ typedef unsigned long Hashcode; /* ------------------------ dynamic arrays ------------------- */ --------------------------------- snip ------------------------------------- 2. in lstream.h, removed duplicate declaration of Bytecount. Rewrote the comment about this type. The changed code should now look like this: --------------------------------- snip ------------------------------------- #endif /* The have been some arguments over the what the type should be that specifies a count of bytes in a data block to be written out or read in, using Lstream_read(), Lstream_write(), and related functions. Originally it was long, which worked fine; Martin "corrected" these to size_t and ssize_t on the grounds that this is theoretically cleaner and is in keeping with the C standards. Unfortunately, this practice is horribly error-prone due to design flaws in the way that mixed signed/unsigned arithmetic happens. In fact, by doing this change, Martin introduced a subtle but fatal error that caused the operation of sending large mail messages to the SMTP server under Windows to fail. By putting all values back to be signed, avoiding any signed/unsigned mixing, the bug immediately went away. The type then in use was Lstream_Data_Count, so that it be reverted cleanly if a vote came to that. Now it is Bytecount. Some earlier comments about why the type must be signed: This MUST BE SIGNED, since it also is used in functions that return the number of bytes actually read to or written from in an operation, and these functions can return -1 to signal error. Note that the standard Unix read() and write() functions define the count going in as a size_t, which is UNSIGNED, and the count going out as an ssize_t, which is SIGNED. This is a horrible design flaw. Not only is it highly likely to lead to logic errors when a -1 gets interpreted as a large positive number, but operations are bound to fail in all sorts of horrible ways when a number in the upper-half of the size_t range is passed in -- this number is unrepresentable as an ssize_t, so code that checks to see how many bytes are actually written (which is mandatory if you are dealing with certain types of devices) will get completely screwed up. --ben */ typedef enum lstream_buffering --------------------------------- snip ------------------------------------- 3. in dumper.c, there are four places, all inside of switch() statements, where XD_BYTECOUNT appears twice as a case tag. In each case, the two case blocks contain identical code, and you should *REMOVE THE SECOND* and leave the first.
author ben
date Thu, 20 Sep 2001 06:31:11 +0000
parents b39c14581166
children 943eaba38521
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
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
4
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
5 This file is part of XEmacs.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
6
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
8 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
9 Free Software Foundation; either version 2, or (at your option) any
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
10 later version.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
11
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
12 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
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
15 for more details.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
16
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
21
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
23
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
24 #include <config.h>
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
25 #include "lisp.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
26
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
27 #include "specifier.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
28 #include "elhash.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
29 #include "sysfile.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
30 #include "console-stream.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
31 #include "dumper.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
32
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
33 #ifdef WIN32_NATIVE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
34 #include "nt.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
35 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
36 #ifdef HAVE_MMAP
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
37 #include <sys/mman.h>
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
38 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
39 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
40
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
41 #ifndef SEPCHAR
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
42 #define SEPCHAR ':'
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
43 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
44
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
45 typedef struct
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
46 {
545
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 462
diff changeset
47 const void *varaddress;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
48 Bytecount size;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
49 } pdump_opaque;
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 typedef struct
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
52 {
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
53 Dynarr_declare (pdump_opaque);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
54 } pdump_opaque_dynarr;
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 typedef struct
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
57 {
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
58 void **ptraddress;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
59 const struct struct_description *desc;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
60 } pdump_root_struct_ptr;
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 typedef struct
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
63 {
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
64 Dynarr_declare (pdump_root_struct_ptr);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
65 } pdump_root_struct_ptr_dynarr;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
66
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
67 typedef struct
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
68 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
69 Lisp_Object *address;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
70 Lisp_Object value;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
71 } pdump_static_Lisp_Object;
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 typedef struct
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
74 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
75 char **address; /* char * for ease of doing relocation */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
76 char * value;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
77 } pdump_static_pointer;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
78
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
79 static pdump_opaque_dynarr *pdump_opaques;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
80 static pdump_root_struct_ptr_dynarr *pdump_root_struct_ptrs;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
81 static Lisp_Object_ptr_dynarr *pdump_root_objects;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
82 static Lisp_Object_ptr_dynarr *pdump_weak_object_chains;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
83
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
84 /* 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
85 without any bit-twiddling. */
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
86 void
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
87 dump_add_opaque (const void *varaddress, Bytecount size)
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
88 {
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
89 pdump_opaque info;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
90 info.varaddress = varaddress;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
91 info.size = size;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
92 if (pdump_opaques == NULL)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
93 pdump_opaques = Dynarr_new (pdump_opaque);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
94 Dynarr_add (pdump_opaques, info);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
95 }
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
96
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
97 /* 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
98 non-heap address VARADDRESS for dumping.
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
99 All the objects reachable from this pointer will also be dumped. */
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
100 void
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
101 dump_add_root_struct_ptr (void *ptraddress, const struct struct_description *desc)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
102 {
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
103 pdump_root_struct_ptr info;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
104 info.ptraddress = (void **) ptraddress;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
105 info.desc = desc;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
106 if (pdump_root_struct_ptrs == NULL)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
107 pdump_root_struct_ptrs = Dynarr_new (pdump_root_struct_ptr);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
108 Dynarr_add (pdump_root_struct_ptrs, info);
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
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
111 /* Mark the Lisp_Object at non-heap address VARADDRESS for dumping.
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
112 All the objects reachable from this var will also be dumped. */
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
113 void
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
114 dump_add_root_object (Lisp_Object *varaddress)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
115 {
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
116 if (pdump_root_objects == NULL)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
117 pdump_root_objects = Dynarr_new2 (Lisp_Object_ptr_dynarr, Lisp_Object *);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
118 Dynarr_add (pdump_root_objects, varaddress);
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
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
121 /* 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
122 void
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
123 dump_add_weak_object_chain (Lisp_Object *varaddress)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
124 {
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
125 if (pdump_weak_object_chains == NULL)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
126 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
127 Dynarr_add (pdump_weak_object_chains, varaddress);
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
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
130
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
131 inline static void
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
132 pdump_align_stream (FILE *stream, Bytecount alignment)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
133 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
134 long offset = ftell (stream);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
135 long adjustment = ALIGN_SIZE (offset, alignment) - offset;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
136 if (adjustment)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
137 fseek (stream, adjustment, SEEK_CUR);
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
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
140 #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
141
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
142 #define PDUMP_WRITE(type, object) \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
143 fwrite (&object, sizeof (object), 1, pdump_out);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
144
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
145 #define PDUMP_WRITE_ALIGNED(type, object) do { \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
146 PDUMP_ALIGN_OUTPUT (type); \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
147 PDUMP_WRITE (type, object); \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
148 } while (0)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
149
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
150 #define PDUMP_READ(ptr, type) \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
151 (((type *) (ptr = (char*) (((type *) ptr) + 1)))[-1])
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
152
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
153 #define PDUMP_READ_ALIGNED(ptr, type) \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
154 ((ptr = (char *) ALIGN_PTR (ptr, ALIGNOF (type))), PDUMP_READ (ptr, type))
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
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
157
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
158 typedef struct
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
159 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
160 const struct lrecord_description *desc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
161 int count;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
162 } pdump_reloc_table;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
163
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
164 static char *pdump_rt_list = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
165
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
166 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
167 pdump_objects_unmark (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
168 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
169 int i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
170 char *p = pdump_rt_list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
171 if (p)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
172 for (;;)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
173 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
174 pdump_reloc_table *rt = (pdump_reloc_table *)p;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
175 p += sizeof (pdump_reloc_table);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
176 if (rt->desc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
177 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
178 for (i=0; i<rt->count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
179 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
180 struct lrecord_header *lh = * (struct lrecord_header **) p;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
181 if (! C_READONLY_RECORD_HEADER_P (lh))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
182 UNMARK_RECORD_HEADER (lh);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
183 p += sizeof (EMACS_INT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
184 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
185 } else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
186 break;
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
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
191 /* The structure of the file
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
192 0 - header
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
193 - dumped objects
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
194 stab_offset - nb_root_struct_ptrs*pair(void *, adr)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
195 for pointers to structures
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
196 - nb_opaques*pair(void *, size) for raw bits to restore
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
197 - relocation table
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
198 - root lisp object address/value couples with the count
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
199 preceding the list
442
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
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
202
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
203 #define PDUMP_SIGNATURE "XEmacsDP"
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
204 #define PDUMP_SIGNATURE_LEN (sizeof (PDUMP_SIGNATURE) - 1)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
205
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
206 typedef struct
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
207 {
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
208 char signature[PDUMP_SIGNATURE_LEN];
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
209 unsigned int id;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
210 EMACS_UINT stab_offset;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
211 EMACS_UINT reloc_address;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
212 int nb_root_struct_ptrs;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
213 int nb_opaques;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
214 } pdump_header;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
215
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
216 char *pdump_start;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
217 char *pdump_end;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
218 static Bytecount pdump_length;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
219
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
220 #ifdef WIN32_NATIVE
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
221 /* Handle for the dump file */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
222 static HANDLE pdump_hFile = INVALID_HANDLE_VALUE;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
223 /* Handle for the file mapping object for the dump file */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
224 static HANDLE pdump_hMap = INVALID_HANDLE_VALUE;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
225 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
226
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
227 static void (*pdump_free) (void);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
228
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
229 static unsigned char pdump_align_table[] =
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
230 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
231 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
232 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
233 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
234 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
235 };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
236
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 619
diff changeset
237 static inline int
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
238 pdump_size_to_align (Bytecount size)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
239 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
240 return pdump_align_table[size % countof (pdump_align_table)];
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
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
243 typedef struct pdump_entry_list_elt
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
244 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
245 struct pdump_entry_list_elt *next;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
246 const void *obj;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
247 Bytecount size;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
248 int count;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
249 EMACS_INT save_offset;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
250 } pdump_entry_list_elt;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
251
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
252 typedef struct
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
253 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
254 pdump_entry_list_elt *first;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
255 int align;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
256 int count;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
257 } pdump_entry_list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
258
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
259 typedef struct pdump_struct_list_elt
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
260 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
261 pdump_entry_list list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
262 const struct struct_description *sdesc;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
263 } pdump_struct_list_elt;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
264
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
265 typedef struct
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
266 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
267 pdump_struct_list_elt *list;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
268 int count;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
269 int size;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
270 } pdump_struct_list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
271
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
272 static pdump_entry_list *pdump_object_table;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
273 static pdump_entry_list pdump_opaque_data_list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
274 static pdump_struct_list pdump_struct_table;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
275
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
276 static int *pdump_alert_undump_object;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
277
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
278 static unsigned long cur_offset;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
279 static Bytecount max_size;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
280 static int pdump_fd;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
281 static void *pdump_buf;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
282 static FILE *pdump_out;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
283
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
284 #define PDUMP_HASHSIZE 200001
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
285
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
286 static pdump_entry_list_elt **pdump_hash;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
287
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
288 /* 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
289 static int
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
290 pdump_make_hash (const void *obj)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
291 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
292 return ((unsigned long)(obj)>>3) % PDUMP_HASHSIZE;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
293 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
294
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
295 static pdump_entry_list_elt *
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
296 pdump_get_entry (const void *obj)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
297 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
298 int pos = pdump_make_hash (obj);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
299 pdump_entry_list_elt *e;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
300
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
301 assert (obj != 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
302
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
303 while ((e = pdump_hash[pos]) != 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
304 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
305 if (e->obj == obj)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
306 return e;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
307
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
308 pos++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
309 if (pos == PDUMP_HASHSIZE)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
310 pos = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
311 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
312 return 0;
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
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
315 static void
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
316 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
317 int count)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
318 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
319 pdump_entry_list_elt *e;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
320 int pos = pdump_make_hash (obj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
321
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
322 while ((e = pdump_hash[pos]) != 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
323 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
324 if (e->obj == obj)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
325 return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
326
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
327 pos++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
328 if (pos == PDUMP_HASHSIZE)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
329 pos = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
330 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
331
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
332 e = xnew (pdump_entry_list_elt);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
333
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
334 e->next = list->first;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
335 e->obj = obj;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
336 e->size = size;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
337 e->count = count;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
338 list->first = e;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
339
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
340 list->count += count;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
341 pdump_hash[pos] = e;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
342
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
343 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
344 int align = pdump_size_to_align (size);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
345
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
346 if (align < list->align)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
347 list->align = align;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
348 }
442
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
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
351 static pdump_entry_list *
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
352 pdump_get_entry_list (const struct struct_description *sdesc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
353 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
354 int i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
355 for (i=0; i<pdump_struct_table.count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
356 if (pdump_struct_table.list[i].sdesc == sdesc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
357 return &pdump_struct_table.list[i].list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
358
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
359 if (pdump_struct_table.size <= pdump_struct_table.count)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
360 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
361 if (pdump_struct_table.size == -1)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
362 pdump_struct_table.size = 10;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
363 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
364 pdump_struct_table.size = pdump_struct_table.size * 2;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
365 pdump_struct_table.list = (pdump_struct_list_elt *)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
366 xrealloc (pdump_struct_table.list,
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
367 pdump_struct_table.size * sizeof (pdump_struct_list_elt));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
368 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
369 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
370 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
371 pdump_struct_table.list[pdump_struct_table.count].list.count = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
372 pdump_struct_table.list[pdump_struct_table.count].sdesc = sdesc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
373
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
374 return &pdump_struct_table.list[pdump_struct_table.count++].list;
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
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
377 static struct
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
378 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
379 struct lrecord_header *obj;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
380 int position;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
381 int offset;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
382 } backtrace[65536];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
383
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
384 static int depth;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
385
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
386 static void
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
387 pdump_backtrace (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
388 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
389 int i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
390 stderr_out ("pdump backtrace :\n");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
391 for (i=0;i<depth;i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
392 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
393 if (!backtrace[i].obj)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
394 stderr_out (" - ind. (%d, %d)\n",
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
395 backtrace[i].position,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
396 backtrace[i].offset);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
397 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
398 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
399 stderr_out (" - %s (%d, %d)\n",
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
400 LHEADER_IMPLEMENTATION (backtrace[i].obj)->name,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
401 backtrace[i].position,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
402 backtrace[i].offset);
442
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
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
407 static void pdump_register_object (Lisp_Object obj);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
408 static void pdump_register_struct (const void *data,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
409 const struct struct_description *sdesc,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
410 int count);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
411
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
412 static EMACS_INT
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
413 pdump_get_indirect_count (EMACS_INT code,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
414 const struct lrecord_description *idesc,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
415 const void *idata)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
416 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
417 EMACS_INT count;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
418 const void *irdata;
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 int line = XD_INDIRECT_VAL (code);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
421 int delta = XD_INDIRECT_DELTA (code);
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 irdata = ((char *)idata) + idesc[line].offset;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
424 switch (idesc[line].type)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
425 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
426 case XD_BYTECOUNT:
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
427 count = *(Bytecount *)irdata;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 619
diff changeset
428 break;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
429 case XD_ELEMCOUNT:
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
430 count = *(Elemcount *)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_HASHCODE:
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
433 count = *(Hashcode *)irdata;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
434 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
435 case XD_INT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
436 count = *(int *)irdata;
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_LONG:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
439 count = *(long *)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 default:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
442 stderr_out ("Unsupported count type : %d (line = %d, code=%ld)\n",
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
443 idesc[line].type, line, (long)code);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
444 pdump_backtrace ();
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 619
diff changeset
445 count = 0; /* warning suppression */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
446 abort ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
447 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
448 count += delta;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
449 return count;
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
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
452 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
453 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
454 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
455 int pos;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
456
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
457 restart:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
458 for (pos = 0; desc[pos].type != XD_END; 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 const void *rdata = (const char *)data + desc[pos].offset;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
461
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
462 backtrace[me].position = pos;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
463 backtrace[me].offset = 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 switch (desc[pos].type)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
466 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
467 case XD_SPECIFIER_END:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
468 pos = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
469 desc = ((const Lisp_Specifier *)data)->methods->extra_description;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
470 goto restart;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
471 case XD_BYTECOUNT:
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
472 case XD_ELEMCOUNT:
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
473 case XD_HASHCODE:
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
474 case XD_INT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
475 case XD_LONG:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
476 case XD_INT_RESET:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
477 case XD_LO_LINK:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
478 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
479 case XD_OPAQUE_DATA_PTR:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
480 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
481 EMACS_INT count = desc[pos].data1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
482 if (XD_IS_INDIRECT (count))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
483 count = pdump_get_indirect_count (count, desc, data);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
484
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
485 pdump_add_entry (&pdump_opaque_data_list,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
486 *(void **)rdata, count, 1);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
487 break;
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 case XD_C_STRING:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
490 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
491 const char *str = *(const char **)rdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
492 if (str)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
493 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
494 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
495 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
496 case XD_DOC_STRING:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
497 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
498 const char *str = *(const char **)rdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
499 if ((EMACS_INT)str > 0)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
500 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
501 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
502 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
503 case XD_LISP_OBJECT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
504 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
505 const Lisp_Object *pobj = (const Lisp_Object *)rdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
506
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
507 assert (desc[pos].data1 == 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
508
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
509 backtrace[me].offset = (const char *)pobj - (const char *)data;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
510 pdump_register_object (*pobj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
511 break;
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 case XD_LISP_OBJECT_ARRAY:
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 int i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
516 EMACS_INT count = desc[pos].data1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
517 if (XD_IS_INDIRECT (count))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
518 count = pdump_get_indirect_count (count, desc, data);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
519
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
520 for (i = 0; i < count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
521 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
522 const Lisp_Object *pobj = ((const Lisp_Object *)rdata) + i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
523 Lisp_Object dobj = *pobj;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
524
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
525 backtrace[me].offset = (const char *)pobj - (const char *)data;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
526 pdump_register_object (dobj);
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 break;
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 case XD_STRUCT_PTR:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
531 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
532 EMACS_INT count = desc[pos].data1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
533 const struct struct_description *sdesc = desc[pos].data2;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
534 const char *dobj = *(const char **)rdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
535 if (dobj)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
536 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
537 if (XD_IS_INDIRECT (count))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
538 count = pdump_get_indirect_count (count, desc, data);
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 pdump_register_struct (dobj, sdesc, count);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
541 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
542 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
543 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
544 default:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
545 stderr_out ("Unsupported dump type : %d\n", desc[pos].type);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
546 pdump_backtrace ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
547 abort ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
548 };
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 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
551
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
552 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
553 pdump_register_object (Lisp_Object obj)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
554 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
555 struct lrecord_header *objh;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
556 const struct lrecord_implementation *imp;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
557
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
558 if (!POINTER_TYPE_P (XTYPE (obj)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
559 return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
560
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
561 objh = XRECORD_LHEADER (obj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
562 if (!objh)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
563 return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
564
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
565 if (pdump_get_entry (objh))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
566 return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
567
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
568 imp = LHEADER_IMPLEMENTATION (objh);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
569
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
570 if (imp->description)
442
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 int me = depth++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
573 if (me>65536)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
574 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
575 stderr_out ("Backtrace overflow, loop ?\n");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
576 abort ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
577 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
578 backtrace[me].obj = objh;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
579 backtrace[me].position = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
580 backtrace[me].offset = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
581
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
582 pdump_add_entry (pdump_object_table + objh->type,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
583 objh,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
584 imp->static_size ?
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
585 imp->static_size :
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
586 imp->size_in_bytes_method (objh),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
587 1);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
588 pdump_register_sub (objh, imp->description, me);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
589 --depth;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
590 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
591 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
592 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
593 pdump_alert_undump_object[objh->type]++;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
594 stderr_out ("Undumpable object type : %s\n", imp->name);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
595 pdump_backtrace ();
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 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
598
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
599 static void
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
600 pdump_register_struct (const void *data,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
601 const struct struct_description *sdesc,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
602 int count)
442
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 if (data && !pdump_get_entry (data))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
605 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
606 int me = depth++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
607 int i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
608 if (me>65536)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
609 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
610 stderr_out ("Backtrace overflow, loop ?\n");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
611 abort ();
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 backtrace[me].obj = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
614 backtrace[me].position = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
615 backtrace[me].offset = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
616
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
617 pdump_add_entry (pdump_get_entry_list (sdesc),
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
618 data, sdesc->size, count);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
619 for (i=0; i<count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
620 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
621 pdump_register_sub (((char *)data) + sdesc->size*i,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
622 sdesc->description,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
623 me);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
624 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
625 --depth;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
626 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
627 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
628
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
629 static void
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
630 pdump_dump_data (pdump_entry_list_elt *elt,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
631 const struct lrecord_description *desc)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
632 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
633 Bytecount size = elt->size;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
634 int count = elt->count;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
635 if (desc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
636 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
637 int pos, i;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
638 memcpy (pdump_buf, elt->obj, size*count);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
639
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
640 for (i=0; i<count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
641 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
642 char *cur = ((char *)pdump_buf) + i*size;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
643 restart:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
644 for (pos = 0; desc[pos].type != XD_END; pos++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
645 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
646 void *rdata = cur + desc[pos].offset;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
647 switch (desc[pos].type)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
648 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
649 case XD_SPECIFIER_END:
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
650 desc = ((const Lisp_Specifier *)(elt->obj))->methods->extra_description;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
651 goto restart;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
652 case XD_BYTECOUNT:
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
653 case XD_ELEMCOUNT:
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
654 case XD_HASHCODE:
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
655 case XD_INT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
656 case XD_LONG:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
657 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
658 case XD_INT_RESET:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
659 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
660 EMACS_INT val = desc[pos].data1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
661 if (XD_IS_INDIRECT (val))
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
662 val = pdump_get_indirect_count (val, desc, elt->obj);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
663 *(int *)rdata = val;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
664 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
665 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
666 case XD_OPAQUE_DATA_PTR:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
667 case XD_C_STRING:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
668 case XD_STRUCT_PTR:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
669 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
670 void *ptr = *(void **)rdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
671 if (ptr)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
672 *(EMACS_INT *)rdata = pdump_get_entry (ptr)->save_offset;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
673 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
674 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
675 case XD_LO_LINK:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
676 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
677 Lisp_Object obj = *(Lisp_Object *)rdata;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
678 pdump_entry_list_elt *elt1;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
679 for (;;)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
680 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
681 elt1 = pdump_get_entry (XRECORD_LHEADER (obj));
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
682 if (elt1)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
683 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
684 obj = *(Lisp_Object *)(desc[pos].offset + (char *)(XRECORD_LHEADER (obj)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
685 }
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
686 *(EMACS_INT *)rdata = elt1->save_offset;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
687 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
688 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
689 case XD_LISP_OBJECT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
690 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
691 Lisp_Object *pobj = (Lisp_Object *) rdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
692
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
693 assert (desc[pos].data1 == 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
694
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
695 if (POINTER_TYPE_P (XTYPE (*pobj)) && XRECORD_LHEADER (*pobj))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
696 *(EMACS_INT *)pobj =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
697 pdump_get_entry (XRECORD_LHEADER (*pobj))->save_offset;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
698 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
699 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
700 case XD_LISP_OBJECT_ARRAY:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
701 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
702 EMACS_INT num = desc[pos].data1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
703 int j;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
704 if (XD_IS_INDIRECT (num))
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
705 num = pdump_get_indirect_count (num, desc, elt->obj);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
706
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
707 for (j=0; j<num; j++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
708 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
709 Lisp_Object *pobj = ((Lisp_Object *)rdata) + j;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
710 if (POINTER_TYPE_P (XTYPE (*pobj)) && XRECORD_LHEADER (*pobj))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
711 *(EMACS_INT *)pobj =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
712 pdump_get_entry (XRECORD_LHEADER (*pobj))->save_offset;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
713 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
714 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
715 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
716 case XD_DOC_STRING:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
717 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
718 EMACS_INT str = *(EMACS_INT *)rdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
719 if (str > 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
720 *(EMACS_INT *)rdata = pdump_get_entry ((void *)str)->save_offset;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
721 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
722 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
723 default:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
724 stderr_out ("Unsupported dump type : %d\n", desc[pos].type);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
725 abort ();
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
726 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
727 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
728 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
729 }
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
730 fwrite (desc ? pdump_buf : elt->obj, size, count, pdump_out);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
731 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
732
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
733 static void
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
734 pdump_reloc_one (void *data, EMACS_INT delta,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
735 const struct lrecord_description *desc)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
736 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
737 int pos;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
738
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
739 restart:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
740 for (pos = 0; desc[pos].type != XD_END; pos++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
741 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
742 void *rdata = (char *)data + desc[pos].offset;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
743 switch (desc[pos].type)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
744 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
745 case XD_SPECIFIER_END:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
746 pos = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
747 desc = ((const Lisp_Specifier *)data)->methods->extra_description;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
748 goto restart;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
749 case XD_BYTECOUNT:
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
750 case XD_ELEMCOUNT:
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
751 case XD_HASHCODE:
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
752 case XD_INT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
753 case XD_LONG:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
754 case XD_INT_RESET:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
755 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
756 case XD_OPAQUE_DATA_PTR:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
757 case XD_C_STRING:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
758 case XD_STRUCT_PTR:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
759 case XD_LO_LINK:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
760 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
761 EMACS_INT ptr = *(EMACS_INT *)rdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
762 if (ptr)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
763 *(EMACS_INT *)rdata = ptr+delta;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
764 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
765 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
766 case XD_LISP_OBJECT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
767 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
768 Lisp_Object *pobj = (Lisp_Object *) rdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
769
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
770 assert (desc[pos].data1 == 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
771
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
772 if (POINTER_TYPE_P (XTYPE (*pobj))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
773 && ! EQ (*pobj, Qnull_pointer))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
774 XSETOBJ (*pobj, (char *) XPNTR (*pobj) + delta);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
775
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
776 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
777 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
778 case XD_LISP_OBJECT_ARRAY:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
779 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
780 EMACS_INT num = desc[pos].data1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
781 int j;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
782 if (XD_IS_INDIRECT (num))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
783 num = pdump_get_indirect_count (num, desc, data);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
784
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
785 for (j=0; j<num; j++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
786 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
787 Lisp_Object *pobj = (Lisp_Object *) rdata + j;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
788
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
789 if (POINTER_TYPE_P (XTYPE (*pobj))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
790 && ! EQ (*pobj, Qnull_pointer))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
791 XSETOBJ (*pobj, (char *) XPNTR (*pobj) + delta);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
792 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
793 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
794 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
795 case XD_DOC_STRING:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
796 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
797 EMACS_INT str = *(EMACS_INT *)rdata;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
798 if (str > 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
799 *(EMACS_INT *)rdata = str + delta;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
800 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
801 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
802 default:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
803 stderr_out ("Unsupported dump type : %d\n", desc[pos].type);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
804 abort ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
805 };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
806 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
807 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
808
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
809 static void
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
810 pdump_allocate_offset (pdump_entry_list_elt *elt,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
811 const struct lrecord_description *desc)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
812 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
813 Bytecount size = elt->count * elt->size;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
814 elt->save_offset = cur_offset;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
815 if (size>max_size)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
816 max_size = size;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
817 cur_offset += size;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
818 }
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 static void
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
821 pdump_scan_by_alignment (void (*f)(pdump_entry_list_elt *,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
822 const struct lrecord_description *))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
823 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
824 int align;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
825
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
826 for (align = ALIGNOF (max_align_t); align; align>>=1)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
827 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
828 int i;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
829 pdump_entry_list_elt *elt;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
830
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
831 for (i=0; i<lrecord_type_count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
832 if (pdump_object_table[i].align == align)
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
833 for (elt = pdump_object_table[i].first; elt; elt = elt->next)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
834 f (elt, lrecord_implementations_table[i]->description);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
835
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
836 for (i=0; i<pdump_struct_table.count; i++)
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
837 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
838 pdump_struct_list_elt list = pdump_struct_table.list[i];
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
839 if (list.list.align == align)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
840 for (elt = list.list.first; elt; elt = elt->next)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
841 f (elt, list.sdesc->description);
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
842 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
843
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
844 for (elt = pdump_opaque_data_list.first; elt; elt = elt->next)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
845 if (pdump_size_to_align (elt->size) == align)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
846 f (elt, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
847 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
848 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
849
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
850 static void
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
851 pdump_dump_root_struct_ptrs (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
852 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
853 int i;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
854 Elemcount count = Dynarr_length (pdump_root_struct_ptrs);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
855 pdump_static_pointer *data = alloca_array (pdump_static_pointer, count);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
856 for (i = 0; i < count; i++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
857 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
858 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
859 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
860 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
861 PDUMP_ALIGN_OUTPUT (pdump_static_pointer);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
862 fwrite (data, sizeof (pdump_static_pointer), count, pdump_out);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
863 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
864
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
865 static void
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
866 pdump_dump_opaques (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
867 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
868 int i;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
869 for (i = 0; i < Dynarr_length (pdump_opaques); i++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
870 {
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
871 pdump_opaque *info = Dynarr_atp (pdump_opaques, i);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
872 PDUMP_WRITE_ALIGNED (pdump_opaque, *info);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
873 fwrite (info->varaddress, info->size, 1, pdump_out);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
874 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
875 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
876
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
877 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
878 pdump_dump_rtables (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
879 {
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
880 int i;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
881 pdump_entry_list_elt *elt;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
882 pdump_reloc_table rt;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
883
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
884 for (i=0; i<lrecord_type_count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
885 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
886 elt = pdump_object_table[i].first;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
887 if (!elt)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
888 continue;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
889 rt.desc = lrecord_implementations_table[i]->description;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
890 rt.count = pdump_object_table[i].count;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
891 PDUMP_WRITE_ALIGNED (pdump_reloc_table, rt);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
892 while (elt)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
893 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
894 EMACS_INT rdata = pdump_get_entry (elt->obj)->save_offset;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
895 PDUMP_WRITE_ALIGNED (EMACS_INT, rdata);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
896 elt = elt->next;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
897 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
898 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
899
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
900 rt.desc = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
901 rt.count = 0;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
902 PDUMP_WRITE_ALIGNED (pdump_reloc_table, rt);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
903
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
904 for (i=0; i<pdump_struct_table.count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
905 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
906 elt = pdump_struct_table.list[i].list.first;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
907 rt.desc = pdump_struct_table.list[i].sdesc->description;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
908 rt.count = pdump_struct_table.list[i].list.count;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
909 PDUMP_WRITE_ALIGNED (pdump_reloc_table, rt);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
910 while (elt)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
911 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
912 EMACS_INT rdata = pdump_get_entry (elt->obj)->save_offset;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
913 int j;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
914 for (j=0; j<elt->count; j++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
915 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
916 PDUMP_WRITE_ALIGNED (EMACS_INT, rdata);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
917 rdata += elt->size;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
918 }
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
919 elt = elt->next;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
920 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
921 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
922 rt.desc = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
923 rt.count = 0;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
924 PDUMP_WRITE_ALIGNED (pdump_reloc_table, rt);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
925 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
926
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
927 static void
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
928 pdump_dump_root_objects (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
929 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
930 Elemcount count = (Dynarr_length (pdump_root_objects) +
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 619
diff changeset
931 Dynarr_length (pdump_weak_object_chains));
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
932 Elemcount i;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
933
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
934 PDUMP_WRITE_ALIGNED (Elemcount, count);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
935 PDUMP_ALIGN_OUTPUT (pdump_static_Lisp_Object);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
936
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 619
diff changeset
937 for (i = 0; i < Dynarr_length (pdump_root_objects); i++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
938 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
939 pdump_static_Lisp_Object obj;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
940 obj.address = Dynarr_at (pdump_root_objects, i);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
941 obj.value = * obj.address;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
942
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
943 if (POINTER_TYPE_P (XTYPE (obj.value)))
619
8d7292eb4a18 [xemacs-hg @ 2001-06-19 01:35:35 by ben]
ben
parents: 617
diff changeset
944 obj.value =
8d7292eb4a18 [xemacs-hg @ 2001-06-19 01:35:35 by ben]
ben
parents: 617
diff changeset
945 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
946 (obj.value))->save_offset);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
947
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
948 PDUMP_WRITE (pdump_static_Lisp_Object, obj);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
949 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
950
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
951 for (i=0; i<Dynarr_length (pdump_weak_object_chains); i++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
952 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
953 pdump_entry_list_elt *elt;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
954 pdump_static_Lisp_Object obj;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
955
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
956 obj.address = Dynarr_at (pdump_weak_object_chains, i);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
957 obj.value = * obj.address;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
958
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
959 for (;;)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
960 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
961 const struct lrecord_description *desc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
962 int pos;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
963 elt = pdump_get_entry (XRECORD_LHEADER (obj.value));
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
964 if (elt)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
965 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
966 desc = XRECORD_LHEADER_IMPLEMENTATION (obj.value)->description;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
967 for (pos = 0; desc[pos].type != XD_LO_LINK; pos++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
968 assert (desc[pos].type != XD_END);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
969
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
970 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
971 }
619
8d7292eb4a18 [xemacs-hg @ 2001-06-19 01:35:35 by ben]
ben
parents: 617
diff changeset
972 obj.value = wrap_pointer_1 ((void *) elt->save_offset);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
973
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
974 PDUMP_WRITE (pdump_static_Lisp_Object, obj);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
975 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
976 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
977
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
978 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
979 pdump (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
980 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
981 int i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
982 Lisp_Object t_console, t_device, t_frame;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
983 int none;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
984 pdump_header header;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
985
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
986 pdump_object_table = xnew_array (pdump_entry_list, lrecord_type_count);
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
987 pdump_alert_undump_object = xnew_array (int, lrecord_type_count);
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
988
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
989 assert (ALIGNOF (max_align_t) <= pdump_align_table[0]);
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
990
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
991 for (i = 0; i < countof (pdump_align_table); i++)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
992 if (pdump_align_table[i] > ALIGNOF (max_align_t))
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
993 pdump_align_table[i] = ALIGNOF (max_align_t);
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
994
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
995 flush_all_buffer_local_cache ();
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
996
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
997 /* These appear in a DEFVAR_LISP, which does a staticpro() */
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
998 t_console = Vterminal_console; Vterminal_console = Qnil;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
999 t_frame = Vterminal_frame; Vterminal_frame = Qnil;
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1000 t_device = Vterminal_device; Vterminal_device = Qnil;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1001
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1002 dump_add_opaque (&lrecord_implementations_table,
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1003 lrecord_type_count * sizeof (lrecord_implementations_table[0]));
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1004 dump_add_opaque (&lrecord_markers,
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1005 lrecord_type_count * sizeof (lrecord_markers[0]));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1006
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1007 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
1008
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1009 for (i=0; i<lrecord_type_count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1010 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1011 pdump_object_table[i].first = 0;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1012 pdump_object_table[i].align = ALIGNOF (max_align_t);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1013 pdump_object_table[i].count = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1014 pdump_alert_undump_object[i] = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1015 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1016 pdump_struct_table.count = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1017 pdump_struct_table.size = -1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1018
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1019 pdump_opaque_data_list.first = 0;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1020 pdump_opaque_data_list.align = ALIGNOF (max_align_t);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1021 pdump_opaque_data_list.count = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1022 depth = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1023
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1024 for (i=0; i<Dynarr_length (pdump_root_objects); i++)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1025 pdump_register_object (* Dynarr_at (pdump_root_objects, i));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1026
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1027 none = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1028 for (i=0; i<lrecord_type_count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1029 if (pdump_alert_undump_object[i])
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1030 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1031 if (none)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1032 printf ("Undumpable types list :\n");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1033 none = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1034 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
1035 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1036 if (!none)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1037 return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1038
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1039 for (i=0; i<Dynarr_length (pdump_root_struct_ptrs); i++)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1040 {
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1041 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
1042 pdump_register_struct (*(info.ptraddress), info.desc, 1);
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1043 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1044
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1045 memcpy (header.signature, PDUMP_SIGNATURE, PDUMP_SIGNATURE_LEN);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1046 header.id = dump_id;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1047 header.reloc_address = 0;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1048 header.nb_root_struct_ptrs = Dynarr_length (pdump_root_struct_ptrs);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1049 header.nb_opaques = Dynarr_length (pdump_opaques);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1050
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1051 cur_offset = ALIGN_SIZE (sizeof (header), ALIGNOF (max_align_t));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1052 max_size = 0;
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 pdump_scan_by_alignment (pdump_allocate_offset);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1055 cur_offset = ALIGN_SIZE (cur_offset, ALIGNOF (max_align_t));
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1056 header.stab_offset = cur_offset;
442
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 pdump_buf = xmalloc (max_size);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1059 /* Avoid use of the `open' macro. We want the real function. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1060 #undef open
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1061 pdump_fd = open (EMACS_PROGNAME ".dmp",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1062 O_WRONLY | O_CREAT | O_TRUNC | OPEN_BINARY, 0666);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1063 pdump_out = fdopen (pdump_fd, "w");
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1064
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1065 fwrite (&header, sizeof (header), 1, pdump_out);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1066 PDUMP_ALIGN_OUTPUT (max_align_t);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1067
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1068 pdump_scan_by_alignment (pdump_dump_data);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1069
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1070 fseek (pdump_out, header.stab_offset, SEEK_SET);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1071
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1072 pdump_dump_root_struct_ptrs ();
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1073 pdump_dump_opaques ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1074 pdump_dump_rtables ();
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1075 pdump_dump_root_objects ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1076
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1077 fclose (pdump_out);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1078 close (pdump_fd);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1079
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1080 free (pdump_buf);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1081
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1082 free (pdump_hash);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1083
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1084 Vterminal_console = t_console;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1085 Vterminal_frame = t_frame;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1086 Vterminal_device = t_device;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1087 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1088
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1089 static int
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1090 pdump_load_check (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1091 {
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1092 return (!memcmp (((pdump_header *)pdump_start)->signature,
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1093 PDUMP_SIGNATURE, PDUMP_SIGNATURE_LEN)
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1094 && ((pdump_header *)pdump_start)->id == dump_id);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1095 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1096
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1097 /*----------------------------------------------------------------------*/
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1098 /* Reading the dump file */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1099 /*----------------------------------------------------------------------*/
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1100 static int
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1101 pdump_load_finish (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1102 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1103 int i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1104 char *p;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1105 EMACS_INT delta;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1106 EMACS_INT count;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1107 pdump_header *header = (pdump_header *)pdump_start;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1108
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1109 pdump_end = pdump_start + pdump_length;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1110
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1111 delta = ((EMACS_INT)pdump_start) - header->reloc_address;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1112 p = pdump_start + header->stab_offset;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1113
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1114 /* Put back the pdump_root_struct_ptrs */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1115 p = (char *) ALIGN_PTR (p, ALIGNOF (pdump_static_pointer));
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1116 for (i=0; i<header->nb_root_struct_ptrs; i++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1117 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1118 pdump_static_pointer ptr = PDUMP_READ (p, pdump_static_pointer);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1119 (* ptr.address) = ptr.value + delta;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1120 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1121
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1122 /* Put back the pdump_opaques */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1123 for (i=0; i<header->nb_opaques; i++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1124 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1125 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
1126 memcpy ((void*)info.varaddress, p, info.size);
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1127 p += info.size;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1128 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1129
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1130 /* Do the relocations */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1131 pdump_rt_list = p;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1132 count = 2;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1133 for (;;)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1134 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1135 pdump_reloc_table rt = PDUMP_READ_ALIGNED (p, pdump_reloc_table);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1136 p = (char *) ALIGN_PTR (p, ALIGNOF (char *));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1137 if (rt.desc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1138 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1139 char **reloc = (char **)p;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1140 for (i=0; i < rt.count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1141 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1142 reloc[i] += delta;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1143 pdump_reloc_one (reloc[i], delta, rt.desc);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1144 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1145 p += rt.count * sizeof (char *);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1146 } else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1147 if (!(--count))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1148 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1149 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1150
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1151 /* 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
1152 i = PDUMP_READ_ALIGNED (p, Elemcount);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1153 p = (char *) ALIGN_PTR (p, ALIGNOF (pdump_static_Lisp_Object));
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1154 while (i--)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1155 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1156 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
1157
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1158 if (POINTER_TYPE_P (XTYPE (obj.value)))
619
8d7292eb4a18 [xemacs-hg @ 2001-06-19 01:35:35 by ben]
ben
parents: 617
diff changeset
1159 obj.value = wrap_pointer_1 ((char *) XPNTR (obj.value) + delta);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1160
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1161 (* obj.address) = obj.value;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1162 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1163
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1164 /* Final cleanups */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1165 /* reorganize hash tables */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1166 p = pdump_rt_list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1167 for (;;)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1168 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1169 pdump_reloc_table rt = PDUMP_READ_ALIGNED (p, pdump_reloc_table);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
1170 p = (char *) ALIGN_PTR (p, ALIGNOF (Lisp_Object));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1171 if (!rt.desc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1172 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1173 if (rt.desc == hash_table_description)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1174 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1175 for (i=0; i < rt.count; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1176 pdump_reorganize_hash_table (PDUMP_READ (p, Lisp_Object));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1177 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1178 } else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1179 p += sizeof (Lisp_Object) * rt.count;
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 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1183 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1184
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1185 #ifdef WIN32_NATIVE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1186 /* 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
1187 static void
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1188 pdump_file_unmap (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1189 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1190 UnmapViewOfFile (pdump_start);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1191 CloseHandle (pdump_hFile);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1192 CloseHandle (pdump_hMap);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1193 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1194
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1195 static int
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1196 pdump_file_get (const char *path)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1197 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1198
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1199 pdump_hFile = CreateFile (path,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1200 GENERIC_READ + GENERIC_WRITE, /* Required for copy on write */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1201 0, /* Not shared */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1202 NULL, /* Not inheritable */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1203 OPEN_EXISTING,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1204 FILE_ATTRIBUTE_NORMAL,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1205 NULL); /* No template file */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1206 if (pdump_hFile == INVALID_HANDLE_VALUE)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1207 return 0;
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 pdump_length = GetFileSize (pdump_hFile, NULL);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1210 pdump_hMap = CreateFileMapping (pdump_hFile,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1211 NULL, /* No security attributes */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1212 PAGE_WRITECOPY, /* Copy on write */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1213 0, /* Max size, high half */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1214 0, /* Max size, low half */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1215 NULL); /* Unnamed */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1216 if (pdump_hMap == INVALID_HANDLE_VALUE)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1217 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1218
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1219 pdump_start = MapViewOfFile (pdump_hMap,
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1220 FILE_MAP_COPY, /* Copy on write */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1221 0, /* Start at zero */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1222 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1223 0); /* Map all of it */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1224 pdump_free = pdump_file_unmap;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1225 return 1;
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
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1228 /* pdump_resource_free is called (via the pdump_free pointer) to release
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1229 any resources allocated by pdump_resource_get. Since the Windows API
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1230 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
1231 resources allocated by FindResource, LoadResource, and LockResource this
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1232 routine does nothing. */
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1233 static void
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1234 pdump_resource_free (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1235 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1236 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1237
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1238 static int
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1239 pdump_resource_get (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1240 {
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1241 HRSRC hRes; /* Handle to dump resource */
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1242 HRSRC hResLoad; /* Handle to loaded dump resource */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1243
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1244 /* See Q126630 which describes how Windows NT and 95 trap writes to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1245 resource sections and duplicate the page to allow the write to proceed.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1246 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
1247 private to each process). Doing this avoids the exceptions and related
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1248 overhead, but causes the resource section to be private to each process
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1249 that is running XEmacs. Since the resource section contains little
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1250 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
1251 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
1252
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1253 hRes = FindResource (NULL, MAKEINTRESOURCE(101), "DUMP");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1254 if (hRes == NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1255 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1256
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1257 /* Found it, use the data in the resource */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1258 hResLoad = LoadResource (NULL, hRes);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1259 if (hResLoad == NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1260 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1261
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1262 pdump_start = LockResource (hResLoad);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1263 if (pdump_start == NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1264 return 0;
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 pdump_free = pdump_resource_free;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1267 pdump_length = SizeofResource (NULL, hRes);
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
1268 if (pdump_length <= (Bytecount) sizeof (pdump_header))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1269 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1270 pdump_start = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1271 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1272 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1273
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1274 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1275 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1276
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1277 #else /* !WIN32_NATIVE */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1278
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1279 static void
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1280 pdump_file_free (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1281 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1282 xfree (pdump_start);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1283 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1284
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1285 #ifdef HAVE_MMAP
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1286 static void
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1287 pdump_file_unmap (void)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1288 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1289 munmap (pdump_start, pdump_length);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1290 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1291 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1292
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1293 static int
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1294 pdump_file_get (const char *path)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1295 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1296 int fd = open (path, O_RDONLY | OPEN_BINARY);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1297 if (fd<0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1298 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1299
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1300 pdump_length = lseek (fd, 0, SEEK_END);
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
1301 if (pdump_length < (Bytecount) sizeof (pdump_header))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1302 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1303 close (fd);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1304 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1305 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1306
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1307 lseek (fd, 0, SEEK_SET);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1308
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1309 #ifdef HAVE_MMAP
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 452
diff changeset
1310 /* Unix 98 requires that sys/mman.h define MAP_FAILED,
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 452
diff changeset
1311 but many earlier implementations don't. */
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 452
diff changeset
1312 # ifndef MAP_FAILED
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 452
diff changeset
1313 # define MAP_FAILED ((void *) -1L)
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 452
diff changeset
1314 # endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1315 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
1316 if (pdump_start != (char *) MAP_FAILED)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1317 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1318 pdump_free = pdump_file_unmap;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1319 close (fd);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1320 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1321 }
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 452
diff changeset
1322 #endif /* HAVE_MMAP */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1323
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1324 pdump_start = xnew_array (char, pdump_length);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1325 pdump_free = pdump_file_free;
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1326 read (fd, pdump_start, pdump_length);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1327
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1328 close (fd);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1329 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1330 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1331 #endif /* !WIN32_NATIVE */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1332
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1333
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1334 static int
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1335 pdump_file_try (char *exe_path)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1336 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 458
diff changeset
1337 char *w = exe_path + strlen (exe_path);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1338
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1339 do
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 sprintf (w, "-%s-%08x.dmp", EMACS_VERSION, dump_id);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1342 if (pdump_file_get (exe_path))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1343 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1344 if (pdump_load_check ())
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1345 return 1;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1346 pdump_free ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1347 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1348
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1349 sprintf (w, "-%08x.dmp", dump_id);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1350 if (pdump_file_get (exe_path))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1351 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1352 if (pdump_load_check ())
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1353 return 1;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1354 pdump_free ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1355 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1356
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1357 sprintf (w, ".dmp");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1358 if (pdump_file_get (exe_path))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1359 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1360 if (pdump_load_check ())
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1361 return 1;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1362 pdump_free ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1363 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1364
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1365 do
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1366 w--;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1367 while (w>exe_path && !IS_DIRECTORY_SEP (*w) && (*w != '-') && (*w != '.'));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1368 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1369 while (w>exe_path && !IS_DIRECTORY_SEP (*w));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1370 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1371 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1372
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1373 int
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1374 pdump_load (const char *argv0)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1375 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1376 char exe_path[PATH_MAX];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1377 #ifdef WIN32_NATIVE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1378 GetModuleFileName (NULL, exe_path, PATH_MAX);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1379 #else /* !WIN32_NATIVE */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1380 char *w;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1381 const char *dir, *p;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1382
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1383 dir = argv0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1384 if (dir[0] == '-')
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1385 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1386 /* XEmacs as a login shell, oh goody! */
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1387 dir = getenv ("SHELL");
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1388 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1389
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1390 p = dir + strlen (dir);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1391 while (p != dir && !IS_ANY_SEP (p[-1])) p--;
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 if (p != dir)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1394 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1395 /* invocation-name includes a directory component -- presumably it
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1396 is relative to cwd, not $PATH */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1397 strcpy (exe_path, dir);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1398 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1399 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1400 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1401 const char *path = getenv ("PATH");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1402 const char *name = p;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1403 for (;;)
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 p = path;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1406 while (*p && *p != SEPCHAR)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1407 p++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1408 if (p == path)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1409 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1410 exe_path[0] = '.';
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1411 w = exe_path + 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1412 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1413 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1414 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1415 memcpy (exe_path, path, p - path);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1416 w = exe_path + (p - path);
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 if (!IS_DIRECTORY_SEP (w[-1]))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1419 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1420 *w++ = '/';
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1421 }
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
1422 strcpy (w, name);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1423
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1424 /* ### #$%$#^$^@%$^#%@$ ! */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1425 #ifdef access
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1426 #undef access
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1427 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1428
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1429 if (!access (exe_path, X_OK))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1430 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1431 if (!*p)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1432 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1433 /* Oh well, let's have some kind of default */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1434 sprintf (exe_path, "./%s", name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1435 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1436 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1437 path = p+1;
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 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1440 #endif /* WIN32_NATIVE */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1441
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1442 if (pdump_file_try (exe_path))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1443 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1444 pdump_load_finish ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1445 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1446 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1447
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1448 #ifdef WIN32_NATIVE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1449 if (pdump_resource_get ())
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1450 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1451 if (pdump_load_check ())
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1452 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1453 pdump_load_finish ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1454 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1455 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1456 pdump_free ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1457 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1458 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1459
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1460 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1461 }