LLDB  mainline
DisassemblerLLVMC.h
Go to the documentation of this file.
1 //===-- DisassemblerLLVMC.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_DISASSEMBLER_LLVMC_DISASSEMBLERLLVMC_H
10 #define LLDB_SOURCE_PLUGINS_DISASSEMBLER_LLVMC_DISASSEMBLERLLVMC_H
11 
12 #include <memory>
13 #include <mutex>
14 #include <string>
15 
16 #include "lldb/Core/Address.h"
17 #include "lldb/Core/Disassembler.h"
19 
20 class InstructionLLVMC;
21 
23 public:
25  const char *flavor /* = NULL */);
26 
27  ~DisassemblerLLVMC() override;
28 
29  // Static Functions
30  static void Initialize();
31 
32  static void Terminate();
33 
35 
37  CreateInstance(const lldb_private::ArchSpec &arch, const char *flavor);
38 
39  size_t DecodeInstructions(const lldb_private::Address &base_addr,
40  const lldb_private::DataExtractor &data,
41  lldb::offset_t data_offset, size_t num_instructions,
42  bool append, bool data_from_file) override;
43 
44  // PluginInterface protocol
46 
47  uint32_t GetPluginVersion() override;
48 
49 protected:
50  friend class InstructionLLVMC;
51 
53  const char *flavor) override;
54 
55  bool IsValid() const;
56 
57  int OpInfo(uint64_t PC, uint64_t Offset, uint64_t Size, int TagType,
58  void *TagBug);
59 
60  const char *SymbolLookup(uint64_t ReferenceValue, uint64_t *ReferenceType,
61  uint64_t ReferencePC, const char **ReferenceName);
62 
63  static int OpInfoCallback(void *DisInfo, uint64_t PC, uint64_t Offset,
64  uint64_t Size, int TagType, void *TagBug);
65 
66  static const char *SymbolLookupCallback(void *DisInfo,
67  uint64_t ReferenceValue,
68  uint64_t *ReferenceType,
69  uint64_t ReferencePC,
70  const char **ReferenceName);
71 
74  std::mutex m_mutex;
76 
77  // Since we need to make two actual MC Disassemblers for ARM (ARM & THUMB),
78  // and there's a bit of goo to set up and own in the MC disassembler world,
79  // this class was added to manage the actual disassemblers.
81  std::unique_ptr<MCDisasmInstance> m_disasm_up;
82  std::unique_ptr<MCDisasmInstance> m_alternate_disasm_up;
83 };
84 
85 #endif // LLDB_SOURCE_PLUGINS_DISASSEMBLER_LLVMC_DISASSEMBLERLLVMC_H
DisassemblerLLVMC::m_inst
InstructionLLVMC * m_inst
Definition: DisassemblerLLVMC.h:73
DisassemblerLLVMC::m_disasm_up
std::unique_ptr< MCDisasmInstance > m_disasm_up
Definition: DisassemblerLLVMC.h:80
lldb_private::ExecutionContext
Definition: ExecutionContext.h:291
lldb_private::ArchSpec
Definition: ArchSpec.h:33
DisassemblerLLVMC::GetPluginName
lldb_private::ConstString GetPluginName() override
Definition: DisassemblerLLVMC.cpp:1380
DisassemblerLLVMC::OpInfo
int OpInfo(uint64_t PC, uint64_t Offset, uint64_t Size, int TagType, void *TagBug)
Definition: DisassemblerLLVMC.cpp:1293
DisassemblerLLVMC::SymbolLookup
const char * SymbolLookup(uint64_t ReferenceValue, uint64_t *ReferenceType, uint64_t ReferencePC, const char **ReferenceName)
Definition: DisassemblerLLVMC.cpp:1305
DisassemblerLLVMC::DisassemblerLLVMC
DisassemblerLLVMC(const lldb_private::ArchSpec &arch, const char *flavor)
Definition: DisassemblerLLVMC.cpp:1030
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
InstructionLLVMC
Definition: DisassemblerLLVMC.cpp:83
Disassembler.h
DisassemblerLLVMC::~DisassemblerLLVMC
~DisassemblerLLVMC() override
DisassemblerLLVMC::FlavorValidForArchSpec
bool FlavorValidForArchSpec(const lldb_private::ArchSpec &arch, const char *flavor) override
Definition: DisassemblerLLVMC.cpp:1278
DisassemblerLLVMC::IsValid
bool IsValid() const
Definition: DisassemblerLLVMC.cpp:1291
lldb_private::DataExtractor
Definition: DataExtractor.h:48
DisassemblerLLVMC::DecodeInstructions
size_t DecodeInstructions(const lldb_private::Address &base_addr, const lldb_private::DataExtractor &data, lldb::offset_t data_offset, size_t num_instructions, bool append, bool data_from_file) override
Definition: DisassemblerLLVMC.cpp:1197
DisassemblerLLVMC::m_alternate_disasm_up
std::unique_ptr< MCDisasmInstance > m_alternate_disasm_up
Definition: DisassemblerLLVMC.h:82
DisassemblerLLVMC
Definition: DisassemblerLLVMC.h:22
lldb_private::ConstString
Definition: ConstString.h:40
DisassemblerLLVMC::GetPluginNameStatic
static lldb_private::ConstString GetPluginNameStatic()
Definition: DisassemblerLLVMC.cpp:1258
Address.h
DisassemblerLLVMC::Initialize
static void Initialize()
Definition: DisassemblerLLVMC.cpp:1242
DisassemblerLLVMC::GetPluginVersion
uint32_t GetPluginVersion() override
Definition: DisassemblerLLVMC.cpp:1382
DisassemblerLLVMC::CreateInstance
static lldb_private::Disassembler * CreateInstance(const lldb_private::ArchSpec &arch, const char *flavor)
Definition: DisassemblerLLVMC.cpp:1185
DisassemblerLLVMC::SymbolLookupCallback
static const char * SymbolLookupCallback(void *DisInfo, uint64_t ReferenceValue, uint64_t *ReferenceType, uint64_t ReferencePC, const char **ReferenceName)
Definition: DisassemblerLLVMC.cpp:1270
DisassemblerLLVMC::OpInfoCallback
static int OpInfoCallback(void *DisInfo, uint64_t PC, uint64_t Offset, uint64_t Size, int TagType, void *TagBug)
Definition: DisassemblerLLVMC.cpp:1263
uint32_t
DisassemblerLLVMC::m_exe_ctx
const lldb_private::ExecutionContext * m_exe_ctx
Definition: DisassemblerLLVMC.h:72
lldb_private::Address
Definition: Address.h:59
DisassemblerLLVMC::m_mutex
std::mutex m_mutex
Definition: DisassemblerLLVMC.h:74
DisassemblerLLVMC::MCDisasmInstance
Definition: DisassemblerLLVMC.cpp:48
PluginManager.h
DisassemblerLLVMC::m_data_from_file
bool m_data_from_file
Definition: DisassemblerLLVMC.h:75
lldb_private::Disassembler
Definition: Disassembler.h:360
DisassemblerLLVMC::Terminate
static void Terminate()
Definition: DisassemblerLLVMC.cpp:1254