@@ -194,6 +194,253 @@ StringRef LVReader::getFilename(LVObject *Object, size_t Index) const {
194
194
return CompileUnit ? CompileUnit->getFilename (Index) : StringRef ();
195
195
}
196
196
197
+ void LVReader::addSectionRange (LVSectionIndex SectionIndex, LVScope *Scope) {
198
+ LVRange *ScopesWithRanges = getSectionRanges (SectionIndex);
199
+ ScopesWithRanges->addEntry (Scope);
200
+ }
201
+
202
+ void LVReader::addSectionRange (LVSectionIndex SectionIndex, LVScope *Scope,
203
+ LVAddress LowerAddress, LVAddress UpperAddress) {
204
+ LVRange *ScopesWithRanges = getSectionRanges (SectionIndex);
205
+ ScopesWithRanges->addEntry (Scope, LowerAddress, UpperAddress);
206
+ }
207
+
208
+ LVRange *LVReader::getSectionRanges (LVSectionIndex SectionIndex) {
209
+ // Check if we already have a mapping for this section index.
210
+ LVSectionRanges::iterator IterSection = SectionRanges.find (SectionIndex);
211
+ if (IterSection == SectionRanges.end ())
212
+ IterSection =
213
+ SectionRanges.emplace (SectionIndex, std::make_unique<LVRange>()).first ;
214
+ LVRange *Range = IterSection->second .get ();
215
+ assert (Range && " Range is null." );
216
+ return Range;
217
+ }
218
+
219
+ LVElement *LVReader::createElement (dwarf::Tag Tag) {
220
+ CurrentScope = nullptr ;
221
+ CurrentSymbol = nullptr ;
222
+ CurrentType = nullptr ;
223
+ CurrentRanges.clear ();
224
+
225
+ LLVM_DEBUG (
226
+ { dbgs () << " \n [createElement] " << dwarf::TagString (Tag) << " \n " ; });
227
+
228
+ if (!options ().getPrintSymbols ()) {
229
+ switch (Tag) {
230
+ // As the command line options did not specify a request to print
231
+ // logical symbols (--print=symbols or --print=all or --print=elements),
232
+ // skip its creation.
233
+ case dwarf::DW_TAG_formal_parameter:
234
+ case dwarf::DW_TAG_unspecified_parameters:
235
+ case dwarf::DW_TAG_member:
236
+ case dwarf::DW_TAG_variable:
237
+ case dwarf::DW_TAG_inheritance:
238
+ case dwarf::DW_TAG_constant:
239
+ case dwarf::DW_TAG_call_site_parameter:
240
+ case dwarf::DW_TAG_GNU_call_site_parameter:
241
+ return nullptr ;
242
+ default :
243
+ break ;
244
+ }
245
+ }
246
+
247
+ switch (Tag) {
248
+ // Types.
249
+ case dwarf::DW_TAG_base_type:
250
+ CurrentType = createType ();
251
+ CurrentType->setIsBase ();
252
+ if (options ().getAttributeBase ())
253
+ CurrentType->setIncludeInPrint ();
254
+ return CurrentType;
255
+ case dwarf::DW_TAG_const_type:
256
+ CurrentType = createType ();
257
+ CurrentType->setIsConst ();
258
+ CurrentType->setName (" const" );
259
+ return CurrentType;
260
+ case dwarf::DW_TAG_enumerator:
261
+ CurrentType = createTypeEnumerator ();
262
+ return CurrentType;
263
+ case dwarf::DW_TAG_imported_declaration:
264
+ CurrentType = createTypeImport ();
265
+ CurrentType->setIsImportDeclaration ();
266
+ return CurrentType;
267
+ case dwarf::DW_TAG_imported_module:
268
+ CurrentType = createTypeImport ();
269
+ CurrentType->setIsImportModule ();
270
+ return CurrentType;
271
+ case dwarf::DW_TAG_pointer_type:
272
+ CurrentType = createType ();
273
+ CurrentType->setIsPointer ();
274
+ CurrentType->setName (" *" );
275
+ return CurrentType;
276
+ case dwarf::DW_TAG_ptr_to_member_type:
277
+ CurrentType = createType ();
278
+ CurrentType->setIsPointerMember ();
279
+ CurrentType->setName (" *" );
280
+ return CurrentType;
281
+ case dwarf::DW_TAG_reference_type:
282
+ CurrentType = createType ();
283
+ CurrentType->setIsReference ();
284
+ CurrentType->setName (" &" );
285
+ return CurrentType;
286
+ case dwarf::DW_TAG_restrict_type:
287
+ CurrentType = createType ();
288
+ CurrentType->setIsRestrict ();
289
+ CurrentType->setName (" restrict" );
290
+ return CurrentType;
291
+ case dwarf::DW_TAG_rvalue_reference_type:
292
+ CurrentType = createType ();
293
+ CurrentType->setIsRvalueReference ();
294
+ CurrentType->setName (" &&" );
295
+ return CurrentType;
296
+ case dwarf::DW_TAG_subrange_type:
297
+ CurrentType = createTypeSubrange ();
298
+ return CurrentType;
299
+ case dwarf::DW_TAG_template_value_parameter:
300
+ CurrentType = createTypeParam ();
301
+ CurrentType->setIsTemplateValueParam ();
302
+ return CurrentType;
303
+ case dwarf::DW_TAG_template_type_parameter:
304
+ CurrentType = createTypeParam ();
305
+ CurrentType->setIsTemplateTypeParam ();
306
+ return CurrentType;
307
+ case dwarf::DW_TAG_GNU_template_template_param:
308
+ CurrentType = createTypeParam ();
309
+ CurrentType->setIsTemplateTemplateParam ();
310
+ return CurrentType;
311
+ case dwarf::DW_TAG_typedef:
312
+ CurrentType = createTypeDefinition ();
313
+ return CurrentType;
314
+ case dwarf::DW_TAG_unspecified_type:
315
+ CurrentType = createType ();
316
+ CurrentType->setIsUnspecified ();
317
+ return CurrentType;
318
+ case dwarf::DW_TAG_volatile_type:
319
+ CurrentType = createType ();
320
+ CurrentType->setIsVolatile ();
321
+ CurrentType->setName (" volatile" );
322
+ return CurrentType;
323
+
324
+ // Symbols.
325
+ case dwarf::DW_TAG_formal_parameter:
326
+ CurrentSymbol = createSymbol ();
327
+ CurrentSymbol->setIsParameter ();
328
+ return CurrentSymbol;
329
+ case dwarf::DW_TAG_unspecified_parameters:
330
+ CurrentSymbol = createSymbol ();
331
+ CurrentSymbol->setIsUnspecified ();
332
+ CurrentSymbol->setName (" ..." );
333
+ return CurrentSymbol;
334
+ case dwarf::DW_TAG_member:
335
+ CurrentSymbol = createSymbol ();
336
+ CurrentSymbol->setIsMember ();
337
+ return CurrentSymbol;
338
+ case dwarf::DW_TAG_variable:
339
+ CurrentSymbol = createSymbol ();
340
+ CurrentSymbol->setIsVariable ();
341
+ return CurrentSymbol;
342
+ case dwarf::DW_TAG_inheritance:
343
+ CurrentSymbol = createSymbol ();
344
+ CurrentSymbol->setIsInheritance ();
345
+ return CurrentSymbol;
346
+ case dwarf::DW_TAG_call_site_parameter:
347
+ case dwarf::DW_TAG_GNU_call_site_parameter:
348
+ CurrentSymbol = createSymbol ();
349
+ CurrentSymbol->setIsCallSiteParameter ();
350
+ return CurrentSymbol;
351
+ case dwarf::DW_TAG_constant:
352
+ CurrentSymbol = createSymbol ();
353
+ CurrentSymbol->setIsConstant ();
354
+ return CurrentSymbol;
355
+
356
+ // Scopes.
357
+ case dwarf::DW_TAG_catch_block:
358
+ CurrentScope = createScope ();
359
+ CurrentScope->setIsCatchBlock ();
360
+ return CurrentScope;
361
+ case dwarf::DW_TAG_lexical_block:
362
+ CurrentScope = createScope ();
363
+ CurrentScope->setIsLexicalBlock ();
364
+ return CurrentScope;
365
+ case dwarf::DW_TAG_try_block:
366
+ CurrentScope = createScope ();
367
+ CurrentScope->setIsTryBlock ();
368
+ return CurrentScope;
369
+ case dwarf::DW_TAG_compile_unit:
370
+ case dwarf::DW_TAG_skeleton_unit:
371
+ CurrentScope = createScopeCompileUnit ();
372
+ CompileUnit = static_cast <LVScopeCompileUnit *>(CurrentScope);
373
+ return CurrentScope;
374
+ case dwarf::DW_TAG_inlined_subroutine:
375
+ CurrentScope = createScopeFunctionInlined ();
376
+ return CurrentScope;
377
+ case dwarf::DW_TAG_namespace:
378
+ CurrentScope = createScopeNamespace ();
379
+ return CurrentScope;
380
+ case dwarf::DW_TAG_template_alias:
381
+ CurrentScope = createScopeAlias ();
382
+ return CurrentScope;
383
+ case dwarf::DW_TAG_array_type:
384
+ CurrentScope = createScopeArray ();
385
+ return CurrentScope;
386
+ case dwarf::DW_TAG_call_site:
387
+ case dwarf::DW_TAG_GNU_call_site:
388
+ CurrentScope = createScopeFunction ();
389
+ CurrentScope->setIsCallSite ();
390
+ return CurrentScope;
391
+ case dwarf::DW_TAG_entry_point:
392
+ CurrentScope = createScopeFunction ();
393
+ CurrentScope->setIsEntryPoint ();
394
+ return CurrentScope;
395
+ case dwarf::DW_TAG_subprogram:
396
+ CurrentScope = createScopeFunction ();
397
+ CurrentScope->setIsSubprogram ();
398
+ return CurrentScope;
399
+ case dwarf::DW_TAG_subroutine_type:
400
+ CurrentScope = createScopeFunctionType ();
401
+ return CurrentScope;
402
+ case dwarf::DW_TAG_label:
403
+ CurrentScope = createScopeFunction ();
404
+ CurrentScope->setIsLabel ();
405
+ return CurrentScope;
406
+ case dwarf::DW_TAG_class_type:
407
+ CurrentScope = createScopeAggregate ();
408
+ CurrentScope->setIsClass ();
409
+ return CurrentScope;
410
+ case dwarf::DW_TAG_structure_type:
411
+ CurrentScope = createScopeAggregate ();
412
+ CurrentScope->setIsStructure ();
413
+ return CurrentScope;
414
+ case dwarf::DW_TAG_union_type:
415
+ CurrentScope = createScopeAggregate ();
416
+ CurrentScope->setIsUnion ();
417
+ return CurrentScope;
418
+ case dwarf::DW_TAG_enumeration_type:
419
+ CurrentScope = createScopeEnumeration ();
420
+ return CurrentScope;
421
+ case dwarf::DW_TAG_GNU_formal_parameter_pack:
422
+ CurrentScope = createScopeFormalPack ();
423
+ return CurrentScope;
424
+ case dwarf::DW_TAG_GNU_template_parameter_pack:
425
+ CurrentScope = createScopeTemplatePack ();
426
+ return CurrentScope;
427
+ case dwarf::DW_TAG_module:
428
+ CurrentScope = createScopeModule ();
429
+ return CurrentScope;
430
+ default :
431
+ // Collect TAGs not implemented.
432
+ if (options ().getInternalTag () && Tag)
433
+ CompileUnit->addDebugTag (Tag, CurrentOffset);
434
+ break ;
435
+ }
436
+
437
+ LLVM_DEBUG ({
438
+ dbgs () << " DWARF Tag not implemented: " << dwarf::TagString (Tag) << " \n " ;
439
+ });
440
+
441
+ return nullptr ;
442
+ }
443
+
197
444
// The Reader is the module that creates the logical view using the debug
198
445
// information contained in the binary file specified in the command line.
199
446
// This is the main entry point for the Reader and performs the following
0 commit comments