LLVM 22.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
19#include "llvm/Object/Archive.h"
25#include <string>
26#include <vector>
27
28namespace llvm {
29namespace logicalview {
30
31using LVReaders = std::vector<std::unique_ptr<LVReader>>;
32using ArgVector = std::vector<std::string>;
34
35// This class performs the following tasks:
36// - Creates a logical reader for every binary file in the command line,
37// that parses the debug information and creates a high level logical
38// view representation containing scopes, symbols, types and lines.
39// - Prints and compares the logical views.
40//
41// The supported binary formats are: ELF, Mach-O and CodeView.
43 ArgVector &Objects;
45 raw_ostream &OS;
46 LVReaders TheReaders;
47
48 Error createReaders();
49 Error printReaders();
50 Error compareReaders();
51
52 Error handleArchive(LVReaders &Readers, StringRef Filename,
53 object::Archive &Arch);
54 Error handleBuffer(LVReaders &Readers, StringRef Filename,
55 MemoryBufferRef Buffer, StringRef ExePath = {});
56 LLVM_ABI Error handleFile(LVReaders &Readers, StringRef Filename,
57 StringRef ExePath = {});
58 Error handleMach(LVReaders &Readers, StringRef Filename,
60 Error handleObject(LVReaders &Readers, StringRef Filename,
61 object::Binary &Binary);
62 Error handleObject(LVReaders &Readers, StringRef Filename, StringRef Buffer,
63 StringRef ExePath);
64
65 Error createReader(StringRef Filename, LVReaders &Readers, PdbOrObj &Input,
66 StringRef FileFormatName, StringRef ExePath = {});
67
68public:
69 LVReaderHandler() = delete;
71 LVOptions &ReaderOptions)
72 : Objects(Objects), W(W), OS(W.getOStream()) {
73 setOptions(&ReaderOptions);
74 }
77
79 return handleFile(Readers, Filename);
80 }
82
84 LVReaders Readers;
85 if (Error Err = createReader(Pathname, Readers))
86 return std::move(Err);
87 return std::move(Readers[0]);
88 }
89
90 LLVM_ABI void print(raw_ostream &OS) const;
91
92#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
93 void dump() const { print(dbgs()); }
94#endif
95};
96
97} // end namespace logicalview
98} // namespace llvm
99
100#endif // LLVM_DEBUGINFO_LOGICALVIEW_READERS_LVREADERHANDLER_H
#define LLVM_ABI
Definition: Compiler.h:213
This file defines the PointerUnion class, which is a discriminated union of pointer types.
raw_pwrite_stream & OS
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
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Definition: PointerUnion.h:115
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
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 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::string > ArgVector
std::vector< std::unique_ptr< LVReader > > LVReaders
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:207