Path: blob/main/contrib/llvm-project/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_loongarch.cpp
213845 views
//===-- NativeRegisterContextDBReg_loongarch.cpp --------------------------===//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#include "NativeRegisterContextDBReg_loongarch.h"910#include "lldb/Utility/LLDBLog.h"11#include "lldb/Utility/Log.h"12#include "lldb/Utility/RegisterValue.h"1314using namespace lldb_private;1516uint32_t17NativeRegisterContextDBReg_loongarch::GetWatchpointSize(uint32_t wp_index) {18Log *log = GetLog(LLDBLog::Watchpoints);19LLDB_LOG(log, "wp_index: {0}", wp_index);2021switch ((m_hwp_regs[wp_index].control >> 10) & 0x3) {22case 0x0:23return 8;24case 0x1:25return 4;26case 0x2:27return 2;28case 0x3:29return 1;30default:31return 0;32}33}3435std::optional<NativeRegisterContextDBReg::WatchpointDetails>36NativeRegisterContextDBReg_loongarch::AdjustWatchpoint(37const WatchpointDetails &details) {38// LoongArch only needs to check the size; it does not need to check the39// address.40size_t size = details.size;41if (size != 1 && size != 2 && size != 4 && size != 8)42return std::nullopt;4344return details;45}4647uint32_t48NativeRegisterContextDBReg_loongarch::MakeBreakControlValue(size_t size) {49// Return encoded hardware breakpoint control value.50return m_hw_dbg_enable_bit;51}5253uint32_t NativeRegisterContextDBReg_loongarch::MakeWatchControlValue(54size_t size, uint32_t watch_flags) {55// Encoding hardware watchpoint control value.56// Size encoded:57// case 1 : 0b1158// case 2 : 0b1059// case 4 : 0b0160// case 8 : 0b0061size_t encoded_size = (3 - llvm::Log2_32(size)) << 10;6263return m_hw_dbg_enable_bit | encoded_size | (watch_flags << 8);64}656667