Update on-chain debugging docs following up changes in ledger-tool UI (#31593)
This commit is contained in:
parent
30d051da84
commit
c5905f525c
|
@ -113,17 +113,17 @@ To turn on SBF interpreter trace messages in a local cluster configure the
|
||||||
## Source level debugging
|
## Source level debugging
|
||||||
|
|
||||||
Source level debugging of on-chain programs written in Rust or C can
|
Source level debugging of on-chain programs written in Rust or C can
|
||||||
be done using the `run` subcommand of `solana-ledger-tool`, and lldb,
|
be done using the `program run` subcommand of `solana-ledger-tool`,
|
||||||
distrubuted with Solana Rust and Clang compiler binary package
|
and lldb, distrubuted with Solana Rust and Clang compiler binary
|
||||||
platform-tools.
|
package platform-tools.
|
||||||
|
|
||||||
The `solana-ledger-tool run` subcommand loads a compiled on-chain
|
The `solana-ledger-tool program run` subcommand loads a compiled
|
||||||
program, executes it in RBPF virtual machine and runs a gdb server
|
on-chain program, executes it in RBPF virtual machine and runs a gdb
|
||||||
that accepts incoming connections from LLDB or GDB. Once lldb is
|
server that accepts incoming connections from LLDB or GDB. Once lldb
|
||||||
connected to `solana-ledger-tool` gdbserver, it can control execution of
|
is connected to `solana-ledger-tool` gdbserver, it can control
|
||||||
an on-chain program. Run `solana-ledger-tool run --help`
|
execution of an on-chain program. Run `solana-ledger-tool program run
|
||||||
for an example of specifying input data for parameters of the program
|
--help` for an example of specifying input data for parameters of the
|
||||||
entrypoint function.
|
program entrypoint function.
|
||||||
|
|
||||||
To compile a program for debugging use cargo-build-sbf build utility
|
To compile a program for debugging use cargo-build-sbf build utility
|
||||||
with the command line option `--debug`. The utility will generate two
|
with the command line option `--debug`. The utility will generate two
|
||||||
|
@ -131,8 +131,8 @@ loadable files, one a usual loadable module with the extension `.so`,
|
||||||
and another the same loadable module but containing Dwarf debug
|
and another the same loadable module but containing Dwarf debug
|
||||||
information, a file with extension `.debug`.
|
information, a file with extension `.debug`.
|
||||||
|
|
||||||
To execute a program in debugger, run `solana-ledger-tool run` with
|
To execute a program in debugger, run `solana-ledger-tool program run`
|
||||||
`-u debugger` command line option. For example, a crate named
|
with `-e debugger` command line option. For example, a crate named
|
||||||
'helloworld' is compiled and an executable program is built in
|
'helloworld' is compiled and an executable program is built in
|
||||||
`target/deploy` directory. There should be three files in that
|
`target/deploy` directory. There should be three files in that
|
||||||
directory
|
directory
|
||||||
|
@ -141,7 +141,7 @@ directory
|
||||||
- helloworld.so -- an executable file loadable into the virtual machine.
|
- helloworld.so -- an executable file loadable into the virtual machine.
|
||||||
The command line for running `solana-ledger-tool` would be something like this
|
The command line for running `solana-ledger-tool` would be something like this
|
||||||
```
|
```
|
||||||
solana-ledger-tool run -l test-ledger -u debugger target/deploy/helloworld.so
|
solana-ledger-tool program run -l test-ledger -e debugger target/deploy/helloworld.so
|
||||||
```
|
```
|
||||||
Note that `solana-ledger-tool` always loads a ledger database. Most
|
Note that `solana-ledger-tool` always loads a ledger database. Most
|
||||||
on-chain programs interact with a ledger in some manner. Even if for
|
on-chain programs interact with a ledger in some manner. Even if for
|
||||||
|
@ -150,7 +150,7 @@ debugging purpose a ledger is not needed, it has to be provided to
|
||||||
running `solana-test-validator`, which creates a ledger in
|
running `solana-test-validator`, which creates a ledger in
|
||||||
`test-ledger` subdirectory.
|
`test-ledger` subdirectory.
|
||||||
|
|
||||||
In debugger mode `solana-ledger-tool run` loads an `.so` file and
|
In debugger mode `solana-ledger-tool program run` loads an `.so` file and
|
||||||
starts listening for an incoming connection from a debugger
|
starts listening for an incoming connection from a debugger
|
||||||
```
|
```
|
||||||
Waiting for a Debugger connection on "127.0.0.1:9001"...
|
Waiting for a Debugger connection on "127.0.0.1:9001"...
|
||||||
|
@ -159,7 +159,7 @@ Waiting for a Debugger connection on "127.0.0.1:9001"...
|
||||||
To connect to `solana-ledger-tool` and execute the program, run lldb. For
|
To connect to `solana-ledger-tool` and execute the program, run lldb. For
|
||||||
debugging rust programs it may be beneficial to run solana-lldb
|
debugging rust programs it may be beneficial to run solana-lldb
|
||||||
wrapper to lldb, i.e. at a new shell prompt (other than the one used
|
wrapper to lldb, i.e. at a new shell prompt (other than the one used
|
||||||
to run `solana-ledger-tool`) run the command
|
to start `solana-ledger-tool`) run the command
|
||||||
|
|
||||||
```
|
```
|
||||||
solana-lldb
|
solana-lldb
|
||||||
|
@ -230,13 +230,13 @@ First file is `tasks.json` with the following content
|
||||||
{
|
{
|
||||||
"label": "solana-debugger",
|
"label": "solana-debugger",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "solana-ledger-tool run -l test-ledger -u debugger ${workspaceFolder}/target/deploy/helloworld.so"
|
"command": "solana-ledger-tool program run -l test-ledger -e debugger ${workspaceFolder}/target/deploy/helloworld.so"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
The first task is to build the on-chain program using cargo-build-sbf
|
The first task is to build the on-chain program using cargo-build-sbf
|
||||||
utility. The second task is to run `solana-ledger-tool run` in debugger mode.
|
utility. The second task is to run `solana-ledger-tool program run` in debugger mode.
|
||||||
|
|
||||||
Another file is `launch.json` with the following content
|
Another file is `launch.json` with the following content
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue