Debugging with llvm-gcc/mingw doesn't seem to work

Hello, Argiris

Any ideas?

1. Make sure, that you don't mix dwarf and stabs debug information.
AFAIR, this can really mess the things
2. It can be, that debug information emitted is not correct. This is
known open problem.

Anton Korobeynikov wrote:

2. It can be, that debug information emitted is not correct. This is
known open problem.
  
I assume it is known problem for llvm-gcc in general and not only the mingw version, is this correct ?
I say that because I tried the linux binaries and they have the same issue.

-Argiris

Hello, Argiris

I say that because I tried the linux binaries and they have the same issue.

That's strange. Debug information is more or less ok on both linux and
darwin.

Anton Korobeynikov wrote:

I say that because I tried the linux binaries and they have the same issue.
    

That's strange. Debug information is more or less ok on both linux and
darwin.
  
Can you please try out the steps I mentioned before with the linux binaries ? I just want to make sure that there's not something wrong with my setup.

I can set breakpoint by function, I can step throught the lines, but I can't set a breakpoint on a line number.

> gdb -v
GNU gdb 6.3-9pclos2007 (PCLinuxOS release 2007)

When I do "info source" on gdb it says "Compiled with unknown debugging format".

-Argiris

Hello, Argiris

Can you please try out the steps I mentioned before with the linux
binaries ? I just want to make sure that there's not something wrong
with my setup.

Here they are:

$ cat dbg.c
int main()
{
  return 0;
}

$ gdb a.out
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html&gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show
copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) break dbg.c:3
Breakpoint 1 at 0x80483a6: file dbg.c, line 3.
(gdb) r
Starting program: /home/asl/proj/llvm/llvm-gcc-4.2/install/bin/a.out
Failed to read a valid object file image from memory.

Breakpoint 1, main () at dbg.c:3
3 return 0;
(gdb) info source
Current source file is dbg.c
Compilation directory is /home/asl/proj/llvm/llvm-gcc-4.2/install/bin/
Located in /home/asl/proj/llvm/llvm-gcc-4.2/install/bin/dbg.c
Contains 4 lines.
Source language is c.
Compiled with DWARF 2 debugging format.
Does not include preprocessor macro info.

$ uname -a
Linux aslstation 2.6.22-gentoo-r5 #3 SMP Tue Aug 28 22:47:26 MSD 2007
i686 Dual-Core AMD Opteron(tm) Processor 2210 AuthenticAMD GNU/Linux

Thanks a lot Anton.

I installed gdb 6.8 and it works fine on linux.

Unfortunately, the mingw one is problematic (I use gdb 6.8 on mingw too).

Anton Korobeynikov wrote:

Anton Korobeynikov wrote:

2. It can be, that debug information emitted is not correct. This is
known open problem.
  
The attached patch fixes the problem with the line information.

For the "AT_stmt_list" attribute of the compilation unit entry, DWARF-2 specification says:

A DW_AT_stmt_list attribute whose value is a reference to line number information for
this compilation unit.
This information is placed in a separate object file section from the debugging information
entries themselves. The value of the statement list attribute is the offset in the
.debug_line section of the first byte of the line number information for this compilation
unit

DwarfWriter was using a label reference (instead of a section offset) and it was causing a problem because Windows treats
section offsets differently, by emitting the ".secrel32" directive.

-Argiris

dwarf-fix.patch (4.65 KB)

Looks good, please commit.

Evan

Evan Cheng wrote:

Looks good, please commit.

Applied:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080616/063837.html