7 个版本 (破坏性更新)
0.117.0 | 2024年7月30日 |
---|---|
0.116.1 | 2024年5月11日 |
0.115.0-rc2 | 2024年3月21日 |
0.114.0 | 2024年3月1日 |
0.111.0 | 2023年11月17日 |
#23 在 #gdb
每月下载量:196
用于 ckb-debugger
57KB
1.5K SLoC
CKB VM Debug Utils
辅助 CKB VM 调试的实用工具,包括以下组件
- gdb 远程调试支持
- 标准 IO 组件,您可以像使用 printf 一样进行调试
如何使用
虽然这个库包含可以插入到您的 CKB VM 运行时的组件,但我们还准备了一个裸机二进制文件,展示了如何使用这些组件。请注意,目前这个二进制文件只运行简单的 RISC-V 程序,它不支持 CKB 中使用的系统调用。以后我们可能会将其与 ckb-standalone-debugger 结合,为 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
现在 CKB VM 的调试服务器已启动,在另一个终端中,我们可以启动 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)
正如我们所见,gdb 在这里工作。
依赖项
~5–6.5MB
~123K SLoC