brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.5 KiB · d6b3d70 Raw
93 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLDB_SOURCE_PLUGINS_DISASSEMBLER_LLVMC_DISASSEMBLERLLVMC_H10#define LLDB_SOURCE_PLUGINS_DISASSEMBLER_LLVMC_DISASSEMBLERLLVMC_H11 12#include <memory>13#include <mutex>14#include <optional>15#include <string>16 17#include "lldb/Core/Address.h"18#include "lldb/Core/Disassembler.h"19#include "lldb/Core/PluginManager.h"20 21class InstructionLLVMC;22 23class DisassemblerLLVMC : public lldb_private::Disassembler {24public:25  DisassemblerLLVMC(const lldb_private::ArchSpec &arch, const char *flavor,26                    const char *cpu, const char *features);27 28  ~DisassemblerLLVMC() override;29 30  // Static Functions31  static void Initialize();32 33  static void Terminate();34 35  static llvm::StringRef GetPluginNameStatic() { return "llvm-mc"; }36 37  static lldb::DisassemblerSP CreateInstance(const lldb_private::ArchSpec &arch,38                                             const char *flavor,39                                             const char *cpu,40                                             const char *features);41 42  size_t DecodeInstructions(const lldb_private::Address &base_addr,43                            const lldb_private::DataExtractor &data,44                            lldb::offset_t data_offset, size_t num_instructions,45                            bool append, bool data_from_file) override;46 47  // PluginInterface protocol48  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }49 50protected:51  friend class InstructionLLVMC;52 53  bool FlavorValidForArchSpec(const lldb_private::ArchSpec &arch,54                              const char *flavor) override;55 56  bool IsValid() const;57 58  int OpInfo(uint64_t PC, uint64_t Offset, uint64_t Size, int TagType,59             void *TagBug);60 61  const char *SymbolLookup(uint64_t ReferenceValue, uint64_t *ReferenceType,62                           uint64_t ReferencePC, const char **ReferenceName);63 64  static int OpInfoCallback(void *DisInfo, uint64_t PC, uint64_t Offset,65                            uint64_t Size, int TagType, void *TagBug);66 67  static const char *SymbolLookupCallback(void *DisInfo,68                                          uint64_t ReferenceValue,69                                          uint64_t *ReferenceType,70                                          uint64_t ReferencePC,71                                          const char **ReferenceName);72 73  const lldb_private::ExecutionContext *m_exe_ctx;74  InstructionLLVMC *m_inst;75  std::mutex m_mutex;76  bool m_data_from_file;77  // Save the AArch64 ADRP instruction word and address it was at,78  // in case the next instruction is an ADD to the same register;79  // this is a pc-relative address calculation and we need both80  // parts to calculate the symbolication.81  lldb::addr_t m_adrp_address;82  std::optional<uint32_t> m_adrp_insn;83 84  // Since we need to make two actual MC Disassemblers for ARM (ARM & THUMB),85  // and there's a bit of goo to set up and own in the MC disassembler world,86  // this class was added to manage the actual disassemblers.87  class MCDisasmInstance;88  std::unique_ptr<MCDisasmInstance> m_disasm_up;89  std::unique_ptr<MCDisasmInstance> m_alternate_disasm_up;90};91 92#endif // LLDB_SOURCE_PLUGINS_DISASSEMBLER_LLVMC_DISASSEMBLERLLVMC_H93