From 5733daa233a99a828b7b93509b3ecf5e6af46120 Mon Sep 17 00:00:00 2001 From: Frederic Riss Date: Mon, 3 Aug 2015 00:10:25 +0000 Subject: [PATCH] [dwarfdump] Move dumping to a helper function NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243861 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-dwarfdump/llvm-dwarfdump.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index cd48d81c8de..018e6662fac 100644 --- a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -76,6 +76,15 @@ static void error(StringRef Filename, std::error_code EC) { exit(1); } +static void DumpObjectFile(ObjectFile &Obj, StringRef Filename) { + std::unique_ptr DICtx(new DWARFContextInMemory(Obj)); + + outs() << Filename + << ":\tfile format " << Obj.getFileFormatName() << "\n\n"; + // Dump the complete DWARF structure. + DICtx->dump(outs(), DumpType); +} + static void DumpInput(StringRef Filename) { ErrorOr> BuffOrErr = MemoryBuffer::getFileOrSTDIN(Filename); @@ -87,12 +96,7 @@ static void DumpInput(StringRef Filename) { error(Filename, ObjOrErr.getError()); ObjectFile &Obj = *ObjOrErr.get(); - std::unique_ptr DICtx(new DWARFContextInMemory(Obj)); - - outs() << Filename - << ":\tfile format " << Obj.getFileFormatName() << "\n\n"; - // Dump the complete DWARF structure. - DICtx->dump(outs(), DumpType); + DumpObjectFile(Obj, Filename); } int main(int argc, char **argv) { -- 2.34.1