brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · b3b5e6b Raw
66 lines · cpp
1//===-- NativeRegisterContextDBReg_loongarch.cpp --------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#include "NativeRegisterContextDBReg_loongarch.h"10 11#include "lldb/Utility/LLDBLog.h"12#include "lldb/Utility/Log.h"13#include "lldb/Utility/RegisterValue.h"14 15using namespace lldb_private;16 17uint32_t18NativeRegisterContextDBReg_loongarch::GetWatchpointSize(uint32_t wp_index) {19  Log *log = GetLog(LLDBLog::Watchpoints);20  LLDB_LOG(log, "wp_index: {0}", wp_index);21 22  switch ((m_hwp_regs[wp_index].control >> 10) & 0x3) {23  case 0x0:24    return 8;25  case 0x1:26    return 4;27  case 0x2:28    return 2;29  case 0x3:30    return 1;31  default:32    return 0;33  }34}35 36std::optional<NativeRegisterContextDBReg::WatchpointDetails>37NativeRegisterContextDBReg_loongarch::AdjustWatchpoint(38    const WatchpointDetails &details) {39  // LoongArch only needs to check the size; it does not need to check the40  // address.41  size_t size = details.size;42  if (size != 1 && size != 2 && size != 4 && size != 8)43    return std::nullopt;44 45  return details;46}47 48uint32_t49NativeRegisterContextDBReg_loongarch::MakeBreakControlValue(size_t size) {50  // Return encoded hardware breakpoint control value.51  return m_hw_dbg_enable_bit;52}53 54uint32_t NativeRegisterContextDBReg_loongarch::MakeWatchControlValue(55    size_t size, uint32_t watch_flags) {56  // Encoding hardware watchpoint control value.57  // Size encoded:58  // case 1 : 0b1159  // case 2 : 0b1060  // case 4 : 0b0161  // case 8 : 0b0062  size_t encoded_size = (3 - llvm::Log2_32(size)) << 10;63 64  return m_hw_dbg_enable_bit | encoded_size | (watch_flags << 8);65}66