Path: blob/main/contrib/llvm-project/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h
39642 views
//===-- DisassemblerLLVMC.h -------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLDB_SOURCE_PLUGINS_DISASSEMBLER_LLVMC_DISASSEMBLERLLVMC_H9#define LLDB_SOURCE_PLUGINS_DISASSEMBLER_LLVMC_DISASSEMBLERLLVMC_H1011#include <memory>12#include <mutex>13#include <optional>14#include <string>1516#include "lldb/Core/Address.h"17#include "lldb/Core/Disassembler.h"18#include "lldb/Core/PluginManager.h"1920class InstructionLLVMC;2122class DisassemblerLLVMC : public lldb_private::Disassembler {23public:24DisassemblerLLVMC(const lldb_private::ArchSpec &arch,25const char *flavor /* = NULL */);2627~DisassemblerLLVMC() override;2829// Static Functions30static void Initialize();3132static void Terminate();3334static llvm::StringRef GetPluginNameStatic() { return "llvm-mc"; }3536static lldb::DisassemblerSP CreateInstance(const lldb_private::ArchSpec &arch,37const char *flavor);3839size_t DecodeInstructions(const lldb_private::Address &base_addr,40const lldb_private::DataExtractor &data,41lldb::offset_t data_offset, size_t num_instructions,42bool append, bool data_from_file) override;4344// PluginInterface protocol45llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }4647protected:48friend class InstructionLLVMC;4950bool FlavorValidForArchSpec(const lldb_private::ArchSpec &arch,51const char *flavor) override;5253bool IsValid() const;5455int OpInfo(uint64_t PC, uint64_t Offset, uint64_t Size, int TagType,56void *TagBug);5758const char *SymbolLookup(uint64_t ReferenceValue, uint64_t *ReferenceType,59uint64_t ReferencePC, const char **ReferenceName);6061static int OpInfoCallback(void *DisInfo, uint64_t PC, uint64_t Offset,62uint64_t Size, int TagType, void *TagBug);6364static const char *SymbolLookupCallback(void *DisInfo,65uint64_t ReferenceValue,66uint64_t *ReferenceType,67uint64_t ReferencePC,68const char **ReferenceName);6970const lldb_private::ExecutionContext *m_exe_ctx;71InstructionLLVMC *m_inst;72std::mutex m_mutex;73bool m_data_from_file;74// Save the AArch64 ADRP instruction word and address it was at,75// in case the next instruction is an ADD to the same register;76// this is a pc-relative address calculation and we need both77// parts to calculate the symbolication.78lldb::addr_t m_adrp_address;79std::optional<uint32_t> m_adrp_insn;8081// Since we need to make two actual MC Disassemblers for ARM (ARM & THUMB),82// and there's a bit of goo to set up and own in the MC disassembler world,83// this class was added to manage the actual disassemblers.84class MCDisasmInstance;85std::unique_ptr<MCDisasmInstance> m_disasm_up;86std::unique_ptr<MCDisasmInstance> m_alternate_disasm_up;87};8889#endif // LLDB_SOURCE_PLUGINS_DISASSEMBLER_LLVMC_DISASSEMBLERLLVMC_H909192