Skip to Content
C语言核心技术(原书第2版)
book

C语言核心技术(原书第2版)

by Peter Prinz, Tony Crawford
August 2017
Intermediate to advanced
798 pages
17h 44m
Chinese
China Machine Press
Content preview from C语言核心技术(原书第2版)
733
第21章
使用GDB调试C程序
软件开发的一个重要工作是测试程序和排除错误(
troubleshooting
)。特别是在一个大
型程序中,编程错误或故障(
bug
)是不可避免的。程序可能返回错误的结果,因为执
行死循环而死机,甚至因为不当的内存操作而导致系统崩溃。找出并消除这些错误的行
为称为“调试”(
debugging
)一个程序。
大部分的
bug
仅仅通过单一地研究源代码是很难发现的。通过采用程序的测试版本,提
供额外的输出信息是调试过程中一个很有帮助的诊断技巧。你也可以添加语句以在运行
时输出变量内容和其他信息。然而,通常情况下,可以使用调试器(
debugger
)执行高
效、实时的运行诊断。
调试器是一个程序,它可以在一个精确受控的环境中执行另一个程序。例如,调试器
可以单步运行与跟踪程序,查看变量内容、内存位置,以及每条语句执行完成后
CPU
寄
存器的变化情况。同时,调试器也可以分析在执行到程序中给定位置之前的函数调用
序列。
本章介绍一个功能强大、应用广泛的调试器——
GNU
调试器(也称为
GDB
)。后
面各节描述
GDB
的基本选项和命令。这里介绍的大多数特性和工作原理与其他调试
工具基本类似。关于
GDB
功能的详细描述,请参考自由软件基金会(
Free Software
Foundation
)提供的程序手册“
Debugging with GDB
”(
http://www.gnu.org/software/
gdb/documentation
)。该手册有
HTML
和
PDF
两种版本。如果操作系统同时安装了
GNU
T
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

算法精讲视频课程:24篇系列讲座

算法精讲视频课程:24篇系列讲座

罗伯特·塞奇威克, 凯文·韦恩(Kevin Wayne)

Publisher Resources

ISBN: 9787111562207