Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format!() generates code without line number debug info #20292

Closed
vadimcn opened this issue Dec 29, 2014 · 2 comments
Closed

format!() generates code without line number debug info #20292

vadimcn opened this issue Dec 29, 2014 · 2 comments
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)

Comments

@vadimcn
Copy link
Contributor

vadimcn commented Dec 29, 2014

Compile the following with -g flag, then try stepping line-by-line in gdb:

fn main() {
    let a = 42
    println!("The answer = {}", a);
    println!("The end!");
}

After each printlt!() statement the execution point jumps to the first line of the function.
Examination of LLVM IR shows that much of the fmt::Arguments construction code has no line debug metadata attached to it (or at least that's what I think that code does).

@jdm jdm added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Dec 29, 2014
@huonw
Copy link
Member

huonw commented Nov 18, 2015

The debuginfo of macros still seems to be problematic, e.g. this is a session with the example in the issue, first using next and then using step.

(gdb) break debug_println.rs:2
Breakpoint 1 at 0x544b: file debug_println.rs, line 2.
(gdb) r
...

Breakpoint 1, debug_println::main () at debug_println.rs:2
2       let a = 42;
(gdb) n
3       println!("The answer = {}", a);
(gdb) n
2   <std macros>: No such file or directory.
(gdb) n
5   }
(gdb) n
0x0000555555561b55 in sys_common::unwind::try::try_fn::h4848098439110500489 ()
(gdb) 
(gdb)
(gdb) r
...

Breakpoint 1, debug_println::main () at debug_println.rs:2
2       let a = 42;
(gdb) s
3       println!("The answer = {}", a);
(gdb) s
2   <std macros>: No such file or directory.
(gdb) s
debug_println::fmt::ArgumentV1<'a>::new<i32> (x=0x7fffffffdb18, f=0x55555558a570 <fmt::num::i32.fmt..Display::fmt::h05897f40d7b1bb4buzU>) at ../src/libcore/fmt/mod.rs:192
192 ../src/libcore/fmt/mod.rs: No such file or directory.
(gdb) s
193 in ../src/libcore/fmt/mod.rs
(gdb) s
189 in ../src/libcore/fmt/mod.rs
(gdb) s
debug_println::fmt::Arguments<'a>::new_v1 (pieces=&[&str](len: 2) = {...}, args=&[core::fmt::ArgumentV1](len: 1) = {...}) at ../src/libcore/fmt/mod.rs:226
226 in ../src/libcore/fmt/mod.rs
(gdb) s
debug_println::fmt::Arguments<'a>::new_v1 (pieces=&[&str](len: 1) = {...}, args=&[core::fmt::ArgumentV1](len: 0)) at ../src/libcore/fmt/mod.rs:226
226 in ../src/libcore/fmt/mod.rs
(gdb) s
debug_println::main () at debug_println.rs:5
5   }
(gdb) s
0x0000555555561b55 in sys_common::unwind::try::try_fn::h4848098439110500489 ()
(gdb) 

cc #9232, #17234, #18285

@huonw huonw added the A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) label Jan 5, 2016
@vadimcn
Copy link
Contributor Author

vadimcn commented Jan 17, 2016

I've hit this issue again today. This got me thinking: most of the time I don't want to step through a macro. It should be possible to step over them just like any regular function.

We could probably accomplish this by generating the same kind of debug info that LLVM itself creates when it inlines a function. The only issue might be recovering the location of macro invocation from expanded AST nodes. IIRC, the AST currently does not store this information,does it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
Projects
None yet
Development

No branches or pull requests

3 participants