#debugging #standalone #ckb #instructions #syscalls #file #decode

app ckb-debugger

Standalone debugger for Nervos CKB

5 releases (breaking)

0.115.0-rc2 Mar 21, 2024
0.114.0 Mar 1, 2024
0.113.0 Jan 10, 2024
0.112.1 Nov 22, 2023
0.111.0 Nov 17, 2023

#2932 in Magic Beans

Download history 6/week @ 2024-01-08 10/week @ 2024-02-19 181/week @ 2024-02-26 10/week @ 2024-03-04 5/week @ 2024-03-11 80/week @ 2024-03-18 40/week @ 2024-04-01

120 downloads per month

MIT license

2.5MB
1K SLoC

Rust 1K SLoC // 0.0% comments C 135 SLoC // 0.0% comments

Contains (ELF exe/lib, 52KB) examples/print_log, (ELF exe/lib, 34KB) examples/fib, (ELF exe/lib, 26KB) examples/exec_callee, (ELF exe/lib, 26KB) examples/exec_caller, (ELF exe/lib, 27KB) examples/spawn_callee_strcat, (ELF exe/lib, 27KB) examples/spawn_caller_strcat and 2 more.

CKB debugger

A standalone debugger enabling off-chain contract development.

Usage

For Rust library usage, refer to the included tests, they are quite self-explanatory.

See the command line help part for usage on the binary debugger:

ckb-debugger 0.113.0

USAGE:
    ckb-debugger [FLAGS] [OPTIONS] --mode <mode> --tx-file <tx-file> [args]...

FLAGS:
    -h, --help       Prints help information
        --prompt     Set to true to prompt for stdin input before executing
        --step       Set to true to enable step mode, where we print PC address for each instruction
    -V, --version    Prints version information

OPTIONS:
        --bin <bin>                                File used to replace the binary denoted in the script
    -i, --cell-index <cell-index>                  Index of cell to run
    -t, --cell-type <cell-type>                    Type of cell to run [possible values: input, output]
        --decode <decode>                          Decode RISC-V instruction
        --dump-file <dump-file>                    Dump file name
        --gdb-listen <gdb-listen>                  Address to listen for GDB remote debugging server
        --gdb-specify-depth <gdb-specify-depth>    Specifies the depth of the exec/spawn stack [default: 0]
        --max-cycles <max-cycles>                  Max cycles [default: 70000000]
        --mode <mode>
            Execution mode of debugger [default: full]  [possible values: full, fast, gdb, probe, gdb_gdbstub]

        --pprof <pprof>                            Performance profiling, specify output file for further use
        --read-file <read-file>
            Read content from local file or stdin. Then feed the content to syscall in scripts

    -s, --script-group-type <script-group-type>    Script group type [possible values: lock, type]
        --script-hash <script-hash>                Script hash
        --script-version <script-version>          Script version [default: 2]
        --skip-end <skip-end>                      End address to skip printing debug info
        --skip-start <skip-start>                  Start address to skip printing debug info
    -f, --tx-file <tx-file>                        Filename containing JSON formatted transaction dump

ARGS:
    <args>...

ckb-transaction-dumper can be used to dump the full mocked transaction used in the debugger from CKB.

FAQ

How to Print Debug Message

  1. compile the contract via -fno-builtin-printf and replace with CKB_C_STDLIB_PRINTF
  2. set RUST_LOG=debug to enable output debug message

Dependencies

~25–60MB
~1M SLoC