Getting actual value of local variables in llvm

空扰寡人 提交于 2019-12-05 13:55:58

You need to return the value from a JITed LLVM function in order to retrieve it from the code invoking MCJIT.

Check out this Kaleidoscope example.

The relevant code is in HandleTopLevelExpression():

if (FunctionAST *F = ParseTopLevelExpr()) {
  if (Function *LF = F->Codegen()) {
    // JIT the function, returning a function pointer.
    void *FPtr = TheHelper->getPointerToFunction(LF);

    // Cast it to the right type (takes no arguments, returns a double) so we
    // can call it as a native function.
    double (*FP)() = (double (*)())(intptr_t)FPtr;
    fprintf(stderr, "Evaluated to %f\n", FP());
  }
}

Put a break point after execution of the statement where you want to check the value. In the console (lldb) po <variable name>.

Although I guess watch point is more suitable for your requirement, add a watch point for the variable like, watchpoint set variable <variable key path>.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!