dwarf is a too old and too inaccurate protocol to representing source code

dwarf is a too old and too inaccurate protocol to representing source code, i compile the following c code by gcc 5.2.0 and linked it by binutils 2.25

int testVarFunc() {
	int var1 = 1980;
	for (int y = 0; y < var1; y++) {
		int var2 = var1 + y*y;
	}
	int var4 = 2204;
	for (int y2 = 0; y2 < var4; y2++) {
		int var3 = var1 + y2*y2;
	}
	int var5 = 1234;
	var5 = var1*var4;
	return var5;
}

Then i use objdump 2.25 to disassemble it, the c source code line information is too in accurate, and i didn’t use turn on any gcc optimization. As you can see the below disassembly, the testVarFunc() appeared twice.

int testVarFunc() {
 1602903:       55                      push   %ebp
 1602904:       89 e5                   mov    %esp,%ebp
 1602906:       83 ec 20                sub    $0x20,%esp
        int var1 = 1980;
 1602909:       c7 45 f4 bc 07 00 00    movl   $0x7bc,-0xc(%ebp)
        for (int y = 0; y < var1; y++) {
 1602910:       c7 45 fc 00 00 00 00    movl   $0x0,-0x4(%ebp)
 1602917:       8b 45 fc                mov    -0x4(%ebp),%eax
 160291a:       3b 45 f4                cmp    -0xc(%ebp),%eax
 160291d:       7d 16                   jge    1602935 <_Z11testVarFuncv+0x32>
                int var2 = var1 + y*y;
 160291f:       8b 45 fc                mov    -0x4(%ebp),%eax
 1602922:       0f af 45 fc             imul   -0x4(%ebp),%eax
 1602926:       89 c2                   mov    %eax,%edx
 1602928:       8b 45 f4                mov    -0xc(%ebp),%eax
 160292b:       01 d0                   add    %edx,%eax
 160292d:       89 45 f0                mov    %eax,-0x10(%ebp)
        }
}

int testVarFunc() {
        int var1 = 1980;
        for (int y = 0; y < var1; y++) {
 1602930:       ff 45 fc                incl   -0x4(%ebp)
 1602933:       eb e2                   jmp    1602917 <_Z11testVarFuncv+0x14>
                int var2 = var1 + y*y;
        }
        int var4 = 2204;
 1602935:       c7 45 ec 9c 08 00 00    movl   $0x89c,-0x14(%ebp)
        for (int y2 = 0; y2 < var4; y2++) {
 160293c:       c7 45 f8 00 00 00 00    movl   $0x0,-0x8(%ebp)
 1602943:       8b 45 f8                mov    -0x8(%ebp),%eax
 1602946:       3b 45 ec                cmp    -0x14(%ebp),%eax
 1602949:       7d 16                   jge    1602961 <_Z11testVarFuncv+0x5e>
                int var3 = var1 + y2*y2;
 160294b:       8b 45 f8                mov    -0x8(%ebp),%eax
 160294e:       0f af 45 f8             imul   -0x8(%ebp),%eax
 1602952:       89 c2                   mov    %eax,%edx
 1602954:       8b 45 f4                mov    -0xc(%ebp),%eax
 1602957:       01 d0                   add    %edx,%eax
 1602959:       89 45 e8                mov    %eax,-0x18(%ebp)
        int var1 = 1980;
        for (int y = 0; y < var1; y++) {
                int var2 = var1 + y*y;
        }
        int var4 = 2204;
        for (int y2 = 0; y2 < var4; y2++) {
 160295c:       ff 45 f8                incl   -0x8(%ebp)
160295f:       eb e2                   jmp    1602943 <_Z11testVarFuncv+0x40>
                int var3 = var1 + y2*y2;
        }
        int var5 = 1234;
 1602961:       c7 45 e4 d2 04 00 00    movl   $0x4d2,-0x1c(%ebp)
        var5 = var1*var4;
 1602968:       8b 45 f4                mov    -0xc(%ebp),%eax
 160296b:       0f af 45 ec             imul   -0x14(%ebp),%eax
 160296f:       89 45 e4                mov    %eax,-0x1c(%ebp)
        return var5;
 1602972:       8b 45 e4                mov    -0x1c(%ebp),%eax
}
 1602975:       c9                      leave  
 1602976:       c3                      ret    

read count : 22