| 1 |
/* |
| 2 |
Copyright (C) 2010-2018 David Anderson. All rights reserved. |
| 3 |
|
| 4 |
Redistribution and use in source and binary forms, with |
| 5 |
or without modification, are permitted provided that the |
| 6 |
following conditions are met: |
| 7 |
|
| 8 |
* Redistributions of source code must retain the above |
| 9 |
copyright notice, this list of conditions and the following |
| 10 |
disclaimer. |
| 11 |
|
| 12 |
* Redistributions in binary form must reproduce the above |
| 13 |
copyright notice, this list of conditions and the following |
| 14 |
disclaimer in the documentation and/or other materials |
| 15 |
provided with the distribution. |
| 16 |
|
| 17 |
THIS SOFTWARE IS PROVIDED BY David Anderson ''AS IS'' |
| 18 |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT |
| 19 |
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
| 20 |
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN |
| 21 |
NO EVENT SHALL David Anderson BE LIABLE FOR ANY DIRECT, |
| 22 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 23 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
| 24 |
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 25 |
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 26 |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 27 |
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 29 |
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 |
|
| 31 |
*/ |
| 32 |
|
| 33 |
// |
| 34 |
// irepform.h |
| 35 |
// |
| 36 |
// |
| 37 |
class IRCUdata; |
| 38 |
class IRDie; |
| 39 |
class IRAttr; |
| 40 |
class IRFormInterface; |
| 41 |
|
| 42 |
// An Abstract class. |
| 43 |
class IRForm { |
| 44 |
public: |
| 45 |
//virtual void emitvalue() = 0; |
| 46 |
//IRForm & operator=(const IRForm &r); |
| 47 |
virtual IRForm * clone() const =0; |
| 48 |
virtual ~IRForm() {}; |
| 49 |
IRForm() {}; |
| 50 |
virtual enum Dwarf_Form_Class getFormClass() const = 0; |
| 51 |
private: |
| 52 |
}; |
| 53 |
|
| 54 |
class IRFormUnknown : public IRForm { |
| 55 |
public: |
| 56 |
IRFormUnknown(): |
| 57 |
finalform_(0), initialform_(0), |
| 58 |
formclass_(DW_FORM_CLASS_UNKNOWN) |
| 59 |
{} |
| 60 |
~IRFormUnknown() {}; |
| 61 |
IRFormUnknown(IRFormInterface *); |
| 62 |
IRFormUnknown(const IRFormUnknown &r) { |
| 63 |
finalform_ = r.finalform_; |
| 64 |
initialform_ = r.initialform_; |
| 65 |
formclass_ = r.formclass_; |
| 66 |
} |
| 67 |
virtual IRFormUnknown * clone() const { |
| 68 |
return new IRFormUnknown(*this); |
| 69 |
} |
| 70 |
IRFormUnknown & operator=(const IRFormUnknown &r) { |
| 71 |
if (this == &r) return *this; |
| 72 |
finalform_ = r.finalform_; |
| 73 |
initialform_ = r.initialform_; |
| 74 |
formclass_ = r.formclass_; |
| 75 |
return *this; |
| 76 |
}; |
| 77 |
enum Dwarf_Form_Class getFormClass() const { return formclass_; }; |
| 78 |
private: |
| 79 |
Dwarf_Half finalform_; |
| 80 |
// In most cases directform == indirect form. |
| 81 |
// Otherwise, directform == DW_FORM_indirect. |
| 82 |
Dwarf_Half initialform_; |
| 83 |
enum Dwarf_Form_Class formclass_; |
| 84 |
}; |
| 85 |
// An address class entry refers to some part |
| 86 |
// (normally a loadable) section of the object file. |
| 87 |
// Not to DWARF info. Typically into .text or .data for example. |
| 88 |
// We therefore want a section number and offset |
| 89 |
// (generally useless for us) |
| 90 |
// or preferably an elf symbol as that has a value |
| 91 |
// and an elf section number. |
| 92 |
// We often/usually know neither here so we do not even try. |
| 93 |
// Later we will make one up if we have to. |
| 94 |
class IRFormAddress : public IRForm { |
| 95 |
public: |
| 96 |
IRFormAddress(): |
| 97 |
finalform_(0), initialform_(0), |
| 98 |
formclass_(DW_FORM_CLASS_ADDRESS), |
| 99 |
address_(0) |
| 100 |
{}; |
| 101 |
IRFormAddress(IRFormInterface *); |
| 102 |
~IRFormAddress() {}; |
| 103 |
IRFormAddress & operator=(const IRFormAddress &r) { |
| 104 |
if (this == &r) return *this; |
| 105 |
finalform_ = r.finalform_; |
| 106 |
initialform_ = r.initialform_; |
| 107 |
formclass_ = r.formclass_; |
| 108 |
address_ = r.address_; |
| 109 |
return *this; |
| 110 |
}; |
| 111 |
IRFormAddress(const IRFormAddress &r) { |
| 112 |
finalform_ = r.finalform_; |
| 113 |
initialform_ = r.initialform_; |
| 114 |
formclass_ = r.formclass_; |
| 115 |
address_ = r.address_; |
| 116 |
} |
| 117 |
virtual IRFormAddress * clone() const { |
| 118 |
return new IRFormAddress(*this); |
| 119 |
}; |
| 120 |
void setInitialForm(Dwarf_Half v) { initialform_ = v;} |
| 121 |
void setFinalForm(Dwarf_Half v) { finalform_ = v;} |
| 122 |
Dwarf_Half getInitialForm() { return initialform_;} |
| 123 |
Dwarf_Half getFinalForm() {return finalform_;} |
| 124 |
Dwarf_Addr getAddress() { return address_;}; |
| 125 |
enum Dwarf_Form_Class getFormClass() const { return formclass_; }; |
| 126 |
private: |
| 127 |
void setAddress(Dwarf_Addr addr) { address_ = addr; }; |
| 128 |
Dwarf_Half finalform_; |
| 129 |
// In most cases directform == indirect form. |
| 130 |
// Otherwise, directform == DW_FORM_indirect. |
| 131 |
Dwarf_Half initialform_; |
| 132 |
enum Dwarf_Form_Class formclass_; |
| 133 |
Dwarf_Addr address_; |
| 134 |
}; |
| 135 |
class IRFormBlock : public IRForm { |
| 136 |
public: |
| 137 |
IRFormBlock(): |
| 138 |
finalform_(0), initialform_(0), |
| 139 |
formclass_(DW_FORM_CLASS_BLOCK), |
| 140 |
fromloclist_(0),sectionoffset_(0) |
| 141 |
{} |
| 142 |
IRFormBlock(IRFormInterface *); |
| 143 |
~IRFormBlock() {}; |
| 144 |
IRFormBlock & operator=(const IRFormBlock &r) { |
| 145 |
if (this == &r) return *this; |
| 146 |
finalform_ = r.finalform_; |
| 147 |
initialform_ = r.initialform_; |
| 148 |
formclass_ = r.formclass_; |
| 149 |
blockdata_ = r.blockdata_; |
| 150 |
fromloclist_ = r.fromloclist_; |
| 151 |
sectionoffset_ = r.sectionoffset_; |
| 152 |
return *this; |
| 153 |
}; |
| 154 |
IRFormBlock(const IRFormBlock &r) { |
| 155 |
finalform_ = r.finalform_; |
| 156 |
initialform_ = r.initialform_; |
| 157 |
formclass_ = r.formclass_; |
| 158 |
blockdata_ = r.blockdata_; |
| 159 |
fromloclist_ = r.fromloclist_; |
| 160 |
sectionoffset_ = r.sectionoffset_; |
| 161 |
} |
| 162 |
virtual IRFormBlock * clone() const { |
| 163 |
return new IRFormBlock(*this); |
| 164 |
} |
| 165 |
void setInitialForm(Dwarf_Half v) { initialform_ = v;} |
| 166 |
void setFinalForm(Dwarf_Half v) { finalform_ = v;} |
| 167 |
Dwarf_Half getInitialForm() { return initialform_;} |
| 168 |
Dwarf_Half getFinalForm() {return finalform_;} |
| 169 |
Dwarf_Unsigned getBlockLen() {return blockdata_.size();} |
| 170 |
Dwarf_Small* getBlockBytes() { |
| 171 |
// Standard guarantees vector content is simply array. |
| 172 |
return &blockdata_[0]; |
| 173 |
}; |
| 174 |
enum Dwarf_Form_Class getFormClass() const { |
| 175 |
return formclass_; |
| 176 |
}; |
| 177 |
void insertBlock(Dwarf_Block *bl) { |
| 178 |
Dwarf_Small *d = static_cast<Dwarf_Small *>(bl->bl_data); |
| 179 |
Dwarf_Unsigned len = bl->bl_len; |
| 180 |
blockdata_.clear(); |
| 181 |
blockdata_.insert(blockdata_.end(),d+0,d+len); |
| 182 |
fromloclist_ = bl->bl_from_loclist; |
| 183 |
sectionoffset_ = bl->bl_section_offset; |
| 184 |
}; |
| 185 |
std::vector<Dwarf_Small> getBlockData(){ return blockdata_;}; |
| 186 |
private: |
| 187 |
Dwarf_Half finalform_; |
| 188 |
// In most cases directform == indirect form. |
| 189 |
// Otherwise, directform == DW_FORM_indirect. |
| 190 |
Dwarf_Half initialform_; |
| 191 |
enum Dwarf_Form_Class formclass_; |
| 192 |
std::vector<Dwarf_Small> blockdata_; |
| 193 |
Dwarf_Small fromloclist_; |
| 194 |
Dwarf_Unsigned sectionoffset_; |
| 195 |
}; |
| 196 |
class IRFormConstant : public IRForm { |
| 197 |
public: |
| 198 |
enum Signedness {SIGN_NOT_SET,SIGN_UNKNOWN,UNSIGNED, SIGNED }; |
| 199 |
IRFormConstant(): |
| 200 |
finalform_(0), initialform_(0), |
| 201 |
formclass_(DW_FORM_CLASS_CONSTANT), |
| 202 |
signedness_(SIGN_NOT_SET), |
| 203 |
uval_(0), sval_(0) |
| 204 |
{ memset(&data16_,0,sizeof(data16_)); }; |
| 205 |
IRFormConstant(IRFormInterface *); |
| 206 |
~IRFormConstant() {}; |
| 207 |
IRFormConstant(Dwarf_Half finalform, |
| 208 |
Dwarf_Half initialform, |
| 209 |
enum Dwarf_Form_Class formclass, |
| 210 |
IRFormConstant::Signedness signedness, |
| 211 |
Dwarf_Unsigned uval, |
| 212 |
Dwarf_Signed sval) { |
| 213 |
finalform_ = finalform; |
| 214 |
initialform_ = initialform; |
| 215 |
formclass_ = formclass; |
| 216 |
signedness_ = signedness; |
| 217 |
uval_ = uval; |
| 218 |
sval_ = sval; |
| 219 |
}; |
| 220 |
IRFormConstant(Dwarf_Half finalform, |
| 221 |
Dwarf_Half initialform, |
| 222 |
enum Dwarf_Form_Class formclass, |
| 223 |
Dwarf_Form_Data16 & data16) { |
| 224 |
|
| 225 |
(void)formclass; |
| 226 |
finalform_ = finalform; |
| 227 |
initialform_ = initialform; |
| 228 |
formclass_ = DW_FORM_CLASS_CONSTANT; |
| 229 |
signedness_ = SIGN_UNKNOWN; |
| 230 |
uval_ = 0; |
| 231 |
sval_ = 0; |
| 232 |
data16_ = data16; |
| 233 |
}; |
| 234 |
IRFormConstant & operator=(const IRFormConstant &r) { |
| 235 |
if (this == &r) return *this; |
| 236 |
finalform_ = r.finalform_; |
| 237 |
initialform_ = r.initialform_; |
| 238 |
formclass_ = r.formclass_; |
| 239 |
signedness_ = r.signedness_; |
| 240 |
uval_ = r.uval_; |
| 241 |
sval_ = r.sval_; |
| 242 |
data16_ = r.data16_; |
| 243 |
return *this; |
| 244 |
}; |
| 245 |
IRFormConstant(const IRFormConstant &r) { |
| 246 |
finalform_ = r.finalform_; |
| 247 |
initialform_ = r.initialform_; |
| 248 |
formclass_ = r.formclass_; |
| 249 |
signedness_ = r.signedness_; |
| 250 |
uval_ = r.uval_; |
| 251 |
sval_ = r.sval_; |
| 252 |
data16_ = r.data16_; |
| 253 |
} |
| 254 |
virtual IRFormConstant * clone() const { |
| 255 |
return new IRFormConstant(*this); |
| 256 |
} |
| 257 |
void setInitialForm(Dwarf_Half v) { initialform_ = v;} |
| 258 |
void setFinalForm(Dwarf_Half v) { finalform_ = v;} |
| 259 |
Dwarf_Half getInitialForm() { return initialform_;} |
| 260 |
Dwarf_Half getFinalForm() {return finalform_;} |
| 261 |
Dwarf_Form_Class getFormClass() const { return formclass_; }; |
| 262 |
Signedness getSignedness() const {return signedness_; }; |
| 263 |
Dwarf_Signed getSignedVal() const {return sval_;}; |
| 264 |
Dwarf_Unsigned getUnsignedVal() const {return uval_;}; |
| 265 |
Dwarf_Form_Data16 getData16Val() const {return data16_;}; |
| 266 |
private: |
| 267 |
Dwarf_Half finalform_; |
| 268 |
// In most cases directform == indirect form. |
| 269 |
// Otherwise, directform == DW_FORM_indirect. |
| 270 |
Dwarf_Half initialform_; |
| 271 |
enum Dwarf_Form_Class formclass_; |
| 272 |
// Starts at SIGN_NOT_SET. |
| 273 |
// SIGN_UNKNOWN means it was a DW_FORM_data* of some |
| 274 |
// kind so we do not really know. |
| 275 |
Signedness signedness_; |
| 276 |
// Both uval_ and sval_ are always set to the same bits. |
| 277 |
Dwarf_Unsigned uval_; |
| 278 |
Dwarf_Signed sval_; |
| 279 |
Dwarf_Form_Data16 data16_; |
| 280 |
|
| 281 |
void setValues16(Dwarf_Form_Data16 *v, |
| 282 |
enum Signedness s) { |
| 283 |
(void)s; |
| 284 |
uval_ = 0; |
| 285 |
sval_ = 0; |
| 286 |
data16_ = *v; |
| 287 |
} |
| 288 |
void setValues(Dwarf_Signed sval, Dwarf_Unsigned uval, |
| 289 |
enum Signedness s) { |
| 290 |
signedness_ = s; |
| 291 |
uval_ = uval; |
| 292 |
sval_ = sval; |
| 293 |
} |
| 294 |
}; |
| 295 |
|
| 296 |
class IRFormExprloc : public IRForm { |
| 297 |
public: |
| 298 |
IRFormExprloc(): |
| 299 |
finalform_(0), initialform_(0), |
| 300 |
formclass_(DW_FORM_CLASS_EXPRLOC) |
| 301 |
{}; |
| 302 |
IRFormExprloc(IRFormInterface *); |
| 303 |
~IRFormExprloc() {}; |
| 304 |
IRFormExprloc & operator=(const IRFormExprloc &r) { |
| 305 |
if (this == &r) return *this; |
| 306 |
finalform_ = r.finalform_; |
| 307 |
initialform_ = r.initialform_; |
| 308 |
formclass_ = r.formclass_; |
| 309 |
exprlocdata_ = r.exprlocdata_; |
| 310 |
return *this; |
| 311 |
}; |
| 312 |
IRFormExprloc(const IRFormExprloc &r) { |
| 313 |
finalform_ = r.finalform_; |
| 314 |
initialform_ = r.initialform_; |
| 315 |
formclass_ = r.formclass_; |
| 316 |
exprlocdata_ = r.exprlocdata_; |
| 317 |
|
| 318 |
} |
| 319 |
virtual IRFormExprloc * clone() const { |
| 320 |
return new IRFormExprloc(*this); |
| 321 |
} |
| 322 |
void setInitialForm(Dwarf_Half v) { initialform_ = v;} |
| 323 |
void setFinalForm(Dwarf_Half v) { finalform_ = v;} |
| 324 |
Dwarf_Half getInitialForm() { return initialform_;} |
| 325 |
Dwarf_Half getFinalForm() {return finalform_;} |
| 326 |
enum Dwarf_Form_Class getFormClass() const { return formclass_; }; |
| 327 |
std::vector<char> getexprlocdata() const {return exprlocdata_; }; |
| 328 |
void insertBlock(Dwarf_Unsigned len, Dwarf_Ptr data) { |
| 329 |
char *d = static_cast<char *>(data); |
| 330 |
exprlocdata_.clear(); |
| 331 |
exprlocdata_.insert(exprlocdata_.end(),d+0,d+len); |
| 332 |
}; |
| 333 |
private: |
| 334 |
Dwarf_Half finalform_; |
| 335 |
// In most cases directform == indirect form. |
| 336 |
// Otherwise, directform == DW_FORM_indirect. |
| 337 |
Dwarf_Half initialform_; |
| 338 |
enum Dwarf_Form_Class formclass_; |
| 339 |
std::vector<char> exprlocdata_; |
| 340 |
}; |
| 341 |
|
| 342 |
class IRFormFlag : public IRForm { |
| 343 |
public: |
| 344 |
IRFormFlag(): |
| 345 |
initialform_(0), |
| 346 |
finalform_(0), |
| 347 |
formclass_(DW_FORM_CLASS_FLAG), |
| 348 |
flagval_(0) |
| 349 |
{}; |
| 350 |
IRFormFlag(IRFormInterface*); |
| 351 |
~IRFormFlag() {}; |
| 352 |
IRFormFlag & operator=(const IRFormFlag &r) { |
| 353 |
if (this == &r) return *this; |
| 354 |
initialform_ = r.initialform_; |
| 355 |
finalform_ = r.finalform_; |
| 356 |
formclass_ = r.formclass_; |
| 357 |
flagval_ = r.flagval_; |
| 358 |
return *this; |
| 359 |
}; |
| 360 |
IRFormFlag(const IRFormFlag &r) { |
| 361 |
initialform_ = r.initialform_; |
| 362 |
finalform_ = r.finalform_; |
| 363 |
formclass_ = r.formclass_; |
| 364 |
flagval_ = r.flagval_; |
| 365 |
} |
| 366 |
virtual IRFormFlag * clone() const { |
| 367 |
return new IRFormFlag(*this); |
| 368 |
} |
| 369 |
enum Dwarf_Form_Class getFormClass() const { return formclass_; }; |
| 370 |
void setInitialForm(Dwarf_Half v) { initialform_ = v;} |
| 371 |
void setFinalForm(Dwarf_Half v) { finalform_ = v;} |
| 372 |
Dwarf_Half getInitialForm() { return initialform_;} |
| 373 |
Dwarf_Half getFinalForm() {return finalform_;} |
| 374 |
void setFlagVal(Dwarf_Bool v) { flagval_ = v;} |
| 375 |
Dwarf_Bool getFlagVal() { return flagval_; } |
| 376 |
private: |
| 377 |
Dwarf_Half initialform_; |
| 378 |
// In most cases initialform_ == finalform_. |
| 379 |
// Otherwise, initialform == DW_FORM_indirect. |
| 380 |
Dwarf_Half finalform_; |
| 381 |
enum Dwarf_Form_Class formclass_; |
| 382 |
Dwarf_Bool flagval_; |
| 383 |
}; |
| 384 |
|
| 385 |
class IRFormLinePtr : public IRForm { |
| 386 |
public: |
| 387 |
IRFormLinePtr(): |
| 388 |
finalform_(0), initialform_(0), |
| 389 |
formclass_(DW_FORM_CLASS_LINEPTR), |
| 390 |
debug_line_offset_(0) |
| 391 |
{}; |
| 392 |
IRFormLinePtr(IRFormInterface *); |
| 393 |
~IRFormLinePtr() {}; |
| 394 |
IRFormLinePtr & operator=(const IRFormLinePtr &r) { |
| 395 |
if (this == &r) return *this; |
| 396 |
finalform_ = r.finalform_; |
| 397 |
initialform_ = r.initialform_; |
| 398 |
formclass_ = r.formclass_; |
| 399 |
debug_line_offset_ = r.debug_line_offset_; |
| 400 |
return *this; |
| 401 |
}; |
| 402 |
IRFormLinePtr(const IRFormLinePtr &r) { |
| 403 |
finalform_ = r.finalform_; |
| 404 |
initialform_ = r.initialform_; |
| 405 |
formclass_ = r.formclass_; |
| 406 |
debug_line_offset_ = r.debug_line_offset_; |
| 407 |
} |
| 408 |
void setInitialForm(Dwarf_Half v) { initialform_ = v;} |
| 409 |
void setFinalForm(Dwarf_Half v) { finalform_ = v;} |
| 410 |
Dwarf_Half getInitialForm() { return initialform_;} |
| 411 |
Dwarf_Half getFinalForm(void) {return finalform_; } |
| 412 |
virtual IRFormLinePtr * clone() const { |
| 413 |
return new IRFormLinePtr(*this); |
| 414 |
} |
| 415 |
enum Dwarf_Form_Class getFormClass() const { return formclass_; }; |
| 416 |
private: |
| 417 |
Dwarf_Half finalform_; |
| 418 |
// In most cases directform == indirect form. |
| 419 |
// Otherwise, directform == DW_FORM_indirect. |
| 420 |
Dwarf_Half initialform_; |
| 421 |
enum Dwarf_Form_Class formclass_; |
| 422 |
Dwarf_Off debug_line_offset_; |
| 423 |
|
| 424 |
void setOffset(Dwarf_Unsigned uval) { |
| 425 |
debug_line_offset_ = uval; |
| 426 |
}; |
| 427 |
}; |
| 428 |
|
| 429 |
class IRFormLoclistPtr : public IRForm { |
| 430 |
public: |
| 431 |
IRFormLoclistPtr(): |
| 432 |
finalform_(0), initialform_(0), |
| 433 |
formclass_(DW_FORM_CLASS_LOCLISTPTR), |
| 434 |
loclist_offset_(0) |
| 435 |
{}; |
| 436 |
IRFormLoclistPtr(IRFormInterface *); |
| 437 |
~IRFormLoclistPtr() {}; |
| 438 |
IRFormLoclistPtr & operator=(const IRFormLoclistPtr &r) { |
| 439 |
if (this == &r) return *this; |
| 440 |
finalform_ = r.finalform_; |
| 441 |
initialform_ = r.initialform_; |
| 442 |
formclass_ = r.formclass_; |
| 443 |
loclist_offset_ = r.loclist_offset_; |
| 444 |
return *this; |
| 445 |
}; |
| 446 |
IRFormLoclistPtr(const IRFormLoclistPtr &r) { |
| 447 |
finalform_ = r.finalform_; |
| 448 |
initialform_ = r.initialform_; |
| 449 |
formclass_ = r.formclass_; |
| 450 |
loclist_offset_ = r.loclist_offset_; |
| 451 |
} |
| 452 |
virtual IRFormLoclistPtr * clone() const { |
| 453 |
return new IRFormLoclistPtr(*this); |
| 454 |
} |
| 455 |
void setInitialForm(Dwarf_Half v) { initialform_ = v;} |
| 456 |
void setFinalForm(Dwarf_Half v) { finalform_ = v;} |
| 457 |
Dwarf_Half getInitialForm() { return initialform_;} |
| 458 |
Dwarf_Half getFinalForm() {return finalform_;} |
| 459 |
enum Dwarf_Form_Class getFormClass() const { return formclass_; }; |
| 460 |
private: |
| 461 |
Dwarf_Half finalform_; |
| 462 |
// In most cases directform == indirect form. |
| 463 |
// Otherwise, directform == DW_FORM_indirect. |
| 464 |
Dwarf_Half initialform_; |
| 465 |
enum Dwarf_Form_Class formclass_; |
| 466 |
Dwarf_Off loclist_offset_; |
| 467 |
|
| 468 |
void setOffset(Dwarf_Unsigned uval) { |
| 469 |
loclist_offset_ = uval; |
| 470 |
}; |
| 471 |
}; |
| 472 |
|
| 473 |
class IRFormMacPtr : public IRForm { |
| 474 |
public: |
| 475 |
IRFormMacPtr(): |
| 476 |
finalform_(0), initialform_(0), |
| 477 |
formclass_(DW_FORM_CLASS_MACPTR), |
| 478 |
macro_offset_(0) |
| 479 |
{}; |
| 480 |
IRFormMacPtr(IRFormInterface *); |
| 481 |
~IRFormMacPtr() {}; |
| 482 |
IRFormMacPtr & operator=(const IRFormMacPtr &r) { |
| 483 |
if (this == &r) return *this; |
| 484 |
finalform_ = r.finalform_; |
| 485 |
initialform_ = r.initialform_; |
| 486 |
formclass_ = r.formclass_; |
| 487 |
macro_offset_ = r.macro_offset_; |
| 488 |
return *this; |
| 489 |
}; |
| 490 |
IRFormMacPtr(const IRFormMacPtr &r) { |
| 491 |
finalform_ = r.finalform_; |
| 492 |
initialform_ = r.initialform_; |
| 493 |
formclass_ = r.formclass_; |
| 494 |
macro_offset_ = r.macro_offset_; |
| 495 |
} |
| 496 |
virtual IRFormMacPtr * clone() const { |
| 497 |
return new IRFormMacPtr(*this); |
| 498 |
} |
| 499 |
void setInitialForm(Dwarf_Half v) { initialform_ = v;} |
| 500 |
void setFinalForm(Dwarf_Half v) { finalform_ = v;} |
| 501 |
Dwarf_Half getInitialForm() { return initialform_;} |
| 502 |
Dwarf_Half getFinalForm() {return finalform_;} |
| 503 |
enum Dwarf_Form_Class getFormClass() const { return formclass_; }; |
| 504 |
private: |
| 505 |
Dwarf_Half finalform_; |
| 506 |
// In most cases directform == indirect form. |
| 507 |
// Otherwise, directform == DW_FORM_indirect. |
| 508 |
Dwarf_Half initialform_; |
| 509 |
enum Dwarf_Form_Class formclass_; |
| 510 |
Dwarf_Off macro_offset_; |
| 511 |
|
| 512 |
void setOffset(Dwarf_Unsigned uval) { |
| 513 |
macro_offset_ = uval; |
| 514 |
}; |
| 515 |
}; |
| 516 |
|
| 517 |
class IRFormRangelistPtr : public IRForm { |
| 518 |
public: |
| 519 |
IRFormRangelistPtr(): |
| 520 |
finalform_(0), initialform_(0), |
| 521 |
formclass_(DW_FORM_CLASS_RANGELISTPTR), |
| 522 |
rangelist_offset_(0) |
| 523 |
{}; |
| 524 |
IRFormRangelistPtr(IRFormInterface *); |
| 525 |
~IRFormRangelistPtr() {}; |
| 526 |
IRFormRangelistPtr & operator=(const IRFormRangelistPtr &r) { |
| 527 |
if (this == &r) return *this; |
| 528 |
finalform_ = r.finalform_; |
| 529 |
initialform_ = r.initialform_; |
| 530 |
formclass_ = r.formclass_; |
| 531 |
rangelist_offset_ = r.rangelist_offset_; |
| 532 |
return *this; |
| 533 |
}; |
| 534 |
IRFormRangelistPtr(const IRFormRangelistPtr &r) { |
| 535 |
finalform_ = r.finalform_; |
| 536 |
initialform_ = r.initialform_; |
| 537 |
formclass_ = r.formclass_; |
| 538 |
rangelist_offset_ = r.rangelist_offset_; |
| 539 |
} |
| 540 |
void setInitialForm(Dwarf_Half v) { initialform_ = v;} |
| 541 |
void setFinalForm(Dwarf_Half v) { finalform_ = v;} |
| 542 |
Dwarf_Half getInitialForm() { return initialform_;} |
| 543 |
Dwarf_Half getFinalForm() {return finalform_;} |
| 544 |
virtual IRFormRangelistPtr * clone() const { |
| 545 |
return new IRFormRangelistPtr(*this); |
| 546 |
} |
| 547 |
enum Dwarf_Form_Class getFormClass() const { return formclass_; }; |
| 548 |
private: |
| 549 |
Dwarf_Half finalform_; |
| 550 |
// In most cases directform == indirect form. |
| 551 |
// Otherwise, directform == DW_FORM_indirect. |
| 552 |
Dwarf_Half initialform_; |
| 553 |
enum Dwarf_Form_Class formclass_; |
| 554 |
Dwarf_Off rangelist_offset_; |
| 555 |
|
| 556 |
void setOffset(Dwarf_Unsigned uval) { |
| 557 |
rangelist_offset_ = uval; |
| 558 |
}; |
| 559 |
}; |
| 560 |
|
| 561 |
class IRFormFramePtr : public IRForm { |
| 562 |
public: |
| 563 |
IRFormFramePtr(): |
| 564 |
finalform_(0), initialform_(0), |
| 565 |
formclass_(DW_FORM_CLASS_FRAMEPTR), |
| 566 |
frame_offset_(0) |
| 567 |
{}; |
| 568 |
IRFormFramePtr(IRFormInterface *); |
| 569 |
~IRFormFramePtr() {}; |
| 570 |
IRFormFramePtr & operator=(const IRFormFramePtr &r) { |
| 571 |
if (this == &r) return *this; |
| 572 |
finalform_ = r.finalform_; |
| 573 |
initialform_ = r.initialform_; |
| 574 |
formclass_ = r.formclass_; |
| 575 |
frame_offset_ = r.frame_offset_; |
| 576 |
return *this; |
| 577 |
}; |
| 578 |
IRFormFramePtr(const IRFormFramePtr &r) { |
| 579 |
finalform_ = r.finalform_; |
| 580 |
initialform_ = r.initialform_; |
| 581 |
formclass_ = r.formclass_; |
| 582 |
frame_offset_ = r.frame_offset_; |
| 583 |
} |
| 584 |
virtual IRFormFramePtr * clone() const { |
| 585 |
return new IRFormFramePtr(*this); |
| 586 |
} |
| 587 |
void setInitialForm(Dwarf_Half v) { initialform_ = v;} |
| 588 |
void setFinalForm(Dwarf_Half v) { finalform_ = v;} |
| 589 |
Dwarf_Half getInitialForm() { return initialform_;} |
| 590 |
Dwarf_Half getFinalForm() {return finalform_;} |
| 591 |
enum Dwarf_Form_Class getFormClass() const { return formclass_; }; |
| 592 |
private: |
| 593 |
Dwarf_Half finalform_; |
| 594 |
// In most cases directform == indirect form. |
| 595 |
// Otherwise, directform == DW_FORM_indirect. |
| 596 |
Dwarf_Half initialform_; |
| 597 |
enum Dwarf_Form_Class formclass_; |
| 598 |
Dwarf_Off frame_offset_; |
| 599 |
|
| 600 |
void setOffset(Dwarf_Unsigned uval) { |
| 601 |
frame_offset_ = uval; |
| 602 |
}; |
| 603 |
}; |
| 604 |
|
| 605 |
class IRFormReference : public IRForm { |
| 606 |
public: |
| 607 |
IRFormReference(): |
| 608 |
finalform_(0), initialform_(0), |
| 609 |
formclass_(DW_FORM_CLASS_REFERENCE), |
| 610 |
reftype_(RT_NONE), |
| 611 |
globalOffset_(0),cuRelativeOffset_(0), |
| 612 |
targetInputDie_(0), |
| 613 |
target_die_(0) |
| 614 |
{initSig8();}; |
| 615 |
IRFormReference(IRFormInterface *); |
| 616 |
~IRFormReference() {}; |
| 617 |
IRFormReference & operator=(const IRFormReference &r) { |
| 618 |
if (this == &r) return *this; |
| 619 |
finalform_ = r.finalform_; |
| 620 |
initialform_ = r.initialform_; |
| 621 |
formclass_ = r.formclass_; |
| 622 |
reftype_ = r.reftype_; |
| 623 |
globalOffset_ = r.globalOffset_; |
| 624 |
cuRelativeOffset_ = r.cuRelativeOffset_; |
| 625 |
typeSig8_ = r.typeSig8_; |
| 626 |
targetInputDie_ = r.targetInputDie_; |
| 627 |
target_die_ = r.target_die_; |
| 628 |
return *this; |
| 629 |
}; |
| 630 |
IRFormReference(const IRFormReference &r) { |
| 631 |
finalform_ = r.finalform_; |
| 632 |
initialform_ = r.initialform_; |
| 633 |
formclass_ = r.formclass_; |
| 634 |
reftype_ = r.reftype_; |
| 635 |
globalOffset_ = r.globalOffset_; |
| 636 |
cuRelativeOffset_ = r.cuRelativeOffset_; |
| 637 |
typeSig8_ = r.typeSig8_; |
| 638 |
targetInputDie_ = r.targetInputDie_; |
| 639 |
target_die_ = r.target_die_; |
| 640 |
} |
| 641 |
virtual IRFormReference * clone() const { |
| 642 |
return new IRFormReference(*this); |
| 643 |
} |
| 644 |
void setInitialForm(Dwarf_Half v) { initialform_ = v;} |
| 645 |
void setFinalForm(Dwarf_Half v) { finalform_ = v;} |
| 646 |
Dwarf_Half getInitialForm() { return initialform_;} |
| 647 |
Dwarf_Half getFinalForm() {return finalform_;} |
| 648 |
void setOffset(Dwarf_Off off) { globalOffset_ = off; |
| 649 |
reftype_ = RT_GLOBAL;}; |
| 650 |
void setCUOffset(Dwarf_Off off) { cuRelativeOffset_= off; |
| 651 |
reftype_ = RT_CUREL;}; |
| 652 |
void setSignature(Dwarf_Sig8 * sig) { typeSig8_ = *sig; |
| 653 |
reftype_ = RT_SIG;}; |
| 654 |
const Dwarf_Sig8 *getSignature() { return &typeSig8_;}; |
| 655 |
enum Dwarf_Form_Class getFormClass() const { return formclass_; }; |
| 656 |
enum RefType { RT_NONE,RT_GLOBAL, RT_CUREL,RT_SIG }; |
| 657 |
enum RefType getReferenceType() { return reftype_;}; |
| 658 |
Dwarf_P_Die getTargetGenDie() { return target_die_;}; |
| 659 |
IRDie * getTargetInDie() { return targetInputDie_;}; |
| 660 |
void setTargetGenDie(Dwarf_P_Die targ) { target_die_ = targ; }; |
| 661 |
void setTargetInDie(IRDie* targ) { targetInputDie_ = targ; }; |
| 662 |
|
| 663 |
private: |
| 664 |
void initSig8(); |
| 665 |
|
| 666 |
Dwarf_Half finalform_; |
| 667 |
// In most cases directform == indirect form. |
| 668 |
// Otherwise, directform == DW_FORM_indirect. |
| 669 |
Dwarf_Half initialform_; |
| 670 |
enum Dwarf_Form_Class formclass_; |
| 671 |
enum RefType reftype_; |
| 672 |
|
| 673 |
// gobalOffset_ on input target set if and only if RT_GLOBAL |
| 674 |
Dwarf_Off globalOffset_; |
| 675 |
// cuRelativeOffset_ on input targetset if and only if RT_CUREL |
| 676 |
Dwarf_Off cuRelativeOffset_; |
| 677 |
// typeSig8_ on input target set if and only if RT_SIG |
| 678 |
Dwarf_Sig8 typeSig8_; |
| 679 |
|
| 680 |
// For RT_SIG we do not need extra data. |
| 681 |
// For RT_CUREL and RT_GLOBAL we do. |
| 682 |
|
| 683 |
// For RT_CUREL. Points at the target input DIE |
| 684 |
// after all input DIEs set up for a CU . |
| 685 |
IRDie * targetInputDie_; |
| 686 |
// FIXME |
| 687 |
Dwarf_P_Die target_die_; //for RT_CUREL, this is known |
| 688 |
// for sure only after all target DIEs generated! |
| 689 |
|
| 690 |
// RT_GLOBAL. FIXME |
| 691 |
}; |
| 692 |
|
| 693 |
class IRFormString: public IRForm { |
| 694 |
public: |
| 695 |
IRFormString(): |
| 696 |
finalform_(0), initialform_(0), |
| 697 |
formclass_(DW_FORM_CLASS_STRING), |
| 698 |
strpoffset_(0) {}; |
| 699 |
~IRFormString() {}; |
| 700 |
IRFormString(IRFormInterface *); |
| 701 |
IRFormString(const IRFormString &r) { |
| 702 |
finalform_ = r.finalform_; |
| 703 |
initialform_ = r.initialform_; |
| 704 |
formclass_ = r.formclass_; |
| 705 |
formdata_= r.formdata_; |
| 706 |
strpoffset_= r.strpoffset_; |
| 707 |
} |
| 708 |
virtual IRFormString * clone() const { |
| 709 |
return new IRFormString(*this); |
| 710 |
} |
| 711 |
IRFormString & operator=(const IRFormString &r) { |
| 712 |
if (this == &r) return *this; |
| 713 |
finalform_ = r.finalform_; |
| 714 |
initialform_ = r.initialform_; |
| 715 |
formclass_ = r.formclass_; |
| 716 |
formdata_ = r.formdata_; |
| 717 |
strpoffset_ = r.strpoffset_; |
| 718 |
return *this; |
| 719 |
}; |
| 720 |
void setInitialForm(Dwarf_Half v) { initialform_ = v;} |
| 721 |
void setFinalForm(Dwarf_Half v) { finalform_ = v;} |
| 722 |
Dwarf_Half getInitialForm() { return initialform_;} |
| 723 |
Dwarf_Half getFinalForm() {return finalform_;} |
| 724 |
void setString(const char *s) {formdata_ = s; }; |
| 725 |
const std::string & getString() const {return formdata_; }; |
| 726 |
enum Dwarf_Form_Class getFormClass() const { return formclass_; }; |
| 727 |
private: |
| 728 |
Dwarf_Half finalform_; |
| 729 |
// In most cases directform == indirect form. |
| 730 |
// Otherwise, directform == DW_FORM_indirect. |
| 731 |
Dwarf_Half initialform_; |
| 732 |
enum Dwarf_Form_Class formclass_; |
| 733 |
std::string formdata_; |
| 734 |
Dwarf_Unsigned strpoffset_; |
| 735 |
}; |
| 736 |
|
| 737 |
// Factory Method. |
| 738 |
IRForm *formFactory(Dwarf_Debug dbg, Dwarf_Attribute attr, |
| 739 |
IRCUdata &cudata,IRAttr & irattr); |