simulavr  1.1.0
Memory Class Referenceabstract

Hold a memory block and symbol informations. More...

#include <memory.h>

Inheritance diagram for Memory:

Public Member Functions

 Memory (int size)
 
virtual ~Memory ()
 
std::string GetSymbolAtAddress (unsigned int add)
 
unsigned int GetAddressAtSymbol (const std::string &s)
 
void AddSymbol (std::pair< unsigned int, std::string > p)
 
unsigned int GetSize ()
 
virtual void WriteMem (const unsigned char *, unsigned int offset, unsigned int size)=0
 

Public Attributes

unsigned char * myMemory
 
std::multimap< unsigned int, std::string > sym
 

Protected Attributes

unsigned int size
 

Detailed Description

Hold a memory block and symbol informations.

Memory class to hold memory content and symbol informations to map symbols to addresses and vice versa.

Definition at line 38 of file memory.h.

Constructor & Destructor Documentation

◆ Memory()

Memory::Memory ( int  size)

Creates the memory block

Parameters
sizethe memory block size

Definition at line 109 of file memory.cpp.

References avr_new, myMemory, and size.

◆ ~Memory()

virtual Memory::~Memory ( )
inlinevirtual

Destructor, frees myMemory

Definition at line 56 of file memory.h.

References avr_free(), GetAddressAtSymbol(), and GetSymbolAtAddress().

Member Function Documentation

◆ AddSymbol()

void Memory::AddSymbol ( std::pair< unsigned int, std::string >  p)
inline

Add the (address, symbol) pair

Parameters
pa std::pair with address and symbol string

Definition at line 82 of file memory.h.

Referenced by ELFLoad().

◆ GetAddressAtSymbol()

unsigned int Memory::GetAddressAtSymbol ( const std::string &  s)

Returns the address for a symbol

If the given string is a hex string, the hex value will be converted and returned. If the symbol isn't found, program aborts.

Parameters
sthe symbol string or hex string
Returns
address for symbol or value of hex string
Todo:
if the symbol isn't found, it aborts with a message. Maybe it should raise a exeption to handle this on the caller side?

Definition at line 35 of file memory.cpp.

References avr_error, avr_free(), and avr_new.

Referenced by AvrDevice::RegisterTerminationSymbol(), and ~Memory().

◆ GetSize()

unsigned int Memory::GetSize ( )
inline

Returns the size in bytes of memory block

Definition at line 85 of file memory.h.

References size, and WriteMem().

Referenced by avr_op_RCALL::operator()(), avr_op_RJMP::operator()(), HWEeprom::SetEearh(), and AvrDevice::Step().

◆ GetSymbolAtAddress()

string Memory::GetSymbolAtAddress ( unsigned int  add)

Return string with symbols found at address

Seeks for symbols, which are registered for the given address. If the address isn't equal to a symbol address, but before the next one, then a offset to symbol address will be added. Returns a empty string, if nothing is found. (in case of no given symbols!)

Parameters
addthe given address
Returns
a string with all found symbols, concatenated by ','

Definition at line 67 of file memory.cpp.

Referenced by AvrDevice::Step(), and ~Memory().

◆ WriteMem()

virtual void Memory::WriteMem ( const unsigned char *  ,
unsigned int  offset,
unsigned int  size 
)
pure virtual

Write memory data to memory

Implemented in Data, HWEeprom, and AvrFlash.

Referenced by GetSize().

Member Data Documentation

◆ myMemory

◆ size

◆ sym

std::multimap<unsigned int, std::string> Memory::sym

address to symbol map

Definition at line 48 of file memory.h.


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