Breakpoint set 2 locations when I set a breakpoint with LLDB

5b9c91d
Opened by nolimitk at 2023-04-05 17:45:50
    use std::net::{TcpListener};

    fn main() {
        let listener = TcpListener::bind("127.0.0.1:16624").unwrap();
        println!("{:?}", listener);
    }

When I set a breakpoint at line 5 which has a println macro call. LLDB set a breakpoint at 2 locations.

(lldb) target create "target/debug/lldbtest"
Current executable set to 'target/debug/lldbtest' (x86_64).
(lldb) b 5
Breakpoint 1: 2 locations.
(lldb) 

it makes a problem with step-over command. I guess it problem occurs because of {:?} and LLDB. How can I fix it?

  1. As of 1.63 nightly, this now works. I think we should add a regression debuginfo test that we can do this:

    fn main() {
        println!("{:?}", 42u32); // #break
        dbg!(42u32);  // #break
    }
    

    to ensure this doesn't regress in the future and then this can be closed.

    Wesley Wiser at 2022-06-20 14:14:17

  2. It's important to note, that while this specific issue is fixed (with the use of println!), the general case of multiple breakpoints for a single macro is still an issue. You can recreate the issue with this:

    macro_rules! foo {
        () => {{
            let x = 1 + 1;
            println!("{}", x);
        }};
    }
    
    fn main() {
        foo!(); // #break
    }
    

    Setting a breakpoint on the call to foo! will set two breakpoints and still requires the user to step over twice.

    The test that gets added should be speifically for println!. While we should eventually find a fix for the general case of multiline macros, until then, it would be nice if we kept println! from breaking since that's a common case.

    Ryan Levick at 2022-06-20 14:17:53