Open zenspider opened 9 years ago
Maglev automatically generates an ensure block around your code. I'm not sure where, unfortunately, it might be in the Smalltalk code.
@AllenOtis any clues?
You should look at the script file generated by the maglev-ruby script . That script file will show the complete input to topaz . Also run topaz directly as follows to run a sample .rb file Then you can use the smalltalk debugging (up, down, frame, etc, similar to gdb... ) in topaz to look at the stack and see what the parser primitive is getting. Beyond that you would have to look at the C source code that you have for the parser , to understand exactly how the input to the parser is generated. I don't remember where the "ensure", and such that you are seeing is coming from .
topaz 1> run
| fn ctx hm |
hm := (RubyEnv _getenv:'MAGLEV_HOME') . fn := hm , '/src/test/InvokeTest.rb' .
SessionTemps current
at: #MagRpDEBUG put: 1 ;
at:#Maglev_ruby_debugFlag put: true .
ctx := RubyContext load: #( ) . "logSexp traceLoad allIvsDynamic"
System signalAlmostOutOfMemoryThreshold:115 .
"RubyNameSpace traceGlobals: 0 .
RubyStaticScope traceLocals: 0 .
GsNMethod traceIR: 0 .
Exception installDebugBlock: [:ex| nil pause ].
"
ctx runFileNamed: fn env: 1
%
a Breakpoint occurred (error 6005), Method breakpoint encountered.
1 1 RubyParserM class >> parse:cBytes:line:file:yTrace:warnings:evalScope: (envId 0) @1 line 1
topaz 1> where ==> 1 RubyParserM class >> parse:cBytes:line:file:yTrace:warnings:evalScope: (envId 0) @1 line 1 2 RubyParserM class >> rpParseString:path:loadName:yTrace:warnings: (envId 0) @3 line 3 3 RubyParserM class >> rpParseFile:loadName:yTrace:warnings: (envId 0) @8 line 6 4 RubyCompiler >> parseFileNamed:loadName: (envId 0) @13 line 9 5 [] in RubyCompiler >> compileFileNamed:loadName:env: (envId 0) @6 line 8 6 ExecBlock >> onException:do: (envId 0) @2 line 66 7 RubyCompiler >> compileFileNamed:loadName:env: (envId 0) @2 line 35 8 [] in RubyFile >> loadIntoEnv: (envId 0) @8 line 20 9 ExecBlock >> ensure: (envId 0) @2 line 12 10 RubyFile >> loadIntoEnv: (envId 0) @19 line 21 11 RubyContext >> loadFileNamed:env: (envId 0) @13 line 8 12 RubyContext >> runFileNamed:env: (envId 0) @6 line 5 13 Executed Code @12 line 13
recommended .topazini contents (in current directory when starting topaz)
set user DataCurator pass swordfish set gemstone maglev display oops omit classoops set stackpad 50 set tab 8 omit bytes limit bytes 5000 limit oops 20 level 0
note obj @
command to examine contents of a temp shown from "frame" .
You should look at the script file generated by the maglev-ruby script . That script file will show the complete input to topaz . Also run topaz directly as follows to run a sample .rb file Then you can use the smalltalk debugging (up, down, frame, etc, similar to gdb... ) in topaz to look at the stack and see what the parser primitive is getting. Beyond that you would have to look at the C source code that you have for the parser , to understand exactly how the input to the parser is generated. I don't remember where the "ensure", and such that you are seeing is coming from .
topaz 1> run
| fn ctx hm |
hm := (RubyEnv _getenv:'MAGLEV_HOME') . fn := hm , '/src/test/InvokeTest.rb' .
SessionTemps current
at: #MagRpDEBUG put: 1 ;
at:#Maglev_ruby_debugFlag put: true .
ctx := RubyContext load: #( ) . "logSexp traceLoad allIvsDynamic"
System signalAlmostOutOfMemoryThreshold:115 .
"RubyNameSpace traceGlobals: 0 .
RubyStaticScope traceLocals: 0 .
GsNMethod traceIR: 0 .
Exception installDebugBlock: [:ex| nil pause ].
"
ctx runFileNamed: fn env: 1
%
a Breakpoint occurred (error 6005), Method breakpoint encountered.
1 1 RubyParserM class >> parse:cBytes:line:file:yTrace:warnings:evalScope: (envId 0) @1 line 1
topaz 1> where ==> 1 RubyParserM class >> parse:cBytes:line:file:yTrace:warnings:evalScope: (envId 0) @1 line 1 2 RubyParserM class >> rpParseString:path:loadName:yTrace:warnings: (envId 0) @3 line 3 3 RubyParserM class >> rpParseFile:loadName:yTrace:warnings: (envId 0) @8 line 6 4 RubyCompiler >> parseFileNamed:loadName: (envId 0) @13 line 9 5 [] in RubyCompiler >> compileFileNamed:loadName:env: (envId 0) @6 line 8 6 ExecBlock >> onException:do: (envId 0) @2 line 66 7 RubyCompiler >> compileFileNamed:loadName:env: (envId 0) @2 line 35 8 [] in RubyFile >> loadIntoEnv: (envId 0) @8 line 20 9 ExecBlock >> ensure: (envId 0) @2 line 12 10 RubyFile >> loadIntoEnv: (envId 0) @19 line 21 11 RubyContext >> loadFileNamed:env: (envId 0) @13 line 8 12 RubyContext >> runFileNamed:env: (envId 0) @6 line 5 13 Executed Code @12 line 13
recommended .topazini contents (in current directory when starting topaz)
set user DataCurator pass swordfish set gemstone maglev display oops omit classoops set stackpad 50 set tab 8 omit bytes limit bytes 5000 limit oops 20 level 0
note obj @
command to examine contents of a temp shown from "frame" .
Beyond examining the scripts that invoke topaz, and debugging at the smalltalk level, the next step would be to run topaz under gdb, or attach with gdb, and investigate the state of the source string in C code. You could start with a breakpoint on MagParse903 in rubygrammar.c . The libgcilnk.so has one module, omdebug.o , compiled with debug symbols, and includes the following functions that can be called from gdb to print objects in the VM's temporary object memory.
extern "C" int pphandlef(omObjSType *h); extern "C" int ppstringobjf(omObjSType o); extern "C" int ppobjf(omObjSType *o) extern "C" int ppoidf(uint64 addr); // arg is an OopType // alter these value with gdb "set" command to print more // of large objects . static int printLimitBytes = 300; static int printLimitOops = 12;
I'm trying to debug production changes and I'm seeing a lot of extra stuff going on.
maglev-ruby -e nil
winds up scanning all of this:is it possible to simply run raw maglev-ruby?