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

Member Typedef Documentation

◆ AddressToSource

Definition at line 32 of file SourceLocations.h.

◆ SourceToAddress

Definition at line 33 of file SourceLocations.h.

Constructor & Destructor Documentation

◆ SourceLocations()

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

Default constructor.

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

Definition at line 55 of file SourceLocations.h.

Member Function Documentation

◆ insert() [1/3]

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.

◆ insert() [2/3]

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.

◆ insert() [3/3]

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.

◆ erase() [1/3]

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.

◆ erase() [2/3]

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.

◆ erase() [3/3]

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.

◆ insertFromDebug()

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.

◆ fillHoles()

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.

◆ operator()() [1/2]

SourceLocation Rose::BinaryAnalysis::SourceLocations::operator() ( rose_addr_t  va) const
inline

Find the source location for an address.

Definition at line 119 of file SourceLocations.h.

References get().

◆ operator()() [2/2]

Sawyer::Optional< rose_addr_t > Rose::BinaryAnalysis::SourceLocations::operator() ( const SourceLocation loc) const
inline

Find the first address associated with a source location.

Definition at line 131 of file SourceLocations.h.

References firstAddress().

◆ nextSourceLocation()

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.

◆ printSrcToAddr()

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.

◆ print()

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.

◆ printAddrToSrc()

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: