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版)
748
|
第
21
章
来。当再次使用
run
命令执行程序时,
GDB
会发现可执行文件已经被修改过,并且
重新加载它。
21.4.5 显示源代码
可以使用
list
命令(或简写为
l
),在
调试器中显示一个程序的源代码。在默认情况
下,
GDB
一次展示十行代码,接下来要执行的语句位于第六行。
list
命令支持参数,以
方便指定希望显示的程序部分:
list
filename
:
line_number
显示源代码,并以该指定的行代码作为中心。
list
line_number
如果没指定一个源文件,那么所显示的代码来自当前正在执行的源文件。
list
from
, [
to
]
显示特定范围内的源代码。
from
和
to
参数可以是行号或者函数名称。如果没有指定
to
参数,
list
会从
from
开始显示默认行数的代码。例如,下面的命令会显示
main()
函数的前
10
行:
(gdb)
list main,
list
function_name
把指定函数开始的第一行代码当作中间行,显示源代码。
list
、
l
不带参数的
list
命令在上一个
list
命令所显示的源代码行之后,显示更多行的源代
码。如果自上一个
list
命令开始,有另一个命令也是显示一行源代码,那么新的
list
命令会以该命令所显示源代码为中心,显示源代码行。例如,如果调试器是因为遇到
断点而中断执行,下一个
list
命令就会显示以该断点所在行为中心的源代码。
如果尚未开始执行程序,第一个不带参数的
list
命令会显示以
main
()
为中心行的源
代码,如下面例子所示:
$
gdb -silent circle ...
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