LLDB mainline
ArchitectureRISCV.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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
12
13using namespace lldb_private;
14
16
22
26
27std::unique_ptr<Architecture> ArchitectureRISCV::Create(const ArchSpec &arch) {
28 auto machine = arch.GetMachine();
29 if (machine != llvm::Triple::riscv32 && machine != llvm::Triple::riscv64)
30 return nullptr;
31 return std::unique_ptr<Architecture>(new ArchitectureRISCV());
32}
33
35 llvm::ArrayRef<uint8_t> reference, llvm::ArrayRef<uint8_t> observed) const {
36 // RISC-V has only two trap encodings here: 16-bit C.EBREAK or 32-bit EBREAK.
37 // These instructions don't have any operands so check that the reference and
38 // observed bytes match.
39 if ((reference.size() != 2 && reference.size() != 4) ||
40 reference.size() > observed.size())
41 return false;
42
43 return reference == observed.take_front(reference.size());
44}
#define LLDB_PLUGIN_DEFINE(PluginName)
An architecture specification class.
Definition ArchSpec.h:32
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition ArchSpec.cpp:881
static std::unique_ptr< Architecture > Create(const ArchSpec &arch)
bool IsValidTrapInstruction(llvm::ArrayRef< uint8_t > reference, llvm::ArrayRef< uint8_t > observed) const override
Returns whether a given byte sequence is a valid trap instruction for the architecture.
static llvm::StringRef GetPluginNameStatic()
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A class that represents a running process on the host machine.