OpenASIP  2.0
DebugStabElem.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file DebugStabElem.cc
26  *
27  * Non-inline definitions of DebugStabElem class.
28  *
29  * @author Mikael Lepistö 2006 (tmlepist-no.spam-cs.tut.fi)
30  *
31  * @note rating: yellow
32  */
33 
34 #include "DebugStabElem.hh"
35 
36 namespace TPEF {
37 
38 /**
39  * Constructor.
40  *
41  * Creates debug element out of data vector, where all the data
42  * is stored in big endian format.
43  *
44  * This constructor is used when additional data part of debug
45  * element is read from data is read from TPEF file to table.
46  *
47  * @param data Data vector that is used to initialize a.out stab element.
48  */
49 DebugStabElem::DebugStabElem(std::vector<Byte>& data)
50  : DebugElement() {
51 
52  // read element to object
53  stabType_ = data[0];
54  other_ = data[1];
55  description_ = data[2];
56  description_ = (description_ << BYTE_BITWIDTH) | data[3];
57  value_ = data[4];
58  value_ = (value_ << BYTE_BITWIDTH) | data[5];
59  value_ = (value_ << BYTE_BITWIDTH) | data[6];
60  value_ = (value_ << BYTE_BITWIDTH) | data[7];
61 }
62 
63 
64 /**
65  * Constructor.
66  *
67  * @param stabType A.out stab's type field.
68  * @param other A.out stab's other field.
69  * @param desscription A.out stab's description field.
70  * @param value A.out stab's value field.
71  */
73  Byte stabType, Byte other, HalfWord description, Word value) :
74  DebugElement(), stabType_(stabType), other_(other),
75  description_(description), value_(value) {
76 }
77 
78 
79 /**
80  * Destructor.
81  */
83 }
84 
85 
86 /**
87  * Returns one byte of debug element's additional data field.
88  *
89  * @param index Which data byte is wanted.
90  */
91 Byte
92 DebugStabElem::byte(Word index) const {
93  switch (index) {
94  case 0:
95  return stabType_;
96  case 1:
97  return other_;
98  case 2:
99  return description_ >> BYTE_BITWIDTH;
100  case 3:
101  return description_;
102  case 4:
103  return value_ >> (3*BYTE_BITWIDTH);
104  case 5:
105  return value_ >> (2*BYTE_BITWIDTH);
106  case 6:
107  return value_ >> BYTE_BITWIDTH;
108  case 7:
109  return value_;
110  default:
111  throw OutOfRange(__FILE__, __LINE__, __func__,
112  "Stab element contains less data that requested.");
113  }
114 }
115 
116 /**
117  * Returns additional data length of TPEF debug element.
118  *
119  * TPEF debug element for sotring a.out stab symbols contains
120  * always 8 bytes of additional data. This element is described
121  * in TPEF specification.
122  *
123  * @return Number of additional data bytes that are stored.
124  */
125 Word
127  return 8;
128 }
129 
130 
131 /**
132  * Returns type of TPEF debug element.
133  *
134  * @return Type of TPEF debug element.
135  */
138  return DE_STAB;
139 }
140 
141 
142 /**
143  * Returns type of stored a.out stab symbol.
144  *
145  * @return Type of stored a.out stab symbol.
146  */
147 Byte
149  return stabType_;
150 }
151 
152 
153 /**
154  * Returns other field of stored a.out stab symbol.
155  *
156  * @return Other field of stored a.out stab symbol.
157  */
158 Byte
160  return other_;
161 }
162 
163 
164 /**
165  * Returns description field of stored a.out stab symbol.
166  *
167  * @return Description field of stored a.out stab symbol.
168  */
169 HalfWord
171  return description_;
172 }
173 
174 
175 /**
176  * Returns value field of stored a.out stab symbol.
177  *
178  * @return Value field of stored a.out stab symbol.
179  */
180 Word
182  return value_;
183 }
184 
185 } // namespace TPEF
TPEF::DebugStabElem::other
Byte other() const
Definition: DebugStabElem.cc:159
TPEF::DebugStabElem::length
virtual Word length() const
Definition: DebugStabElem.cc:126
OutOfRange
Definition: Exception.hh:320
Byte
unsigned char Byte
Definition: BaseType.hh:116
TPEF::DebugElement::DE_STAB
@ DE_STAB
Definition: DebugElement.hh:59
TPEF::DebugStabElem::description
HalfWord description() const
Definition: DebugStabElem.cc:170
TPEF::DebugStabElem::description_
HalfWord description_
a.out stab description field.
Definition: DebugStabElem.hh:76
TPEF::DebugStabElem::~DebugStabElem
virtual ~DebugStabElem()
Definition: DebugStabElem.cc:82
TPEF::DebugStabElem::stabType_
Byte stabType_
a.out stab type.
Definition: DebugStabElem.hh:72
TPEF::DebugStabElem::stabType
Byte stabType() const
Definition: DebugStabElem.cc:148
__func__
#define __func__
Definition: Application.hh:67
TPEF::DebugStabElem::value_
Word value_
a.out stab value field.
Definition: DebugStabElem.hh:78
TPEF::DebugStabElem::other_
Byte other_
a.out stab other field.
Definition: DebugStabElem.hh:74
TPEF::DebugStabElem::DebugStabElem
DebugStabElem(std::vector< Byte > &data)
Definition: DebugStabElem.cc:49
BYTE_BITWIDTH
const Byte BYTE_BITWIDTH
Definition: BaseType.hh:136
TPEF::DebugStabElem::type
virtual ElementType type() const
Definition: DebugStabElem.cc:137
TPEF::DebugStabElem::value
Word value() const
Definition: DebugStabElem.cc:181
TPEF::DebugElement
Definition: DebugElement.hh:56
TPEF::DebugElement::ElementType
ElementType
Definition: DebugElement.hh:58
DebugStabElem.hh
TPEF
Definition: Assembler.hh:43
TPEF::DebugStabElem::byte
virtual Byte byte(Word index) const
Definition: DebugStabElem.cc:92