|
1 | 1 | # Tooling Support for Python
|
2 | 2 |
|
3 |
| -The GraalVM's Python implementation is incomplete and cannot launch the standard Python |
4 |
| -debugger `pdb`. However, it can run the tools that GraalVM provides. |
5 |
| -The `graalpython --help:tools` command will give you more information |
6 |
| -about tools currently supported on Python. |
7 |
| - |
8 |
| -### Debugger |
9 |
| -To enable debugging, pass the `--inspect` option to the `graalpython` |
10 |
| -launcher. For example: |
| 3 | +GraalVM's Python implementation is incomplete and cannot launch the standard Python debugger `pdb`. |
| 4 | +However, it can run the tools that GraalVM provides. |
| 5 | +The `graalpython --help:tools` command will give you more information about tools currently supported on Python. |
| 6 | + |
| 7 | +## Debugger |
| 8 | + |
| 9 | +To enable debugging, pass the `--inspect` option to the `graalpython` launcher. |
| 10 | +For example: |
11 | 11 | ```shell
|
12 | 12 | graalpython --inspect -c "breakpoint(); import os; os.exit()"
|
13 | 13 | Debugger listening on port 9229.
|
14 | 14 | To start debugging, open the following URL in Chrome:
|
15 | 15 | chrome-devtools://devtools/bundled/js_app.html?ws=127.0.1.1:9229/76fcb6dd-35267eb09c3
|
16 | 16 | ```
|
17 |
| -As you see, the standard Python built-in `breakpoint()` will work with our |
18 |
| -debugger. You can inspect variables, set watch expressions, interactively |
19 |
| -evaluate code snippets etc. However, this only works if you pass `--inspect` or |
20 |
| -some other inspect option. Otherwise, `pdb` is triggered as on CPython (and |
21 |
| -does not currently work). |
22 |
| - |
23 |
| -### Coverage |
24 |
| -GraalVM comes with a coverage instrument that can be used with `--coverage`. The |
25 |
| -the `graalpython --help:tools` command line help for more details on how to use |
26 |
| -it. In order to work better with existing Python code, we also partially support |
27 |
| -the standard library `trace` module with this low-overhead GraalVM coverage |
28 |
| -instrument. So you can do this: |
| 17 | + |
| 18 | +The standard Python built-in `breakpoint()` will work using the [GraalVM's Chrome Inspector](https://www.graalvm.org/tools/chrome-debugger/) implementation. |
| 19 | +You can inspect variables, set watch expressions, interactively evaluate code snippets, etc. |
| 20 | +However, this only works if you pass `--inspect` or some other inspect option. Otherwise, `pdb` is triggered as on CPython (and does not currently work). |
| 21 | + |
| 22 | +## Code Coverage |
| 23 | + |
| 24 | +GraalVM comes with a coverage instrument that can be used with `--coverage`. |
| 25 | +Use the `graalpython --help:tools` command to see details on how to use it. |
| 26 | + |
| 27 | +In order to work better with existing Python code, the standard library `trace` module is partially supported with this low-overhead GraalVM coverage instrument. |
| 28 | +So you can do this: |
29 | 29 | ```shell
|
30 | 30 | graalpython -m trace -m -c -s my_script.py
|
31 | 31 | ```
|
32 |
| -This will work similarly to how it will run on CPython. The programmatic API |
33 |
| -also works, with some limitations. For example, it does not currently track calls, |
34 |
| -only line counts and called functions. |
35 |
| - |
36 |
| -### Profiling |
37 |
| -The `_lsprof` built-in module has been implemented using the GraalVM `cpusampler` |
38 |
| -tool. Not all profiling features are currently supported, but basic profiling |
39 |
| -works: |
| 32 | + |
| 33 | +This will work similarly to how it would run on CPython. |
| 34 | + |
| 35 | +The programmatic API also works, with some limitations. |
| 36 | +For example, it does not currently track calls, only line counts and called functions. |
| 37 | + |
| 38 | +## Profiling |
| 39 | + |
| 40 | +The `_lsprof` built-in module has been implemented using the GraalVM `cpusampler` tool. |
| 41 | +Not all profiling features are currently supported, but basic profiling works: |
40 | 42 | ```shell
|
41 | 43 | graalpython -m cProfile -s sort -m ginstall --help
|
42 | 44 | ```
|
| 45 | + |
43 | 46 | The interactive exploration of a stats output file also works:
|
44 | 47 | ```shell
|
45 | 48 | graalpython -m cProfile -o ginstall.profile -m ginstall --help
|
|
0 commit comments