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

wrong line number for function in DWARF #33146

Closed
tromey opened this issue Apr 22, 2016 · 3 comments
Closed

wrong line number for function in DWARF #33146

tromey opened this issue Apr 22, 2016 · 3 comments
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.)

Comments

@tromey
Copy link
Contributor

tromey commented Apr 22, 2016

Consider this test case:

fn main() {
    p();
}

fn p() {
    println!("Hi");
}

If I compile this and then examine the resulting DWARF line table for p, I see that it apparently covers line 2:

./p.rs:[++]
p.rs                                           5              0x4c50
p.rs                                           2              0x4cd8
p.rs                                           7              0x4cf1

A somewhat easy way to see this is with disassemble/s in gdb. (Also for some reason gdb thinks that this line 2 is the end of the prologue for the function, but from the disassembly this is many instructions in, so I think something else weird is going on here.)

@sanxiyn sanxiyn added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Apr 23, 2016
@jseyfried
Copy link
Contributor

This might be related to the failing test in #33749.

@xanlpz
Copy link

xanlpz commented Feb 27, 2017

This seems to work fine with latest git rust (cb1f649).

@Mark-Simulacrum
Copy link
Member

This appears to be fixed today; closing.

Dump of assembler code for function test::p:
test.rs:
5	fn p() {
   0x000055555555ce30 <+0>:	push   %rbp
   0x000055555555ce31 <+1>:	mov    %rsp,%rbp
   0x000055555555ce34 <+4>:	sub    $0x30,%rsp
   0x000055555555ce38 <+8>:	lea    -0x30(%rbp),%rdi
   0x000055555555ce3c <+12>:	lea    0x54b7d(%rip),%rcx        # 0x5555555b19c0 <str.1>
   0x000055555555ce43 <+19>:	xor    %eax,%eax
   0x000055555555ce45 <+21>:	mov    %eax,%r8d

6	    println!("Hi");
=> 0x000055555555ce48 <+24>:	mov    0x270441(%rip),%rsi        # 0x5555557cd290 <_ZN4test1p15__STATIC_FMTSTR17hb6e039e832f7c61fE>
   0x000055555555ce4f <+31>:	mov    0x270442(%rip),%rdx        # 0x5555557cd298 <_ZN4test1p15__STATIC_FMTSTR17hb6e039e832f7c61fE+8>
   0x000055555555ce56 <+38>:	callq  0x55555555cdb0 <core::fmt::{{impl}}::new_v1>
   0x000055555555ce5b <+43>:	lea    -0x30(%rbp),%rdi
   0x000055555555ce5f <+47>:	callq  0x55555556b070 <std::io::stdio::_print>

7	}
   0x000055555555ce64 <+52>:	add    $0x30,%rsp
   0x000055555555ce68 <+56>:	pop    %rbp
   0x000055555555ce69 <+57>:	retq
End of assembler dump.

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.)
Projects
None yet
Development

No branches or pull requests

5 participants