ROSE  0.11.145.0
Public Types | Public Member Functions | List of all members
Rose::BinaryAnalysis::SourceLocations Class Reference

Description

Bidirectional mapping between addresses and source locations.

This class stores a mapping between virtual addresses and source locations (file name, line number, and optional column number) and vice versa. Each source location can have multiple virtual addresses, but each address has zero or one source location.

Definition at line 24 of file SourceLocations.h.

#include <Rose/BinaryAnalysis/SourceLocations.h>

Public Types

typedef Sawyer::Container::IntervalMap< AddressInterval, SourceLocationAddressToSource
 
typedef Sawyer::Container::Map< SourceLocation, AddressIntervalSetSourceToAddress
 

Public Member Functions

 SourceLocations ()
 Default constructor. More...
 
void erase (const SourceLocation &)
 Remove all links for the specified source location regardless of address. More...
 
void clear ()
 Remove all links. More...
 
void insertFromDebug (SgNode *ast)
 Insert information from debug tables. More...
 
void fillHoles (size_t maxHoleSize=64)
 Fill in small holes in the address space. More...
 
AddressIntervalSet get (const SourceLocation &) const
 Find the addresses associated with a source location. More...
 
std::set< boost::filesystem::path > allFileNames () const
 Get the list of all known source files. More...
 
SourceLocation nextSourceLocation (const SourceLocation &current=SourceLocation()) const
 Given a source location, return the next source location. More...
 
void printAddrToSrc (std::ostream &, const std::string &prefix="") const
 Print the address to source mapping. More...
 
 SourceLocations (const SourceLocations &)
 Atomic copy.
 
SourceLocationsoperator= (const SourceLocations &)
 Atomic copy.
 
void insert (const SourceLocation &, rose_addr_t)
 Insert links between source and adresseses. More...
 
void insert (const SourceLocation &, const AddressInterval &)
 Insert links between source and adresseses. More...
 
void insert (const SourceLocation &, const AddressIntervalSet &)
 Insert links between source and adresseses. More...
 
void erase (const SourceLocation &, rose_addr_t)
 Remove links between source and addresses. More...
 
void erase (const SourceLocation &, const AddressInterval &)
 Remove links between source and addresses. More...
 
void erase (const SourceLocation &, const AddressIntervalSet &)
 Remove links between source and addresses. More...
 
void erase (rose_addr_t)
 Remove all links for the specified addresses regardless of source.
 
void erase (const AddressInterval &)
 Remove all links for the specified addresses regardless of source.
 
void erase (const AddressIntervalSet &)
 Remove all links for the specified addresses regardless of source.
 
SourceLocation get (rose_addr_t) const
 Find the source location for an address.
 
SourceLocation operator() (rose_addr_t va) const
 Find the source location for an address.
 
Sawyer::Optional< rose_addr_t > firstAddress (const SourceLocation &) const
 Find the first address associated with a source location.
 
Sawyer::Optional< rose_addr_t > operator() (const SourceLocation &loc) const
 Find the first address associated with a source location.
 
void printSrcToAddr (std::ostream &, const std::string &prefix="") const
 Print the source to address mapping. More...
 
void print (std::ostream &, const std::string &prefix="") const
 Print the source to address mapping. More...
 

Constructor & Destructor Documentation

Rose::BinaryAnalysis::SourceLocations::SourceLocations ( )
inline

Default constructor.

Creates a mapping that has no links between source and binary.

Definition at line 49 of file SourceLocations.h.

Member Function Documentation

void Rose::BinaryAnalysis::SourceLocations::insert ( const SourceLocation ,
rose_addr_t   
)

Insert links between source and adresseses.

If the source location is empty then the address is removed from the mapping.

void Rose::BinaryAnalysis::SourceLocations::insert ( const SourceLocation ,
const AddressInterval  
)

Insert links between source and adresseses.

If the source location is empty then the address is removed from the mapping.

void Rose::BinaryAnalysis::SourceLocations::insert ( const SourceLocation ,
const AddressIntervalSet  
)

Insert links between source and adresseses.

If the source location is empty then the address is removed from the mapping.

void Rose::BinaryAnalysis::SourceLocations::erase ( const SourceLocation ,
rose_addr_t   
)

Remove links between source and addresses.

Links between the source location and the address (either direction) are removed only if those links exist. No other links are affected. Since links to empty source locations never exist, calling this with an empty source location has no effect.

void Rose::BinaryAnalysis::SourceLocations::erase ( const SourceLocation ,
const AddressInterval  
)

Remove links between source and addresses.

Links between the source location and the address (either direction) are removed only if those links exist. No other links are affected. Since links to empty source locations never exist, calling this with an empty source location has no effect.

void Rose::BinaryAnalysis::SourceLocations::erase ( const SourceLocation ,
const AddressIntervalSet  
)

Remove links between source and addresses.

Links between the source location and the address (either direction) are removed only if those links exist. No other links are affected. Since links to empty source locations never exist, calling this with an empty source location has no effect.

void Rose::BinaryAnalysis::SourceLocations::erase ( const SourceLocation )

Remove all links for the specified source location regardless of address.

void Rose::BinaryAnalysis::SourceLocations::clear ( )

Remove all links.

void Rose::BinaryAnalysis::SourceLocations::insertFromDebug ( SgNode ast)

Insert information from debug tables.

This method traverses the specified AST to find the ELF DWARF information that specifies mappings between source code and addresses and adds that information to this object.

void Rose::BinaryAnalysis::SourceLocations::fillHoles ( size_t  maxHoleSize = 64)

Fill in small holes in the address space.

The DWARF information stored in a file typically maps source location to only the first virtual address for that source location. This method fills in the mapping so that any unmapped virtual address within a certain delta of a previous mapped address will map to the same source location as the previous mapped address. Mappings will be added only for addresses where the distance between the next lower mapped address and the next higher mapped address is less than or equal to maxHoleSize.

AddressIntervalSet Rose::BinaryAnalysis::SourceLocations::get ( const SourceLocation ) const

Find the addresses associated with a source location.

std::set<boost::filesystem::path> Rose::BinaryAnalysis::SourceLocations::allFileNames ( ) const

Get the list of all known source files.

SourceLocation Rose::BinaryAnalysis::SourceLocations::nextSourceLocation ( const SourceLocation current = SourceLocation()) const

Given a source location, return the next source location.

Returns the next source location that has a mapping to some address. The order will be first by increaing column number, then by increasing line number, and finally by different file names. The file names are not sorted. When called with no source location then the first source location is returned. When there is no next source location then an empty source location is returned.

void Rose::BinaryAnalysis::SourceLocations::printSrcToAddr ( std::ostream &  ,
const std::string &  prefix = "" 
) const

Print the source to address mapping.

Each line of output is the specified prefix, the source location, a colon, and a space separated list of addresses.

void Rose::BinaryAnalysis::SourceLocations::print ( std::ostream &  ,
const std::string &  prefix = "" 
) const

Print the source to address mapping.

Each line of output is the specified prefix, the source location, a colon, and a space separated list of addresses.

void Rose::BinaryAnalysis::SourceLocations::printAddrToSrc ( std::ostream &  ,
const std::string &  prefix = "" 
) const

Print the address to source mapping.

Each line of output is the specified prefix, an address or address interval, a colon, and the source location.


The documentation for this class was generated from the following file: