Skip to content

Instantly share code, notes, and snippets.

@carloscn
Last active March 20, 2022 06:16
Show Gist options
  • Save carloscn/f628bb08453cdda3a33de58caa06ba1f to your computer and use it in GitHub Desktop.
Save carloscn/f628bb08453cdda3a33de58caa06ba1f to your computer and use it in GitHub Desktop.
GBD using note

Base operation

gdb-multiarch --tui benos.elf
gdb> file benos.elf
gdb> target remote localhost:1234
gdb> b ldr_test // 设定断点
gdb> c
gdb> n
gdb> next //下一步
gdb> info register // 查看所有寄存器
gdb> info x1 x2 x3 // 查看x1/x2/x3寄存器
gdb> x 0x80000 // 读取内存0x80000值 32位
gdb> x/xg 0x80000 // 读取内存0x80000值64位
gdb> layout src
gdb> layout regs
gdb> layout split

tui window operation

gdb> info win
gdb> fs src

Deal with signal

  • 改变gdb信号处理的设置 比如,以下设置会告诉gdb在接收到SIGINT时不要停止、打印出来、传递给调试目标程序
===================================== 
(gdb) handle SIGINT nostop print pass 
SIGINT is used by the debugger. 
Are you sure you want to change it? (y or n) y 

Signal Stop Print Pass to program Description 
SIGINT No Yes Yes Interrupt 
(gdb) 
===================================== 
  • 使用gdb命令直接向调试的应用程序发送信号 首先在你希望发送信号的语句处设置断点,然后运行程序,当停止到断点所在位置后,用gdb的signal命令发送信号给调试目标程序
==================================== 
(gdb) signal SIGINT 
Continuing with signal SIGINT. 

Breakpoint 1, handler (signal=2) at main.cpp:15 
15 printf( "Signal handler.../n "); 
====================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment