home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.tcl
- Path: sparky!uunet!eco.twg.com!twg.com!news
- From: "David Herron" <david@twg.com>
- Subject: Re: Dumping/Restoring Interpreter Memory
- Message-ID: <1992Nov12.010420.4752@twg.com>
- Sensitivity: Personal
- Encoding: 56 TEXT , 4 TEXT
- Sender: news@twg.com (USENET News System)
- Conversion: Prohibited
- Organization: The Wollongong Group, Inc., Palo Alto, CA
- Conversion-With-Loss: Prohibited
- Date: Thu, 12 Nov 1992 01:08:07 GMT
- Lines: 61
-
- I've been looking at interpretOR internals lately, sooo...
-
-
- > I have noted that the tclTest program has a function call to
- > Tcl_DumpActiveMemory, but can't seem to locate this function (John, is this
- > not included in the regular distribution?).
-
- Isn't that just part of the malloc-checking part of TCL?
-
- > This may sound like an odd request, but I was wondering if anyone has devised
- > a method for dumping interpreter memory to a file, the restoring this file
- > back into an interpreter and continuing processing right where the dump
- > left off.
-
- Hmm.. an interesting feature here. But some problems depending on how
- much you were interested in saving away. I wonder (rhetorically) whether
- it is of a general enough value that `everyone' would want this feature?
-
- Like you suggest one could step through the hash tables and write
- out everything you see in some interesting format. A lot of it
- will be variables, arrays and TCL procedures. Those could be dumped
- out as a TCL script and read back in at any time w/o problem.
-
- The commands are another problem entirely. Their entry in the
- hash table contains a couple of pointers. One is to the function
- which is to handle the call. This shouldn't change unless the
- program is recompiled. I don't know if dynamically loadable libraries
- will make function addresses change, but very few people are using
- dynamically loaded libraries in TCL anyway (which is a pity by itself).
-
- The other is programmer-specified data (the clientData argument) which
- will almost certainly change between runs of the program and is an
- opaque pointer which TCL hasn't the foggiest idea of how to duplicate.
- TK Widgets, for instance, put the Tcl_Interp pointer there. The constant
- module I posted a few days ago put a strdup() of the value there. In my
- interp module, the interpInfo structure is passed around in the clientData.
-
- This last is, IMO, the killer.
-
- If you want to investigate further:
-
- the code behind Tcl_CreateCommand() shows how commands are
- entered in the hash table.
-
- the code which handles the `proc' command shows how procedures
- are entered in the hash table.
-
- The code behind Tcl_SetVar2() shows how variables are entered
- in the hash table.
-
- Oh yeah.. another piece of state to save is the function(s) being
- executed & the TCL stack. This is something I haven't looked
- at closely, but a fair bit of data seems to be recorded in
- the argument lists & local variables of functions all through
- the TCL library. Some data is recorded in the interpretOR
- structure ... Tcl_Eval() will give clues on this.
-
- <- David Herron <david@twg.com> (work) <david@davids.mmdf.com> (home)
- <-
- <- During the '80s Usenet's mantra was: "Not all the world's a VAX".
- <- During the '90s I hope it becomes: "Not all the world's DOS (ick)".
-