Repository: rust
Issue: Macro call breaks debug line information in PDB
Labels: A-debuginfo,A-macros,T-compiler,C-bug

Certain macro calls seem to break the debug line information in PDB files.

Consider the following code:
```Rust
fn main() {
    let my_string_1 = String::from("a");
    let my_string_2 = String::from("b");
    println!("{}", my_string_1); // break
}
```
When the debugger stops at `println!` call, it does not show `my_string_2` variable and is unable to evaluate it when adding it as a watch. This affects both Visual Studio debugger and MSVC-enabled LLDB, with 1.64.0-stable and 1.66.0-nightly Rust toolchains.

![string_println_debuginfo_bug](https://user-images.githubusercontent.com/4854600/194296285-eb2e06cc-98db-48de-b860-cb263f16e1cf.PNG)


<details><summary>PDB dump</summary>
<p>

```
Mod 0037: 
     4 | S_OBJNAME [size = 12] sig=0, ``
    16 | S_COMPILE3 [size = 84]
         machine = intel x86-x64, Ver = clang LLVM (rustc version 1.64.0 (a55dd71d5 2022-09-19)), language = rust
         frontend = 1.64.0.0, backend = 14006.0.0.0
         flags = none
   100 | S_BUILDINFO [size = 8] BuildId = `0x2A2A`
   108 | S_LPROC32 [size = 56] `rusttest::main`
         parent = 0, end = 308, addr = 0001:7504, code size = 273
         type = `0x1014 (void ())`, debug start = 0, debug end = 0, flags = none
   164 | S_FRAMEPROC [size = 32]
         size = 200, padding size = 0, offset to padding = 0
         bytes of callee saved registers = 0, exception handler addr = 0000:0000
         local fp reg = RBP, param fp reg = RBP
         flags = has eh
   196 | S_LOCAL [size = 24] `my_string_1`
         type=0x1550 (alloc::string::String), flags = none
   220 | S_DEFRANGE_FRAMEPOINTER_REL [size = 20]
         offset = -56, range = [0001:7558,+219)
         gaps = 2
   240 | S_BLOCK32 [size = 24] ``
         parent = 108, end = 304
         code size = 81, addr = 0001:7580
   264 | S_LOCAL [size = 24] `my_string_2`
         type=0x1550 (alloc::string::String), flags = none
   288 | S_DEFRANGE_FRAMEPOINTER_REL [size = 16]
         offset = -32, range = [0001:7580,+81)
         gaps = 2
   304 | S_END [size = 4]
   308 | S_END [size = 4]
```

</p>
</details>


Interestingly, the problem does not reproduce anymore after we replace the `println!` macro call with an empty one:
```Rust
fn main() {
    let my_string_1 = String::from("a");
    let my_string_2 = String::from("b");
    println!(); // break
}
```

<details><summary>PDB dump for empty `println!`</summary>
<p>

```
Mod 0034: 
     4 | S_OBJNAME [size = 12] sig=0, ``
    16 | S_COMPILE3 [size = 84]
         machine = intel x86-x64, Ver = clang LLVM (rustc version 1.64.0 (a55dd71d5 2022-09-19)), language = rust
         frontend = 1.64.0.0, backend = 14006.0.0.0
         flags = none
   100 | S_BUILDINFO [size = 8] BuildId = `0x2A2A`
   108 | S_LPROC32 [size = 56] `rusttest::main`
         parent = 0, end = 308, addr = 0001:6816, code size = 241
         type = `0x1014 (void ())`, debug start = 0, debug end = 0, flags = none
   164 | S_FRAMEPROC [size = 32]
         size = 168, padding size = 0, offset to padding = 0
         bytes of callee saved registers = 0, exception handler addr = 0000:0000
         local fp reg = RBP, param fp reg = RBP
         flags = has eh
   196 | S_LOCAL [size = 24] `my_string_1`
         type=0x1550 (alloc::string::String), flags = none
   220 | S_DEFRANGE_FRAMEPOINTER_REL [size = 20]
         offset = -72, range = [0001:6870,+187)
         gaps = 2
   240 | S_BLOCK32 [size = 24] ``
         parent = 108, end = 304
         code size = 53, addr = 0001:6888
   264 | S_LOCAL [size = 24] `my_string_2`
         type=0x1550 (alloc::string::String), flags = none
   288 | S_DEFRANGE_FRAMEPOINTER_REL [size = 16]
         offset = -48, range = [0001:6888,+53)
         gaps = 2
   304 | S_END [size = 4]
   308 | S_END [size = 4]
```

</p>
</details>

The PDB dumps seem to be almost identical, except for the offsets and ranges. So maybe the problem is caused by wrong offsets/ranges generation.

Initially reported in https://github.com/intellij-rust/intellij-rust/issues/9464#issuecomment-1269614191