source line number for instruction


I want to retrieve a function from a source line-number, is this something possible to achieve? 
I tried the following code snippet with LLVM-7 but it doesn't seem to work

Is there specific documentation I can refer to implement this?


Not sure what you tried/how it didn’t work - could you explain more?

You could scan through all the llvm::Functions in an llvm::Module and look at the debug info associated with them (getSubprogram) then check the location of that debug info.

  • Dave

Hi David,

Thanks for your email, I was able to get it right after some googling.
Indeed it was as you suggested, we can get the line information with debug info associated in an instruction