Skip to content
This repository has been archived by the owner on Mar 26, 2023. It is now read-only.

how to run maglev-ruby w/ NO extras #388

Open
zenspider opened this issue Apr 9, 2015 · 5 comments
Open

how to run maglev-ruby w/ NO extras #388

zenspider opened this issue Apr 9, 2015 · 5 comments
Assignees

Comments

@zenspider
Copy link
Contributor

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:

     26:yydebug: state 2, reading 261 (kBEGIN)
     31:yydebug: state 212, reading 287 (kNIL)
     35:yydebug: state 94, reading 10 ('\n')
     55:yydebug: state 302, reading 263 (kENSURE)
     72:yydebug: state 806, reading 309 (tCONSTANT)
     74:yydebug: state 37, reading 46 ('.')
     86:yydebug: state 342, reading 305 (tIDENTIFIER)
     88:yydebug: state 517, reading 40 ('(')
     92:yydebug: state 248, reading 307 (tGVAR)
     96:yydebug: state 241, reading 44 (',')
    112:yydebug: state 624, reading 307 (tGVAR)
    116:yydebug: state 241, reading 41 (')')
    154:yydebug: state 79, reading 10 ('\n')
    171:yydebug: state 302, reading 264 (kEND)
    187:yydebug: state 76, reading 10 ('\n')
    202:yydebug: state 302, reading 0 (end-of-file)

is it possible to simply run raw maglev-ruby?

@timfel
Copy link
Member

timfel commented Apr 9, 2015

Maglev automatically generates an ensure block around your code. I'm not sure where, unfortunately, it might be in the Smalltalk code.

@zenspider
Copy link
Contributor Author

@AllenOtis any clues?

@AllenOtis
Copy link
Contributor

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

14 GsNMethod class >> _gsReturnToC (envId 0) @1 line 1

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" .

1 similar comment
@AllenOtis
Copy link
Contributor

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

14 GsNMethod class >> _gsReturnToC (envId 0) @1 line 1

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" .

@AllenOtis
Copy link
Contributor

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;

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants