decompiler  1.0.0
Public Member Functions | Private Attributes | List of all members
ghidra::RangeList Class Reference

A disjoint set of Ranges, possibly across multiple address spaces. More...

#include <address.hh>

Public Member Functions

 RangeList (const RangeList &op2)
 Copy constructor.
 
 RangeList (void)
 Construct an empty container.
 
void clear (void)
 Clear this container to empty.
 
bool empty (void) const
 Return true if this is empty.
 
set< Range >::const_iterator begin (void) const
 Get iterator to beginning Range.
 
set< Range >::const_iterator end (void) const
 Get iterator to ending Range.
 
int4 numRanges (void) const
 Return the number of Range objects in container.
 
const RangegetFirstRange (void) const
 Get the first Range. More...
 
const RangegetLastRange (void) const
 Get the last Range. More...
 
const RangegetLastSignedRange (AddrSpace *spaceid) const
 Get the last Range viewing offsets as signed. More...
 
const RangegetRange (AddrSpace *spaceid, uintb offset) const
 Get Range containing the given byte. More...
 
void insertRange (AddrSpace *spc, uintb first, uintb last)
 Insert a range of addresses. More...
 
void removeRange (AddrSpace *spc, uintb first, uintb last)
 Remove a range of addresses. More...
 
void merge (const RangeList &op2)
 Merge another RangeList into this.
 
bool inRange (const Address &addr, int4 size) const
 Check containment an address range. More...
 
uintb longestFit (const Address &addr, uintb maxsize) const
 Find size of biggest Range containing given address. More...
 
void printBounds (ostream &s) const
 Print a description of this RangeList to stream. More...
 
void encode (Encoder &encoder) const
 Encode this RangeList to a stream. More...
 
void decode (Decoder &decoder)
 Decode this RangeList from a <rangelist> element. More...
 

Private Attributes

set< Rangetree
 The sorted list of Range objects.
 

Detailed Description

A disjoint set of Ranges, possibly across multiple address spaces.

This is a container for addresses. It maintains a disjoint list of Ranges that cover all the addresses in the container. Ranges can be inserted and removed, but overlapping/adjacent ranges will get merged.

Member Function Documentation

◆ decode()

void ghidra::RangeList::decode ( Decoder decoder)

Decode this RangeList from a <rangelist> element.

Recover each individual disjoint Range for this RangeList.

Parameters
decoderis the stream decoder

References ghidra::calc_mask(), ghidra::Decoder::closeElement(), ghidra::Range::decode(), ghidra::Decoder::openElement(), and ghidra::Decoder::peekElement().

Referenced by ghidra::SymbolEntry::decode(), and ghidra::ScopeInternal::decode().

◆ encode()

void ghidra::RangeList::encode ( Encoder encoder) const

Encode this RangeList to a stream.

Encode this as a <rangelist> element

Parameters
encoderis the stream encoder

References ghidra::Encoder::closeElement(), and ghidra::Encoder::openElement().

Referenced by ghidra::SymbolEntry::encode(), and ghidra::ScopeInternal::encode().

◆ getFirstRange()

const Range * ghidra::RangeList::getFirstRange ( void  ) const

Get the first Range.

Returns
the first contiguous range of addresses or NULL if empty

Referenced by ghidra::ScopeLocal::addRecommendName(), ghidra::SymbolEntry::getFirstUseAddress(), and ghidra::SymbolEntry::getSubsort().

◆ getLastRange()

const Range * ghidra::RangeList::getLastRange ( void  ) const

Get the last Range.

Returns
the last contiguous range of addresses or NULL if empty

◆ getLastSignedRange()

const Range * ghidra::RangeList::getLastSignedRange ( AddrSpace spaceid) const

Get the last Range viewing offsets as signed.

Treating offsets with their high-bits set as coming before offset where the high-bit is clear, return the last/latest contiguous Range within the given address space

Parameters
spaceidis the given address space
Returns
indicated Range or NULL if empty

References ghidra::AddrSpace::getHighest().

Referenced by ghidra::MapState::initialize().

◆ getRange()

const Range * ghidra::RangeList::getRange ( AddrSpace spaceid,
uintb  offset 
) const

Get Range containing the given byte.

If this RangeList contains the specific address (spaceid,offset), return it

Returns
the containing Range or NULL

◆ inRange()

bool ghidra::RangeList::inRange ( const Address addr,
int4  size 
) const

Check containment an address range.

Make sure indicated range of addresses is contained in this RangeList

Parameters
addris the first Address in the target range
sizeis the number of bytes in the target range
Returns
true is the range is fully contained by this RangeList

References ghidra::Address::getOffset(), ghidra::Address::getSpace(), and ghidra::Address::isInvalid().

Referenced by ghidra::MapState::addRange(), ghidra::ScopeLocal::buildVariableName(), ghidra::FuncCallSpecs::checkInputTrialUse(), ghidra::BlockBasic::contains(), ghidra::Heritage::handleNewLoadCopies(), ghidra::Scope::inScope(), ghidra::SymbolEntry::inUse(), and ghidra::ScopeGhidra::removeQuery().

◆ insertRange()

void ghidra::RangeList::insertRange ( AddrSpace spc,
uintb  first,
uintb  last 
)

Insert a range of addresses.

Insert a new Range merging as appropriate to maintain the disjoint cover

Parameters
spcis the address space containing the new range
firstis the offset of the first byte in the new range
lastis the offset of the last byte in the new range

Referenced by ghidra::Scope::addDynamicSymbol(), ghidra::Scope::addEquateSymbol(), ghidra::Scope::addMapPoint(), ghidra::Scope::addUnionFacetSymbol(), ghidra::ScopeGhidra::decodeHole(), ghidra::ScopeGhidra::dump2Cache(), ghidra::ParamListStandard::getRangeList(), ghidra::LoadImageXml::getReadonly(), ghidra::Heritage::handleNewLoadCopies(), ghidra::ScopeLocal::remapSymbol(), and ghidra::ScopeLocal::remapSymbolDynamic().

◆ longestFit()

uintb ghidra::RangeList::longestFit ( const Address addr,
uintb  maxsize 
) const

Find size of biggest Range containing given address.

Return the size of the biggest contiguous sequence of addresses in this RangeList which contain the given address

Parameters
addris the given address
maxsizeis the large range to consider before giving up
Returns
the size (in bytes) of the biggest range

References ghidra::Address::getOffset(), ghidra::Address::getSpace(), and ghidra::Address::isInvalid().

Referenced by ghidra::ScopeLocal::adjustFit().

◆ printBounds()

void ghidra::RangeList::printBounds ( ostream &  s) const

Print a description of this RangeList to stream.

Print a one line description of each disjoint Range making up this RangeList

Parameters
sis the output stream

Referenced by ghidra::Scope::printBounds(), and ghidra::SymbolEntry::printEntry().

◆ removeRange()

void ghidra::RangeList::removeRange ( AddrSpace spc,
uintb  first,
uintb  last 
)

Remove a range of addresses.

Remove/narrow/split existing Range objects to eliminate the indicated addresses while still maintaining a disjoint cover.

Parameters
spcis the address space of the address range to remove
firstis the offset of the first byte of the range
lastis the offset of the last byte of the range

Referenced by ghidra::MapState::MapState().


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