#include "DisassemblerLLVMC.h"
#include "llvm-c/Disassembler.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDisassembler/MCDisassembler.h"
#include "llvm/MC/MCDisassembler/MCExternalSymbolizer.h"
#include "llvm/MC/MCDisassembler/MCRelocationInfo.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstPrinter.h"
#include "llvm/MC/MCInstrAnalysis.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCTargetOptions.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/TargetParser/AArch64TargetParser.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Stream.h"
#include <optional>
usingnamespacelldb;
usingnamespacelldb_private;
LLDB_PLUGIN_DEFINE(…)
class DisassemblerLLVMC::MCDisasmInstance { … };
namespace x86 {
struct InstructionOpcodeAndModrm { … };
lldb::InstructionControlFlowKind
MapOpcodeIntoControlFlowKind(InstructionOpcodeAndModrm opcode_and_modrm) { … }
std::optional<InstructionOpcodeAndModrm>
InstructionLengthDecode(const uint8_t *inst_bytes, int bytes_len,
bool is_exec_mode_64b) { … }
lldb::InstructionControlFlowKind GetControlFlowKind(bool is_exec_mode_64b,
Opcode m_opcode) { … }
}
class InstructionLLVMC : public lldb_private::Instruction { … };
std::unique_ptr<DisassemblerLLVMC::MCDisasmInstance>
DisassemblerLLVMC::MCDisasmInstance::Create(const char *triple, const char *cpu,
const char *features_str,
unsigned flavor,
DisassemblerLLVMC &owner) { … }
DisassemblerLLVMC::MCDisasmInstance::MCDisasmInstance(
std::unique_ptr<llvm::MCInstrInfo> &&instr_info_up,
std::unique_ptr<llvm::MCRegisterInfo> &®_info_up,
std::unique_ptr<llvm::MCSubtargetInfo> &&subtarget_info_up,
std::unique_ptr<llvm::MCAsmInfo> &&asm_info_up,
std::unique_ptr<llvm::MCContext> &&context_up,
std::unique_ptr<llvm::MCDisassembler> &&disasm_up,
std::unique_ptr<llvm::MCInstPrinter> &&instr_printer_up,
std::unique_ptr<llvm::MCInstrAnalysis> &&instr_analysis_up)
: … { … }
uint64_t DisassemblerLLVMC::MCDisasmInstance::GetMCInst(
const uint8_t *opcode_data, size_t opcode_data_len, lldb::addr_t pc,
llvm::MCInst &mc_inst) const { … }
void DisassemblerLLVMC::MCDisasmInstance::PrintMCInst(
llvm::MCInst &mc_inst, lldb::addr_t pc, std::string &inst_string,
std::string &comments_string) { … }
void DisassemblerLLVMC::MCDisasmInstance::SetStyle(
bool use_hex_immed, HexImmediateStyle hex_style) { … }
void DisassemblerLLVMC::MCDisasmInstance::SetUseColor(bool use_color) { … }
bool DisassemblerLLVMC::MCDisasmInstance::GetUseColor() const { … }
bool DisassemblerLLVMC::MCDisasmInstance::CanBranch(
llvm::MCInst &mc_inst) const { … }
bool DisassemblerLLVMC::MCDisasmInstance::HasDelaySlot(
llvm::MCInst &mc_inst) const { … }
bool DisassemblerLLVMC::MCDisasmInstance::IsCall(llvm::MCInst &mc_inst) const { … }
bool DisassemblerLLVMC::MCDisasmInstance::IsLoad(llvm::MCInst &mc_inst) const { … }
bool DisassemblerLLVMC::MCDisasmInstance::IsAuthenticated(
llvm::MCInst &mc_inst) const { … }
DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch,
const char *flavor_string)
: … { … }
DisassemblerLLVMC::~DisassemblerLLVMC() = default;
lldb::DisassemblerSP DisassemblerLLVMC::CreateInstance(const ArchSpec &arch,
const char *flavor) { … }
size_t DisassemblerLLVMC::DecodeInstructions(const Address &base_addr,
const DataExtractor &data,
lldb::offset_t data_offset,
size_t num_instructions,
bool append, bool data_from_file) { … }
void DisassemblerLLVMC::Initialize() { … }
void DisassemblerLLVMC::Terminate() { … }
int DisassemblerLLVMC::OpInfoCallback(void *disassembler, uint64_t pc,
uint64_t offset, uint64_t size,
int tag_type, void *tag_bug) { … }
const char *DisassemblerLLVMC::SymbolLookupCallback(void *disassembler,
uint64_t value,
uint64_t *type, uint64_t pc,
const char **name) { … }
bool DisassemblerLLVMC::FlavorValidForArchSpec(
const lldb_private::ArchSpec &arch, const char *flavor) { … }
bool DisassemblerLLVMC::IsValid() const { … }
int DisassemblerLLVMC::OpInfo(uint64_t PC, uint64_t Offset, uint64_t Size,
int tag_type, void *tag_bug) { … }
const char *DisassemblerLLVMC::SymbolLookup(uint64_t value, uint64_t *type_ptr,
uint64_t pc, const char **name) { … }