没有合适的资源?快使用搜索试试~ 我知道了~
首页Linux GDB调试文档
Linux GDB调试文档
需积分: 50 16 下载量 10 浏览量
更新于2023-03-16
评论
收藏 2.48MB PDF 举报
使用GDB调试,英文版。对于从事 Linux C/C++ 后台开发的读者来说,GDB 调试是需要熟练掌握的一项技能
资源详情
资源评论
资源推荐
Debugging with gdb
The gnu Source-Level Debugger
Tenth Edition, for gdb version 8.0.1.19.a76e2bffa6+1714abab88
(GDB)
Intel documentation version number 1.18.0
Documentation extensions by Intel Corporation
Richard Stallman, Roland Pesch, Stan Shebs, et al.
(Send bugs and comments on gdb to Intel’s Debug Solutions User Forum (http://
software.intel.com/forums/debug-solutions).)
See Chapter 32 [GDB Bugs], page 579, for details on how to report bugs.
Debugging with gdb
T
E
Xinfo 2017-06-04.19
Published by the Free Software Foundation
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
ISBN 978-0-9831592-3-0
Copyright
c
1988-2017 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under the terms
of the GNU Free Documentation License, Version 1.3 or any later version published by
the Free Software Foundation; with the Invariant Sections being “Free Software” and “Free
Software Needs Free Documentation”, with the Front-Cover Texts being “A GNU Manual,”
and with the Back-Cover Texts as in (a) below.
(a) The FSF’s Back-Cover Text is: “You are free to copy and modify this GNU Man-
ual. Buying copies from GNU Press supports the FSF in developing GNU and promoting
software freedom.”
Copyright
c
2016-2018, Intel Corporation. Intel’s modifications are provided pursuant to
the GNU Free Documentation license. For more information, see Appendix M [GNU Free
Documentation License], page 749.
List of extended features for gdb version 8.0.1.19.a76e2bffa6+1714abab88:
• Debugging OpenMP*:
Section 12.5 [OpenMP* Debugging], page 169.
• Debugging Data Race Conditions:
Section 12.1 [Data Race Detection], page 163.
• Decoding Abort Reasons of a Speculative Execution:
Section 12.2 [Decoding Abort Reasons], page 167,
• Detecting Boundary Violations in code:
Section 12.3 [Pointer Checker], page 168,
• Serializing the execution of parallel applications with Intel
R
Cilk(TM) Plus:
Section 12.4 [Serializing Parallel Execution], page 168.
‘gdb-ia’ For debugging IA-32/Intel
R
64 Applications, the command to invoke gdb is
gdb-ia.
i
Table of Contents
Summary of gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Free Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Free Software Needs Free Documentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Contributors to gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1 A Sample gdb Session. . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2 Getting In and Out of gdb . . . . . . . . . . . . . . . . . . . . 11
2.1 Invoking gdb. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1.1 Choosing Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.1.2 Choosing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.1.3 What gdb Does During Startup . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.2 Quitting gdb. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3 Shell Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.4 Logging Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3 gdb Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.1 Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.2 Command Completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.3 Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4 Running Programs Under gdb . . . . . . . . . . . . . . . . 25
4.1 Compiling for Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2 Starting your Program. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.3 Your Program’s Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.4 Your Program’s Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.5 Your Program’s Working Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.6 Your Program’s Input and Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.7 Debugging an Already-running Process . . . . . . . . . . . . . . . . . . . . . . . . 32
4.8 Killing the Child Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.9 Debugging Multiple Inferiors and Programs . . . . . . . . . . . . . . . . . . . . 33
4.10 Debugging Programs with Multiple Threads . . . . . . . . . . . . . . . . . . 36
4.11 Debugging Forks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.12 Setting a Bookmark to Return to Later . . . . . . . . . . . . . . . . . . . . . . . 43
4.12.1 A Non-obvious Benefit of Using Checkpoints . . . . . . . . . . . . . 44
5 Stopping and Continuing . . . . . . . . . . . . . . . . . . . . . . 45
5.1 Breakpoints, Watchpoints, and Catchpoints . . . . . . . . . . . . . . . . . . . . 45
5.1.1 Setting Breakpoints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.1.2 Setting Watchpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.1.3 Setting Catchpoints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
ii Debugging with gdb
5.1.4 Deleting Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.1.5 Disabling Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.1.6 Break Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.1.7 Breakpoint Command Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
5.1.8 Dynamic Printf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
5.1.9 How to save breakpoints to a file . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.1.10 Static Probe Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.1.11 “Cannot insert breakpoints” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.1.12 “Breakpoint address adjusted...” . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.2 Continuing and Stepping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
5.3 Skipping Over Functions and Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
5.4 Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
5.5 Stopping and Starting Multi-thread Programs. . . . . . . . . . . . . . . . . . 77
5.5.1 All-Stop Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
5.5.2 Non-Stop Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
5.5.3 Background Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
5.5.4 Thread-Specific Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
5.5.5 Interrupted System Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
5.5.6 Observer Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
6 Running programs backward . . . . . . . . . . . . . . . . . . 85
7 Recording Inferior’s Execution
and Replaying It . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
8 Examining the Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
8.1 Stack Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
8.2 Backtraces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
8.3 Selecting a Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
8.4 Information About a Frame. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
8.5 Management of Frame Filters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
9 Examining Source Files . . . . . . . . . . . . . . . . . . . . . . 103
9.1 Printing Source Lines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
9.2 Specifying a Location. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
9.2.1 Linespec Locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
9.2.2 Explicit Locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
9.2.3 Address Locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
9.3 Editing Source Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
9.3.1 Choosing your Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
9.4 Searching Source Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
9.5 Specifying Source Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
9.6 Source and Machine Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
剩余810页未读,继续阅读
phywxl
- 粉丝: 0
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
- MW全能培训汽轮机调节保安系统PPT教学课件.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0