Clang链接器问题和获取调试信息
C++ - Clang linker problem and getting debug information
我想做c++代码的调试信息分析。据我所知,Clang应该能够处理c++。
我试过clang myFile.cpp
。但是我得到
clang: error: unable to execute command: program not executable
clang error: linker command failed due to signal 1 (use -v to see invocation).
设置llvm-ld的路径后,部分生效。我的意思是,如果我执行
clang C:myFile.cpp -S -emit-llvm -o -
则输出一些信息。但clang myFile.cpp
仍然失败,错误
clang version 2.9 (tags/RELEASE_29/final)
Target: i686-pc-win32
Thread model: posix
"C:/FrontEnd/llvm/bin/Debug/clang.exe" -cc1 -triple i686-pc-win32 -emit-obj -mrelax-all -disable-free -main-file-name BinarySearch_Kernels.cpp -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -momit-leaf-frame-pointer -v -resource-dir C:/FrontEnd/l
lvm/bin/Debug..libclang2.9 -ferror-limit 19 -fmessage-length 280 -fcxx-exceptions -fexceptions -fms-extensions -fmsc-version=1300 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o C:/Users/ilipov/AppData/Local/Temp/cc-563130.o -x c++ C:clangBinarySearch_Kernels
.cpp
clang -cc1 version 2.9 based upon llvm 2.9 hosted on i686-pc-win32
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
C:/FrontEnd/llvm/bin/Debug/../lib/clang/2.9/include
C:Program Files (x86)Microsoft Visual Studio 10.0VCinclude
C:Program Files (x86)Microsoft SDKsWindowsv7.0A\include
End of search list.
"link.exe" -out:a.out -defaultlib:libcmt -nologo C:/Users/ilipov/AppData/Local/Temp/cc-563130.o
clang: error: unable to execute command: program not executable
clang: error: linker command failed due to signal 1 (use -v to see invocation)
无论如何,我想获得尽可能完整的调试信息
例如,对于
class stamBase
{
public:
int get1(){return 2;};
int get0(){return 0;}
};
class stamDer : public stamBase
{
public:
int get1(){return 1;}
};
void func()
{
stamDer d;
int x = d.get1();
}
我target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:128:128-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
target triple = "i686-pc-win32"
%class.stamDer = type { i8 }
define void @_Z4funcv() {
entry:
%d = alloca %class.stamDer, align 1
%x = alloca i32, align 4
%call = call i32 @_ZN7stamDer4get1Ev(%class.stamDer* %d)
store i32 %call, i32* %x, align 4
ret void
}
define linkonce_odr i32 @_ZN7stamDer4get1Ev(%class.stamDer* %this) nounwind align 2 {
entry:
%this.addr = alloca %class.stamDer*, align 4
store %class.stamDer* %this, %class.stamDer** %this.addr, align 4
%this1 = load %class.stamDer** %this.addr
ret i32 1
}
从我对Clang调试信息代码的调查中,我认为我也应该得到stamBase的信息!
如何正确运行Clang以接受全部调试信息并防止Clang错误?
我认为你需要安装一个链接器。GNU会很好;你应该可以通过你的包管理器安装它。
还有一个LLVM链接器。它不太受欢迎,但是一旦安装了Clang,它就会在盒子里运行(只需将它添加到PATH
中,然后重新运行clang
)。
相关文章:
- 无法使函数公开。获取:"LNK2005"错误。如何调试链接器错误
- 如何在 WSL 上获取 VS 代码以调试我的C++代码?
- 附加调试器并以编程方式获取变量地址 Visual Studio
- 在集成终端上运行vscode lldb调试器时,如何获取程序的输出?
- 获取有关调试断言失败的错误:表达式:"(_Ptr_user &(_BIG_ALLOCATION_ALIGNMENT -1)) == 0" &&0
- 错误 VSP1011:无法获取调试信息.与 /配置文件链接器开关链接
- 获取stacktrace for Crash,而无需在调试器中运行该应用程序
- 从LLVM IR获取精确的行/列调试信息
- 如何在gdb中获取当前调试进程的pid
- 无效迭代器:如何在第一次使用时获取一些调试信息
- 如何在调试时获取CEdit(或CWnd)文本
- 在visualc++中调试代码时,获取argc为零和argv为null
- 如果用调试信息编译,则通过其名称获取全局变量地址
- 在GDB中调试程序时如何获取程序的环境
- 调试发布构建客户端崩溃:获取调用堆栈的可能方法是什么?
- 无法获取转储的调试符号
- VS Studio调试器-获取(并观察)一个类型的所有实例
- Clang链接器问题和获取调试信息
- 在程序中获取调试断言错误
- 获取调试符号的模块名称