Encapsulation of a bfd object. More...
#include <op_bfd.h>

Public Member Functions | |
| op_bfd (std::string const &filename, string_filter const &symbol_filter, extra_images const &extra_images, bool &ok) | |
| op_bfd (uint64_t spu_offset, std::string const &filename, string_filter const &symbol_filter, extra_images const &extra_images, bool &ok) | |
| This constructor is used when processing an SPU profile where the SPU ELF is embedded within the PPE binary. | |
| std::string | get_embedding_filename () const |
| ~op_bfd () | |
| close an opened bfd image and free all related resources | |
| bool | get_linenr (symbol_index_t sym_idx, bfd_vma offset, std::string &filename, unsigned int &linenr) const |
| void | get_symbol_range (symbol_index_t sym_idx, unsigned long long &start, unsigned long long &end) const |
| void | get_vma_range (bfd_vma &start, bfd_vma &end) const |
| bfd_vma | offset_to_pc (bfd_vma offset) const |
| return the relocated PC value for the given file offset | |
| unsigned long | get_start_offset (bfd_vma vma=0) const |
| If passed 0, return the file position of the .text section. | |
| std::string | get_filename () const |
| Return the image name of the underlying binary image. | |
| size_t | bfd_arch_bits_per_address () const |
| return in bits the bfd_vma size for this binary. | |
| bool | has_debug_info () const |
| return true if binary contain some debug information | |
| bool | symbol_has_contents (symbol_index_t sym_idx) |
| bool | get_symbol_contents (symbol_index_t sym_index, unsigned char *contents) const |
| bool | valid () const |
| bfd_vma | get_vma_adj (void) const |
Public Attributes | |
| std::vector< op_bfd_symbol > | syms |
| sorted vector by vma of interesting symbol. | |
Encapsulation of a bfd object.
Simplifies open/close of bfd, enumerating symbols and retrieving informations for symbols or vma.
Use of this class relies on a std::ostream cverb
| op_bfd::op_bfd | ( | std::string const & | filename, | |
| string_filter const & | symbol_filter, | |||
| extra_images const & | extra_images, | |||
| bool & | ok | |||
| ) |
| filename | the name of the image file | |
| symbol_filter | filter to apply to symbols | |
| extra_images | container where all extra candidate filenames are stored | |
| ok | in-out parameter: on in, if not set, don't open the bfd (because it's not there or whatever). On out, it's set to false if the bfd couldn't be loaded. |
| op_bfd::op_bfd | ( | uint64_t | spu_offset, | |
| std::string const & | filename, | |||
| string_filter const & | symbol_filter, | |||
| extra_images const & | extra_images, | |||
| bool & | ok | |||
| ) |
This constructor is used when processing an SPU profile where the SPU ELF is embedded within the PPE binary.
| op_bfd::~op_bfd | ( | ) |
close an opened bfd image and free all related resources
| size_t op_bfd::bfd_arch_bits_per_address | ( | ) | const |
return in bits the bfd_vma size for this binary.
This is needed because gprof output depend on the bfd_vma for *this* binary and do not depend on sizeof(bfd_vma)
References bfd_info::abfd, and bfd_info::valid().
| std::string op_bfd::get_embedding_filename | ( | ) | const [inline] |
| string op_bfd::get_filename | ( | ) | const |
Return the image name of the underlying binary image.
For an archive, this returns the path *within* the archive, not the full path of the file.
| bool op_bfd::get_linenr | ( | symbol_index_t | sym_idx, | |
| bfd_vma | offset, | |||
| std::string & | filename, | |||
| unsigned int & | linenr | |||
| ) | const |
| sym_idx | index of the symbol | |
| offset | fentry number | |
| filename | output parameter to store filename | |
| linenr | output parameter to store linenr. |
Retrieve the relevant finename:linenr information for the sym_idx at offset. If the lookup fails, return false. In some cases this function can retrieve the filename and return true but fail to retrieve the linenr and so can return zero in linenr
| unsigned long op_bfd::get_start_offset | ( | bfd_vma | vma = 0 |
) | const |
If passed 0, return the file position of the .text section.
Otherwise, return the filepos of a section with a matching vma.
References bfd_info::valid().
Referenced by profile_t::set_offset().
| bool op_bfd::get_symbol_contents | ( | symbol_index_t | sym_index, | |
| unsigned char * | contents | |||
| ) | const |
References bfd_info::abfd, op_bfd_symbol::size(), op_bfd_symbol::symbol(), syms, and op_bfd_symbol::value().
| void op_bfd::get_symbol_range | ( | symbol_index_t | sym_idx, | |
| unsigned long long & | start, | |||
| unsigned long long & | end | |||
| ) | const |
| sym_idx | symbol index | |
| start | reference to start var | |
| end | reference to end var |
Calculates the range of sample file entries covered by sym. start and end will be filled in appropriately. If index is the last entry in symbol table, all entries up to the end of the sample file will be used. After calculating start and end they are sanitized
All errors are fatal.
References cverb, op_bfd_symbol::filepos(), op_bfd_symbol::name(), op_bfd_symbol::size(), op_bfd_symbol::symbol(), syms, op_bfd_symbol::value(), vbfd, vlevel1, and op_bfd_symbol::vma().
| bfd_vma op_bfd::get_vma_adj | ( | void | ) | const [inline] |
| void op_bfd::get_vma_range | ( | bfd_vma & | start, | |
| bfd_vma & | end | |||
| ) | const |
| start | reference to the start vma | |
| end | reference to the end vma |
return in start, end the vma range for this binary object.
References op_bfd_symbol::size(), syms, and op_bfd_symbol::vma().
| bool op_bfd::has_debug_info | ( | ) | const |
return true if binary contain some debug information
References bfd_info::abfd, cverb, options::debug_info, find_separate_debug_file(), bfd_info::has_debug_info(), open_bfd(), bfd_info::valid(), and vbfd.
Referenced by populate_for_image().
| bfd_vma op_bfd::offset_to_pc | ( | bfd_vma | offset | ) | const |
return the relocated PC value for the given file offset
References bfd_info::abfd.
| bool op_bfd::symbol_has_contents | ( | symbol_index_t | sym_idx | ) |
| sym_idx | symbol index |
Return true or false, indicating whether or not the symbol referenced by the passed sym_idx has code available. Some symbols have no code associated with them; for example, artificial symbols created for anonymous memory samples or for stripped binaries with no symbol debug info. Additionally, if the bfd object associated with the symbol is not valid, this function will also return false.
NOTE: This call should be made prior to invoking get_symbol_contents to avoid unnecessarily allocating memory for the symbol contents.
References op_bfd_symbol::artificial(), op_bfd_symbol::name(), syms, and bfd_info::valid().
| bool op_bfd::valid | ( | ) | const [inline] |
References bfd_info::valid().
Referenced by profile_t::set_offset().
| std::vector<op_bfd_symbol> op_bfd::syms |
sorted vector by vma of interesting symbol.
Referenced by get_symbol_contents(), get_symbol_range(), get_vma_range(), and symbol_has_contents().
1.6.1