|
|
||
|---|---|---|
| .. | ||
| XSPdb | ||
| XSPython | ||
| example | ||
| ready-to-run | ||
| LICENSE | ||
| Makefile | ||
| README.cn.md | ||
| README.en.md | ||
| pdb_code.tar.gz | ||
| pyproject.toml | ||
| requirements.txt | ||
| xs.fst | ||
README.en.md
Introduction to XSPdb
XSPdb is a specialized Python pdb-based debugging tool for RISC-V IP cores, customized for Xiangshan's difftest interface. It provides GDB-like interactive debugging capabilities, integrating: Terminal command-line interface, RTL-level waveform toggling, Automated script replay, System snapshot save/restore, Register initialization configuration, Instruction set disassembly, etc. Advanced debugging features: conditional breakpoints, real-time watchpoints, register/memory visualization, Hardware signal-level debugging interface synchronized with software execution states. It is a Hardware/software co-verification solution for RISC-V IPs.
Screenshot of the XSPdb
Installation & Dependencies
Clone repository and install dependencies:
git clone https://github.com/OpenXiangShan/XSPdb.git # Clone repository
pip install -r XSPdb/requirements.txt # Install dependencies
pip install . # Optional installation
If source integration is not required, use alternative pip installation:
pip3 install XSPdb@git+https://github.com/OpenXiangShan/XSPdb@master
Quick Start
After cloning, run test suite:
cd XSPdb
make test
This command executes:
- Downloads Xiangshan Python binaries
- Fetches test binaries
- Launches interactive debug via example/test.py
Example output and interaction:
LD_PRELOAD=XSPython/xspcomm/libxspcomm.so.0.0.1 PYTHONPATH=. python3 example/test.py
Using simulated 32768B flash
[Info] reset complete
> XSPdb/example/test.py(13)test_sim_top()
-> while True:
(XiangShan) # Enter interactive mode (use Tab for command list)
(XiangShan)xui # Enter TUI mode
(XiangShan)xload ready-to-run/microbench.bin # Load binary (Tab-compatible)
(XiangShan)xistep # Step to next instruction commit
(XiangShan)xstep 10000 # Execute 10000 cycles
Note: XSPdb prioritizes spike-dasm for disassembly, falling back to capstone(limited instruction support).
Manual Testing
Prerequisite: Build Xiangshan Python simulator (build guide).
Alternative: Download prebuilt binaries:
cd XSPdb
wget https://github.com/OpenXiangShan/XSPdb/releases/download/v0.1.0-test/XSPython.tar.gz
wget https://github.com/OpenXiangShan/XSPdb/releases/download/v0.1.0-test/ready-to-run.tar.gz
tar xf XSPython.tar.gz
tar xf ready-to-run.tar.gz
Launch test:
LD_PRELOAD=XSPython/xspcomm/libxspcomm.so.0.0.1 PYTHONPATH=. python3 example/test.py
Node: The reason for using LD_PRELOAD to load xspcomm in advance is to prevent version conflicts between the system xspcomm library and the local xspcomm packaged in XSPython.
Common Commands:
xloadLoad a binary file into memoryxflashLoad a binary file into Flashxreset_flashReset Flashxexport_binExport Flash + memory data to a filexexport_flashExport Flash data to a filexexport_ramExport memory data to a filexload_scriptLoad an XSPdb scriptxmem_writeWrite memory dataxbytes_to_binConvert bytes data to a binary filexnop_insertInsert NOP instructions in a specified address rangexclear_dasm_cacheClear disassembly cachexprintPrint the value and width of an internal signalxsetSet the value of an internal signalxstepStep through the circuitxistepStep through instructionsxwatch_commit_pcWatch commit PCxunwatch_commit_pcUnwatch commit PCxwatchAdd a watch variablexunwatchRemove a watch variablexpcPrint the current Commit PCsxexpdiffstateSet a variable to difftest_statxexportselfSet a variable to XSPdb selfxresetReset DUTxlist_xclock_cbList all xclock callbacksxuiEnter the Text UI interfacexdasmDisassemble memory dataxdasmflashDisassemble Flash dataxdasmbytesDisassemble binary dataxdasmnumberDisassemble a numberxbytes2numberConvert bytes to an integerxnumber2bytesConvert an integer to bytesxparse_instr_fileParse uint64 stringsxload_instr_fileLoad uint64 strings into memoryxparse_reg_fileParse a register filexload_reg_fileLoad a register filexset_iregsSet Flash internal registers (Integer)xset_mpcSet the jump address (by mpc) after Flash initialization, default is 0x80000000xget_mpcGet the jump address after Flash initialization, default is 0x80000000xset_fregsSet Flash floating-point registers (general)xset_iregSet a single Flash internal register (Integer)xset_fregSet a Flash floating-point registerxlist_flash_iregsList Flash internal registersxlist_flash_fregsList Flash floating-point registersxlist_freg_mapList floating-point register mappings
You can use xcmds to list all commands, their descriptions, and the modules they belong to (use xapis to list all APIs, their descriptions, and their modules).