LLVM 20.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"
24#include <string>
25#include <vector>
26
27namespace llvm {
28namespace logicalview {
29
30using LVReaders = std::vector<std::unique_ptr<LVReader>>;
31using ArgVector = std::vector<std::string>;
33
34// This class performs the following tasks:
35// - Creates a logical reader for every binary file in the command line,
36// that parses the debug information and creates a high level logical
37// view representation containing scopes, symbols, types and lines.
38// - Prints and compares the logical views.
39//
40// The supported binary formats are: ELF, Mach-O and CodeView.
42 ArgVector &Objects;
44 raw_ostream &OS;
45 LVReaders TheReaders;
46
47 Error createReaders();
48 Error printReaders();
49 Error compareReaders();
50
51 Error handleArchive(LVReaders &Readers, StringRef Filename,
52 object::Archive &Arch);
53 Error handleBuffer(LVReaders &Readers, StringRef Filename,
54 MemoryBufferRef Buffer, StringRef ExePath = {});
55 Error handleFile(LVReaders &Readers, StringRef Filename,
56 StringRef ExePath = {});
57 Error handleMach(LVReaders &Readers, StringRef Filename,
59 Error handleObject(LVReaders &Readers, StringRef Filename,
60 object::Binary &Binary);
61 Error handleObject(LVReaders &Readers, StringRef Filename, StringRef Buffer,
62 StringRef ExePath);
63
64 Error createReader(StringRef Filename, LVReaders &Readers, PdbOrObj &Input,
65 StringRef FileFormatName, StringRef ExePath = {});
66
67public:
68 LVReaderHandler() = delete;
70 LVOptions &ReaderOptions)
71 : Objects(Objects), W(W), OS(W.getOStream()) {
72 setOptions(&ReaderOptions);
73 }
76
78 return handleFile(Readers, Filename);
79 }
80 Error process();
81
83 LVReaders Readers;
84 if (Error Err = createReader(Pathname, Readers))
85 return std::move(Err);
86 return std::move(Readers[0]);
87 }
88
89 void print(raw_ostream &OS) const;
90
91#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
92 void dump() const { print(dbgs()); }
93#endif
94};
95
96} // end namespace logicalview
97} // namespace llvm
98
99#endif // LLVM_DEBUGINFO_LOGICALVIEW_READERS_LVREADERHANDLER_H
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:160
Tagged union holding either a T or a Error.
Definition: Error.h:481
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Definition: PointerUnion.h:118
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
LVReaderHandler(ArgVector &Objects, ScopedPrinter &W, LVOptions &ReaderOptions)
Error createReader(StringRef Filename, LVReaders &Readers)
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:52
void setOptions(LVOptions *Options)
Definition: LVOptions.h:446
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
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163