Re: building an image
"Topher Cyll" <[email protected]>
| Newsgroups | gmane.comp.lang.smalltalk.strongtalk |
|---|---|
| Message-ID | <[email protected]> |
Fantastic news! -Toph On 3/6/07, David Griswold <[email protected]> wrote: > > > I've added headless scripting capability to Strongtalk, which should help > with testing ports to other OSes without the GUI. Now, the command line can > take -script <filepath> (path can be double-quoted if has imbedded spaces). > The script file must be in chunk/fileIn format (So for example a simple doit > can be done with syntax like "Transcript show: 'hello world'; cr !"). > > The script runs in the startup (scheduler) Smalltalk process, so it may be > simpler to debug as you may be able to avoid having to switch processes as > much. > > (As an aside, this changes the command line syntax for benchmark running; > benchmark args must now be preceded by -benchmark, and not be intermixed > with other arguments.) > > I will commit the changes, which are in runtime\arguments.cpp for the VM, > and SourceHandler.dlt, SystemInitializer.dlt, and Platform.dlt on the > Smalltalk side. I have attached the new arguments.cpp, and a patch file > containing the Smalltalk side modifications. My first attempt to commit the > changes failed for some reason (and was incredibly slow), so use the > attached files for now. > > -Dave > > > -----Original Message----- > From: [email protected] > [mailto:[email protected]]On Behalf Of > Dave Raymer > Sent: Monday, March 05, 2007 11:55 AM > To: [email protected] > Subject: Re: building an image > > Dave, > > And getting the VM to run without the UI on Linux was indeed my plan; > get a basic headless mode up and running, that basically provides a > command line "shell" to the VM. > > I'll wait for your "command line arg" work and move forward from there. > > thanks for the response. > -- the other Dave > > > On 3/5/07, David Griswold <[email protected]> wrote: > > > > Hi, > > > > Sorry I've been off the list for a while. I'll be more engaged going > > forward. > > > > Yes, your description looks pretty accurate. As you said, the method that > > is the hook for starting the Smalltalk level code executing is > > ProcessorScheduler>>start. That calls SystemInitializer > class>>run, which > > runs all the non-scheduling specific startup code, including class > > initializers (class initializers don't run automatically right now, you > have > > to invoke them explicitely some where. Critical library initializers are > > called from SystemInitializer > class>>runBaseClassInitializers. Other > > non-core initializers are currently called from > > SystemInitializer>>runNonCriticalClassInitializers. A > better method is > > needed for organizing class initializers.) If there are no command line > > arguments, the UI is started when SystemInitializer class>>run by forking > > [UI start], the processorscheduler then enters into it's main loop which > > then schedules and executes the [UI start] block. Generally, each > > application runs in a separate process. > > > > As much code as possible is written in Smalltalk, which of course means > the > > UI code is *entirely* written in Smalltalk, including all the > > platform-dependent code. However, that doesn't mean the GUI is > > non-portable, since while the UI implementation contains lots of Win32 > > specific code, device dependent code is factored out by class or category > > and the interface it presents to applications is designed to be fully > > portable, with device independent ways of doing rendering, event > processing, > > etc. So obviously the GUI isn't going to run out-of-the-box on > non-Windows > > systems; there is a big project involved to port the implementation, > however > > none of the applications or interfaces should have to be modified (that I > > know of). > > > > But given that porting the GUI is a big project that isn't going to happen > > anytime real soon, I think the focus should be on getting the VM running > > without the UI on Linux, since that would still be useful for a Squeak > port > > etc. To do that, remember that the GUI only starts if there are no > command > > line arguments. So we need to modify SystemInitializer > > class>>processArguments: with another option that takes a filename to > > file-in and execute, then we can test the VM reasonably without the GUI > (as > > well as use it to run scripts). I'll set that command-line arg up. But > > there is still a significant piece of work to port the VM code that > > automatically loads and invokes external library DLLs, since all Smalltalk > > I/O goes through that. And then the basic non-GUI I/O code must be ported > > to call Linux libs (not hard, although a socket implementation is > missing). > > At that point we would be able to run headless code that does basic file > > manipulation. > > > > As for rebuilding the image file from within Smalltalk, that doesn't work > > yet, partly because there is a single method in the system right now that > > currently causes the bytecode compiler to crash. I will be looking into > > getting image bootstrapping working again, so that we can recompile and > > bootstrap the entire image, which would be an excellent first piece of > code > > for putting in an automated test suite for the VM, since it could be done > > without needing the UI. As part of that, I've been looking into the image > > format, and I'll post some info on that when I set up the wiki, which I > will > > do "Real Soon Now". > > > > -Dave > > > > > -----Original Message----- > > > From: [email protected] > > > [mailto:[email protected]]On Behalf > Of oe > > > Sent: Monday, March 05, 2007 8:57 AM > > > To: Strongtalk-general > > > Subject: Re: building an image > > > > > > > > > > > > Hello, > > > > > > I'm still trying to figure out, like a high level model of the VM. The > > > available documentation doesn't help me much here, I have to say, and > > > it took some time to get into this. So not sure what you mean exactly > > > with > > > > > > > trying to sort out how the image gets built so I can track the > > > > entrypoint into the runtime environment and see what how the UI gets > > > > loaded. > > > > > > , but I'll try to explain briefly what I've found out about how the VM > > > starts into the GUI. > > > > > > - VM starts in shell.cpp, initialization (bootstrap.cpp, mainly > > > bootstrap::parse_file()) > > > - in process.cpp: VMProcess::activate_system(). This is where things > > > get interesting (and difficult, at least for me ;). The VM process > > > tries to retrieve a 'Delta level Processor' (see comments there) from > > > the system dictionary, which was (supposedly) previously loaded from > > > the image by the bootstrap code. I guess that the OOPs (processOop > > > etc.) involved are actually C++ representations of Smalltalk classes/ > > > objects stored in the image (if this makes sense). You can inspect the > > > Smalltalk code by opening Strongtalk, then Browse->All Classes- > > > >Processor(->ProcessorScheduler). > > > - then, the "initial process" is created (new DeltaProcess) to call > > > the "start" method of scheduler just created (a method written in > > > Smalltalk, see Strongtalk class browser: Class ProcessorScheduler- > > > >Instance side->restricted->start). > > > - the actual call to "start" originates in the delta process once it > > > is run (that is, control is transfered by the scheduler): process.cpp > > > DeltaProcess::launch_delta, then delta.cpp Delta::call, all the way > > > down to interpreter_asm.asm call_delta, where the actual call takes > > > place. So I assume this is the point where Smalltalk code takes over > > > and drives further initialization of the system and GUI. > > > - also, if you look at the Smalltalk classes, especially > > > ExternalProxy, External* and Win32, I believe that there is a lot of > > > platform specific code written in Smalltalk, using Windows DLL calls > > > to interface with the OS (hence all the dll stuff/primitives in the C+ > > > + code)... just speculating, though! > > > > > > So, that's about my quick tour of the VM startup, hope it helps -- or > > > maybe I've just missed the point of your post? I haven't even manage > > > to build a new image file from within the Strongtalk GUI, but it's > > > been a while.Some information about the image file format and its > > > contents would definitely be helpful; I have to look at this again > > > when time permits. > > > > > > Oliver > > > > > > > > > > > > > > > > > > > /* Copyright 1994, 1995 LongView Technologies L.L.C. $Revision: 1.13 $ */ > /* Copyright (c) 2006, Sun Microsystems, Inc. > All rights reserved. > > Redistribution and use in source and binary forms, with or without > modification, are permitted provided that the > following conditions are met: > > * Redistributions of source code must retain the above copyright notice, > this list of conditions and the following disclaimer. > * Redistributions in binary form must reproduce the above copyright > notice, this list of conditions and the following > disclaimer in the documentation and/or other materials provided > with the distribution. > * Neither the name of Sun Microsystems nor the names of its contributors > may be used to endorse or promote products derived > from this software without specific prior written permission. > > THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" > AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT > NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A > PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL > THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, > INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES > (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; > LOSS OF USE, DATA, OR PROFITS; OR BUSINESS > INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN > CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE > OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF > ADVISED OF THE POSSIBILITY OF SUCH DAMAGE > > > */ > > # include "incls/_precompiled.incl" > # include "incls/_arguments.cpp.incl" > # include <ctype.h> > > // Recipe for setting flags for the VM: > // 1. Read the file .deltarc > // 2. Process the arguments > > //char* boot_filename = "delta.bst"; > char* boot_filename = SYSTEM_NAME ".bst"; > char* rc_filename = "." SYSTEM_NAME "rc"; > > static void set_bool_flag(char* name, bool value) { > bool s = value; > if (!debugFlags::boolAtPut(name, &s)) > fprintf(stderr, "Boolean flag %s unknown.\n", name); > } > > static void set_int_flag(char* name, int value) { > int v = value; > if (!debugFlags::intAtPut(name, &v)) > fprintf(stderr, "Integer flag %s unknown.\n", name); > } > > static void process_token(char* token) { > if (token[0] == '-') set_bool_flag(&token[1], false); > else if (token[0] == '+') set_bool_flag(&token[1], true); > else { > char name[100]; > int value; > if (sscanf(token, "%[a-zA-Z]=%d", name, &value) == 2) { > set_int_flag(name, value); > } > } > } > > void process_settings_file(char* file_name, bool quiet) { > FILE* stream = fopen(file_name, "rb"); > if (stream == NULL) { > if (quiet) return; > fprintf(stderr, "Could not open %s\n", file_name); > exit(-1); > } > > char token[1024]; > int pos = 0; > > bool in_white_space = true; > bool in_comment = false; > > int c = getc(stream); > while(c != EOF) { > if (in_white_space) { > if (in_comment) { > if (c == '\n') in_comment = false; > } else { > if (c == '#') in_comment = true; > else if (!isspace(c)) { > in_white_space = false; > token[pos++] = c; > } > } > } else { > if (isspace(c)) { > token[pos] = '\0'; > process_token(token); > pos = 0; > in_white_space = true; > } else { > token[pos++] = c; > } > } > c = getc(stream); > } > if (pos>0) { > token[pos] = '\0'; > process_token(token); > } > fclose(stream); > } > > void print_credits() { > // string minimaly encrypted to make it more difficult to > // tamper with it by looking for it in the executable... > const char credits[] = "\ > \x11\x5a\x04\x1e\x7a\x76\x08\x38\x0b\x6e\x5b\x50\x1e\x04\x2e\x34\x6b\x21\x47\x2e\ > \x73\x57\x41\x7b\x65\x18\x3c\x54\x03\x2e\x79\x0e\x1a\x49\x17\x1f\x2f\x44\x45\x73\ > \x75\x21\x7e\x5c\x00\x11\x6a\x53\x5b\x3a\x43\x3e\x7e\x5b\x08\x29\x1a\x4c\x1d\x53\ > \x13\x22\x73\x0e\x1a\x49\x1f\x1e\x2d\x5b\x05\x37\x0b\x6e\x49\x4b\x01\x45\x02\x7b\ > \x4c\x3f\x5c\x21\x7e\x3c\ > "; > int mask = 0xa729b65d; > for (int i = 0; i < sizeof(credits) - 1; i++) { > fputc((credits[i] ^ mask) & 0x7f, stdout); > mask = (mask << 1) | (mask >> 31) & 1; // rotate mask > } > } > > void parse_arguments(int argc, char* argv[]) { > bool parse_files = true; > > if (argc > 1 && strcmp(argv[1], "-t") == 0) { > fprintf(stdout, "Timers turned off, flags file and -f arguments are > ignored.\n"); > UseTimers = false; > EnableTasks = false; > parse_files = false; > } > > if (parse_files) { > process_settings_file(rc_filename, true); > } > > for (int index = parse_files ? 1 : 2; index < argc; index++) { > if (strcmp(argv[index], "-?") == 0) { > debugFlags::printFlags(); > exit(0); > } else if (strcmp(argv[index], "-credits") == 0) { > print_credits(); > exit(0); > } else if (strcmp(argv[index], "-b") == 0) { > index++; > if (index >= argc) { > fprintf(stderr, "file name expected after '-b'\n"); > exit(-1); > } > boot_filename = argv[index]; > } else if (strcmp(argv[index], "-f") == 0) { > index++; > if (index >= argc) { > fprintf(stderr, "file name expected after '-f'\n"); > exit(-1); > } > if (parse_files) { > process_settings_file(argv[index]); > } > } else if (strcmp(argv[index], "-script") == 0) { > // The script file name is read and processed by Smalltalk > // code, not here. Here we just recognize it and skip over it. > index++; > if (index >= argc) { > fprintf(stderr, "file name expected after '-script'\n"); > exit(-1); > } > } else if (strcmp(argv[index], "-benchmark") == 0) { > // signals to ignore the rest of the command line, which will be > // interpreted by Smalltalk code as benchmark commands. > return; > } else process_token(argv[index]); > } > } > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Strongtalk-general" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/strongtalk-general?hl=en -~----------~----~----~----~------~----~------~--~---