OpenASIP 2.2
Loading...
Searching...
No Matches
Protected Member Functions | Private Member Functions | Static Private Attributes | List of all members
TPEF::TPEFDebugSectionReader Class Reference

#include <TPEFDebugSectionReader.hh>

Inheritance diagram for TPEF::TPEFDebugSectionReader:
Inheritance graph
Collaboration diagram for TPEF::TPEFDebugSectionReader:
Collaboration graph

Protected Member Functions

 TPEFDebugSectionReader ()
 
virtual ~TPEFDebugSectionReader ()
 
virtual void readData (BinaryStream &stream, Section *section) const
 
virtual Section::SectionType type () const
 
- Protected Member Functions inherited from TPEF::TPEFSectionReader
 TPEFSectionReader ()
 
virtual BinaryReaderparent () const
 
virtual void readInfo (BinaryStream &stream, Section *sect) const
 
- Protected Member Functions inherited from TPEF::SectionReader
 SectionReader ()
 
virtual void finalize (Section *section) const
 

Private Member Functions

 TPEFDebugSectionReader (const TPEFDebugSectionReader &)
 Copying not allowed.
 
TPEFDebugSectionReaderoperator= (TPEFDebugSectionReader &)
 Assignment not allowed.
 

Static Private Attributes

static TPEFDebugSectionReader proto_
 Prototype instance of TPEFDebugSectionReader to be registered to SectionReader.
 

Additional Inherited Members

- Public Types inherited from TPEF::SectionReader
typedef BinaryReader::Length Length
 
- Public Member Functions inherited from TPEF::TPEFSectionReader
virtual ~TPEFSectionReader ()
 
- Public Member Functions inherited from TPEF::SectionReader
virtual ~SectionReader ()
 
- Static Public Member Functions inherited from TPEF::SectionReader
static void readSection (BinaryStream &stream, Section *section, BinaryReader *reader)
 
static void finalizeBinary (Binary *binaryToFinalize, BinaryReader *reader)
 
- Static Protected Member Functions inherited from TPEF::TPEFSectionReader
static const Headerheader ()
 
- Static Protected Member Functions inherited from TPEF::SectionReader
static const SectionReaderfindSectionReader (const Section::SectionType type, const BinaryReader *bReader)
 
static void registerSectionReader (const SectionReader *sReader)
 

Detailed Description

Reads debug section from TPEF binary file.

Definition at line 46 of file TPEFDebugSectionReader.hh.

Constructor & Destructor Documentation

◆ TPEFDebugSectionReader() [1/2]

TPEF::TPEFDebugSectionReader::TPEFDebugSectionReader ( )
protected

Constructor.

Registers itself to SectionReader.

Definition at line 59 of file TPEFDebugSectionReader.cc.

61}
static void registerSectionReader(const SectionReader *sReader)

References TPEF::SectionReader::registerSectionReader().

Here is the call graph for this function:

◆ ~TPEFDebugSectionReader()

TPEF::TPEFDebugSectionReader::~TPEFDebugSectionReader ( )
protectedvirtual

Destructor.

Definition at line 66 of file TPEFDebugSectionReader.cc.

66 {
67}

◆ TPEFDebugSectionReader() [2/2]

TPEF::TPEFDebugSectionReader::TPEFDebugSectionReader ( const TPEFDebugSectionReader )
private

Copying not allowed.

Member Function Documentation

◆ operator=()

TPEFDebugSectionReader & TPEF::TPEFDebugSectionReader::operator= ( TPEFDebugSectionReader )
private

Assignment not allowed.

◆ readData()

void TPEF::TPEFDebugSectionReader::readData ( BinaryStream stream,
Section section 
) const
protectedvirtual

Reads section data from TPEF binary file.

Parameters
streamStream to be read from.
sectionSection where the information is to be stored.
Exceptions
UnreachableStreamIf reading of section fails.
KeyAlreadyExistsKey was in use when trying to register object.
EndOfFileIf end of file were reached while it shouldn't.
OutOfRangeSome of read value were out of range.
WrongSubclassSome class couldn't do what it was asked for.
UnexpectedValueIf there was unexpected value when reading.

Reimplemented from TPEF::TPEFSectionReader.

Definition at line 92 of file TPEFDebugSectionReader.cc.

92 {
93 // size taken by fields common to any type of debug section element
94 const std::size_t BASE_ELEM_SIZE = 10;
95
96 // base classes implementation must be called with these.
97 TPEFSectionReader::readData(stream, section);
98
99 DebugSection* debugSection =
100 dynamic_cast<DebugSection*>(section);
101 assert(debugSection != NULL);
102
103 // check that link section is defined properly
104 assert(header().linkId != 0);
105
106 if (!section->noBits()) {
107 // start of first element
108 SectionOffset currElement = header().bodyOffset;
109
110 while (currElement < header().bodyOffset + header().bodyLength) {
111
112 HalfWord type = stream.readHalfWord();
113 Word stringOffset = stream.readWord();
114 Word size = stream.readWord();
115
116 std::vector<Byte> data;
117
118 for (unsigned i = 0; i < size; i++) {
119 data.push_back(stream.readByte());
120 }
121
122 DebugElement* newElem = NULL;
123
124 switch (static_cast<DebugElement::ElementType>(type)) {
126 newElem = new DebugStabElem(data);
127 break;
128 default:
129 throw UnexpectedValue(
130 __FILE__, __LINE__, __func__,
131 "Unknown debug element type: " +
133 }
134
135 // set name string for element
136 SectionOffsetKey sOffKey(header().linkId, stringOffset);
137 newElem->setDebugString(CREATE_SAFEPOINTER(sOffKey));
138
139 section->addElement(newElem);
140
141 currElement += size + BASE_ELEM_SIZE;
142 stream.setReadPosition(currElement);
143 }
144 }
145}
#define __func__
#define assert(condition)
static std::string toString(const T &source)
virtual Section::SectionType type() const
virtual void readData(BinaryStream &stream, Section *section) const
static const Header & header()
Word SectionOffset
Type for storing offsets relative to a given base offset value.

References __func__, TPEF::Section::addElement(), assert, TPEF::TPEFSectionReader::Header::bodyOffset, TPEF::DebugElement::DE_STAB, TPEF::TPEFSectionReader::header(), TPEF::Section::noBits(), TPEF::BinaryStream::readByte(), TPEF::TPEFSectionReader::readData(), TPEF::BinaryStream::readHalfWord(), TPEF::BinaryStream::readWord(), TPEF::DebugElement::setDebugString(), TPEF::BinaryStream::setReadPosition(), Conversion::toString(), and type().

Here is the call graph for this function:

◆ type()

Section::SectionType TPEF::TPEFDebugSectionReader::type ( ) const
protectedvirtual

Returns the type of section it is meant to read.

Returns
The type of section it can read.

Implements TPEF::SectionReader.

Definition at line 75 of file TPEFDebugSectionReader.cc.

75 {
76 return Section::ST_DEBUG;
77}
@ ST_DEBUG
Debug section.
Definition Section.hh:73

References TPEF::Section::ST_DEBUG.

Referenced by readData().

Member Data Documentation

◆ proto_

TPEFDebugSectionReader TPEF::TPEFDebugSectionReader::proto_
staticprivate

Prototype instance of TPEFDebugSectionReader to be registered to SectionReader.

Definition at line 63 of file TPEFDebugSectionReader.hh.


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