forked from oracle/graal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GR-22025] Insight script in Python.
PullRequest: graal/6514
- Loading branch information
Showing
4 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
print(f"Python: Insight version {insight.version} is launching") | ||
insight.on("source", lambda env : print(f"Python: observed loading of {env.name}")) | ||
print("Python: Hooks are ready!") | ||
|
||
def onEnter(ctx, frame): | ||
print(f"minusOne {frame.n}") | ||
|
||
class Roots: | ||
roots = True | ||
|
||
def sourceFilter(self, src): | ||
return src.name == "agent-fib.js" | ||
|
||
def rootNameFilter(self, n): | ||
return n == "minusOne" | ||
|
||
insight.on("enter", onEnter, Roots()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
> cat > ${TMP_DIR}/test.py | ||
< print('Ahoj') | ||
> graalpython --insight=agent-python.py --experimental-options ${TMP_DIR}/test.py | ||
Python: Insight version 0.6 is launching | ||
Python: Hooks are ready! | ||
Python: observed loading of site.py | ||
Python: observed loading of _sitebuiltins.py | ||
Please note: This Python implementation is in the very early stages, and can run little more than basic benchmarks at this point. | ||
Python: observed loading of test.py | ||
Ahoj | ||
> js --polyglot --insight=agent-python.py --experimental-options agent-fib.js | ||
Python: Insight version 0.6 is launching | ||
Python: Hooks are ready! | ||
Python: observed loading of agent-fib.js | ||
minusOne 4 | ||
minusOne 3 | ||
minusOne 2 | ||
minusOne 2 | ||
Three is the result 3 |