Crates.io | ckb-vm-debug-utils |
lib.rs | ckb-vm-debug-utils |
version | 0.119.0 |
source | src |
created_at | 2023-11-17 00:56:50.278548 |
updated_at | 2024-10-25 08:55:04.332333 |
description | Utils for ckb-debugger |
homepage | |
repository | |
max_upload_size | |
id | 1038526 |
size | 63,717 |
Utilities aiding CKB VM debug, including the following components:
While this library contains components to plugin to your CKB VM runtime, we also prepare a bare metal binary showcasing how to use the components. Notice for now this binary only runs simple RISC-V programs, it doesn't support syscalls used in CKB. Later we might combine this with ckb-standalone-debugger to create a unified debugging experience for CKB.
$ cat program.c
int power(int, int);
int main() {
int i, result;
for (i = 0; i < 10; i++) {
result += power(2, i);
}
return result;
}
int power(int base, int n) {
int i, p;
p = 1;
for (i = 1; i <= n; i++) p = p * base;
return p;
}
$ git clone https://github.com/nervosnetwork/ckb-vm-debug-utils
$ cd ckb-vm-debug-utils
$ cargo build
$ riscv64-unknown-elf-gcc -g ../program.c -o program
$ ./target/debug/baremetal 0.0.0.0:2000 program
Now CKB VM's debug server has been started, in a different terminal, we can launch gdb:
$ cd ckb-vm-debug-utils
$ gdb program
(gdb) target remote localhost:2000
Remote debugging using localhost:2000
0x00000000000100c8 in _start ()
(gdb) b main
Breakpoint 1 at 0x101ba: file program.c, line 6.
(gdb) c
Continuing.
Breakpoint 1, main () at program.c:6
6 for (i = 0; i < 10; i++) {
(gdb) s
7 result += power(2, i);
(gdb) print i
$1 = 0
(gdb)
As we can see, gdb works here.