1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[llvm-dwarfdump] Interface cleanup. NFC

This patch moves interface declarations into llvm-dwarfdump.h and wrap
declarations in anonymous namespaces as appropriate. At the same time,
the externals are moved into the `llvm::dwarfdump` namespace`.

Reviewed By: djtodoro

Differential Revision: https://reviews.llvm.org/D77848
This commit is contained in:
Fangrui Song 2020-04-09 18:23:39 -07:00
parent 290d634505
commit c96a431cd3
4 changed files with 41 additions and 30 deletions

View File

@ -6,12 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "SectionSizes.h"
#include "llvm-dwarfdump.h"
#define DEBUG_TYPE "dwarfdump"
using namespace llvm;
using namespace object;
using namespace llvm::dwarfdump;
using namespace llvm::object;
static size_t getNameColumnWidth(const SectionSizes &Sizes,
const StringRef SectionNameTitle) {
@ -77,8 +78,9 @@ static void prettyPrintSectionSizes(const ObjectFile &Obj,
OS << "----------------------------------------------------" << '\n';
}
void llvm::calculateSectionSizes(const ObjectFile &Obj, SectionSizes &Sizes,
const Twine &Filename) {
void dwarfdump::calculateSectionSizes(const ObjectFile &Obj,
SectionSizes &Sizes,
const Twine &Filename) {
// Get total size.
Sizes.TotalObjectSize = Obj.getData().size();
@ -101,8 +103,10 @@ void llvm::calculateSectionSizes(const ObjectFile &Obj, SectionSizes &Sizes,
}
}
bool collectObjectSectionSizes(ObjectFile &Obj, DWARFContext & /*DICtx*/,
const Twine &Filename, raw_ostream &OS) {
bool dwarfdump::collectObjectSectionSizes(ObjectFile &Obj,
DWARFContext & /*DICtx*/,
const Twine &Filename,
raw_ostream &OS) {
SectionSizes Sizes;
// Get the section sizes.

View File

@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "llvm-dwarfdump.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSet.h"
@ -15,11 +16,10 @@
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/JSON.h"
#include "SectionSizes.h"
#define DEBUG_TYPE "dwarfdump"
using namespace llvm;
using namespace object;
using namespace llvm::dwarfdump;
using namespace llvm::object;
/// This represents the number of categories of debug location coverage being
/// calculated. The first category is the number of variables with 0% location
@ -27,6 +27,7 @@ using namespace object;
/// location coverage.
constexpr int NumOfCoverageCategories = 12;
namespace {
/// Holds statistics for one function (or other entity that has a PC range and
/// contains variables, such as a compile unit).
struct PerFunctionStats {
@ -141,6 +142,7 @@ struct LocationStats {
/// Total number of local variables processed.
unsigned NumVar = 0;
};
} // namespace
/// Collect debug location statistics for one DIE.
static void collectLocStats(uint64_t BytesCovered, uint64_t BytesInScope,
@ -510,8 +512,9 @@ static void printSectionSizes(raw_ostream &OS, const SectionSizes &Sizes) {
/// of particular optimizations. The raw numbers themselves are not particularly
/// useful, only the delta between compiling the same program with different
/// compilers is.
bool collectStatsForObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
const Twine &Filename, raw_ostream &OS) {
bool dwarfdump::collectStatsForObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
const Twine &Filename,
raw_ostream &OS) {
StringRef FormatName = Obj.getFileFormatName();
GlobalStats GlobalStats;
LocationStats LocStats;

View File

@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===//
#include "llvm-dwarfdump.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/Triple.h"
@ -32,8 +33,10 @@
#include <cstdlib>
using namespace llvm;
using namespace object;
using namespace llvm::dwarfdump;
using namespace llvm::object;
namespace {
/// Parser for options that take an optional offest argument.
/// @{
struct OffsetOption {
@ -41,6 +44,7 @@ struct OffsetOption {
bool HasValue = false;
bool IsRequested = false;
};
} // namespace
namespace llvm {
namespace cl {
@ -82,8 +86,8 @@ public:
// An out-of-line virtual method to provide a 'home' for this class.
void anchor() override {};
};
} // cl
} // llvm
} // namespace cl
} // namespace llvm
/// @}
/// Command line options.
@ -416,12 +420,6 @@ static bool lookup(ObjectFile &Obj, DWARFContext &DICtx, uint64_t Address,
return true;
}
bool collectStatsForObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
const Twine &Filename, raw_ostream &OS);
bool collectObjectSectionSizes(ObjectFile &Obj, DWARFContext & /*DICtx*/,
const Twine &Filename, raw_ostream &OS);
static bool dumpObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
const Twine &Filename, raw_ostream &OS) {
logAllUnhandledErrors(DICtx.loadRegisterInfo(Obj), errs(),

View File

@ -1,28 +1,28 @@
//===- SectionSizes.h - Debug section sizes ---------------------*- C++ -*-===//
//===-- llvm-dwarfdump - Debug info dumping utility -------------*- 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
//
//===-----------------------------------------------------------------------===/
//===----------------------------------------------------------------------===//
#ifndef LLVM_TOOLS_SECTION_SIZES_H
#define LLVM_TOOLS_SECTION_SIZES_H
#ifndef LLVM_TOOLS_LLVM_DWARFDUMP_LLVM_DWARFDUMP_H
#define LLVM_TOOLS_LLVM_DWARFDUMP_LLVM_DWARFDUMP_H
#include "llvm/DebugInfo/DIContext.h"
#include "llvm/ADT/Twine.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
namespace llvm {
using SectionSizeMap = StringMap<uint64_t>;
namespace dwarfdump {
/// Holds cumulative section sizes for an object file.
struct SectionSizes {
/// Map of .debug section names and their sizes across all such-named
/// sections.
SectionSizeMap DebugSectionSizes;
StringMap<uint64_t> DebugSectionSizes;
/// Total number of bytes of all sections.
uint64_t TotalObjectSize = 0;
/// Total number of bytes of all debug sections.
@ -33,6 +33,12 @@ struct SectionSizes {
void calculateSectionSizes(const object::ObjectFile &Obj, SectionSizes &Sizes,
const Twine &Filename);
} // end namespace llvm
bool collectStatsForObjectFile(object::ObjectFile &Obj, DWARFContext &DICtx,
const Twine &Filename, raw_ostream &OS);
bool collectObjectSectionSizes(object::ObjectFile &Obj, DWARFContext &DICtx,
const Twine &Filename, raw_ostream &OS);
#endif // LLVM_TOOLS_SECTION_SIZES_H
} // namespace dwarfdump
} // namespace llvm
#endif