bfd_support.h

Go to the documentation of this file.
00001 
00011 #ifndef BFD_SUPPORT_H
00012 #define BFD_SUPPORT_H
00013 
00014 #include "config.h"
00015 #include "utility.h"
00016 #include "op_types.h"
00017 #include "locate_images.h"
00018 
00019 #include <bfd.h>
00020 #include <stdint.h>
00021 
00022 #include <string>
00023 #include <map>
00024 
00025 class op_bfd_symbol;
00026 
00028 struct bfd_info {
00029     bfd_info() : abfd(0), nr_syms(0), synth_syms(0), image_bfd_info(0) {}
00030 
00031     ~bfd_info();
00032 
00034     void close();
00035 
00037     bool valid() const { return abfd; }
00038 
00040     bool has_debug_info() const;
00041 
00043     void get_symbols();
00044 
00046     bfd * abfd;
00048     scoped_array<asymbol *> syms;
00050     size_t nr_syms;
00051 
00052     void set_image_bfd_info(bfd_info * ibfd) { image_bfd_info = ibfd; }
00053     bfd_info * get_image_bfd_info(void) const { return image_bfd_info; }
00054 
00055 private:
00059     bool get_synth_symbols();
00060 
00067     asymbol * synth_syms;
00068 
00076     bfd_info * image_bfd_info;
00077 
00078 #if SYNTHESIZE_SYMBOLS
00079 
00084     void translate_debuginfo_syms(asymbol ** dbg_syms, long nr_dbg_syms);
00085 
00090     std::map<bfd_vma, bfd_vma> section_vma_maps;
00091 
00092 #endif
00093 
00094 };
00095 
00096 
00097 /*
00098  * find_separate_debug_file - return true if a valid separate debug file found
00099  * @param ibfd binary file
00100  * @param dir_in directory holding the binary file
00101  * @param global_in
00102  * @param filename path to valid debug file
00103  *
00104  * Search order for debug file and use first one found:
00105  * 1) dir_in directory
00106  * 2) dir_in/.debug directory
00107  * 3) global_in/dir_in directory
00108  *
00109  * Newer binutils and Linux distributions (e.g. Fedora) allow the
00110  * creation of debug files that are separate from the binary. The
00111  * debugging information is stripped out of the binary file, placed in
00112  * this separate file, and a link to the new file is placed in the
00113  * binary. The debug files hold the information needed by the debugger
00114  * (and OProfile) to map machine instructions back to source code.
00115  */
00116 extern bool
00117 find_separate_debug_file(bfd * ibfd, 
00118                          std::string const & filepath_in,
00119                          std::string & debug_filename,
00120                          extra_images const & extra);
00121 
00123 bfd * open_bfd(std::string const & file);
00124 
00126 bfd * fdopen_bfd(std::string const & file, int fd);
00127 
00129 bfd * spu_open_bfd(std::string const name, int fd, uint64_t offset_to_spu_elf);
00130 
00132 bool interesting_symbol(asymbol * sym);
00133 
00138 bool boring_symbol(op_bfd_symbol const & first, op_bfd_symbol const & second);
00139 
00141 struct linenr_info {
00143     bool found;
00145     std::string filename;
00147     unsigned int line;
00148 };
00149 
00160 linenr_info const
00161 find_nearest_line(bfd_info const & ibfd, op_bfd_symbol const & sym,
00162                   bfd_vma offset, bool anon_obj);
00163 
00164 #endif /* !BFD_SUPPORT_H */

Generated on 8 Nov 2012 for Oprofile by  doxygen 1.6.1