Skip to content

Commit

Permalink
Merge pull request #28 from tin-z/trace_tips_2
Browse files Browse the repository at this point in the history
adding trace instructions example
  • Loading branch information
xingmingjie authored Oct 30, 2023
2 parents e2c32e9 + f1d5bfa commit b134d12
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/trace-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 从起始地址($start_pc)跟踪指令至结束地址($end_pc),并将输出保存在 'gdb.txt' 文件中

```
# set tracing points
set $start_pc=<trace-from-address>
set $end_pc=<trace-to-address>
# disable pagination
set pagination off
# log output to gdb.txt file instead of standard output
set logging on
set logging redirect on
# Warning: 'set logging on', an alias for the command 'set logging enabled', is deprecated. Use 'set logging enabled on'.
# run until $start_pc address hit
tbreak *$start_pc
run
# for each breakpoint hit print the instruction
display/i $pc
while $while_true
si
if $pc == $end_pc
printf "Breakpoint reached\n"
set $while_true=0
end
end
```


## 贡献者

tin-z

0 comments on commit b134d12

Please sign in to comment.