Hi I am using LLVM Pass combined with dwarf debug information to get all the function's start address. My steps are below: First, I write the function pass to get the start line of each function, which is finished. Then, based on the start line of every single function, I try to query the specific line from the dwarf's line binary table, which is generated with llvm-dwarfdump -debug-line. However, About one third of the whole functions' start line is not found in the mapping table. Thus, I can not get the start binary address. I know that the mapping between source locations and binary addresses is not bijective. I am using O1 optimization option. I know that some of the information might be lost legitimately because of optimization. But I don't think dwarf will miss so many functions' start addresses. Am I right? Any useful comments and suggestions are welcomed. Many Thanks Regards Muhui -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180601/1399953e/attachment.html>
Any particular reason you're using debug info to achieve this (& if you are, why you're using the line table?)? You could query the object/executable file's symbol table to find all the functions in an object or executable, and the instruction/address they start at. Or, if you are using debug info for some reason, you could look in the debug_info rather than the line table, and find the DW_TAG_subprogram for each function and look at its low_pc. On Fri, Jun 1, 2018 at 3:36 AM Muhui Jiang via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi > > I am using LLVM Pass combined with dwarf debug information to get all the > function's start address. My steps are below: > > First, I write the function pass to get the start line of each function, > which is finished. > > Then, based on the start line of every single function, I try to query the > specific line from the dwarf's line binary table, which is generated with > llvm-dwarfdump -debug-line. > > However, About one third of the whole functions' start line is not found > in the mapping table. Thus, I can not get the start binary address. I know > that the mapping between source locations and binary addresses is not > bijective. I am using O1 optimization option. I know that some of the > information might be lost legitimately because of optimization. But I don't > think dwarf will miss so many functions' start addresses. Am I right? Any > useful comments and suggestions are welcomed. Many Thanks > > Regards > Muhui > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180601/20498e76/attachment.html>
[Re-sending with llvm-dev included this time] Hi Muhui, Are the functions emitted to the final binary? If a function is not used, there might not be any object code for it in the final binary. Naturally there would be no entry in the line table in this case. If the function does exist in the binary, it is entirely possible (I think) to have no instruction specifically associated with the function definition's source line, even though other instructions are associated with other lines in the function. I (or someone) would need to look at a specific example before being able to say one way or the other if that is what you are running into. Have you considered building a static array of function addresses? If you used weak references it would not interfere with optimizing away entire functions, which I mentioned above. Or would that be too intrusive into your use case? Apologies if this suggestion has come up before. --paulr From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of Muhui Jiang via llvm-dev Sent: Friday, June 01, 2018 6:36 AM To: llvm-dev Subject: [llvm-dev] Function start address Hi I am using LLVM Pass combined with dwarf debug information to get all the function's start address. My steps are below: First, I write the function pass to get the start line of each function, which is finished. Then, based on the start line of every single function, I try to query the specific line from the dwarf's line binary table, which is generated with llvm-dwarfdump -debug-line. However, About one third of the whole functions' start line is not found in the mapping table. Thus, I can not get the start binary address. I know that the mapping between source locations and binary addresses is not bijective. I am using O1 optimization option. I know that some of the information might be lost legitimately because of optimization. But I don't think dwarf will miss so many functions' start addresses. Am I right? Any useful comments and suggestions are welcomed. Many Thanks Regards Muhui -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180601/82782c52/attachment.html>
Hi Actually, No particular reason. I just think this might be a solution, then I use think kind of method. Querying the symbol table would be a good choice, but I prefer to use LLVM and dwarf information. I am sorry that I am not familiar with debug_info. But thanks to your suggestions. I would like to try to solve it with debug_info. It seems work according to your comments By the way, I am still curious about the reason, why dwarf line mapping table would lost so many function's start addresses' information. It would be great if you have any comments on this problem. Many Thanks Regards Muhui 2018-06-01 23:00 GMT+08:00 David Blaikie <dblaikie at gmail.com>:> Any particular reason you're using debug info to achieve this (& if you > are, why you're using the line table?)? You could query the > object/executable file's symbol table to find all the functions in an > object or executable, and the instruction/address they start at. Or, if you > are using debug info for some reason, you could look in the debug_info > rather than the line table, and find the DW_TAG_subprogram for each > function and look at its low_pc. > > On Fri, Jun 1, 2018 at 3:36 AM Muhui Jiang via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> Hi >> >> I am using LLVM Pass combined with dwarf debug information to get all the >> function's start address. My steps are below: >> >> First, I write the function pass to get the start line of each function, >> which is finished. >> >> Then, based on the start line of every single function, I try to query >> the specific line from the dwarf's line binary table, which is generated >> with llvm-dwarfdump -debug-line. >> >> However, About one third of the whole functions' start line is not found >> in the mapping table. Thus, I can not get the start binary address. I know >> that the mapping between source locations and binary addresses is not >> bijective. I am using O1 optimization option. I know that some of the >> information might be lost legitimately because of optimization. But I don't >> think dwarf will miss so many functions' start addresses. Am I right? Any >> useful comments and suggestions are welcomed. Many Thanks >> >> Regards >> Muhui >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180602/4b421e9c/attachment.html>