LLVM 23.0.0git
LVReaderHandler.h
Go to the documentation of this file.
1//===-- LVReaderHandler.h ---------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This class implements the Reader handler.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_DEBUGINFO_LOGICALVIEW_READERS_LVREADERHANDLER_H
14#define LLVM_DEBUGINFO_LOGICALVIEW_READERS_LVREADERHANDLER_H
15
18#include "llvm/Object/Archive.h"
25#include <string>
26#include <variant>
27#include <vector>
28
29namespace llvm {
30namespace logicalview {
31
32using LVReaders = std::vector<std::unique_ptr<LVReader>>;
33using ArgVector = std::vector<std::string>;
35 std::variant<StringRef *, MemoryBufferRef *, object::ObjectFile *,
37
38// This class performs the following tasks:
39// - Creates a logical reader for every binary file in the command line,
40// that parses the debug information and creates a high level logical
41// view representation containing scopes, symbols, types and lines.
42// - Prints and compares the logical views.
43//
44// The supported binary formats are: ELF, Mach-O and CodeView.
46 ArgVector &Objects;
48 raw_ostream &OS;
49 LVReaders TheReaders;
50
51 Error createReaders();
52 Error printReaders();
53 Error compareReaders();
54
55 Error handleArchive(LVReaders &Readers, StringRef Filename,
56 object::Archive &Arch);
57 Error handleBuffer(LVReaders &Readers, StringRef Filename,
58 MemoryBufferRef Buffer, StringRef ExePath = {});
59 LLVM_ABI Error handleFile(LVReaders &Readers, StringRef Filename,
60 StringRef ExePath = {});
61 Error handleMach(LVReaders &Readers, StringRef Filename,
63 Error handleObject(LVReaders &Readers, StringRef Filename,
64 object::Binary &Binary);
65 Error handleObject(LVReaders &Readers, StringRef Filename, StringRef Buffer,
66 StringRef ExePath);
67 Error handleObject(LVReaders &Readers, StringRef Filename,
68 MemoryBufferRef Buffer);
69
70 Error createReader(StringRef Filename, LVReaders &Readers, InputHandle &Input,
71 StringRef FileFormatName, StringRef ExePath = {});
72
73public:
74 LVReaderHandler() = delete;
76 LVOptions &ReaderOptions)
77 : Objects(Objects), W(W), OS(W.getOStream()) {
78 setOptions(&ReaderOptions);
79 }
82
84 return handleFile(Readers, Filename);
85 }
87
89 LVReaders Readers;
90 if (Error Err = createReader(Pathname, Readers))
91 return std::move(Err);
92 return std::move(Readers[0]);
93 }
94
95 LLVM_ABI void print(raw_ostream &OS) const;
96
97#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
98 void dump() const { print(dbgs()); }
99#endif
100};
101
102} // end namespace logicalview
103} // namespace llvm
104
105#endif // LLVM_DEBUGINFO_LOGICALVIEW_READERS_LVREADERHANDLER_H
#define LLVM_ABI
Definition Compiler.h:215
The Input class is used to parse a yaml document into in-memory structs and vectors.
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Tagged union holding either a T or a Error.
Definition Error.h:485
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
LVReaderHandler(ArgVector &Objects, ScopedPrinter &W, LVOptions &ReaderOptions)
Error createReader(StringRef Filename, LVReaders &Readers)
LLVM_ABI void print(raw_ostream &OS) const
Expected< std::unique_ptr< LVReader > > createReader(StringRef Pathname)
LVReaderHandler & operator=(const LVReaderHandler &)=delete
LVReaderHandler(const LVReaderHandler &)=delete
This class is the base class for all object file types.
Definition ObjectFile.h:231
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
void setOptions(LVOptions *Options)
Definition LVOptions.h:449
std::vector< std::unique_ptr< LVReader > > LVReaders
std::vector< std::string > ArgVector
std::variant< StringRef *, MemoryBufferRef *, object::ObjectFile *, object::IRObjectFile *, pdb::PDBFile * > InputHandle
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209