| 1 |
#ifndef IREPLINE_H |
| 2 |
#define IREPLINE_H |
| 3 |
/* |
| 4 |
Copyright (C) 2010-2013 David Anderson. All rights reserved. |
| 5 |
|
| 6 |
Redistribution and use in source and binary forms, with |
| 7 |
or without modification, are permitted provided that the |
| 8 |
following conditions are met: |
| 9 |
|
| 10 |
* Redistributions of source code must retain the above |
| 11 |
copyright notice, this list of conditions and the following |
| 12 |
disclaimer. |
| 13 |
|
| 14 |
* Redistributions in binary form must reproduce the above |
| 15 |
copyright notice, this list of conditions and the following |
| 16 |
disclaimer in the documentation and/or other materials |
| 17 |
provided with the distribution. |
| 18 |
|
| 19 |
* Neither the name of the example nor the names of its |
| 20 |
contributors may be used to endorse or promote products |
| 21 |
derived from this software without specific prior written |
| 22 |
permission. |
| 23 |
|
| 24 |
THIS SOFTWARE IS PROVIDED BY David Anderson ''AS IS'' |
| 25 |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT |
| 26 |
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
| 27 |
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN |
| 28 |
NO EVENT SHALL David Anderson BE LIABLE FOR ANY DIRECT, |
| 29 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 30 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
| 31 |
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 32 |
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 33 |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 34 |
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 35 |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 36 |
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 37 |
*/ |
| 38 |
|
| 39 |
// |
| 40 |
// irepline.h |
| 41 |
// |
| 42 |
|
| 43 |
class IRCULine { |
| 44 |
public: |
| 45 |
IRCULine(Dwarf_Addr addr,Dwarf_Bool isset, |
| 46 |
Dwarf_Unsigned fileno, |
| 47 |
Dwarf_Unsigned lineno, |
| 48 |
Dwarf_Unsigned linecol, |
| 49 |
const std::string & linename, |
| 50 |
Dwarf_Bool is_stmt, |
| 51 |
Dwarf_Bool bb, |
| 52 |
Dwarf_Bool endseq, |
| 53 |
Dwarf_Bool prol_end, |
| 54 |
Dwarf_Bool epil_beg, |
| 55 |
Dwarf_Unsigned isa, |
| 56 |
Dwarf_Unsigned discrim): |
| 57 |
address_(addr), |
| 58 |
isaddrset_(isset), |
| 59 |
srcfileno_(fileno), |
| 60 |
lineno_(lineno), |
| 61 |
linecol_(linecol), |
| 62 |
linesrc_(linename), |
| 63 |
is_stmt_(is_stmt), |
| 64 |
basic_block_(bb), |
| 65 |
end_sequence_(endseq), |
| 66 |
prologue_end_(prol_end), |
| 67 |
epilogue_begin_(epil_beg), |
| 68 |
isa_(isa), |
| 69 |
discriminator_(discrim) |
| 70 |
{}; |
| 71 |
const std::string &getpath() { return linesrc_; }; |
| 72 |
Dwarf_Addr getaddr() { return address_;}; |
| 73 |
bool getaddrset() { return isaddrset_;}; |
| 74 |
bool getendsequence() { return end_sequence_; }; |
| 75 |
Dwarf_Unsigned getlineno() { return lineno_; }; |
| 76 |
Dwarf_Unsigned getlinecol() { return linecol_; }; |
| 77 |
Dwarf_Unsigned getsrcfileno() { return srcfileno_; }; |
| 78 |
bool getisstmt() { return is_stmt_; }; |
| 79 |
bool getisblock() { return basic_block_; }; |
| 80 |
bool getepiloguebegin() { return epilogue_begin_; }; |
| 81 |
bool getprologueend() { return prologue_end_; }; |
| 82 |
Dwarf_Unsigned getisa() { return isa_; }; |
| 83 |
Dwarf_Unsigned getdiscriminator() { return discriminator_; }; |
| 84 |
~IRCULine() {}; |
| 85 |
private: |
| 86 |
|
| 87 |
// Names taken from the DWARF4 std. document, sec 6.2.2. |
| 88 |
Dwarf_Addr address_; |
| 89 |
bool isaddrset_; |
| 90 |
Dwarf_Unsigned srcfileno_; |
| 91 |
Dwarf_Unsigned lineno_; |
| 92 |
Dwarf_Signed linecol_; // aka lineoff |
| 93 |
std::string linesrc_; // Name for the file, |
| 94 |
//constructed by libdwarf. |
| 95 |
bool is_stmt_; |
| 96 |
bool basic_block_; |
| 97 |
bool end_sequence_; |
| 98 |
bool prologue_end_; |
| 99 |
bool epilogue_begin_; |
| 100 |
int isa_; |
| 101 |
int discriminator_; |
| 102 |
}; |
| 103 |
class IRCUSrcfile { |
| 104 |
public: |
| 105 |
IRCUSrcfile(std::string file): cusrcfile_(std::move(file)) {}; |
| 106 |
~IRCUSrcfile() {}; |
| 107 |
std::string &getfilepath() {return cusrcfile_;}; |
| 108 |
private: |
| 109 |
std::string cusrcfile_; |
| 110 |
}; |
| 111 |
|
| 112 |
class IRCULineData { |
| 113 |
public: |
| 114 |
IRCULineData() {}; |
| 115 |
~IRCULineData() {}; |
| 116 |
std::vector<IRCULine> &get_cu_lines() { return culinedata_; }; |
| 117 |
std::vector<IRCUSrcfile> &get_cu_srcfiles() { |
| 118 |
return cusrcfiledata_; }; |
| 119 |
private: |
| 120 |
std::vector<IRCUSrcfile> cusrcfiledata_; |
| 121 |
std::vector<IRCULine> culinedata_; |
| 122 |
}; |
| 123 |
#endif // IREPLINE_H |