背景:在Rust中,通常会调用多个源文件mod.rs.例如:
app_name
src
main.rs
foo
mod.rs
bar
mod.rs
Run Code Online (Sandbox Code Playgroud)
问题:mod.rs在设置LLDB断点时,我无法找到区分彼此的方法:
$ cargo build
$ rust-lldb target/debug/app_name
(lldb) breakpoint set -f mod.rs -l 10
Breakpoint 1: 2 locations.
(lldb) breakpoint set -f foo/mod.rs -l 10
Breakpoint 2: no locations (pending).
WARNING: Unable to resolve breakpoint to any actual locations.
(lldb) breakpoint set -f src/foo/mod.rs -l 10
Breakpoint 3: no locations (pending).
WARNING: Unable to resolve breakpoint to any actual locations.
Run Code Online (Sandbox Code Playgroud)
这个问题最常见mod.rs.更一般地说,任何时候多个源文件共享相同的名称就会出现.
问题:有没有办法在第10行foo/mod.rs而不是第10 行设置断点bar/mod.rs?
您可以使用文件的绝对路径.就我而言,我编译在/tmpOS X 的目录中,实际上是/private/tmp.这意味着我可以做这样的事情:
breakpoint set --file /private/tmp/debug/src/bar/mod.rs --line 2
Run Code Online (Sandbox Code Playgroud)
我通过查看DWARF调试信息来解决这个问题:
dwarfdump target/debug/debug.dSYM/Contents/Resources/DWARF/debug | grep mod.rs
Run Code Online (Sandbox Code Playgroud)
如果这不起作用,还有一些解决方法:
打破一个功能:breakpoint set --name my_func.您不太可能拥有相同的方法名称,但在这里您也可以使用模块名称:breakpoint set --name foo::my_func.
禁用无意义的重复断点.使用数字ID(如)breakpoint set建立逻辑断点1,然后匹配条件的实际断点具有子ID(如1.1).你可以看到这些,breakpoint list然后禁用其他人breakpoint disable 1.1.