当多个Rust源文件共享同一名称时,我可以设置LLDB断点吗?

时间:2016-01-18 16:48:26

标签: rust lldb

后台:在Rust中,您通常有多个名为mod.rs的源文件。例如:

app_name
  src
    main.rs
    foo
      mod.rs
    bar
      mod.rs

问题:在设置LLDB断点时,我找不到区分mod.rs与其他$ 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. 的方法:

mod.rs

此问题最常见于foo/mod.rs。更一般地说,只要多个源文件共享相同的名称,它就会出现。

问题:有没有办法在bar/mod.rs的第10行设置断点,但不能在START n=node:locations('withinDistance:[1.0, 1.0, 10.0]') return n 的第10行设置断点?

1 个答案:

答案 0 :(得分:7)

您可以将绝对路径用于该文件。在我的例子中,我编译在OS X上的/tmp目录中,实际上是/private/tmp。这意味着我可以做这样的事情:

breakpoint set --file /private/tmp/debug/src/bar/mod.rs --line 2

我通过查看DWARF调试信息来解决这个问题:

dwarfdump target/debug/debug.dSYM/Contents/Resources/DWARF/debug | grep mod.rs

如果这不起作用,还有一些解决方法:

  1. 中断函数:breakpoint set --name my_func。您不太可能拥有相同的方法名称,但在这里您也可以使用模块名称:breakpoint set --name foo::my_func

  2. 禁用无意义的重复断点。 breakpoint set使用数字ID(如1)建立逻辑断点,然后与条件匹配的实际断点具有子ID(如1.1)。您可以使用breakpoint list查看这些内容,然后使用breakpoint disable 1.1停用其他内容。