LLDB:列出源代码
LLDB: List source code
我最常用的一个gdb
命令是l
、n
和l -
。
如何在lldb中获得相同的结果?
我不满足于必须键入一些行号才能在某个地方看到代码。在向终端转储了大量变量之后,我想看看我在代码中的位置。我过去常常使用l -
返回查看我所在的位置,因为后续对l
的调用会向下滚动我(lldb也会这样做,但关键是不会响应l -
)。
也许我错过了什么,我可以把它放在某种"模式"中,它会一直在一个单独的缓冲区中显示相应的源位置。那太好了,但我甚至没有要求。
在Xcode 4.6中,lldb的l
别名是source list
的一个简单快捷方式。
在树源的顶部,这已经得到了改进,表现得更像gdb。如果您查看source/Interpreter/CommandInterpreter.cpp
http://lldb.llvm.org/您将看到l
现在是一个正则表达式命令别名,有以下情况:
if (list_regex_cmd_ap->AddRegexCommand("^([0-9]+)[[:space:]]*$", "source list --line %1") &&
list_regex_cmd_ap->AddRegexCommand("^(.*[^[:space:]])[[:space:]]*:[[:space:]]*([[:digit:]]+)[[:space:]]*$", "source list --file '%1' --line %2") &&
list_regex_cmd_ap->AddRegexCommand("^\*?(0x[[:xdigit:]]+)[[:space:]]*$", "source list --address %1") &&
list_regex_cmd_ap->AddRegexCommand("^-[[:space:]]*$", "source list --reverse") &&
list_regex_cmd_ap->AddRegexCommand("^-([[:digit:]]+)[[:space:]]*$", "source list --reverse --count %1") &&
list_regex_cmd_ap->AddRegexCommand("^(.+)$", "source list --name "%1"") &&
list_regex_cmd_ap->AddRegexCommand("^$", "source list"))
在这些情况下,你会得到这样的行为:
显示当前帧:
(lldb) f
#0: 0x0000000100000f2b a.out`main + 27 at a.c:15
12
13
14
-> 15 puts ("hi"); // line 15
16
17 puts ("hi"); // line 17
18 }
显示前十行:
(lldb) l -
5
6
7
8
9 puts ("hi"); // line 9
10
11
还可以使用stop-line-count-after
和stop-line-count-before
设置来控制在帧停止时显示多少源上下文。
请注意,您可以在~/.lldbinit
文件中创建自己的正则表达式命令别名,其行为与树顶部lldb的l
相同。有关语法和示例,请参见help command regex
。
LLDB:[如何]列出源代码
ie:对于任何寻找"如何使lldb再次显示我在上的哪一行?(因为我最近的命令掩盖了这一点)",它就是简单的f
。键入f
以再次查看代码中的位置。
f
或
frame select
来源:LLDB:列出源代码
另请参阅lldb
:中的帮助菜单
help f
显示以下内容:
(lldb) help f Select the current stack frame by index from within the current thread (see 'thread backtrace'.) Syntax: f <cmd-options> [<frame-index>] Command Options Usage: f [-r <offset>] [<frame-index>] -r <offset> ( --relative <offset> ) A relative frame index offset from the current frame index. This command takes options and free-form arguments. If your arguments resemble option specifiers (i.e., they start with a - or --), you must use ' -- ' between the end of the command options and the beginning of the arguments. 'f' is an abbreviation for 'frame select'
该帮助菜单的底部显示;CCD_ 20是CCD_;。
请注意,在gdb
中,等效命令只是:
f
或
frame
user@hostname> lldb -o "image lookup -rvn file" -o "quit" "Name of exec-file" | grep "CompileUnit"
user@hostname> lldb -o "image lookup -rvs file" -o "quit" "Name of exec-file" | grep "CompileUnit"
- 在Linux中哪里可以找到互斥、未来等的源代码
- 如果编译的源代码是特定于它编译的硬件的,我们如何分发它
- 使用cmake从源代码构建MySQL连接器/C++失败(与以前的声明冲突)
- 如何让LLDB在成功时退出,在失败时等待
- 难以理解某些人解决IOI问题的源代码
- 使用g++编译hdf5源代码
- 如何使用C++读取另一个程序中的源代码输出
- Poco FindMySql.cmake 无法找到 MySQL 源代码
- 更改命令行 qt5 源代码构建配置的正确/快速方法
- C++出现控制台错误.我无法识别源代码的问题
- Qt Quick,如何更改 Ui 源代码?
- 使用 Git 处理 C++ Visual Studio 2019 解决方案的外部依赖项源代码管理的最佳方法是什么?
- 从macOS Catalina上的源代码编译LLVM(如何解决未找到"stdio.h")
- 如何使用QT创建器获取网页源代码?
- 从源代码构建 gRPC C++
- 如何使用 lldb 查找我的代码运行的位置
- 如何使用我构建的库,而不会从源代码出错,但不为我自己的项目编译?
- LLDB没有显示源代码
- LLDB:列出源代码
- LLDB -设置源代码路径