LLVM调试技巧之Value类

计算机天才
·

Value是llvm中最重要的一个类,它是最基础的基类

https://llvm.org/doxygen/classllvm_1_1Value.html

一般Value它是有一个类成员提供这个对象的名字的,这个名字作为创建时用户提供的参数。这个成员在调试的时候我认为是有大用的。

bool llvm::Value::hasName	(		)	const
StringRef Value::getName	(		)	const
StringRef Value::getName() const {
  // Make sure the empty string is still a C string. For historical reasons,
  // some clients want to call .data() on the result and expect it to be null
  // terminated.
  if (!hasName())
    return StringRef("", 0);
  return getValueName()->getKey();
}
ValueName *Value::getValueName() const {
  if (!HasName) return nullptr;
 
  LLVMContext &Ctx = getContext();
  auto I = Ctx.pImpl->ValueNames.find(this);
  assert(I != Ctx.pImpl->ValueNames.end() &&
         "No name entry found!");
 
  return I->second;
}
 
LLVMContext &Value::getContext() const { return VTy->getContext(); }

DenseMap类似于C++标准库里的std::map

class LLVMContextImpl:{
public:
	DenseMap<const Value*, ValueName*> ValueNames;
}

但是每次调试定位到这个DenseMap的时候,Vistual Studio无法正确显示里面的键值对。

社区准则 博客 联系 社区 状态
主题