Skip to content

[llvm-debuginfo-analyzer][NFC] Rename LVElfReader.cpp[h] #85530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
//===-- LVELFReader.h -------------------------------------------*- C++ -*-===//
//===-- LVDWARFReader.h -----------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines the LVELFReader class, which is used to describe a
// This file defines the LVDWARFReader class, which is used to describe a
// debug information (DWARF) reader.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_DEBUGINFO_LOGICALVIEW_READERS_LVELFREADER_H
#define LLVM_DEBUGINFO_LOGICALVIEW_READERS_LVELFREADER_H
#ifndef LLVM_DEBUGINFO_LOGICALVIEW_READERS_LVDWARFREADER_H
#define LLVM_DEBUGINFO_LOGICALVIEW_READERS_LVDWARFREADER_H

#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
Expand All @@ -30,7 +30,7 @@ class LVType;

using AttributeSpec = DWARFAbbreviationDeclaration::AttributeSpec;

class LVELFReader final : public LVBinaryReader {
class LVDWARFReader final : public LVBinaryReader {
object::ObjectFile &Obj;

// Indicates if ranges data are available; in the case of split DWARF any
Expand Down Expand Up @@ -127,14 +127,14 @@ class LVELFReader final : public LVBinaryReader {
void sortScopes() override;

public:
LVELFReader() = delete;
LVELFReader(StringRef Filename, StringRef FileFormatName,
object::ObjectFile &Obj, ScopedPrinter &W)
LVDWARFReader() = delete;
LVDWARFReader(StringRef Filename, StringRef FileFormatName,
object::ObjectFile &Obj, ScopedPrinter &W)
: LVBinaryReader(Filename, FileFormatName, W, LVBinaryType::ELF),
Obj(Obj) {}
LVELFReader(const LVELFReader &) = delete;
LVELFReader &operator=(const LVELFReader &) = delete;
~LVELFReader() = default;
LVDWARFReader(const LVDWARFReader &) = delete;
LVDWARFReader &operator=(const LVDWARFReader &) = delete;
~LVDWARFReader() = default;

LVAddress getCUBaseAddress() const { return CUBaseAddress; }
void setCUBaseAddress(LVAddress Address) { CUBaseAddress = Address; }
Expand All @@ -158,4 +158,4 @@ class LVELFReader final : public LVBinaryReader {
} // end namespace logicalview
} // end namespace llvm

#endif // LLVM_DEBUGINFO_LOGICALVIEW_READERS_LVELFREADER_H
#endif // LLVM_DEBUGINFO_LOGICALVIEW_READERS_LVDWARFREADER_H
2 changes: 1 addition & 1 deletion llvm/lib/DebugInfo/LogicalView/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ add_lv_impl_folder(Readers
Readers/LVBinaryReader.cpp
Readers/LVCodeViewReader.cpp
Readers/LVCodeViewVisitor.cpp
Readers/LVELFReader.cpp
Readers/LVDWARFReader.cpp
)

list(APPEND LIBLV_ADDITIONAL_HEADER_DIRS
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/DebugInfo/LogicalView/LVReaderHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
#include "llvm/DebugInfo/LogicalView/Core/LVCompare.h"
#include "llvm/DebugInfo/LogicalView/Readers/LVCodeViewReader.h"
#include "llvm/DebugInfo/LogicalView/Readers/LVELFReader.h"
#include "llvm/DebugInfo/LogicalView/Readers/LVDWARFReader.h"
#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
#include "llvm/DebugInfo/PDB/PDB.h"
#include "llvm/Object/COFF.h"
Expand Down Expand Up @@ -49,7 +49,8 @@ Error LVReaderHandler::createReader(StringRef Filename, LVReaders &Readers,
*COFF, W, ExePath);
}
if (Obj.isELF() || Obj.isMachO() || Obj.isWasm())
return std::make_unique<LVELFReader>(Filename, FileFormatName, Obj, W);
return std::make_unique<LVDWARFReader>(Filename, FileFormatName, Obj,
W);
}
if (isa<PDBFile *>(Input)) {
PDBFile &Pdb = *cast<PDBFile *>(Input);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
//===-- LVELFReader.cpp ---------------------------------------------------===//
//===-- LVDWARFReader.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This implements the LVELFReader class.
// This implements the LVDWARFReader class.
// It supports ELF, Mach-O and Wasm binary formats.
//
//===----------------------------------------------------------------------===//

#include "llvm/DebugInfo/LogicalView/Readers/LVELFReader.h"
#include "llvm/DebugInfo/LogicalView/Readers/LVDWARFReader.h"
#include "llvm/DebugInfo/DIContext.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
Expand All @@ -27,9 +27,9 @@ using namespace llvm;
using namespace llvm::object;
using namespace llvm::logicalview;

#define DEBUG_TYPE "ElfReader"
#define DEBUG_TYPE "DWARFReader"

LVElement *LVELFReader::createElement(dwarf::Tag Tag) {
LVElement *LVDWARFReader::createElement(dwarf::Tag Tag) {
CurrentScope = nullptr;
CurrentSymbol = nullptr;
CurrentType = nullptr;
Expand Down Expand Up @@ -243,8 +243,9 @@ LVElement *LVELFReader::createElement(dwarf::Tag Tag) {
return nullptr;
}

void LVELFReader::processOneAttribute(const DWARFDie &Die, LVOffset *OffsetPtr,
const AttributeSpec &AttrSpec) {
void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
LVOffset *OffsetPtr,
const AttributeSpec &AttrSpec) {
uint64_t OffsetOnEntry = *OffsetPtr;
DWARFUnit *U = Die.getDwarfUnit();
const DWARFFormValue &FormValue =
Expand Down Expand Up @@ -515,8 +516,8 @@ void LVELFReader::processOneAttribute(const DWARFDie &Die, LVOffset *OffsetPtr,
}
}

LVScope *LVELFReader::processOneDie(const DWARFDie &InputDIE, LVScope *Parent,
DWARFDie &SkeletonDie) {
LVScope *LVDWARFReader::processOneDie(const DWARFDie &InputDIE, LVScope *Parent,
DWARFDie &SkeletonDie) {
// If the input DIE corresponds to the compile unit, it can be:
// a) Simple DWARF: a standard DIE. Ignore the skeleton DIE (is empty).
// b) Split DWARF: the DIE for the split DWARF. The skeleton is the DIE
Expand Down Expand Up @@ -688,8 +689,8 @@ LVScope *LVELFReader::processOneDie(const DWARFDie &InputDIE, LVScope *Parent,
return CurrentScope;
}

void LVELFReader::traverseDieAndChildren(DWARFDie &DIE, LVScope *Parent,
DWARFDie &SkeletonDie) {
void LVDWARFReader::traverseDieAndChildren(DWARFDie &DIE, LVScope *Parent,
DWARFDie &SkeletonDie) {
// Process the current DIE.
LVScope *Scope = processOneDie(DIE, Parent, SkeletonDie);
if (Scope) {
Expand All @@ -709,13 +710,13 @@ void LVELFReader::traverseDieAndChildren(DWARFDie &DIE, LVScope *Parent,
}
}

void LVELFReader::processLocationGaps() {
void LVDWARFReader::processLocationGaps() {
if (options().getAttributeAnyLocation())
for (LVSymbol *Symbol : SymbolsWithLocations)
Symbol->fillLocationGaps();
}

void LVELFReader::createLineAndFileRecords(
void LVDWARFReader::createLineAndFileRecords(
const DWARFDebugLine::LineTable *Lines) {
if (!Lines)
return;
Expand Down Expand Up @@ -772,8 +773,8 @@ void LVELFReader::createLineAndFileRecords(
}
}

std::string LVELFReader::getRegisterName(LVSmall Opcode,
ArrayRef<uint64_t> Operands) {
std::string LVDWARFReader::getRegisterName(LVSmall Opcode,
ArrayRef<uint64_t> Operands) {
// The 'prettyPrintRegisterOp' function uses the DWARFUnit to support
// DW_OP_regval_type. At this point we are operating on a logical view
// item, with no access to the underlying DWARF data used by LLVM.
Expand All @@ -800,7 +801,7 @@ std::string LVELFReader::getRegisterName(LVSmall Opcode,
return Stream.str();
}

Error LVELFReader::createScopes() {
Error LVDWARFReader::createScopes() {
LLVM_DEBUG({
W.startLine() << "\n";
W.printString("File", Obj.getFileName().str());
Expand Down Expand Up @@ -980,11 +981,11 @@ Error LVELFReader::createScopes() {
}

// Get the location information for the associated attribute.
void LVELFReader::processLocationList(dwarf::Attribute Attr,
const DWARFFormValue &FormValue,
const DWARFDie &Die,
uint64_t OffsetOnEntry,
bool CallSiteLocation) {
void LVDWARFReader::processLocationList(dwarf::Attribute Attr,
const DWARFFormValue &FormValue,
const DWARFDie &Die,
uint64_t OffsetOnEntry,
bool CallSiteLocation) {

auto ProcessLocationExpression = [&](const DWARFExpression &Expression) {
for (const DWARFExpression::Operation &Op : Expression)
Expand Down Expand Up @@ -1061,10 +1062,10 @@ void LVELFReader::processLocationList(dwarf::Attribute Attr,
}
}

void LVELFReader::processLocationMember(dwarf::Attribute Attr,
const DWARFFormValue &FormValue,
const DWARFDie &Die,
uint64_t OffsetOnEntry) {
void LVDWARFReader::processLocationMember(dwarf::Attribute Attr,
const DWARFFormValue &FormValue,
const DWARFDie &Die,
uint64_t OffsetOnEntry) {
// Check if the value is an integer constant.
if (FormValue.isFormClass(DWARFFormValue::FC_Constant))
// Add a record to hold a constant as location.
Expand All @@ -1076,8 +1077,8 @@ void LVELFReader::processLocationMember(dwarf::Attribute Attr,
}

// Update the current element with the reference.
void LVELFReader::updateReference(dwarf::Attribute Attr,
const DWARFFormValue &FormValue) {
void LVDWARFReader::updateReference(dwarf::Attribute Attr,
const DWARFFormValue &FormValue) {
// FIXME: We are assuming that at most one Reference (DW_AT_specification,
// DW_AT_abstract_origin, ...) and at most one Type (DW_AT_import, DW_AT_type)
// appear in any single DIE, but this may not be true.
Expand Down Expand Up @@ -1129,8 +1130,8 @@ void LVELFReader::updateReference(dwarf::Attribute Attr,
}

// Get an element given the DIE offset.
LVElement *LVELFReader::getElementForOffset(LVOffset Offset, LVElement *Element,
bool IsType) {
LVElement *LVDWARFReader::getElementForOffset(LVOffset Offset,
LVElement *Element, bool IsType) {
auto Iter = ElementTable.try_emplace(Offset).first;
// Update the element and all the references pointing to this element.
LVElementEntry &Entry = Iter->second;
Expand All @@ -1143,7 +1144,7 @@ LVElement *LVELFReader::getElementForOffset(LVOffset Offset, LVElement *Element,
return Entry.Element;
}

Error LVELFReader::loadTargetInfo(const ObjectFile &Obj) {
Error LVDWARFReader::loadTargetInfo(const ObjectFile &Obj) {
// Detect the architecture from the object file. We usually don't need OS
// info to lookup a target and create register info.
Triple TT;
Expand All @@ -1162,7 +1163,7 @@ Error LVELFReader::loadTargetInfo(const ObjectFile &Obj) {
return loadGenericTargetInfo(TT.str(), FeaturesValue.getString());
}

void LVELFReader::mapRangeAddress(const ObjectFile &Obj) {
void LVDWARFReader::mapRangeAddress(const ObjectFile &Obj) {
for (auto Iter = Obj.symbol_begin(); Iter != Obj.symbol_end(); ++Iter) {
const SymbolRef &Symbol = *Iter;

Expand Down Expand Up @@ -1238,9 +1239,9 @@ void LVELFReader::mapRangeAddress(const ObjectFile &Obj) {
}
}

void LVELFReader::sortScopes() { Root->sort(); }
void LVDWARFReader::sortScopes() { Root->sort(); }

void LVELFReader::print(raw_ostream &OS) const {
void LVDWARFReader::print(raw_ostream &OS) const {
OS << "LVType\n";
LLVM_DEBUG(dbgs() << "CreateReaders\n");
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

; The above test compiled with clang++ produces both a DW_AT_type and
; DW_AT_specification on the definition die for S::Arr, which previously caused
; an assert in the LVELFReader:
; an assert in the LVDWARFReader:
; $ clang++ -g -c dw-at-specification.cpp -o dw-at-specification.o

; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
; DW_AT_decl_file DW_FORM_implicit_const 1
; DW_AT_decl_line DW_FORM_data1

; Attributes with DW_FORM_implicit_const being ignored by the ELFReader,
; Attributes with DW_FORM_implicit_const being ignored by the DWARFReader,
; causing {Parameter} and {TypeAlias} to omit line numbers.

; test.cpp
Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/llvm-debuginfo-analyzer/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ use LIT tests to validate the logical readers.

Convert the unitests:
llvm-project/llvm/unittests/DebugInfo/LogicalView/CodeViewReaderTest.cpp
llvm-project/llvm/unittests/DebugInfo/LogicalView/ELFReaderTest.cpp
llvm-project/llvm/unittests/DebugInfo/LogicalView/DWARFReaderTest.cpp

into LIT tests:
llvm-project/llvm/test/DebugInfo/LogicalView/CodeViewReader.test
llvm-project/llvm/test/DebugInfo/LogicalView/ELFReader.test
llvm-project/llvm/test/DebugInfo/LogicalView/DWARFReader.test

//===----------------------------------------------------------------------===//
// Eliminate calls to 'getInputFileDirectory()' in the unit tests.
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/DebugInfo/LogicalView/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ add_llvm_unittest_with_input_files(DebugInfoLogicalViewTests
CodeViewReaderTest.cpp
CommandLineOptionsTest.cpp
CompareElementsTest.cpp
ELFReaderTest.cpp
DWARFReaderTest.cpp
SelectElementsTest.cpp
LocationRangesTest.cpp
LogicalElementsTest.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- llvm/unittest/DebugInfo/LogicalView/ELFReaderTest.cpp --------------===//
//===- llvm/unittest/DebugInfo/LogicalView/DWARFReaderTest.cpp ------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down Expand Up @@ -323,7 +323,7 @@ void compareElements(SmallString<128> &InputsDir) {
checkElementComparison(Reference.get(), Target.get());
}

TEST(LogicalViewTest, ELFReader) {
TEST(LogicalViewTest, DWARFReader) {
// Initialize targets and assembly printers/parsers.
llvm::InitializeAllTargetInfos();
llvm::InitializeAllTargetMCs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ static_library("LogicalView") {
"Readers/LVBinaryReader.cpp",
"Readers/LVCodeViewReader.cpp",
"Readers/LVCodeViewVisitor.cpp",
"Readers/LVELFReader.cpp",
"Readers/LVDWARFReader.cpp",
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ unittest("DebugInfoLogicalViewTests") {
"CodeViewReaderTest.cpp",
"CommandLineOptionsTest.cpp",
"CompareElementsTest.cpp",
"ELFReaderTest.cpp",
"DWARFReaderTest.cpp",
"LocationRangesTest.cpp",
"LogicalElementsTest.cpp",
"SelectElementsTest.cpp",
Expand Down