0

I want to debug a jit function. just like the source code below , I want to debug the FibF function , but when I debug it by gdb , it seems can't run into the function scope. How to debug it? thank you in advance.

// We are about to create the "fib" function:
  Function *FibF = CreateFibFunction(M.get(), Context);

  // Now we going to create JIT
  std::string errStr;
  ExecutionEngine *EE =
    EngineBuilder(M.get())
    .setErrorStr(&errStr)
    .setEngineKind(EngineKind::JIT)
    .create();

  if (!EE) {
    errs() << argv[0] << ": Failed to construct ExecutionEngine: " << errStr
           << "\n";
    return 1;
  }

  errs() << "verifying... ";
  if (verifyModule(*M)) {
    errs() << argv[0] << ": Error constructing function!\n";
    return 1;
  }


  // Call the Fibonacci function with argument n:
  std::vector<GenericValue> Args(1);
  Args[0].IntVal = APInt(32, n);
  GenericValue GV = EE->runFunction(FibF, Args);
childrenOurFuture
  • 1,889
  • 2
  • 14
  • 23
richardzhu
  • 41
  • 5

1 Answers1

2

If you like the full debugging experience, with function name, line numbers and variable names, you need to add debug information when you JIT your code. Part 9 of the Kaleidoscope tutorial demonstrates how to add debug information to JITted code.

Mohamed Elzarei
  • 515
  • 3
  • 20
Oak
  • 26,231
  • 8
  • 93
  • 152
  • The link seems to be dead now. Also the new ORC JIT does not seem to support debugging JITed code. I believe the information has moved to chapter 9: https://llvm.org/docs/tutorial/LangImpl09.html – PaulR Aug 07 '17 at 14:59
  • @PaulR indeed it's in part 9 now, thanks for the heads-up! – Oak Aug 07 '17 at 15:13