Clang 为什么我没有从LLVM获得精确的行/列调试信息
我正在编写一个非常简单的LLVM过程,以简单地迭代函数中的所有指令Clang 为什么我没有从LLVM获得精确的行/列调试信息,clang,llvm,clang++,llvm-ir,Clang,Llvm,Clang++,Llvm Ir,我正在编写一个非常简单的LLVM过程,以简单地迭代函数中的所有指令 bool TestInstrument::runOnFunction(Function &F) { for (inst_iterator it = inst_begin(F), E = inst_end(F); it != E; ++it) { std::string str; llvm::raw_string_ostream ss(str); ss <
bool TestInstrument::runOnFunction(Function &F)
{
for (inst_iterator it = inst_begin(F), E = inst_end(F); it != E; ++it)
{
std::string str;
llvm::raw_string_ostream ss(str);
ss << *it;
errs() << ss.str() << "\n";
const DebugLoc &location = (&(*it))->getDebugLoc();
if (location)
std::cout << " see line: " << location.getLine() << ", col " << location.getCol() << " \n";
else
std::cout << "no debugloc information detected\n";
}
return true;
}
当我在一个非常简单的hello world c程序上运行上面的工具传递时,我可以看到迭代的每条指令的打印输出。但是,没有找到任何指令的debugloc信息。该位置的所有打印输出显示“未检测到调试位置信息\n”
这是打印的输出
%retval = alloca i32, align 4
no debug info!
store i32 0, i32* %retval, align 4
no debug info!
%call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0))
no debug info!
ret i32 0
no debug info!
找不到位置元数据有什么原因吗?提前感谢。我没有得到任何debugloc信息的原因是,在我的build命令中,我使用了
clang -emit-llvm -S -fno-discard-value-names -c hello.c
应该用
clang -emit-llvm -S -fno-discard-value-names -c hello.c -g
-g选项启用调试信息。您可能在编译时没有调试信息。谢谢@arnt,我添加了用于生成密码的命令。我的编译中是否有排除调试信息的错误?
clang -emit-llvm -S -fno-discard-value-names -c hello.c -g