3

How to find if debug information contains relative paths or absolute paths?

I am trying to Outputting annotated source (opannotate) using the following link. http://oprofile.sourceforge.net/doc/opannotate.html

I would like to know about it in order to give the following options along with opannotate.

--base-dirs / -b [paths]/ Comma-separated list of path prefixes. This can be used to point OProfile to a different location for source files when the debug information specifies an absolute path on your system for the source that does not exist. The prefix is stripped from the debug source file paths, then searched in the search dirs specified by --search-dirs.

--search-dirs / -d [paths] Comma-separated list of paths to search for source files. This is useful to find source files when the debug information only contains relative paths.

Thanks.

New to Rails
  • 2,824
  • 5
  • 27
  • 43

1 Answers1

4

If the C_FLAGS during compilation contain the -g parameter, then all the paths of individual source files are included in the .debug_info section in the resulting binary executable.

The following command will dump to the console, a complete list of all the paths to various .c source files that are present in the binary built with debug-info.

$ readelf --debug-dump=info <binary-executable> | grep "\.c" | awk '{print $8}'

To search for the path of a particular source-file within the debug-info of the binary, one can modify the grep "\.c" to grep "<filename>" as appropriate.

For more details, checkout this excellent article on debug-info in binaries.

TheCodeArtist
  • 21,479
  • 4
  • 69
  • 130
  • Thank you so much TheCodeArtist. Saved my day again with the correct answer. Am not able to upvote your answer. Thanks again. – New to Rails Aug 08 '13 at 06:18
  • On SO, you will need a [minimum of 15points to upvote answers](http://meta.stackexchange.com/questions/41347/why-are-15-reputation-points-required-to-upvote). Time for you to start answering Qs and make some points for yourself. ;-) ;-) – TheCodeArtist Aug 08 '13 at 07:12