Loading...
Searching...
No Matches
TrcMemAccessorFile Class Reference

Memory accessor for a binary file. More...

`#include <trc_mem_acc_file.h>`

Inheritance diagram for TrcMemAccessorFile:
[legend]
Collaboration diagram for TrcMemAccessorFile:
[legend]

## Public Member Functions

virtual const uint32_t | readBytes (const ocsd_vaddr_t address, const ocsd_mem_space_acc_t memSpace, const uint8_t trcID, const uint32_t reqBytes, uint8_t *byteBuffer)
bool | AddOffsetRange (const ocsd_vaddr_t startAddr, const size_t size, const size_t offset)
virtual const bool | addrInRange (const ocsd_vaddr_t s_address) const
virtual const bool | addrStartOfRange (const ocsd_vaddr_t s_address) const
virtual const uint32_t | bytesInRange (const ocsd_vaddr_t s_address, const uint32_t reqBytes) const
virtual const bool | overLapRange (const TrcMemAccessorBase *p_test_acc) const
virtual void | getMemAccString (std::string &accStr) const
Public Member Functions inherited from TrcMemAccessorBase
| TrcMemAccessorBase (MemAccTypes type)
| TrcMemAccessorBase (MemAccTypes type, ocsd_vaddr_t startAddr, ocsd_vaddr_t endAddr)
virtual | ~TrcMemAccessorBase ()
void | setRange (ocsd_vaddr_t startAddr, ocsd_vaddr_t endAddr)
enum MemAccTypes | getType () const
void | setMemSpace (ocsd_mem_space_acc_t memSpace)
const ocsd_mem_space_acc_t | getMemSpace () const
const bool | inMemSpace (const ocsd_mem_space_acc_t mem_space) const

## Static Public Member Functions

static ocsd_err_t | createFileAccessor (TrcMemAccessorFile **p_acc, const std::string &pathToFile, ocsd_vaddr_t startAddr, size_t offset=0, size_t size=0)
static void | destroyFileAccessor (TrcMemAccessorFile *p_accessor)
static const bool | isExistingFileAccessor (const std::string &pathToFile)
static TrcMemAccessorFile * | getExistingFileAccessor (const std::string &pathToFile)

## Protected Member Functions

| TrcMemAccessorFile ()
virtual | ~TrcMemAccessorFile ()
void | IncRefCount ()
void | DecRefCount ()
const int | getRefCount () const
ocsd_err_t | initAccessor (const std::string &pathToFile, ocsd_vaddr_t startAddr, size_t offset, size_t size)
const std::string & | getFilePath () const
FileRegionMemAccessor * | getRegionForAddress (const ocsd_vaddr_t startAddr) const
virtual const bool | validateRange ()

## Additional Inherited Members

Public Types inherited from TrcMemAccessorBase
enum | MemAccTypes { MEMACC_UNKNOWN , MEMACC_FILE , MEMACC_BUFPTR , MEMACC_CB_IF }
Protected Attributes inherited from TrcMemAccessorBase
ocsd_vaddr_t | m_startAddress
ocsd_vaddr_t | m_endAddress
const MemAccTypes | m_type
ocsd_mem_space_acc_t | m_mem_space

## Detailed Description

Memory accessor for a binary file.

Memory accessor based on a binary file snapshot of some memory.

Static creation code to allow reference counted accessor usable for multiple access maps attached to multiple source trees for the same system.

Definition at line 76 of file trc_mem_acc_file.h.

## Constructor & Destructor Documentation

## TrcMemAccessorFile()

TrcMemAccessorFile::TrcMemAccessorFile | ( |  | ) |

protected

protected default constructor

## ~TrcMemAccessorFile()

virtual TrcMemAccessorFile::~TrcMemAccessorFile | ( |  | ) |

protected virtual

protected default destructor

## Member Function Documentation

## AddOffsetRange()

bool TrcMemAccessorFile::AddOffsetRange | ( | const ocsd_vaddr_t | startAddr,
|  | const size_t | size,
|  | const size_t | offset
| ) |  |

File may contain multiple none-overlapping ranges in a single file.

Parameters

  startAddr | : Address for beginning of byte data.
  size | : size of range in bytes.
  offset | : offset into file for that data.

Returns
  bool : true if set successfully.

## addrInRange()

virtual const bool TrcMemAccessorFile::addrInRange | ( | const ocsd_vaddr_t | s_address | ) | const

virtual

Override in case we have multiple regions in the file.

Parameters

  s_address | : Address to test.

Returns
  const bool : true if the address is in range.

Reimplemented from TrcMemAccessorBase.

## addrStartOfRange()

virtual const bool TrcMemAccessorFile::addrStartOfRange | ( | const ocsd_vaddr_t | s_address | ) | const

virtual

test if an address is the start of range for this accessor

Parameters

  s_address | : Address to test.

Returns
  const bool : true if the address is start of range.

Reimplemented from TrcMemAccessorBase.

## bytesInRange()

virtual const uint32_t TrcMemAccessorFile::bytesInRange | ( | const ocsd_vaddr_t | s_address,
|  | const uint32_t | reqBytes
| ) |  | const

virtual

Test number of bytes available from the start address, up to the number of requested bytes. Tests if all the requested bytes are available from the supplied start address. Returns the number available up to full requested amount.

Parameters

  s_address | : Start address within the range.
  reqBytes | : Number of bytes needed from the start address.

Returns
  const uint32_t : Bytes available, up to reqBytes. 0 is s_address not in range.

Reimplemented from TrcMemAccessorBase.

## createFileAccessor()

static ocsd_err_t TrcMemAccessorFile::createFileAccessor | ( | TrcMemAccessorFile ** | p_acc,
|  | const std::string & | pathToFile,
|  | ocsd_vaddr_t | startAddr,
|  | size_t | offset = `0`,
|  | size_t | size = `0`
| ) |  |

static

Create a file accessor based on the supplied path and address. Keeps a list of file accessors created.

File will be checked to ensure valid accessor can be created.

If an accessor using the supplied file is currently in use then a reference to that accessor will be returned and the accessor reference counter updated.

Parameters

  &pathToFile | : Path to binary file
  startAddr | : Start address of data represented by file.

Returns
  TrcMemAccessorFile * : pointer to accessor if successful, 0 if it could not be created.

## DecRefCount()

void TrcMemAccessorFile::DecRefCount | ( |  | ) |

inline protected

decrement reference counter

Definition at line 90 of file trc_mem_acc_file.h.

## destroyFileAccessor()

static void TrcMemAccessorFile::destroyFileAccessor | ( | TrcMemAccessorFile * | p_accessor | ) |

static

Destroy supplied accessor.

Reference counter decremented and checked and accessor destroyed if no longer in use.

Parameters

  *p_accessor | : File Accessor to destroy.

## getExistingFileAccessor()

static TrcMemAccessorFile * TrcMemAccessorFile::getExistingFileAccessor | ( | const std::string & | pathToFile | ) |

static

Get the accessor using the supplied file path Use after createFileAccessor if additional memory ranges need adding to an exiting file accessor.

Parameters

  &pathToFile | : Path to test.

Returns
  TrcMemAccessorFile * : none 0 if an accessor exists with this file path.

## getFilePath()

const std::string & TrcMemAccessorFile::getFilePath | ( |  | ) | const

inline protected

get the file path

Definition at line 107 of file trc_mem_acc_file.h.

## getMemAccString()

virtual void TrcMemAccessorFile::getMemAccString | ( | std::string & | accStr | ) | const

virtual

Override to handle ranges and offset accessors plus add in file name.

Reimplemented from TrcMemAccessorBase.

## getRefCount()

const int TrcMemAccessorFile::getRefCount | ( |  | ) | const

inline protected

get current reference count

Definition at line 93 of file trc_mem_acc_file.h.

## getRegionForAddress()

FileRegionMemAccessor * TrcMemAccessorFile::getRegionForAddress | ( | const ocsd_vaddr_t | startAddr | ) | const

protected

get an offset region if extant for the address

## IncRefCount()

void TrcMemAccessorFile::IncRefCount | ( |  | ) |

inline protected

increment reference counter

Definition at line 87 of file trc_mem_acc_file.h.

## initAccessor()

ocsd_err_t TrcMemAccessorFile::initAccessor | ( | const std::string & | pathToFile,
|  | ocsd_vaddr_t | startAddr,
|  | size_t | offset,
|  | size_t | size
| ) |  |

protected

Initialise accessor with file name and path, and start address. File opened and length calculated to determine end address for the range.

Parameters

  &pathToFile | : Binary file path and name
  startAddr | : system memory address associated with start of binary datain file.

Returns
  bool : true if set up successfully, false if file could not be opened.

## isExistingFileAccessor()

static const bool TrcMemAccessorFile::isExistingFileAccessor | ( | const std::string & | pathToFile | ) |

static

Test if any accessor is currently using the supplied file path

Parameters

  &pathToFile | : Path to test.

Returns
  bool : true if an accessor exists with this file path.

## overLapRange()

virtual const bool TrcMemAccessorFile::overLapRange | ( | const TrcMemAccessorBase * | p_test_acc | ) | const

virtual

test is supplied range accessor overlaps this range.

Parameters

  *p_test_acc | : Accessor to test for overlap.

Returns
  bool : true if overlap, false if not.

Reimplemented from TrcMemAccessorBase.

## readBytes()

virtual const uint32_t TrcMemAccessorFile::readBytes | ( | const ocsd_vaddr_t | address,
|  | const ocsd_mem_space_acc_t | memSpace,
|  | const uint8_t | trcID,
|  | const uint32_t | reqBytes,
|  | uint8_t * | byteBuffer
| ) |  |

virtual

read bytes override - reads from file

Implements TrcMemAccessorBase.

## validateRange()

virtual const bool TrcMemAccessorFile::validateRange | ( |  | ) |

protected virtual

Validate the address range - ensure addresses aligned, different, st < en etc.

Returns
  bool : true if valid range.

Reimplemented from TrcMemAccessorBase.

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

- /build/libopencsd-16huoW/libopencsd-1.4.1/decoder/include/mem_acc/trc_mem_acc_file.h