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 Range * getFirstRange (void) const
 Get the first Range. More...
 
const Range * getLastRange (void) const
 Get the last Range. More...
 
const Range * getLastSignedRange (AddrSpace *spaceid) const
 Get the last Range viewing offsets as signed. More...
 
const Range * getRange (AddrSpace *spaceid, uintb offset) const
 Get Range containing the given byte. More...
 
const Range * getNearestRange (AddrSpace *spaceid, uintb offset) const
 Get the nearest Range to the given byte. More...
 
void insertRange (AddrSpace *spc, uintb first, uintb last)
 Insert a range of addresses. More...
 
void insertRange (const Range &rng)
 Insert a range.
 
void removeRange (AddrSpace *spc, uintb first, uintb last)
 Remove a range of addresses. More...
 
void removeRange (const Range &rng)
 Remove a range.
 
void merge (const RangeList &op2)
 Merge another RangeList into this.
 
bool inRange (const Address &addr, uintb size) const
 Check containment an address range. More...
 
bool inRange (const Range &rng) const
 Check containment of given 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< Range > tree
 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::Decoder::closeElement(), ghidra::Range::decode(), ghidra::Decoder::openElement(), ghidra::Decoder::peekElement(), and tree.

Referenced by ghidra::MapEntry::decode(), ghidra::DynamicEntry::decode(), ghidra::ScopeInternal::decode(), and ghidra::BlockBasic::decodeBody().

◆ 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(), ghidra::Encoder::openElement(), and tree.

Referenced by ghidra::MapEntry::encode(), ghidra::MapEntryConflict::encode(), ghidra::DynamicEntry::encode(), ghidra::ScopeInternal::encode(), and ghidra::BlockBasic::encodeBody().

◆ getFirstRange()

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

◆ getLastRange()

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

Get the last Range.

Returns
the last contiguous range of addresses or NULL if empty

References tree.

Referenced by ghidra::AliasChecker::deriveBoundaries(), and ghidra::BlockBasic::getStop().

◆ 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(), and tree.

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

◆ getNearestRange()

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

Get the nearest Range to the given byte.

If this contains no Range in the given address space, null is returned. If a range contains offset, it is returned. Otherwise the range with a boundary point closest to offset is returned. If two ranges are equidistant to offset, the earlier Range is returned.

Parameters
spaceidis the given address space
offsetis the given offset
Returns
the nearest Range in the same address space or null

References ghidra::Range::first, ghidra::Range::last, ghidra::Range::spc, and tree.

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

◆ 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

References tree.

Referenced by ghidra::BlockBasic::getEntryAddr(), and ghidra::MapState::initialize().

◆ inRange() [1/2]

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

◆ inRange() [2/2]

bool ghidra::RangeList::inRange ( const Range &  rng) const

Check containment of given range.

Parameters
rngis the target range
Returns
true if the range is fully contained by this RangeList

References ghidra::Range::getSpace(), ghidra::Range::last, and tree.

◆ insertRange()

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

◆ 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(), ghidra::Address::isInvalid(), and tree.

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

References tree.

Referenced by ghidra::Scope::printBounds(), ghidra::MapEntry::printEntry(), and ghidra::DynamicEntry::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

References tree.

Referenced by ghidra::MapState::MapState(), and ghidra::Scope::removeRange().


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