forked from OSchip/llvm-project
Rebase: [BOLT][DebugFission] Fix reading support for DWP
Summary: Dived more in to DWARF APIs and llvm-symbolizer this is a more streamline way of doing it, and address base gets set properly. Writing out dwo files with dwp input will be separate patch. (cherry picked from FBD31361529)
This commit is contained in:
parent
a8b9319536
commit
e485a9830b
|
@ -50,12 +50,6 @@ extern cl::opt<unsigned> ExecutionCountThreshold;
|
|||
|
||||
extern bool processAllFunctions();
|
||||
|
||||
static cl::opt<std::string>
|
||||
DWPPath("dwp-path",
|
||||
cl::desc("Path to DWP file. DWP file name must be same as "
|
||||
"binary name with .dwp extension."),
|
||||
cl::Hidden, cl::ZeroOrMore, cl::cat(BoltCategory));
|
||||
|
||||
cl::opt<bool>
|
||||
NoHugePages("no-huge-pages",
|
||||
cl::desc("use regular size pages for code alignment"),
|
||||
|
@ -1467,27 +1461,10 @@ Optional<DWARFUnit *> BinaryContext::getDWOCU(uint64_t DWOId) {
|
|||
|
||||
/// Handles DWO sections that can either be in .o, .dwo or .dwp files.
|
||||
void BinaryContext::preprocessDWODebugInfo() {
|
||||
// If DWP file exists use it to populate CU map.
|
||||
if (!opts::DWPPath.empty()) {
|
||||
DWPContext = DwCtx->getDWOContext(opts::DWPPath.c_str());
|
||||
if (!DWPContext)
|
||||
report_error("DWP file not found.",
|
||||
std::make_error_code(std::errc::no_such_file_or_directory));
|
||||
for (const std::unique_ptr<DWARFUnit> &CU : DwCtx->compile_units()) {
|
||||
DWARFUnit *DwarfUnit = CU.get();
|
||||
if (llvm::Optional<uint64_t> DWOId = DwarfUnit->getDWOId()) {
|
||||
DWARFCompileUnit *DWOCU =
|
||||
DWPContext.get()->getDWOCompileUnitForHash(*DWOId);
|
||||
if (DWOCU)
|
||||
DWOCUs[*DWOId] = DWOCU;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const std::unique_ptr<DWARFUnit> &CU : DwCtx->compile_units()) {
|
||||
DWARFUnit *const DwarfUnit = CU.get();
|
||||
if (llvm::Optional<uint64_t> DWOId = DwarfUnit->getDWOId()) {
|
||||
DWARFUnit *DWOCU =
|
||||
DwarfUnit->getNonSkeletonUnitDIE(false).getDwarfUnit();
|
||||
DWARFUnit *DWOCU = DwarfUnit->getNonSkeletonUnitDIE(false).getDwarfUnit();
|
||||
if (!DWOCU->isDWOUnit()) {
|
||||
std::string DWOName = dwarf::toString(
|
||||
DwarfUnit->getUnitDIE().find(
|
||||
|
@ -1503,7 +1480,6 @@ void BinaryContext::preprocessDWODebugInfo() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BinaryContext::preprocessDebugInfo() {
|
||||
struct CURange {
|
||||
|
|
|
@ -322,6 +322,11 @@ TrapOldCode("trap-old-code",
|
|||
cl::Hidden,
|
||||
cl::cat(BoltCategory));
|
||||
|
||||
static cl::opt<std::string> DWPPathName("dwp",
|
||||
cl::desc("Path and name to DWP file."),
|
||||
cl::Hidden, cl::ZeroOrMore,
|
||||
cl::init(""), cl::cat(BoltCategory));
|
||||
|
||||
cl::opt<bool>
|
||||
UpdateDebugSections("update-debug-sections",
|
||||
cl::desc("update DWARF debug sections of the executable"),
|
||||
|
@ -474,8 +479,9 @@ RewriteInstance::RewriteInstance(ELFObjectFileBase *File, const int Argc,
|
|||
BC = BinaryContext::createBinaryContext(
|
||||
File, IsPIC,
|
||||
DWARFContext::create(
|
||||
*File, DWARFContext::ProcessDebugRelocations::Process, nullptr, "",
|
||||
WithColor::defaultErrorHandler, WithColor::defaultWarningHandler));
|
||||
*File, DWARFContext::ProcessDebugRelocations::Process, nullptr,
|
||||
opts::DWPPathName, WithColor::defaultErrorHandler,
|
||||
WithColor::defaultWarningHandler));
|
||||
|
||||
BAT = std::make_unique<BoltAddressTranslation>(*BC);
|
||||
|
||||
|
|
Loading…
Reference in New Issue