home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.wizards:5293 comp.unix.programmer:5750 comp.unix.questions:14856
- Path: sparky!uunet!olivea!charnel!sifon!thunder.mcrcim.mcgill.edu!mouse
- From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
- Newsgroups: comp.unix.wizards,comp.unix.programmer,comp.unix.questions
- Subject: Re: Portability issues in using a memory dump
- Message-ID: <1992Dec21.165835.17205@thunder.mcrcim.mcgill.edu>
- Date: 21 Dec 92 16:58:35 GMT
- References: <1992Dec17.222402.18347@sj.ate.slb.com>
- Organization: McGill Research Centre for Intelligent Machines
- Lines: 48
-
- In article <1992Dec17.222402.18347@sj.ate.slb.com>, bharat@sj.ate.slb.com (Bharat Venkatasubramanian) writes:
-
- > I have a wierd problem. I would like to dump the contents of a chunk
- > of contiguous memory locations. The contents represent some complex
- > graph structure which once built is constant over different
- > invocations of the program.
-
- > Instead of traversing the graph and dumping its contents, I would
- > like to dump the contents of this contiguous memory. Subsequent
- > invocations of this program could then use mmap() system call to map
- > the information in this file to the address used when the file was
- > first created.
-
- It's a bit ugly, but it should be workable on most systems. Sendmail
- does something similar with its frozen config files.
-
- > The program has static behavior until the creation of this graph and
- > so on the same machine I will definitely be able to guarantee the
- > availability of that address space.
-
- Are you sure? Part of that space is probably already occupied by
- data/bss. You'd probably be better off using brk() to set the break to
- the appropriate place and then just read()ing in the file. Be careful
- to use only automatic variables....
-
- Unless you are specifically allocating a block of memory for this
- purpose, and want to save and restore only that block. You still may
- be better off with read than mmap, if for no other reason than some
- systems don't have mmap.
-
- > One of my concerns is will the address space be different on
- > different Operating Systems??
-
- Yes. The difference is usually fairly minor; most UNIXish systems just
- give you text/data/stack at runtime, so if you dump out the data
- segment you should be OK, even though the data segment may begin at a
- different address and be a different size from system to system. If
- you encounter a system that doesn't fit this model, you may have to
- abandon this technique. (On SunOS 4.x, for example, you will likely
- have to link -Bstatic if you want to dump the whole data segment,
- because otherwise pieces of the conceptual data segment are up at
- random addresses thanks to shared object files being brought in at
- run-time.)
-
- der Mouse
-
- mouse@larry.mcrcim.mcgill.edu
-