Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the type of llvm::Value with lldb

When working with LLVM IR, we can use LLVM Raw Stream to print the type of every llvm::Value. e.g.

void someFunction(llvm::IRBuilder* iBuilder) {
    llvm::Value* v = iBuilder->getInt64(0);
    // Print the type of value "v"
    v->getType()->print(llvm::outs()); // line A, get "i64" in stdout
}

However, if we want to debug some related codes, I don't think it is a good practise to modify the original code (add print function call) and compile again in order to get some debug information of value type.
So, assumed I have a break point at "line A", can I get some human readable type information (similar to "i64" in stdout) of llvm::Value* v in lldb?

like image 558
Xiangyu.Wu Avatar asked Sep 18 '25 14:09

Xiangyu.Wu


1 Answers

As describe in the comment of @IsmailBadawi, we can use p v->dump() p v->getType()->dump() to print the target information (in stdout instead of debug output)

like image 62
Xiangyu.Wu Avatar answered Sep 20 '25 21:09

Xiangyu.Wu