[cfe-dev] Debug Clang executables on Windows with GDB

Spast via cfe-dev cfe-dev at lists.llvm.org
Sat Jul 1 13:32:30 PDT 2017


Hey Clang Community,

I am currently trying to use Clang + LLD on Windows 7 and get a debuggable executable that can be processed by GDB.
I compiled the newest SVN version for this with VS2017 and also tried the 4.1 and 4.0 binary available on the website with the same result.

The GDB version is got is 7.11.1 and it is the one bundled in Mingw-w64


I use the following simple commands:

clang++ -fuse-ld=lld -gdwarf -O0 test.cpp -o test.exe -v

gdb test.exe
break main
start


The compiler spits out the following (I removed "-internal-isystem" for readability):

-cc1 -triple x86_64-pc-windows-msvc19.10.25019 -emit-obj -mrelax-all -mincremental-linker-compatible -disable-free -disable-llvm-verifier -discard-value-names -main-file-name test.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases-munwind-tables -target-cpu x86-64 -D_MT -flto-visibility-public-std --dependent-lib=libcmt --dependent-lib=oldnames -stack-protector 2 -fms-volatile -fdiagnostics-format msvc -momit-leaf-frame-pointer -v -dwarf-column-info -debug-info-kind=limited
-dwarf-version=4 -debugger-tuning=gdb -resource-dir "C:\\LLVM\\lib\\clang\\5.0.0" -O0 -fdeprecated-macro -fdebug-compilation-dir "C:\\LLVM\\bin" -ferror-limit 19 -fmessage-length 113 -fms-extensions -fms-compatibility -fms-compatibility-version=19.10.25019 -std=c++14 -fdelayed-template-parsing -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o "C:\\Users\\***\\AppData\\Local\\Temp\\test-e9cc9b.obj" -x c++ test.cpp

And the linker this (I removed "-libpath" for readability):

-out:test.exe -nologo -debug "C:\\Users\\***\\AppData\\Local\\Temp\\test-e9cc9b.obj"


Then when I try to debug it gives me the following error:

Reading symbols from test.exe...done.
(gdb) break main
Breakpoint 1 at 0x14001b012: file test.cpp, line 5.
(gdb) start
Temporary breakpoint 2 at 0x14001b012: file test.cpp, line 5.
Starting program: C:\LLVM\bin\test.exe
[New Thread 19548.0x4fc4]
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x14001b012

Command aborted.



This is the first time I post here and if I can improve my question or provide more information in any way please don't hesitate to tell me.


Thanks.


More information about the cfe-dev mailing list