# 得到命令的幫助信息
## 技巧
使用`help`命令可以得到gdb的命令幫助信息:
(1)`help`命令不加任何參數會得到命令的分類:
(gdb) help
List of classes of commands:
aliases -- Aliases of other commands
breakpoints -- Making program stop at certain points
data -- Examining data
files -- Specifying and examining files
internals -- Maintenance commands
obscure -- Obscure features
running -- Running the program
stack -- Examining the stack
status -- Status inquiries
support -- Support facilities
tracepoints -- Tracing of program execution without stopping the program
user-defined -- User-defined commands
Type "help" followed by a class name for a list of commands in that class.
Type "help all" for the list of all commands.
Type "help" followed by command name for full documentation.
Type "apropos word" to search for commands related to "word".
Command name abbreviations are allowed if unambiguous.
(2)當輸入`help class`命令時,可以得到這個類別下所有命令的列表和命令功能:
(gdb) help data
Examining data.
List of commands:
append -- Append target code/data to a local file
append binary -- Append target code/data to a raw binary file
append binary memory -- Append contents of memory to a raw binary file
append binary value -- Append the value of an expression to a raw binary file
append memory -- Append contents of memory to a raw binary file
append value -- Append the value of an expression to a raw binary file
call -- Call a function in the program
disassemble -- Disassemble a specified section of memory
display -- Print value of expression EXP each time the program stops
dump -- Dump target code/data to a local file
dump binary -- Write target code/data to a raw binary file
dump binary memory -- Write contents of memory to a raw binary file
dump binary value -- Write the value of an expression to a raw binary file
......
(3)也可以用`help command`命令得到某一個具體命令的用法:
(gdb) help mem
Define attributes for memory region or reset memory region handling totarget-based.
Usage: mem auto
mem <lo addr> <hi addr> [<mode> <width> <cache>],
where <mode> may be rw (read/write), ro (read-only) or wo (write-only),
<width> may be 8, 16, 32, or 64, and
<cache> may be cache or nocache
(4)用`apropos regexp`命令查找所有符合`regexp`正則表達式的命令信息:
(gdb) apropos set
awatch -- Set a watchpoint for an expression
b -- Set breakpoint at specified line or function
br -- Set breakpoint at specified line or function
bre -- Set breakpoint at specified line or function
brea -- Set breakpoint at specified line or function
......
詳情參見[gdb手冊](https://sourceware.org/gdb/onlinedocs/gdb/Help.html)
## 貢獻者
nanxiao
- 介紹
- 信息顯示
- 顯示gdb版本信息
- 顯示gdb版權相關信息
- 啟動時不顯示提示信息
- 退出時不顯示提示信息
- 輸出信息多時不會暫停輸出
- 函數
- 列出函數的名字
- 是否進入帶調試信息的函數
- 進入不帶調試信息的函數
- 退出正在調試的函數
- 直接執行函數
- 打印函數堆棧幀信息
- 打印尾調用堆棧幀信息
- 選擇函數堆棧幀
- 向上或向下切換函數堆棧幀
- 斷點
- 在匿名空間設置斷點
- 在程序地址上打斷點
- 在程序入口處打斷點
- 在文件行號上打斷點
- 保存已經設置的斷點
- 設置臨時斷點
- 設置條件斷點
- 忽略斷點
- 觀察點
- 設置觀察點
- 設置觀察點只針對特定線程生效
- 設置讀觀察點
- 設置讀寫觀察點
- Catchpoint
- 讓catchpoint只觸發一次
- 為fork調用設置catchpoint
- 為vfork調用設置catchpoint
- 為exec調用設置catchpoint
- 為系統調用設置catchpoint
- 通過為ptrace調用設置catchpoint破解anti-debugging的程序
- 打印
- 打印ASCII和寬字符字符串
- 打印STL容器中的內容
- 打印大數組中的內容
- 打印數組中任意連續元素值
- 打印數組的索引下標
- 打印函數局部變量的值
- 打印進程內存信息
- 打印靜態變量的值
- 打印變量的類型和所在文件
- 打印內存的值
- 打印源代碼行
- 每行打印一個結構體成員
- 按照派生類型打印對象
- 指定程序的輸入輸出設備
- 使用“$\”和“$\_”變量
- 打印程序動態分配內存的信息
- 打印調用棧幀中變量的值
- 多進程/線程
- 調試已經運行的進程
- 調試子進程
- 同時調試父進程和子進程
- 查看線程信息
- 在Solaris上使用maintenance命令查看線程信息
- 不顯示線程啟動和退出信息
- 只允許一個線程運行
- 使用“$_thread”變量
- 一個gdb會話中同時調試多個程序
- 打印程序進程空間信息
- 使用“$_exitcode”變量
- core dump文件
- 為調試進程產生core dump文件
- 加載可執行程序和core dump文件
- 匯編
- 設置匯編指令格式
- 在函數的第一條匯編指令打斷點
- 自動反匯編后面要執行的代碼
- 將源程序和匯編指令映射起來
- 顯示將要執行的匯編指令
- 打印寄存器的值
- 顯示程序原始機器碼
- 改變程序的執行
- 改變字符串的值
- 設置變量的值
- 修改PC寄存器的值
- 跳轉到指定位置執行
- 使用斷點命令改變程序的執行
- 修改被調試程序的二進制文件
- 信號
- 查看信號處理信息
- 信號發生時是否暫停程序
- 信號發生時是否打印信號信息
- 信號發生時是否把信號丟給程序處理
- 給程序發送信號
- 使用“$_siginfo”變量
- 共享庫
- 顯示共享鏈接庫信息
- 腳本
- 配置gdb init文件
- 按何種方式解析腳本文件
- 保存歷史命令
- 源文件
- 設置源文件查找路徑
- 替換查找源文件的目錄
- 圖形化界面
- 進入和退出圖形化調試界面
- 顯示匯編代碼窗口
- 顯示寄存器窗口
- 調整窗口大小
- 其它
- 命令行選項的格式
- 支持預處理器宏信息
- 使用命令的縮寫形式
- 在gdb中執行shell命令和make
- 在gdb中執行cd和pwd命令
- 設置命令提示符
- 設置被調試程序的參數
- 設置被調試程序的環境變量
- 得到命令的幫助信息
- 記錄執行gdb的過程