Can I set an LLDB breakpoint when multiple Rust source files have the same name?

Background: In Rust, you usually have several source files called mod.rs For instance:

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

Problem: I cannot find a way to distinguish one mod.rs from another when setting the LLDB breakpoint:

 $ 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. 

This question is most often found with mod.rs More generally, this occurs at any time when multiple source files have the same name.

Question Is there a way to set a breakpoint on line 10 of foo/mod.rs but not on line 10 bar/mod.rs ?

+5
source share
1 answer

You can use the absolute path to the file. In my case, I compiled in the /tmp on OS X, which is actually /private/tmp . This means that I can do something like this:

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

I figured this out by looking at the DWARF debug info:

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

There are also several workarounds if this does not work:

  • Function break instead: breakpoint set --name my_func . It is unlikely that you will have one method name, but here you can also use the module name: breakpoint set --name foo::my_func .

  • Disable non-interesting duplicate breakpoints. breakpoint set sets a logical breakpoint with a numeric identifier (for example, 1 ), and then real breakpoints that match the condition have an additional identifier (for example, 1.1 ). You can see them using breakpoint list , and then disable others with breakpoint disable 1.1 .

+6
source

Source: https://habr.com/ru/post/1240861/


All Articles