Skip to content

Commit

Permalink
[lldb] Rename NativeRegisterContext{Watchpoint => DBReg}_x86
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D97210
  • Loading branch information
mgorny committed Mar 1, 2021
1 parent 7ec7876 commit c41372c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h"
#include "Plugins/Process/Utility/RegisterContext_x86.h"
#include "Plugins/Process/Utility/NativeRegisterContextWatchpoint_x86.h"
#include "Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h"
#include "Plugins/Process/Utility/lldb-x86-register-enums.h"

#define LLDB_INVALID_XSAVE_OFFSET UINT32_MAX
Expand All @@ -34,7 +34,7 @@ class NativeProcessFreeBSD;

class NativeRegisterContextFreeBSD_x86_64
: public NativeRegisterContextFreeBSD,
public NativeRegisterContextWatchpoint_x86 {
public NativeRegisterContextDBReg_x86 {
public:
NativeRegisterContextFreeBSD_x86_64(const ArchSpec &target_arch,
NativeThreadProtocol &native_thread);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#define lldb_NativeRegisterContextLinux_x86_64_h

#include "Plugins/Process/Linux/NativeRegisterContextLinux.h"
#include "Plugins/Process/Utility/NativeRegisterContextWatchpoint_x86.h"
#include "Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h"
#include "Plugins/Process/Utility/RegisterContext_x86.h"
#include "Plugins/Process/Utility/lldb-x86-register-enums.h"
#include <sys/uio.h>
Expand All @@ -24,7 +24,7 @@ class NativeProcessLinux;

class NativeRegisterContextLinux_x86_64
: public NativeRegisterContextLinux,
public NativeRegisterContextWatchpoint_x86 {
public NativeRegisterContextDBReg_x86 {
public:
NativeRegisterContextLinux_x86_64(const ArchSpec &target_arch,
NativeThreadProtocol &native_thread);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h"
#include "Plugins/Process/Utility/RegisterContext_x86.h"
#include "Plugins/Process/Utility/NativeRegisterContextWatchpoint_x86.h"
#include "Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h"
#include "Plugins/Process/Utility/lldb-x86-register-enums.h"

namespace lldb_private {
Expand All @@ -32,7 +32,7 @@ class NativeProcessNetBSD;

class NativeRegisterContextNetBSD_x86_64
: public NativeRegisterContextNetBSD,
public NativeRegisterContextWatchpoint_x86 {
public NativeRegisterContextDBReg_x86 {
public:
NativeRegisterContextNetBSD_x86_64(const ArchSpec &target_arch,
NativeThreadProtocol &native_thread);
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/Process/Utility/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ add_lldb_library(lldbPluginProcessUtility
LinuxSignals.cpp
MipsLinuxSignals.cpp
NativeProcessSoftwareSingleStep.cpp
NativeRegisterContextDBReg_x86.cpp
NativeRegisterContextRegisterInfo.cpp
NativeRegisterContextWatchpoint_x86.cpp
NetBSDSignals.cpp
RegisterContext_x86.cpp
RegisterContextDarwin_arm.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//===-- NativeRegisterContextWatchpoint_x86.cpp ---------------------------===//
//===-- NativeRegisterContextDBReg_x86.cpp --------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "NativeRegisterContextWatchpoint_x86.h"
#include "NativeRegisterContextDBReg_x86.h"

#include "lldb/Utility/Log.h"
#include "lldb/Utility/RegisterValue.h"
Expand Down Expand Up @@ -80,7 +80,7 @@ static inline uint64_t GetWatchControlBitmask(uint32_t wp_index) {
// Bit mask for control bits regarding all watchpoints.
static constexpr uint64_t watchpoint_all_control_bit_mask = 0xFFFF00FF;

const RegisterInfo *NativeRegisterContextWatchpoint_x86::GetDR(int num) const {
const RegisterInfo *NativeRegisterContextDBReg_x86::GetDR(int num) const {
assert(num >= 0 && num <= 7);
switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
case llvm::Triple::x86:
Expand All @@ -92,8 +92,8 @@ const RegisterInfo *NativeRegisterContextWatchpoint_x86::GetDR(int num) const {
}
}

Status NativeRegisterContextWatchpoint_x86::IsWatchpointHit(uint32_t wp_index,
bool &is_hit) {
Status NativeRegisterContextDBReg_x86::IsWatchpointHit(uint32_t wp_index,
bool &is_hit) {
if (wp_index >= NumSupportedHardwareWatchpoints())
return Status("Watchpoint index out of range");

Expand All @@ -107,8 +107,9 @@ Status NativeRegisterContextWatchpoint_x86::IsWatchpointHit(uint32_t wp_index,
return error;
}

Status NativeRegisterContextWatchpoint_x86::GetWatchpointHitIndex(
uint32_t &wp_index, lldb::addr_t trap_addr) {
Status
NativeRegisterContextDBReg_x86::GetWatchpointHitIndex(uint32_t &wp_index,
lldb::addr_t trap_addr) {
uint32_t num_hw_wps = NumSupportedHardwareWatchpoints();
for (wp_index = 0; wp_index < num_hw_wps; ++wp_index) {
bool is_hit;
Expand All @@ -124,9 +125,8 @@ Status NativeRegisterContextWatchpoint_x86::GetWatchpointHitIndex(
return Status();
}

Status
NativeRegisterContextWatchpoint_x86::IsWatchpointVacant(uint32_t wp_index,
bool &is_vacant) {
Status NativeRegisterContextDBReg_x86::IsWatchpointVacant(uint32_t wp_index,
bool &is_vacant) {
if (wp_index >= NumSupportedHardwareWatchpoints())
return Status("Watchpoint index out of range");

Expand All @@ -140,7 +140,7 @@ NativeRegisterContextWatchpoint_x86::IsWatchpointVacant(uint32_t wp_index,
return error;
}

Status NativeRegisterContextWatchpoint_x86::SetHardwareWatchpointWithIndex(
Status NativeRegisterContextDBReg_x86::SetHardwareWatchpointWithIndex(
lldb::addr_t addr, size_t size, uint32_t watch_flags, uint32_t wp_index) {

if (wp_index >= NumSupportedHardwareWatchpoints())
Expand Down Expand Up @@ -202,7 +202,7 @@ Status NativeRegisterContextWatchpoint_x86::SetHardwareWatchpointWithIndex(
return error;
}

bool NativeRegisterContextWatchpoint_x86::ClearHardwareWatchpoint(
bool NativeRegisterContextDBReg_x86::ClearHardwareWatchpoint(
uint32_t wp_index) {
if (wp_index >= NumSupportedHardwareWatchpoints())
return false;
Expand All @@ -217,8 +217,7 @@ bool NativeRegisterContextWatchpoint_x86::ClearHardwareWatchpoint(
.Success();
}

Status
NativeRegisterContextWatchpoint_x86::ClearWatchpointHit(uint32_t wp_index) {
Status NativeRegisterContextDBReg_x86::ClearWatchpointHit(uint32_t wp_index) {
if (wp_index >= NumSupportedHardwareWatchpoints())
return Status("Watchpoint index out of range");

Expand All @@ -231,7 +230,7 @@ NativeRegisterContextWatchpoint_x86::ClearWatchpointHit(uint32_t wp_index) {
GetDR(6), RegisterValue(dr6.GetAsUInt64() & ~GetStatusBit(wp_index)));
}

Status NativeRegisterContextWatchpoint_x86::ClearAllHardwareWatchpoints() {
Status NativeRegisterContextDBReg_x86::ClearAllHardwareWatchpoints() {
RegisterValue dr7;
Status error = ReadRegister(GetDR(7), dr7);
if (error.Fail())
Expand All @@ -241,7 +240,7 @@ Status NativeRegisterContextWatchpoint_x86::ClearAllHardwareWatchpoints() {
RegisterValue(dr7.GetAsUInt64() & ~watchpoint_all_control_bit_mask));
}

uint32_t NativeRegisterContextWatchpoint_x86::SetHardwareWatchpoint(
uint32_t NativeRegisterContextDBReg_x86::SetHardwareWatchpoint(
lldb::addr_t addr, size_t size, uint32_t watch_flags) {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
const uint32_t num_hw_watchpoints = NumSupportedHardwareWatchpoints();
Expand All @@ -254,15 +253,15 @@ uint32_t NativeRegisterContextWatchpoint_x86::SetHardwareWatchpoint(
return wp_index;
}
if (error.Fail() && log) {
LLDB_LOGF(log, "NativeRegisterContextWatchpoint_x86::%s Error: %s",
LLDB_LOGF(log, "NativeRegisterContextDBReg_x86::%s Error: %s",
__FUNCTION__, error.AsCString());
}
}
return LLDB_INVALID_INDEX32;
}

lldb::addr_t
NativeRegisterContextWatchpoint_x86::GetWatchpointAddress(uint32_t wp_index) {
NativeRegisterContextDBReg_x86::GetWatchpointAddress(uint32_t wp_index) {
if (wp_index >= NumSupportedHardwareWatchpoints())
return LLDB_INVALID_ADDRESS;
RegisterValue drN;
Expand All @@ -271,8 +270,7 @@ NativeRegisterContextWatchpoint_x86::GetWatchpointAddress(uint32_t wp_index) {
return drN.GetAsUInt64();
}

uint32_t
NativeRegisterContextWatchpoint_x86::NumSupportedHardwareWatchpoints() {
uint32_t NativeRegisterContextDBReg_x86::NumSupportedHardwareWatchpoints() {
// Available debug address registers: dr0, dr1, dr2, dr3
return 4;
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
//===-- NativeRegisterContextWatchpoint_x86.h -------------------*- C++ -*-===//
//===-- NativeRegisterContextDBReg_x86.h ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef lldb_NativeRegisterContextWatchpoint_x86_h
#define lldb_NativeRegisterContextWatchpoint_x86_h
#ifndef lldb_NativeRegisterContextDBReg_x86_h
#define lldb_NativeRegisterContextDBReg_x86_h

#include "Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h"

namespace lldb_private {

class NativeRegisterContextWatchpoint_x86
class NativeRegisterContextDBReg_x86
: public virtual NativeRegisterContextRegisterInfo {
public:
Status IsWatchpointHit(uint32_t wp_index, bool &is_hit) override;
Expand Down Expand Up @@ -45,4 +45,4 @@ class NativeRegisterContextWatchpoint_x86

} // namespace lldb_private

#endif // #ifndef lldb_NativeRegisterContextWatchpoint_x86_h
#endif // #ifndef lldb_NativeRegisterContextDBReg_x86_h

0 comments on commit c41372c

Please sign in to comment.