llvm.org GIT mirror llvm / 0275be3
Allow DWARFFormValue::extractValue to be called with a null CU. Currently FormValues are only used for attributes of DIEs and thus uers always have a CU lying around when calling into the FormValue API. Accelerator tables encode their information using the same Forms as the attributes, thus it is natural to use DWARFFormValue to extract/dump them. There is no CU in that case though. Allow the API to be called with a null CU arguemnt by making the RelocMap lookup conditional on the CU pointer validity. And document this new behvior in the header. (Test coverage for this use of the API comes in the DwarfAccelTable support patch) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221835 91177308-0d34-0410-b5e6-96231b3b80d8 Frederic Riss 5 years ago
2 changed file(s) with 24 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
5656 bool isFormClass(FormClass FC) const;
5757
5858 void dump(raw_ostream &OS, const DWARFUnit *U) const;
59
60 /// \brief extracts a value in data at offset *offset_ptr.
61 ///
62 /// The passed DWARFUnit is allowed to be nullptr, in which
63 /// case no relocation processing will be performed and some
64 /// kind of forms that depend on Unit information are disallowed.
65 /// \returns wether the extraction succeeded.
5966 bool extractValue(DataExtractor data, uint32_t *offset_ptr,
6067 const DWARFUnit *u);
6168 bool isInlinedCStr() const {
138138 switch (Form) {
139139 case DW_FORM_addr:
140140 case DW_FORM_ref_addr: {
141 if (!cu)
142 return false;
141143 uint16_t AddrSize =
142144 (Form == DW_FORM_addr)
143145 ? cu->getAddressByteSize()
178180 break;
179181 case DW_FORM_data4:
180182 case DW_FORM_ref4: {
181 RelocAddrMap::const_iterator AI = cu->getRelocMap()->find(*offset_ptr);
182183 Value.uval = data.getU32(offset_ptr);
184 if (!cu)
185 break;
186 RelocAddrMap::const_iterator AI = cu->getRelocMap()->find(*offset_ptr-4);
183187 if (AI != cu->getRelocMap()->end())
184188 Value.uval += AI->second.second;
185189 break;
192196 Value.sval = data.getSLEB128(offset_ptr);
193197 break;
194198 case DW_FORM_strp: {
195 RelocAddrMap::const_iterator AI
196 = cu->getRelocMap()->find(*offset_ptr);
197 if (AI != cu->getRelocMap()->end()) {
198 const std::pair &R = AI->second;
199 Value.uval = data.getU32(offset_ptr) + R.second;
200 } else
201 Value.uval = data.getU32(offset_ptr);
199 Value.uval = data.getU32(offset_ptr);
200 if (!cu)
201 break;
202 RelocAddrMap::const_iterator AI = cu->getRelocMap()->find(*offset_ptr-4);
203 if (AI != cu->getRelocMap()->end())
204 Value.uval += AI->second.second;
202205 break;
203206 }
204207 case DW_FORM_udata:
214217 break;
215218 case DW_FORM_sec_offset: {
216219 // FIXME: This is 64-bit for DWARF64.
217 RelocAddrMap::const_iterator AI
218 = cu->getRelocMap()->find(*offset_ptr);
219 if (AI != cu->getRelocMap()->end()) {
220 const std::pair &R = AI->second;
221 Value.uval = data.getU32(offset_ptr) + R.second;
222 } else
223 Value.uval = data.getU32(offset_ptr);
220 Value.uval = data.getU32(offset_ptr);
221 if (!cu)
222 break;
223 RelocAddrMap::const_iterator AI = cu->getRelocMap()->find(*offset_ptr-4);
224 if (AI != cu->getRelocMap()->end())
225 Value.uval += AI->second.second;
224226 break;
225227 }
226228 case DW_FORM_flag_present: