Coverage Report

Created: 2023-09-21 18:56

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.h
Line
Count
Source (jump to first uncovered line)
1
//===-- ObjectContainerMachOFileset.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
#ifndef LLDB_SOURCE_PLUGINS_OBJECTCONTAINER_MACH_O_FILESET_OBJECTCONTAINERMADCHOFILESET_H
10
#define LLDB_SOURCE_PLUGINS_OBJECTCONTAINER_MACH_O_FILESET_OBJECTCONTAINERMADCHOFILESET_H
11
12
#include "lldb/Host/SafeMachO.h"
13
#include "lldb/Symbol/ObjectContainer.h"
14
#include "lldb/Utility/FileSpec.h"
15
16
namespace lldb_private {
17
18
class ObjectContainerMachOFileset : public lldb_private::ObjectContainer {
19
public:
20
  ObjectContainerMachOFileset(const lldb::ModuleSP &module_sp,
21
                              lldb::DataBufferSP &data_sp,
22
                              lldb::offset_t data_offset,
23
                              const lldb_private::FileSpec *file,
24
                              lldb::offset_t offset, lldb::offset_t length);
25
26
  ObjectContainerMachOFileset(const lldb::ModuleSP &module_sp,
27
                              lldb::WritableDataBufferSP data_sp,
28
                              const lldb::ProcessSP &process_sp,
29
                              lldb::addr_t header_addr);
30
31
  ~ObjectContainerMachOFileset() override;
32
33
  static void Initialize();
34
  static void Terminate();
35
36
3.92k
  static llvm::StringRef GetPluginNameStatic() { return "mach-o-fileset"; }
37
38
3.92k
  static llvm::StringRef GetPluginDescriptionStatic() {
39
3.92k
    return "Mach-O Fileset container reader.";
40
3.92k
  }
41
42
  static lldb_private::ObjectContainer *
43
  CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
44
                 lldb::offset_t data_offset, const lldb_private::FileSpec *file,
45
                 lldb::offset_t offset, lldb::offset_t length);
46
47
  static lldb_private::ObjectContainer *CreateMemoryInstance(
48
      const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp,
49
      const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
50
51
  static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
52
                                        lldb::DataBufferSP &data_sp,
53
                                        lldb::offset_t data_offset,
54
                                        lldb::offset_t file_offset,
55
                                        lldb::offset_t length,
56
                                        lldb_private::ModuleSpecList &specs);
57
58
  static bool MagicBytesMatch(const lldb_private::DataExtractor &data);
59
  static bool MagicBytesMatch(lldb::DataBufferSP data_sp,
60
                              lldb::addr_t data_offset,
61
                              lldb::addr_t data_length);
62
63
  bool ParseHeader() override;
64
65
0
  size_t GetNumObjects() const override { return m_entries.size(); }
66
67
  lldb::ObjectFileSP GetObjectFile(const lldb_private::FileSpec *file) override;
68
69
0
  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
70
71
  struct Entry {
72
    Entry(uint64_t vmaddr, uint64_t fileoff, std::string id)
73
0
        : vmaddr(vmaddr), fileoff(fileoff), id(id) {}
74
    uint64_t vmaddr;
75
    uint64_t fileoff;
76
    std::string id;
77
  };
78
79
  Entry *FindEntry(llvm::StringRef id);
80
81
private:
82
  static bool ParseHeader(lldb_private::DataExtractor &data,
83
                          const lldb_private::FileSpec &file,
84
                          lldb::offset_t file_offset,
85
                          std::vector<Entry> &entries);
86
87
  std::vector<Entry> m_entries;
88
  lldb::ProcessWP m_process_wp;
89
  const lldb::addr_t m_memory_addr;
90
};
91
92
} // namespace lldb_private
93
94
#endif // LLDB_SOURCE_PLUGINS_OBJECTCONTAINER_MACH_O_FILESET_OBJECTCONTAINERMADCHOFILESET_H