所以我所尝试做的就是得到调用指令所调用的函数的名称:这是我的简单代码:
for(Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
{
for(BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE; ++BI){
if(isa<CallInst>(&(*BI)) ) {
StringRef fname = cast<CallInst>(&(*BI))->getCalledFunction()->getName();
}
}
}
这是一个令人讨厌的错误:
0 libllvm-3.4.so.1 0x40f8150f llvm::sys::PrintStackTrace(_IO_File*)+47
1 libllvm-3.4.so.1 0x40F8177F
2 LIBLLVM-3.4.SO.1 0x40F812EC
3 0x40022400__Kernel_SIGRETURN+0
4 libllvm-3.4.so.1 0x40899c74 llvm::value::getName()常量+20
5 SKELEONPASS.SO 0x40027786
堆栈转储:0。程序参数:/usr/bin/clang-cc1-triple i386-pc-linux-gnu-emit-obj-disable-free-disable-llvm-verifier-main-file-name test_atomics.cc-mrelocation-model pic-pic-level 2-fmath-errno-masm-verbose-mconstructor-aliases-fuse-init-array-target-cpu-pentium4-target-linker-version 2.24-Momit-leaf-frame-parget-g-coverage-file-I/usr/lib/llvm-3.4/include-internal-isystem/usr/include//C++/4.8-internal-isystem/usr/include//C++/4.8/i386-linux-internal-isystem/usr/include//C++/4.8/back-internal-isystem/usr/include//C++/4.8-internal-isystem/usr/include//C++/4.8-internal-isystem/usr/include//C++/4.8-internal-isystemme/danish/desktop/owl/llvm/llvm-3.4/lib/transforms/syncprof/testing/masstree-beta-master-Ferror-limit 19-Fmessage-length 80-Fvisibility-inlines-hidding-MstackRealign-Fobjc-runtime=gcc-fdiagnostics-show-option-fcolor-diagnostics-vectorize-loops-vectorize-slp-load/home/danish/desktop/owl/llvm/llvm-3.4/release+
>
文件末尾的分析器
按功能优化
在函数“@_z9test_jsonv”上运行pass“skeleton pass”clang:error:无法执行命令:分段错误(核心转储)clang:error:clang前端命令失败,原因是信号(使用-v查看调用)Ubuntu clang版本3.4-1ubuntu3(Tags/release_34/final)(基于LLVM 3.4)目标:i386-pc-linux-gnu线程模型:posix clang:note:diagnostic msg:请向http://bugs.debian.org/提交错误报告,并包括崩溃回溯,预处理源和相关的运行脚本。CLANG:注意:诊断消息:
请将以下文件附加到错误报告:预处理的源和关联的运行脚本位于:clang:注意:诊断消息:/tmp/test_atomics-128b00.cpp clang:注意:诊断消息:/tmp/test_atomics-128b00.sh clang:注意:诊断消息:
make:***[test_atomics.o]错误254
当我添加->getName()
部分来检索函数名时,出现了这个错误。救命啊!
是的。我想你是对的!我添加了这个null检查,它起作用了:Function*func=cast(&(*bi))->getCalledFunction();if(func!=NULL)errs()