aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp')
-rw-r--r--lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp40
1 files changed, 31 insertions, 9 deletions
diff --git a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
index edc5f005c7ac..c85c66442510 100644
--- a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -10,6 +10,7 @@
#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"
@@ -22,6 +23,7 @@
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCTargetOptions.h"
#include "llvm/MC/TargetRegistry.h"
+#include "llvm/Support/AArch64TargetParser.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/TargetSelect.h"
@@ -36,6 +38,7 @@
#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"
@@ -89,8 +92,7 @@ public:
AddressClass addr_class)
: Instruction(address, addr_class),
m_disasm_wp(std::static_pointer_cast<DisassemblerLLVMC>(
- disasm.shared_from_this())),
- m_using_file_addr(false) {}
+ disasm.shared_from_this())) {}
~InstructionLLVMC() override = default;
@@ -795,8 +797,7 @@ public:
}
}
- if (Log *log =
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)) {
+ if (Log *log = GetLog(LLDBLog::Process)) {
StreamString ss;
ss.Printf("[%s] expands to %zu operands:\n", operands_string,
@@ -822,7 +823,7 @@ protected:
std::weak_ptr<DisassemblerLLVMC> m_disasm_wp;
bool m_is_valid = false;
- bool m_using_file_addr;
+ bool m_using_file_addr = false;
bool m_has_visited_instruction = false;
// Be conservative. If we didn't understand the instruction, say it:
@@ -1178,15 +1179,36 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch,
features_str += "+dspr2,";
}
- // If any AArch64 variant, enable latest ISA with any optional
- // extensions like MTE.
+ // If any AArch64 variant, enable latest ISA with all extensions.
if (triple.isAArch64()) {
- features_str += "+v9.3a,+mte";
+ features_str += "+v9.3a,";
+ std::vector<llvm::StringRef> features;
+ // Get all possible features
+ llvm::AArch64::getExtensionFeatures(-1, features);
+ features_str += llvm::join(features, ",");
if (triple.getVendor() == llvm::Triple::Apple)
cpu = "apple-latest";
}
+ if (triple.isRISCV()) {
+ uint32_t arch_flags = arch.GetFlags();
+ if (arch_flags & ArchSpec::eRISCV_rvc)
+ features_str += "+c,";
+ if (arch_flags & ArchSpec::eRISCV_rve)
+ features_str += "+e,";
+ if ((arch_flags & ArchSpec::eRISCV_float_abi_single) ==
+ ArchSpec::eRISCV_float_abi_single)
+ features_str += "+f,";
+ if ((arch_flags & ArchSpec::eRISCV_float_abi_double) ==
+ ArchSpec::eRISCV_float_abi_double)
+ features_str += "+f,+d,";
+ if ((arch_flags & ArchSpec::eRISCV_float_abi_quad) ==
+ ArchSpec::eRISCV_float_abi_quad)
+ features_str += "+f,+d,+q,";
+ // FIXME: how do we detect features such as `+a`, `+m`?
+ }
+
// We use m_disasm_up.get() to tell whether we are valid or not, so if this
// isn't good for some reason, we won't be valid and FindPlugin will fail and
// we won't get used.
@@ -1360,7 +1382,7 @@ const char *DisassemblerLLVMC::SymbolLookup(uint64_t value, uint64_t *type_ptr,
// the ADRP's register and this ADD's register are the same,
// then this is a pc-relative address calculation.
if (*type_ptr == LLVMDisassembler_ReferenceType_In_ARM64_ADDXri &&
- m_adrp_insn.hasValue() && m_adrp_address == pc - 4 &&
+ m_adrp_insn && m_adrp_address == pc - 4 &&
(m_adrp_insn.getValue() & 0x1f) == ((value >> 5) & 0x1f)) {
uint32_t addxri_inst;
uint64_t adrp_imm, addxri_imm;