@@ -443,8 +443,7 @@ static bool getFileLineInfoForCompileUnit(DWARFCompileUnit *CU,
443
443
const DWARFLineTable *LineTable,
444
444
uint64_t Address,
445
445
bool NeedsAbsoluteFilePath,
446
- std::string &FileName,
447
- uint32_t &Line, uint32_t &Column) {
446
+ DILineInfo &Result) {
448
447
if (!CU || !LineTable)
449
448
return false ;
450
449
// Get the index of row we're looking for in the line table.
@@ -453,45 +452,49 @@ static bool getFileLineInfoForCompileUnit(DWARFCompileUnit *CU,
453
452
return false ;
454
453
// Take file number and line/column from the row.
455
454
const DWARFDebugLine::Row &Row = LineTable->Rows [RowIndex];
456
- if (!getFileNameForCompileUnit (CU, LineTable, Row.File ,
457
- NeedsAbsoluteFilePath, FileName))
455
+ if (!getFileNameForCompileUnit (CU, LineTable, Row.File , NeedsAbsoluteFilePath,
456
+ Result. FileName ))
458
457
return false ;
459
- Line = Row.Line ;
460
- Column = Row.Column ;
458
+ Result. Line = Row.Line ;
459
+ Result. Column = Row.Column ;
461
460
return true ;
462
461
}
463
462
463
+ static bool getFunctionNameForAddress (DWARFCompileUnit *CU, uint64_t Address,
464
+ std::string &FunctionName) {
465
+ // The address may correspond to instruction in some inlined function,
466
+ // so we have to build the chain of inlined functions and take the
467
+ // name of the topmost function in it.
468
+ const DWARFDebugInfoEntryInlinedChain &InlinedChain =
469
+ CU->getInlinedChainForAddress (Address);
470
+ if (InlinedChain.DIEs .size () == 0 )
471
+ return false ;
472
+ const DWARFDebugInfoEntryMinimal &TopFunctionDIE = InlinedChain.DIEs [0 ];
473
+ if (const char *Name = TopFunctionDIE.getSubroutineName (InlinedChain.U )) {
474
+ FunctionName = Name;
475
+ return true ;
476
+ }
477
+ return false ;
478
+ }
479
+
464
480
DILineInfo DWARFContext::getLineInfoForAddress (uint64_t Address,
465
481
DILineInfoSpecifier Specifier) {
482
+ DILineInfo Result;
483
+
466
484
DWARFCompileUnit *CU = getCompileUnitForAddress (Address);
467
485
if (!CU)
468
- return DILineInfo ();
469
- std::string FileName = " <invalid>" ;
470
- std::string FunctionName = " <invalid>" ;
471
- uint32_t Line = 0 ;
472
- uint32_t Column = 0 ;
486
+ return Result;
473
487
if (Specifier.needs (DILineInfoSpecifier::FunctionName)) {
474
- // The address may correspond to instruction in some inlined function,
475
- // so we have to build the chain of inlined functions and take the
476
- // name of the topmost function in it.
477
- const DWARFDebugInfoEntryInlinedChain &InlinedChain =
478
- CU->getInlinedChainForAddress (Address);
479
- if (InlinedChain.DIEs .size () > 0 ) {
480
- const DWARFDebugInfoEntryMinimal &TopFunctionDIE = InlinedChain.DIEs [0 ];
481
- if (const char *Name = TopFunctionDIE.getSubroutineName (InlinedChain.U ))
482
- FunctionName = Name;
483
- }
488
+ getFunctionNameForAddress (CU, Address, Result.FunctionName );
484
489
}
485
490
if (Specifier.needs (DILineInfoSpecifier::FileLineInfo)) {
486
491
const DWARFLineTable *LineTable = getLineTableForCompileUnit (CU);
487
492
const bool NeedsAbsoluteFilePath =
488
493
Specifier.needs (DILineInfoSpecifier::AbsoluteFilePath);
489
- getFileLineInfoForCompileUnit (CU, LineTable, Address,
490
- NeedsAbsoluteFilePath,
491
- FileName, Line, Column);
494
+ getFileLineInfoForCompileUnit (CU, LineTable, Address, NeedsAbsoluteFilePath,
495
+ Result);
492
496
}
493
- return DILineInfo (StringRef (FileName), StringRef (FunctionName),
494
- Line, Column);
497
+ return Result;
495
498
}
496
499
497
500
DILineInfoTable DWARFContext::getLineInfoForAddressRange (uint64_t Address,
@@ -504,23 +507,15 @@ DILineInfoTable DWARFContext::getLineInfoForAddressRange(uint64_t Address,
504
507
505
508
std::string FunctionName = " <invalid>" ;
506
509
if (Specifier.needs (DILineInfoSpecifier::FunctionName)) {
507
- // The address may correspond to instruction in some inlined function,
508
- // so we have to build the chain of inlined functions and take the
509
- // name of the topmost function in it.
510
- const DWARFDebugInfoEntryInlinedChain &InlinedChain =
511
- CU->getInlinedChainForAddress (Address);
512
- if (InlinedChain.DIEs .size () > 0 ) {
513
- const DWARFDebugInfoEntryMinimal &TopFunctionDIE = InlinedChain.DIEs [0 ];
514
- if (const char *Name = TopFunctionDIE.getSubroutineName (InlinedChain.U ))
515
- FunctionName = Name;
516
- }
510
+ getFunctionNameForAddress (CU, Address, FunctionName);
517
511
}
518
512
519
513
// If the Specifier says we don't need FileLineInfo, just
520
514
// return the top-most function at the starting address.
521
515
if (!Specifier.needs (DILineInfoSpecifier::FileLineInfo)) {
522
- Lines.push_back (
523
- std::make_pair (Address, DILineInfo (" <invalid>" , FunctionName, 0 , 0 )));
516
+ DILineInfo Result;
517
+ Result.FunctionName = FunctionName;
518
+ Lines.push_back (std::make_pair (Address, Result));
524
519
return Lines;
525
520
}
526
521
@@ -536,11 +531,13 @@ DILineInfoTable DWARFContext::getLineInfoForAddressRange(uint64_t Address,
536
531
for (uint32_t RowIndex : RowVector) {
537
532
// Take file number and line/column from the row.
538
533
const DWARFDebugLine::Row &Row = LineTable->Rows [RowIndex];
539
- std::string FileName = " <invalid>" ;
540
- getFileNameForCompileUnit (CU, LineTable, Row.File ,
541
- NeedsAbsoluteFilePath, FileName);
542
- Lines.push_back (std::make_pair (
543
- Row.Address , DILineInfo (FileName, FunctionName, Row.Line , Row.Column )));
534
+ DILineInfo Result;
535
+ getFileNameForCompileUnit (CU, LineTable, Row.File , NeedsAbsoluteFilePath,
536
+ Result.FileName );
537
+ Result.FunctionName = FunctionName;
538
+ Result.Line = Row.Line ;
539
+ Result.Column = Row.Column ;
540
+ Lines.push_back (std::make_pair (Row.Address , Result));
544
541
}
545
542
546
543
return Lines;
@@ -562,14 +559,11 @@ DIInliningInfo DWARFContext::getInliningInfoForAddress(uint64_t Address,
562
559
const DWARFLineTable *LineTable = nullptr ;
563
560
for (uint32_t i = 0 , n = InlinedChain.DIEs .size (); i != n; i++) {
564
561
const DWARFDebugInfoEntryMinimal &FunctionDIE = InlinedChain.DIEs [i];
565
- std::string FileName = " <invalid>" ;
566
- std::string FunctionName = " <invalid>" ;
567
- uint32_t Line = 0 ;
568
- uint32_t Column = 0 ;
562
+ DILineInfo Frame;
569
563
// Get function name if necessary.
570
564
if (Specifier.needs (DILineInfoSpecifier::FunctionName)) {
571
565
if (const char *Name = FunctionDIE.getSubroutineName (InlinedChain.U ))
572
- FunctionName = Name;
566
+ Frame. FunctionName = Name;
573
567
}
574
568
if (Specifier.needs (DILineInfoSpecifier::FileLineInfo)) {
575
569
const bool NeedsAbsoluteFilePath =
@@ -581,23 +575,21 @@ DIInliningInfo DWARFContext::getInliningInfoForAddress(uint64_t Address,
581
575
// For the topmost routine, get file/line info from line table.
582
576
getFileLineInfoForCompileUnit (CU, LineTable, Address,
583
577
NeedsAbsoluteFilePath,
584
- FileName, Line, Column );
578
+ Frame );
585
579
} else {
586
580
// Otherwise, use call file, call line and call column from
587
581
// previous DIE in inlined chain.
588
582
getFileNameForCompileUnit (CU, LineTable, CallFile,
589
- NeedsAbsoluteFilePath, FileName);
590
- Line = CallLine;
591
- Column = CallColumn;
583
+ NeedsAbsoluteFilePath, Frame. FileName );
584
+ Frame. Line = CallLine;
585
+ Frame. Column = CallColumn;
592
586
}
593
587
// Get call file/line/column of a current DIE.
594
588
if (i + 1 < n) {
595
589
FunctionDIE.getCallerFrame (InlinedChain.U , CallFile, CallLine,
596
590
CallColumn);
597
591
}
598
592
}
599
- DILineInfo Frame (StringRef (FileName), StringRef (FunctionName),
600
- Line, Column);
601
593
InliningInfo.addFrame (Frame);
602
594
}
603
595
return InliningInfo;
0 commit comments