Path: blob/main/contrib/llvm-project/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg.h
213845 views
//===-- NativeRegisterContextDBReg.h ----------------------------*- C++ -*-===//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#ifndef lldb_NativeRegisterContextDBReg_h9#define lldb_NativeRegisterContextDBReg_h1011#include "Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h"1213#include <array>1415// Common utilities for hardware breakpoints and hardware watchpoints on AArch6416// and LoongArch.1718namespace lldb_private {1920class NativeRegisterContextDBReg21: public virtual NativeRegisterContextRegisterInfo {22public:23explicit NativeRegisterContextDBReg(uint32_t enable_bit)24: m_hw_dbg_enable_bit(enable_bit) {}2526uint32_t NumSupportedHardwareBreakpoints() override;2728uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;2930bool ClearHardwareBreakpoint(uint32_t hw_idx) override;3132Status ClearAllHardwareBreakpoints() override;3334Status GetHardwareBreakHitIndex(uint32_t &bp_index,35lldb::addr_t trap_addr) override;3637uint32_t NumSupportedHardwareWatchpoints() override;3839uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,40uint32_t watch_flags) override;4142bool ClearHardwareWatchpoint(uint32_t hw_index) override;4344Status ClearAllHardwareWatchpoints() override;4546Status GetWatchpointHitIndex(uint32_t &wp_index,47lldb::addr_t trap_addr) override;4849lldb::addr_t GetWatchpointHitAddress(uint32_t wp_index) override;5051lldb::addr_t GetWatchpointAddress(uint32_t wp_index) override;5253protected:54// Debug register type select55enum DREGType { eDREGTypeWATCH = 0, eDREGTypeBREAK };5657/// Debug register info for hardware breakpoints and watchpoints management.58struct DREG {59lldb::addr_t address; // Breakpoint/watchpoint address value.60lldb::addr_t hit_addr; // Address at which last watchpoint trigger exception61// occurred.62lldb::addr_t real_addr; // Address value that should cause target to stop.63uint32_t control; // Breakpoint/watchpoint control value.64};6566std::array<struct DREG, 16> m_hbp_regs; // hardware breakpoints67std::array<struct DREG, 16> m_hwp_regs; // hardware watchpoints6869uint32_t m_max_hbp_supported;70uint32_t m_max_hwp_supported;71const uint32_t m_hw_dbg_enable_bit;7273bool WatchpointIsEnabled(uint32_t wp_index);74bool BreakpointIsEnabled(uint32_t bp_index);7576// On AArch64 and Loongarch the hardware breakpoint length size is 4, and the77// target address must 4-byte alignment.78bool ValidateBreakpoint(size_t size, lldb::addr_t addr) {79return (size == 4) && !(addr & 0x3);80}81struct WatchpointDetails {82size_t size;83lldb::addr_t addr;84};85virtual std::optional<WatchpointDetails>86AdjustWatchpoint(const WatchpointDetails &details) = 0;87virtual uint32_t MakeBreakControlValue(size_t size) = 0;88virtual uint32_t MakeWatchControlValue(size_t size, uint32_t watch_flags) = 0;89virtual uint32_t GetWatchpointSize(uint32_t wp_index) = 0;9091virtual llvm::Error ReadHardwareDebugInfo() = 0;92virtual llvm::Error WriteHardwareDebugRegs(DREGType hwbType) = 0;93virtual lldb::addr_t FixWatchpointHitAddress(lldb::addr_t hit_addr) {94return hit_addr;95}96};9798} // namespace lldb_private99100#endif // #ifndef lldb_NativeRegisterContextDBReg_h101102103