如何在 gdb 中使用 list 命令打印当前文件的所有行?

KiY*_*ter 1 gdb

如何在 gdb 中使用 list 命令打印当前文件的所有行?
list命令默认只显示 10 行,所以我想显示当前文件的所有行。
我该怎么做?

ks1*_*322 5

您可以使用list 1,10000where10000是足够大的数字,以便您调试的文件的大小小于这个足够大的数字。请参阅内置 gdb 帮助:

(gdb) help list
List specified function or line.
With no argument, lists ten more lines after or around previous listing.
"list -" lists the ten lines before a previous ten-line listing.
One argument specifies a line, and ten lines are listed around that line.
Two arguments with comma between specify starting and ending lines to list.
Lines can be specified in these ways:
  LINENUM, to list around that line in current file,
  FILE:LINENUM, to list around that line in that file,
  FUNCTION, to list around beginning of that function,
  FILE:FUNCTION, to distinguish among like-named static functions.
  *ADDRESS, to list around the line containing that address.
With two args, if one is empty, it stands for ten lines away from
the other arg.

By default, when a single location is given, display ten lines.
This can be changed using "set listsize", and the current value
can be shown using "show listsize".
Run Code Online (Sandbox Code Playgroud)