仿真平台内核初版 -tlib库 包含<sparc arm riscv powerPC>
This commit is contained in:
72
scripts/complex/reverse_execution/README.md
Normal file
72
scripts/complex/reverse_execution/README.md
Normal file
@@ -0,0 +1,72 @@
|
||||
# Reverse Execution Demo
|
||||
|
||||
This is a demo showcasing Renode's support for GDB reverse execution.
|
||||
|
||||
## Running the demo
|
||||
|
||||
1. `gdb_reverse_execution.resc` Renode script creates a RISC-V machine with small assembly printing to UART.
|
||||
|
||||
```bash
|
||||
renode scripts/complex/reverse_execution/gdb_reverse_execution.resc
|
||||
```
|
||||
|
||||
2. Use `script.gdb` GDB script to easily connect to Renode with preset breakpoints.
|
||||
|
||||
```bash
|
||||
gdb -x script.gdb
|
||||
```
|
||||
|
||||
3. Follow the flow of the demonstration
|
||||
|
||||
```
|
||||
Breakpoint 1, 0x80000000 in ?? ()
|
||||
(gdb) continue
|
||||
Continuing.
|
||||
|
||||
Breakpoint 2, 0x80000014 in ?? ()
|
||||
(gdb) continue
|
||||
Continuing.
|
||||
|
||||
Breakpoint 3, 0x8000003a in ?? ()
|
||||
```
|
||||
|
||||
Now you can see `:(` printed on UART.
|
||||
|
||||
4. Execute `reverse-*` commands in GDB:
|
||||
|
||||
```
|
||||
(gdb) reverse-continue
|
||||
Continuing.
|
||||
|
||||
Breakpoint 2, 0x80000014 in ?? ()
|
||||
(gdb) reverse-stepi
|
||||
0x80000010 in ?? ()
|
||||
(gdb) rsi
|
||||
0x8000000e in ?? ()
|
||||
(gdb) rc
|
||||
Continuing.
|
||||
|
||||
Breakpoint 1, 0x80000000 in ?? ()
|
||||
(gdb)
|
||||
```
|
||||
|
||||
5. Set `t4` register to `0x1337` to branch in `beq t3, t4, ok` test.
|
||||
|
||||
```
|
||||
(gdb) set $t4=0x1337
|
||||
(gdb) continue
|
||||
Continuing.
|
||||
|
||||
Breakpoint 2, 0x80000014 in ?? ()
|
||||
(gdb) continue
|
||||
Continuing.
|
||||
|
||||
Breakpoint 3, 0x8000003a in ?? ()
|
||||
(gdb)
|
||||
```
|
||||
|
||||
Spot `OK` on UART console!
|
||||
|
||||
---
|
||||
|
||||
For more information visit [Renode documentation](https://renode.readthedocs.io/en/latest/debugging/gdb.html#reverse-execution)
|
||||
59
scripts/complex/reverse_execution/gdb_reverse_execution.resc
Normal file
59
scripts/complex/reverse_execution/gdb_reverse_execution.resc
Normal file
@@ -0,0 +1,59 @@
|
||||
mach create
|
||||
machine LoadPlatformDescription @platforms/cpus/sifive-fe310.repl
|
||||
|
||||
cpu AssembleBlock 0x80000000 """
|
||||
.equ UART0_BASE, 0x10013000
|
||||
.equ UART_TXDATA, 0x00
|
||||
.equ UART_TXCTRL, 0x08
|
||||
|
||||
li sp, 0x80004000
|
||||
// UART Setup
|
||||
li t0, UART0_BASE
|
||||
li t1, 1
|
||||
sw t1, UART_TXCTRL(t0)
|
||||
|
||||
// Our test
|
||||
li t3, 0x1337
|
||||
beq t3, t4, ok
|
||||
|
||||
wrong:
|
||||
la a0, wrong_str
|
||||
call uart_puts
|
||||
j hang
|
||||
|
||||
ok:
|
||||
la a0, ok_str
|
||||
call uart_puts
|
||||
|
||||
hang:
|
||||
j hang
|
||||
|
||||
uart_putc:
|
||||
li t2, UART0_BASE
|
||||
sw a0, UART_TXDATA(t2)
|
||||
ret
|
||||
|
||||
uart_puts:
|
||||
addi sp, sp, -16
|
||||
sw ra, 12(sp)
|
||||
mv t0, a0
|
||||
1: lbu a0, 0(t0)
|
||||
beqz a0, 2f
|
||||
addi t0, t0, 1
|
||||
call uart_putc
|
||||
j 1b
|
||||
2: lw ra, 12(sp)
|
||||
addi sp, sp, 16
|
||||
ret
|
||||
|
||||
wrong_str:
|
||||
.string ":("
|
||||
ok_str:
|
||||
.string "OK"
|
||||
"""
|
||||
|
||||
cpu PC 0x80000000
|
||||
|
||||
showAnalyzer uart0
|
||||
machine StartGdbServer 3333
|
||||
reverseExecMode true
|
||||
11
scripts/complex/reverse_execution/script.gdb
Normal file
11
scripts/complex/reverse_execution/script.gdb
Normal file
@@ -0,0 +1,11 @@
|
||||
layout asm
|
||||
target remote :3333
|
||||
|
||||
# Break on the beginning of the program
|
||||
break *0x80000000
|
||||
|
||||
# Break on the `beq t3, t4, ok` test
|
||||
break *0x80000014
|
||||
|
||||
# Break on infinite loop
|
||||
break *0x8000003a
|
||||
Reference in New Issue
Block a user