#debugging #standalone #ckb #line #step #syscalls #script

bin+lib ckb-debugger

Standalone debugger for Nervos CKB

11 releases (breaking)

new 0.119.0 Oct 25, 2024
0.118.0-rc1 Aug 28, 2024
0.117.0 Jul 30, 2024
0.115.0-rc2 Mar 21, 2024
0.112.1 Nov 22, 2023

#34 in #ckb

37 downloads per month

MIT license

1.5MB
2.5K SLoC

Contains (ELF exe/lib, 150KB) examples/file_operations, (ELF exe/lib, 145KB) examples/print_log, (ELF exe/lib, 145KB) examples/read_file, (ELF exe/lib, 145KB) examples/timenow, (ELF exe/lib, 99KB) examples/exec_callee, (ELF exe/lib, 99KB) examples/exec_caller and 5 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.116.1

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

FLAGS:
        --enable-overlapping-detection    Set to true to enable overlapping detection between stack and heap
        --enable-steplog                  Set to true to enable step mode, where we print PC address for each
                                          instruction
    -h, --help                            Prints help information
        --prompt                          Set to true to prompt for stdin input before executing
    -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]
        --dump-file <dump-file>                    Dump file name
        --gdb-listen <gdb-listen>
            Address to listen for GDB remote debugging server [default: 127.0.0.1:9999]

        --max-cycles <max-cycles>                  Max cycles [default: 70000000]
        --mode <mode>
            Execution mode of debugger [default: full]  [possible values: decode-instruction, fast, full, gdb, probe]

        --pid <pid>                                Process ID [default: 0]
        --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]
    -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

~27–57MB
~1M SLoC