OLD | NEW |
| (Empty) |
1 // Copyright 2010 Google, Inc. All Rights reserved | |
2 // | |
3 // Redistribution and use in source and binary forms, with or without | |
4 // modification, are permitted provided that the following conditions are | |
5 // met: | |
6 // | |
7 // * Redistributions of source code must retain the above copyright | |
8 // notice, this list of conditions and the following disclaimer. | |
9 // * Redistributions in binary form must reproduce the above | |
10 // copyright notice, this list of conditions and the following disclaimer | |
11 // in the documentation and/or other materials provided with the | |
12 // distribution. | |
13 // * Neither the name of Google Inc. nor the names of its | |
14 // contributors may be used to endorse or promote products derived from | |
15 // this software without specific prior written permission. | |
16 // | |
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | |
29 | |
30 // This file contains the interface for processing DWARF Data | |
31 | |
32 #ifndef DWARF_READER_DWARF_READER_H_ | |
33 #define DWARF_READER_DWARF_READER_H_ | |
34 | |
35 #include "common/types.h" | |
36 #include "common/dwarf/dwarf2enums.h" | |
37 | |
38 namespace dwarf_reader { | |
39 | |
40 using dwarf2reader::DwarfAttribute; | |
41 using dwarf2reader::DwarfForm; | |
42 using dwarf2reader::DwarfTag; | |
43 | |
44 class IDwarfReader { | |
45 // All offsets are from the beginning of the .debug_info for this module | |
46 // and when combined with the module uniquely identify the object. In | |
47 // addition all notifications function which can have children return a | |
48 // context as a void *, which be passed into any child references to | |
49 // facility building of tree structure. The order of calls and the values | |
50 // they pass can be seen bellow: | |
51 // | |
52 // root = StartCompilationUnit(...) | |
53 // child = StartDIE(root, ....) | |
54 // Property(child, ....) | |
55 // sub = StartDIE(child, ...) | |
56 // Property(sub, ....) | |
57 // EndDIE(sub) | |
58 // EndDIE(child) | |
59 // AddDir(root, ...) | |
60 // AddFile(root, ...) | |
61 // AddLine(root, ...) | |
62 // EndComplicationUnit(root) | |
63 | |
64 public: | |
65 // Start to process a compilation unit at OFFSET from the beginning of the | |
66 // .debug_info section. Return false if you would like to skip this | |
67 // compilation unit. | |
68 virtual void *StartCompilationUnit(uint64 offset, uint8 address_size, | |
69 uint8 offset_size, uint64 cu_length, | |
70 uint8 dwarf_version) = 0; | |
71 | |
72 // Called when finished processing the CompilationUnit at OFFSET. | |
73 // CU's are in the form of a linear list, so each one forms the root of | |
74 // a DIE tree. | |
75 virtual void EndCompilationUnit(void *ctx, uint64 offset) = 0; | |
76 | |
77 // Start to process a DIE at OFFSET from the beginning of the .debug_info | |
78 // section. Return false if you would like to skip this DIE. | |
79 virtual void *StartDIE(void *ctx, uint64 parent, uint64 offset, enum DwarfTag
tag) = 0; | |
80 | |
81 // Called when finished processing the DIE at OFFSET. | |
82 // Because DWARF2/3 specifies a tree of DIEs, you may get starts | |
83 // before ends of the previous DIE, as we process children before | |
84 // ending the parent. | |
85 virtual void EndDIE(void *ctx, uint64 offset) = 0; | |
86 | |
87 // Called when we have an attribute with unsigned data to give to our | |
88 // handler. The attribute is for the DIE at OFFSET from the beginning of the | |
89 // .debug_info section. Its name is ATTR, its form is FORM, and its value is | |
90 // DATA. | |
91 virtual void ProcessAttributeUnsigned(void *ctx, | |
92 uint64 offset, | |
93 uint64 parent, | |
94 enum DwarfAttribute attr, | |
95 enum DwarfForm form, | |
96 uint64 data) = 0; | |
97 | |
98 // Called when we have an attribute with signed data to give to our handler. | |
99 // The attribute is for the DIE at OFFSET from the beginning of the | |
100 // .debug_info section. Its name is ATTR, its form is FORM, and its value is | |
101 // DATA. | |
102 virtual void ProcessAttributeSigned(void *ctx, | |
103 uint64 offset, | |
104 uint64 parent, | |
105 enum DwarfAttribute attr, | |
106 enum DwarfForm form, | |
107 int64 data) = 0; | |
108 | |
109 // Called when we have an attribute whose value is a reference to | |
110 // another DIE. The attribute belongs to the DIE at OFFSET from the | |
111 // beginning of the .debug_info section. Its name is ATTR, its form | |
112 // is FORM, and the offset of the DIE being referred to from the | |
113 // beginning of the .debug_info section is DATA. | |
114 virtual void ProcessAttributeReference(void *ctx, | |
115 uint64 offset, | |
116 uint64 parent, | |
117 enum DwarfAttribute attr, | |
118 enum DwarfForm form, | |
119 uint64 data) = 0; | |
120 | |
121 // Called when we have an attribute with a buffer of data to give to our | |
122 // handler. The attribute is for the DIE at OFFSET from the beginning of the | |
123 // .debug_info section. Its name is ATTR, its form is FORM, DATA points to | |
124 // the buffer's contents, and its length in bytes is LENGTH. The buffer is | |
125 // owned by the caller, not the callee, and may not persist for very long. | |
126 // If you want the data to be available later, it needs to be copied. | |
127 virtual void ProcessAttributeBuffer(void *ctx, | |
128 uint64 offset, | |
129 uint64 parent, | |
130 enum DwarfAttribute attr, | |
131 enum DwarfForm form, | |
132 const char* data, | |
133 uint64 len) = 0; | |
134 | |
135 // Called when we have an attribute with string data to give to our handler. | |
136 // The attribute is for the DIE at OFFSET from the beginning of the | |
137 // .debug_info section. Its name is ATTR, its form is FORM, and its value is | |
138 // DATA. | |
139 virtual void ProcessAttributeString(void *ctx, | |
140 uint64 offset, | |
141 uint64 parent, | |
142 enum DwarfAttribute attr, | |
143 enum DwarfForm form, | |
144 const char* data) = 0; | |
145 | |
146 // Called when we define a directory. NAME is the directory name, | |
147 // DIR_NUM is one based directory index number. The context will | |
148 // be the one passe back by StartCompileUnit. | |
149 virtual void DefineDir(void *ctx, const char *name, uint32 dir_num) = 0; | |
150 | |
151 // Called when we define a file. NAME is the directory name, | |
152 // DIR_NUM is one based directory index number. | |
153 virtual void DefineFile(void *ctx, const char *name, int32 file_num, | |
154 uint32 dir_num, uint64 mod_time, | |
155 uint64 length) = 0; | |
156 | |
157 // Called when the line info reader has a new line, address pair | |
158 // ready for us. ADDRESS is the address of the code, LENGTH is the | |
159 // length of its machine code in bytes, FILE_NUM is the file number | |
160 // containing the code, LINE_NUM is the line number in that file for | |
161 // the code, and COLUMN_NUM is the column number the code starts at, | |
162 // if we know it (0 otherwise). | |
163 virtual void AddLine(void *ctx, uint64 address, uint64 length, uint32 file_num
, | |
164 uint32 line_num, uint32 column_num) = 0; | |
165 | |
166 // Called when the location list reader has a new location list entry | |
167 // ready for us. | |
168 // Params: | |
169 // offset: offset of this entry from the beginning of the | |
170 // .debug_loc section. This is used elsewhere to identify | |
171 // the location list. | |
172 // | |
173 // is_first_entry: If true, signifies that this entry is the first entry | |
174 // in a new list. The DWARF info refers to lists by their | |
175 // first entry, so if is_first_entry is false it's not | |
176 // particularly important to remember the value of offset. | |
177 // | |
178 // lowPc, highPc: Range of program counter values for which this location | |
179 // entry is valid. | |
180 // | |
181 // data, dataSize: Defines an array of bytes containg DWARF VM | |
182 // instructions that can be used to decode the address | |
183 // encoded in this loc entry. | |
184 virtual void AddLocListEntry( | |
185 uint64 offset, | |
186 bool is_first_entry, | |
187 uint64 lowPc, | |
188 uint64 highPc, | |
189 const void* data, | |
190 size_t dataSize) = 0; | |
191 | |
192 // | |
193 // Call Frame Information (CFI) handling | |
194 // | |
195 | |
196 enum CFI_RuleType { | |
197 CFIRT_UNDEFINED, | |
198 CFIRT_SAMEVALUE, | |
199 CFIRT_OFFSET, | |
200 CFIRT_VALOFFSET, | |
201 CFIRT_REGISTER, | |
202 CFIRT_EXPRESSION, | |
203 CFIRT_VALEXPRESSION | |
204 }; | |
205 | |
206 virtual bool BeginCfiEntry ( | |
207 size_t offset, | |
208 uint64 address, | |
209 uint64 length, | |
210 uint8 version, | |
211 const char* augmentation, | |
212 unsigned return_address) = 0; | |
213 | |
214 virtual bool AddCfiRule( | |
215 uint64 address, | |
216 int reg, | |
217 CFI_RuleType ruleType, | |
218 int base_register, | |
219 int32 offset, | |
220 const void* expression, | |
221 uint32 expressionLength) = 0; | |
222 | |
223 virtual bool EndCfiEntry() = 0; | |
224 }; | |
225 | |
226 | |
227 } // namespace dwarf_reader | |
228 | |
229 #endif // DWARF_READER_DWARF_READER_H_ | |
230 | |
OLD | NEW |