Developed at Lawrence Livermore National Laboratory (LLNL), ROSE is an open source compiler infrastructure to build source-to-source program transformation and analysis tools for large-scale C (C89 and C98), C++ (C++98 and C++11), UPC, Fortran (77/95/2003), OpenMP, Java, Python and PHP applications.
I am using the OFP frontend. Can anyone recommend a means of recovering the pre-parsing line number of an SgLocatedNode? I have tried ->get_file_info()->get_line(), ->get_file_info()->get_raw_line(), and ->get_file_info()->get_physical_line(), though each of these gives the line number of the node in the resulting unparsed file which can be dramatically different. I am aware that it is expected behavior to have the unparsed file differ from the original.
What I am trying to accomplish is to automatically map execution counts for lines (from using gcov or some such on the original source) to the AST nodes from that line.
A potential workaround is to try running the profiler on a binary compiled using the unparsed files, though this is cumbersome since the unparsed files often do not compile without some manual massaging.
I have also tried adding a line before each line that containing a single comment with the original line number which I then access via ->getAttachedPreprocessingInfo(), though this admittedly hacky approach also fails since ROSE seems to arbitrarily move some comments around or remove them altogether. I can't help but feel like I'm missing something quite obvious?
I am using the OFP frontend. Can anyone recommend a means of recovering the pre-parsing line number of an
SgLocatedNode
? I have tried->get_file_info()->get_line()
,->get_file_info()->get_raw_line()
, and->get_file_info()->get_physical_line()
, though each of these gives the line number of the node in the resulting unparsed file which can be dramatically different. I am aware that it is expected behavior to have the unparsed file differ from the original.What I am trying to accomplish is to automatically map execution counts for lines (from using
gcov
or some such on the original source) to the AST nodes from that line.A potential workaround is to try running the profiler on a binary compiled using the unparsed files, though this is cumbersome since the unparsed files often do not compile without some manual massaging.
I have also tried adding a line before each line that containing a single comment with the original line number which I then access via
->getAttachedPreprocessingInfo()
, though this admittedly hacky approach also fails since ROSE seems to arbitrarily move some comments around or remove them altogether. I can't help but feel like I'm missing something quite obvious?