[LLVMbugs] [Bug 22567] New: can't debug lto'd windows executables (invalid dwarf2 offset)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Feb 12 09:44:33 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22567

            Bug ID: 22567
           Summary: can't debug lto'd windows executables (invalid dwarf2
                    offset)
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: t.poechtrager at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I have skipped error checking and so on to keep this as small as possible.

### Compile the "link time optimizer": ###

$ cat lto.c
#include <llvm-c/lto.h>
#include <stdio.h>

int main()
{
    const char *object;
    lto_code_gen_t codegen = lto_codegen_create();
    lto_codegen_add_module(codegen, lto_module_create("a.bc"));
    lto_codegen_add_module(codegen, lto_module_create("b.bc"));
    lto_codegen_set_debug_model(codegen, LTO_DEBUG_MODEL_DWARF);
    lto_codegen_add_must_preserve_symbol(codegen, "_main");
    lto_codegen_compile_to_file(codegen, &object);
    printf("%s", object);
    return 0;
}

$ clang lto.c `llvm-config --cflags --ldflags` -lLTO -o lto

### Generate two bitcode files for testing: ###

$ cat a.c
int x = 10;

int test()
{
    return ++x;
}

$ cat b.c
extern int test();

int main()
{
    return test();
}

$ clang -target i686-w64-mingw32 a.c -g -flto -c -o a.bc
$ clang -target i686-w64-mingw32 b.c -g -flto -c -o b.bc

$ file *.bc
a.bc: LLVM IR bitcode
b.bc: LLVM IR bitcode

### Generate the LTO'd executable: ###

i686-w64-mingw32-gcc `./lto` -o test.exe

$ file test.exe
test.exe: PE32 executable (console) Intel 80386, for MS Windows

### Load the LTO'd excutable with GDB: ###

$ i686-w64-mingw32-gdb test.exe
GNU gdb (GDB) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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 "--host=x86_64-linux-gnu --target=i686-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from test.exe...done.
invalid dwarf2 offset 4252634

Now GDB complains about an invalid dwarf2 offset and therefore it's
not possible to debug the resulting executable.

This also happens on a native Windows machine.

The resulting executable works the way it should though:

$ wine test.exe ; echo $?
11

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150212/c0a2bc6a/attachment.html>


More information about the llvm-bugs mailing list