File: | tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp |
Location: | line 509, column 21 |
Description: | Null pointer passed as an argument to a 'nonnull' parameter |
1 | //===-- DWARFASTParserJava.cpp ----------------------------------*- C++ -*-===// | |||
2 | // | |||
3 | // The LLVM Compiler Infrastructure | |||
4 | // | |||
5 | // This file is distributed under the University of Illinois Open Source | |||
6 | // License. See LICENSE.TXT for details. | |||
7 | // | |||
8 | //===----------------------------------------------------------------------===// | |||
9 | ||||
10 | #include "DWARFASTParserJava.h" | |||
11 | #include "DWARFAttribute.h" | |||
12 | #include "DWARFCompileUnit.h" | |||
13 | #include "DWARFDebugInfoEntry.h" | |||
14 | #include "DWARFDebugInfoEntry.h" | |||
15 | #include "DWARFDeclContext.h" | |||
16 | #include "SymbolFileDWARF.h" | |||
17 | ||||
18 | #include "lldb/Core/Module.h" | |||
19 | #include "lldb/Symbol/CompileUnit.h" | |||
20 | #include "lldb/Symbol/SymbolContextScope.h" | |||
21 | #include "lldb/Symbol/TypeList.h" | |||
22 | ||||
23 | using namespace lldb; | |||
24 | using namespace lldb_private; | |||
25 | ||||
26 | DWARFASTParserJava::DWARFASTParserJava(JavaASTContext &ast) : m_ast(ast) | |||
27 | { | |||
28 | } | |||
29 | ||||
30 | DWARFASTParserJava::~DWARFASTParserJava() | |||
31 | { | |||
32 | } | |||
33 | ||||
34 | TypeSP | |||
35 | DWARFASTParserJava::ParseBaseTypeFromDIE(const DWARFDIE &die) | |||
36 | { | |||
37 | SymbolFileDWARF *dwarf = die.GetDWARF(); | |||
38 | dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED((lldb_private::Type*)1); | |||
39 | ||||
40 | ConstString type_name; | |||
41 | uint64_t byte_size = 0; | |||
42 | ||||
43 | DWARFAttributes attributes; | |||
44 | const size_t num_attributes = die.GetAttributes(attributes); | |||
45 | for (uint32_t i = 0; i < num_attributes; ++i) | |||
46 | { | |||
47 | DWARFFormValue form_value; | |||
48 | dw_attr_t attr = attributes.AttributeAtIndex(i); | |||
49 | if (attributes.ExtractFormValueAtIndex(i, form_value)) | |||
50 | { | |||
51 | switch (attr) | |||
52 | { | |||
53 | case DW_AT_name: | |||
54 | type_name.SetCString(form_value.AsCString()); | |||
55 | break; | |||
56 | case DW_AT_byte_size: | |||
57 | byte_size = form_value.Unsigned(); | |||
58 | break; | |||
59 | case DW_AT_encoding: | |||
60 | break; | |||
61 | default: | |||
62 | assert(false && "Unsupported attribute for DW_TAG_base_type")((false && "Unsupported attribute for DW_TAG_base_type" ) ? static_cast<void> (0) : __assert_fail ("false && \"Unsupported attribute for DW_TAG_base_type\"" , "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270356/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp" , 62, __PRETTY_FUNCTION__)); | |||
63 | } | |||
64 | } | |||
65 | } | |||
66 | ||||
67 | Declaration decl; | |||
68 | CompilerType compiler_type = m_ast.CreateBaseType(type_name); | |||
69 | return std::make_shared<Type>(die.GetID(), dwarf, type_name, byte_size, nullptr, LLDB_INVALID_UID(18446744073709551615UL), | |||
70 | Type::eEncodingIsUID, decl, compiler_type, Type::eResolveStateFull); | |||
71 | } | |||
72 | ||||
73 | TypeSP | |||
74 | DWARFASTParserJava::ParseArrayTypeFromDIE(const DWARFDIE &die) | |||
75 | { | |||
76 | SymbolFileDWARF *dwarf = die.GetDWARF(); | |||
77 | dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED((lldb_private::Type*)1); | |||
78 | ||||
79 | ConstString linkage_name; | |||
80 | DWARFFormValue type_attr_value; | |||
81 | lldb::addr_t data_offset = LLDB_INVALID_ADDRESS(18446744073709551615UL); | |||
82 | DWARFExpression length_expression(die.GetCU()); | |||
83 | ||||
84 | DWARFAttributes attributes; | |||
85 | const size_t num_attributes = die.GetAttributes(attributes); | |||
86 | for (uint32_t i = 0; i < num_attributes; ++i) | |||
87 | { | |||
88 | DWARFFormValue form_value; | |||
89 | dw_attr_t attr = attributes.AttributeAtIndex(i); | |||
90 | if (attributes.ExtractFormValueAtIndex(i, form_value)) | |||
91 | { | |||
92 | switch (attr) | |||
93 | { | |||
94 | case DW_AT_linkage_name: | |||
95 | linkage_name.SetCString(form_value.AsCString()); | |||
96 | break; | |||
97 | case DW_AT_type: | |||
98 | type_attr_value = form_value; | |||
99 | break; | |||
100 | case DW_AT_data_member_location: | |||
101 | data_offset = form_value.Unsigned(); | |||
102 | break; | |||
103 | case DW_AT_declaration: | |||
104 | break; | |||
105 | default: | |||
106 | assert(false && "Unsupported attribute for DW_TAG_array_type")((false && "Unsupported attribute for DW_TAG_array_type" ) ? static_cast<void> (0) : __assert_fail ("false && \"Unsupported attribute for DW_TAG_array_type\"" , "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270356/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp" , 106, __PRETTY_FUNCTION__)); | |||
107 | } | |||
108 | } | |||
109 | } | |||
110 | ||||
111 | for (DWARFDIE child_die = die.GetFirstChild(); child_die.IsValid(); child_die = child_die.GetSibling()) | |||
112 | { | |||
113 | if (child_die.Tag() == DW_TAG_subrange_type) | |||
114 | { | |||
115 | DWARFAttributes attributes; | |||
116 | const size_t num_attributes = child_die.GetAttributes(attributes); | |||
117 | for (uint32_t i = 0; i < num_attributes; ++i) | |||
118 | { | |||
119 | DWARFFormValue form_value; | |||
120 | dw_attr_t attr = attributes.AttributeAtIndex(i); | |||
121 | if (attributes.ExtractFormValueAtIndex(i, form_value)) | |||
122 | { | |||
123 | switch (attr) | |||
124 | { | |||
125 | case DW_AT_count: | |||
126 | if (form_value.BlockData()) | |||
127 | length_expression.CopyOpcodeData(form_value.BlockData(), form_value.Unsigned(), | |||
128 | child_die.GetCU()->GetByteOrder(), | |||
129 | child_die.GetCU()->GetAddressByteSize()); | |||
130 | break; | |||
131 | default: | |||
132 | assert(false && "Unsupported attribute for DW_TAG_subrange_type")((false && "Unsupported attribute for DW_TAG_subrange_type" ) ? static_cast<void> (0) : __assert_fail ("false && \"Unsupported attribute for DW_TAG_subrange_type\"" , "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270356/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp" , 132, __PRETTY_FUNCTION__)); | |||
133 | } | |||
134 | } | |||
135 | } | |||
136 | } | |||
137 | else | |||
138 | { | |||
139 | assert(false && "Unsupported child for DW_TAG_array_type")((false && "Unsupported child for DW_TAG_array_type") ? static_cast<void> (0) : __assert_fail ("false && \"Unsupported child for DW_TAG_array_type\"" , "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270356/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp" , 139, __PRETTY_FUNCTION__)); | |||
140 | } | |||
141 | } | |||
142 | ||||
143 | DIERef type_die_ref(type_attr_value); | |||
144 | Type *element_type = dwarf->ResolveTypeUID(type_die_ref); | |||
145 | if (!element_type) | |||
146 | return nullptr; | |||
147 | ||||
148 | CompilerType element_compiler_type = element_type->GetForwardCompilerType(); | |||
149 | CompilerType array_compiler_type = | |||
150 | m_ast.CreateArrayType(linkage_name, element_compiler_type, length_expression, data_offset); | |||
151 | ||||
152 | Declaration decl; | |||
153 | TypeSP type_sp(new Type(die.GetID(), dwarf, array_compiler_type.GetTypeName(), -1, nullptr, | |||
154 | type_die_ref.GetUID(dwarf), Type::eEncodingIsUID, &decl, | |||
155 | array_compiler_type, Type::eResolveStateFull)); | |||
156 | type_sp->SetEncodingType(element_type); | |||
157 | return type_sp; | |||
158 | } | |||
159 | ||||
160 | TypeSP | |||
161 | DWARFASTParserJava::ParseReferenceTypeFromDIE(const DWARFDIE &die) | |||
162 | { | |||
163 | SymbolFileDWARF *dwarf = die.GetDWARF(); | |||
164 | dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED((lldb_private::Type*)1); | |||
165 | ||||
166 | Declaration decl; | |||
167 | DWARFFormValue type_attr_value; | |||
168 | ||||
169 | DWARFAttributes attributes; | |||
170 | const size_t num_attributes = die.GetAttributes(attributes); | |||
171 | for (uint32_t i = 0; i < num_attributes; ++i) | |||
172 | { | |||
173 | DWARFFormValue form_value; | |||
174 | dw_attr_t attr = attributes.AttributeAtIndex(i); | |||
175 | if (attributes.ExtractFormValueAtIndex(i, form_value)) | |||
176 | { | |||
177 | switch (attr) | |||
178 | { | |||
179 | case DW_AT_type: | |||
180 | type_attr_value = form_value; | |||
181 | break; | |||
182 | default: | |||
183 | assert(false && "Unsupported attribute for DW_TAG_array_type")((false && "Unsupported attribute for DW_TAG_array_type" ) ? static_cast<void> (0) : __assert_fail ("false && \"Unsupported attribute for DW_TAG_array_type\"" , "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270356/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp" , 183, __PRETTY_FUNCTION__)); | |||
184 | } | |||
185 | } | |||
186 | } | |||
187 | ||||
188 | DIERef type_die_ref(type_attr_value); | |||
189 | Type *pointee_type = dwarf->ResolveTypeUID(type_die_ref); | |||
190 | if (!pointee_type) | |||
191 | return nullptr; | |||
192 | ||||
193 | CompilerType pointee_compiler_type = pointee_type->GetForwardCompilerType(); | |||
194 | CompilerType reference_compiler_type = m_ast.CreateReferenceType(pointee_compiler_type); | |||
195 | TypeSP type_sp(new Type(die.GetID(), dwarf, reference_compiler_type.GetTypeName(), -1, nullptr, | |||
196 | type_die_ref.GetUID(dwarf), Type::eEncodingIsUID, &decl, | |||
197 | reference_compiler_type, Type::eResolveStateFull)); | |||
198 | type_sp->SetEncodingType(pointee_type); | |||
199 | return type_sp; | |||
200 | } | |||
201 | ||||
202 | lldb::TypeSP | |||
203 | DWARFASTParserJava::ParseClassTypeFromDIE(const DWARFDIE &die, bool &is_new_type) | |||
204 | { | |||
205 | SymbolFileDWARF *dwarf = die.GetDWARF(); | |||
206 | dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED((lldb_private::Type*)1); | |||
207 | ||||
208 | Declaration decl; | |||
209 | ConstString name; | |||
210 | ConstString linkage_name; | |||
211 | bool is_forward_declaration = false; | |||
212 | uint32_t byte_size = 0; | |||
213 | ||||
214 | DWARFAttributes attributes; | |||
215 | const size_t num_attributes = die.GetAttributes(attributes); | |||
216 | for (uint32_t i = 0; i < num_attributes; ++i) | |||
217 | { | |||
218 | DWARFFormValue form_value; | |||
219 | dw_attr_t attr = attributes.AttributeAtIndex(i); | |||
220 | if (attributes.ExtractFormValueAtIndex(i, form_value)) | |||
221 | { | |||
222 | switch (attr) | |||
223 | { | |||
224 | case DW_AT_name: | |||
225 | name.SetCString(form_value.AsCString()); | |||
226 | break; | |||
227 | case DW_AT_declaration: | |||
228 | is_forward_declaration = form_value.Boolean(); | |||
229 | break; | |||
230 | case DW_AT_byte_size: | |||
231 | byte_size = form_value.Unsigned(); | |||
232 | break; | |||
233 | case DW_AT_linkage_name: | |||
234 | linkage_name.SetCString(form_value.AsCString()); | |||
235 | break; | |||
236 | default: | |||
237 | assert(false && "Unsupported attribute for DW_TAG_class_type")((false && "Unsupported attribute for DW_TAG_class_type" ) ? static_cast<void> (0) : __assert_fail ("false && \"Unsupported attribute for DW_TAG_class_type\"" , "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270356/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp" , 237, __PRETTY_FUNCTION__)); | |||
238 | } | |||
239 | } | |||
240 | } | |||
241 | ||||
242 | UniqueDWARFASTType unique_ast_entry; | |||
243 | if (name) | |||
244 | { | |||
245 | std::string qualified_name; | |||
246 | if (die.GetQualifiedName(qualified_name)) | |||
247 | { | |||
248 | name.SetCString(qualified_name.c_str()); | |||
249 | if (dwarf->GetUniqueDWARFASTTypeMap().Find(name, die, Declaration(), -1, unique_ast_entry)) | |||
250 | { | |||
251 | if (unique_ast_entry.m_type_sp) | |||
252 | { | |||
253 | dwarf->GetDIEToType()[die.GetDIE()] = unique_ast_entry.m_type_sp.get(); | |||
254 | is_new_type = false; | |||
255 | return unique_ast_entry.m_type_sp; | |||
256 | } | |||
257 | } | |||
258 | } | |||
259 | } | |||
260 | ||||
261 | if (is_forward_declaration) | |||
262 | { | |||
263 | DWARFDeclContext die_decl_ctx; | |||
264 | die.GetDWARFDeclContext(die_decl_ctx); | |||
265 | ||||
266 | TypeSP type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx); | |||
267 | if (type_sp) | |||
268 | { | |||
269 | // We found a real definition for this type elsewhere so lets use it | |||
270 | dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); | |||
271 | is_new_type = false; | |||
272 | return type_sp; | |||
273 | } | |||
274 | } | |||
275 | ||||
276 | CompilerType compiler_type(&m_ast, dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE())); | |||
277 | if (!compiler_type) | |||
278 | compiler_type = m_ast.CreateObjectType(name, linkage_name, byte_size); | |||
279 | ||||
280 | is_new_type = true; | |||
281 | TypeSP type_sp(new Type(die.GetID(), dwarf, name, | |||
282 | -1, // byte size isn't specified | |||
283 | nullptr, LLDB_INVALID_UID(18446744073709551615UL), Type::eEncodingIsUID, &decl, compiler_type, | |||
284 | Type::eResolveStateForward)); | |||
285 | ||||
286 | // Add our type to the unique type map | |||
287 | unique_ast_entry.m_type_sp = type_sp; | |||
288 | unique_ast_entry.m_die = die; | |||
289 | unique_ast_entry.m_declaration = decl; | |||
290 | unique_ast_entry.m_byte_size = -1; | |||
291 | dwarf->GetUniqueDWARFASTTypeMap().Insert(name, unique_ast_entry); | |||
292 | ||||
293 | if (!is_forward_declaration) | |||
294 | { | |||
295 | // Leave this as a forward declaration until we need to know the details of the type | |||
296 | dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] = compiler_type.GetOpaqueQualType(); | |||
297 | dwarf->GetForwardDeclClangTypeToDie()[compiler_type.GetOpaqueQualType()] = die.GetDIERef(); | |||
298 | } | |||
299 | return type_sp; | |||
300 | } | |||
301 | ||||
302 | lldb::TypeSP | |||
303 | DWARFASTParserJava::ParseTypeFromDWARF(const lldb_private::SymbolContext &sc, const DWARFDIE &die, | |||
304 | lldb_private::Log *log, bool *type_is_new_ptr) | |||
305 | { | |||
306 | if (type_is_new_ptr) | |||
307 | *type_is_new_ptr = false; | |||
308 | ||||
309 | if (!die) | |||
310 | return nullptr; | |||
311 | ||||
312 | SymbolFileDWARF *dwarf = die.GetDWARF(); | |||
313 | ||||
314 | Type *type_ptr = dwarf->m_die_to_type.lookup(die.GetDIE()); | |||
315 | if (type_ptr == DIE_IS_BEING_PARSED((lldb_private::Type*)1)) | |||
316 | return nullptr; | |||
317 | if (type_ptr != nullptr) | |||
318 | return type_ptr->shared_from_this(); | |||
319 | ||||
320 | TypeSP type_sp; | |||
321 | if (type_is_new_ptr) | |||
322 | *type_is_new_ptr = true; | |||
323 | ||||
324 | switch (die.Tag()) | |||
325 | { | |||
326 | case DW_TAG_base_type: | |||
327 | { | |||
328 | type_sp = ParseBaseTypeFromDIE(die); | |||
329 | break; | |||
330 | } | |||
331 | case DW_TAG_array_type: | |||
332 | { | |||
333 | type_sp = ParseArrayTypeFromDIE(die); | |||
334 | break; | |||
335 | } | |||
336 | case DW_TAG_class_type: | |||
337 | { | |||
338 | bool is_new_type = false; | |||
339 | type_sp = ParseClassTypeFromDIE(die, is_new_type); | |||
340 | if (!is_new_type) | |||
341 | return type_sp; | |||
342 | break; | |||
343 | } | |||
344 | case DW_TAG_reference_type: | |||
345 | { | |||
346 | type_sp = ParseReferenceTypeFromDIE(die); | |||
347 | break; | |||
348 | } | |||
349 | } | |||
350 | ||||
351 | if (!type_sp) | |||
352 | return nullptr; | |||
353 | ||||
354 | DWARFDIE sc_parent_die = SymbolFileDWARF::GetParentSymbolContextDIE(die); | |||
355 | dw_tag_t sc_parent_tag = sc_parent_die.Tag(); | |||
356 | ||||
357 | SymbolContextScope *symbol_context_scope = nullptr; | |||
358 | if (sc_parent_tag == DW_TAG_compile_unit) | |||
359 | { | |||
360 | symbol_context_scope = sc.comp_unit; | |||
361 | } | |||
362 | else if (sc.function != nullptr && sc_parent_die) | |||
363 | { | |||
364 | symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID()); | |||
365 | if (symbol_context_scope == nullptr) | |||
366 | symbol_context_scope = sc.function; | |||
367 | } | |||
368 | ||||
369 | if (symbol_context_scope != nullptr) | |||
370 | type_sp->SetSymbolContextScope(symbol_context_scope); | |||
371 | ||||
372 | dwarf->GetTypeList()->Insert(type_sp); | |||
373 | dwarf->m_die_to_type[die.GetDIE()] = type_sp.get(); | |||
374 | ||||
375 | return type_sp; | |||
376 | } | |||
377 | ||||
378 | lldb_private::Function * | |||
379 | DWARFASTParserJava::ParseFunctionFromDWARF(const lldb_private::SymbolContext &sc, const DWARFDIE &die) | |||
380 | { | |||
381 | assert(die.Tag() == DW_TAG_subprogram)((die.Tag() == DW_TAG_subprogram) ? static_cast<void> ( 0) : __assert_fail ("die.Tag() == DW_TAG_subprogram", "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270356/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp" , 381, __PRETTY_FUNCTION__)); | |||
382 | ||||
383 | const char *name = nullptr; | |||
384 | const char *mangled = nullptr; | |||
385 | int decl_file = 0; | |||
386 | int decl_line = 0; | |||
387 | int decl_column = 0; | |||
388 | int call_file = 0; | |||
389 | int call_line = 0; | |||
390 | int call_column = 0; | |||
391 | DWARFRangeList func_ranges; | |||
392 | DWARFExpression frame_base(die.GetCU()); | |||
393 | ||||
394 | if (die.GetDIENamesAndRanges(name, mangled, func_ranges, decl_file, decl_line, decl_column, call_file, call_line, | |||
395 | call_column, &frame_base)) | |||
396 | { | |||
397 | // Union of all ranges in the function DIE (if the function is discontiguous) | |||
398 | AddressRange func_range; | |||
399 | lldb::addr_t lowest_func_addr = func_ranges.GetMinRangeBase(0); | |||
400 | lldb::addr_t highest_func_addr = func_ranges.GetMaxRangeEnd(0); | |||
401 | if (lowest_func_addr != LLDB_INVALID_ADDRESS(18446744073709551615UL) && lowest_func_addr <= highest_func_addr) | |||
402 | { | |||
403 | ModuleSP module_sp(die.GetModule()); | |||
404 | func_range.GetBaseAddress().ResolveAddressUsingFileSections(lowest_func_addr, module_sp->GetSectionList()); | |||
405 | if (func_range.GetBaseAddress().IsValid()) | |||
406 | func_range.SetByteSize(highest_func_addr - lowest_func_addr); | |||
407 | } | |||
408 | ||||
409 | if (func_range.GetBaseAddress().IsValid()) | |||
410 | { | |||
411 | std::unique_ptr<Declaration> decl_ap; | |||
412 | if (decl_file != 0 || decl_line != 0 || decl_column != 0) | |||
413 | decl_ap.reset(new Declaration(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file), decl_line, | |||
414 | decl_column)); | |||
415 | ||||
416 | if (die.GetDWARF()->FixupAddress(func_range.GetBaseAddress())) | |||
417 | { | |||
418 | FunctionSP func_sp(new Function(sc.comp_unit, die.GetID(), die.GetID(), | |||
419 | Mangled(ConstString(name), false), | |||
420 | nullptr, // No function types in java | |||
421 | func_range)); | |||
422 | if (frame_base.IsValid()) | |||
423 | func_sp->GetFrameBaseExpression() = frame_base; | |||
424 | sc.comp_unit->AddFunction(func_sp); | |||
425 | ||||
426 | return func_sp.get(); | |||
427 | } | |||
428 | } | |||
429 | } | |||
430 | return nullptr; | |||
431 | } | |||
432 | ||||
433 | bool | |||
434 | DWARFASTParserJava::CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type, | |||
435 | lldb_private::CompilerType &java_type) | |||
436 | { | |||
437 | switch (die.Tag()) | |||
| ||||
438 | { | |||
439 | case DW_TAG_class_type: | |||
440 | { | |||
441 | if (die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 0) | |||
442 | { | |||
443 | if (die.HasChildren()) | |||
444 | ParseChildMembers(die, java_type); | |||
445 | m_ast.CompleteObjectType(java_type); | |||
446 | return java_type.IsValid(); | |||
447 | } | |||
448 | } | |||
449 | break; | |||
450 | default: | |||
451 | assert(false && "Not a forward java type declaration!")((false && "Not a forward java type declaration!") ? static_cast <void> (0) : __assert_fail ("false && \"Not a forward java type declaration!\"" , "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270356/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp" , 451, __PRETTY_FUNCTION__)); | |||
452 | break; | |||
453 | } | |||
454 | return false; | |||
455 | } | |||
456 | ||||
457 | void | |||
458 | DWARFASTParserJava::ParseChildMembers(const DWARFDIE &parent_die, CompilerType &compiler_type) | |||
459 | { | |||
460 | DWARFCompileUnit *dwarf_cu = parent_die.GetCU(); | |||
461 | for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling()) | |||
462 | { | |||
463 | switch (die.Tag()) | |||
464 | { | |||
465 | case DW_TAG_member: | |||
466 | { | |||
467 | const char *name = nullptr; | |||
468 | DWARFFormValue encoding_uid; | |||
469 | uint32_t member_byte_offset = UINT32_MAX(4294967295U); | |||
470 | DWARFExpression member_location_expression(dwarf_cu); | |||
471 | bool artificial = true; | |||
472 | ||||
473 | DWARFAttributes attributes; | |||
474 | size_t num_attributes = die.GetAttributes(attributes); | |||
475 | for (size_t i = 0; i < num_attributes; ++i) | |||
476 | { | |||
477 | DWARFFormValue form_value; | |||
478 | if (attributes.ExtractFormValueAtIndex(i, form_value)) | |||
479 | { | |||
480 | switch (attributes.AttributeAtIndex(i)) | |||
481 | { | |||
482 | case DW_AT_name: | |||
483 | name = form_value.AsCString(); | |||
484 | break; | |||
485 | case DW_AT_type: | |||
486 | encoding_uid = form_value; | |||
487 | break; | |||
488 | case DW_AT_data_member_location: | |||
489 | if (form_value.BlockData()) | |||
490 | member_location_expression.CopyOpcodeData( | |||
491 | form_value.BlockData(), form_value.Unsigned(), dwarf_cu->GetByteOrder(), | |||
492 | dwarf_cu->GetAddressByteSize()); | |||
493 | else | |||
494 | member_byte_offset = form_value.Unsigned(); | |||
495 | break; | |||
496 | case DW_AT_artificial: | |||
497 | artificial = form_value.Boolean(); | |||
498 | break; | |||
499 | case DW_AT_accessibility: | |||
500 | // TODO: Handle when needed | |||
501 | break; | |||
502 | default: | |||
503 | assert(false && "Unhandled attribute for DW_TAG_member")((false && "Unhandled attribute for DW_TAG_member") ? static_cast<void> (0) : __assert_fail ("false && \"Unhandled attribute for DW_TAG_member\"" , "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270356/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp" , 503, __PRETTY_FUNCTION__)); | |||
504 | break; | |||
505 | } | |||
506 | } | |||
507 | } | |||
508 | ||||
509 | if (strcmp(name, ".dynamic_type") == 0) | |||
| ||||
510 | m_ast.SetDynamicTypeId(compiler_type, member_location_expression); | |||
511 | else | |||
512 | { | |||
513 | if (Type *member_type = die.ResolveTypeUID(DIERef(encoding_uid))) | |||
514 | m_ast.AddMemberToObject(compiler_type, ConstString(name), member_type->GetFullCompilerType(), | |||
515 | member_byte_offset); | |||
516 | } | |||
517 | break; | |||
518 | } | |||
519 | case DW_TAG_inheritance: | |||
520 | { | |||
521 | DWARFFormValue encoding_uid; | |||
522 | uint32_t member_byte_offset = UINT32_MAX(4294967295U); | |||
523 | ||||
524 | DWARFAttributes attributes; | |||
525 | size_t num_attributes = die.GetAttributes(attributes); | |||
526 | for (size_t i = 0; i < num_attributes; ++i) | |||
527 | { | |||
528 | DWARFFormValue form_value; | |||
529 | if (attributes.ExtractFormValueAtIndex(i, form_value)) | |||
530 | { | |||
531 | switch (attributes.AttributeAtIndex(i)) | |||
532 | { | |||
533 | case DW_AT_type: | |||
534 | encoding_uid = form_value; | |||
535 | break; | |||
536 | case DW_AT_data_member_location: | |||
537 | member_byte_offset = form_value.Unsigned(); | |||
538 | break; | |||
539 | case DW_AT_accessibility: | |||
540 | // In java all base class is public so we can ignore this attribute | |||
541 | break; | |||
542 | default: | |||
543 | assert(false && "Unhandled attribute for DW_TAG_member")((false && "Unhandled attribute for DW_TAG_member") ? static_cast<void> (0) : __assert_fail ("false && \"Unhandled attribute for DW_TAG_member\"" , "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270356/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp" , 543, __PRETTY_FUNCTION__)); | |||
544 | break; | |||
545 | } | |||
546 | } | |||
547 | } | |||
548 | if (Type *base_type = die.ResolveTypeUID(DIERef(encoding_uid))) | |||
549 | m_ast.AddBaseClassToObject(compiler_type, base_type->GetFullCompilerType(), member_byte_offset); | |||
550 | break; | |||
551 | } | |||
552 | default: | |||
553 | break; | |||
554 | } | |||
555 | } | |||
556 | } |