LLDB  mainline
RegisterContextThreadMemory.h
Go to the documentation of this file.
1 //===-- RegisterContextThreadMemory.h ---------------------------*- C++ -*-===//
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 
9 #ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTTHREADMEMORY_H
10 #define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTTHREADMEMORY_H
11 
12 #include <vector>
13 
16 #include "lldb/lldb-private.h"
17 
18 namespace lldb_private {
19 
21 public:
22  RegisterContextThreadMemory(Thread &thread, lldb::addr_t register_data_addr);
23 
25 
26  void InvalidateAllRegisters() override;
27 
28  size_t GetRegisterCount() override;
29 
30  const RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override;
31 
32  size_t GetRegisterSetCount() override;
33 
34  const RegisterSet *GetRegisterSet(size_t reg_set) override;
35 
36  bool ReadRegister(const RegisterInfo *reg_info,
37  RegisterValue &reg_value) override;
38 
39  bool WriteRegister(const RegisterInfo *reg_info,
40  const RegisterValue &reg_value) override;
41 
42  // These two functions are used to implement "push" and "pop" of register
43  // states. They are used primarily
44  // for expression evaluation, where we need to push a new state (storing the
45  // old one in data_sp) and then
46  // restoring the original state by passing the data_sp we got from
47  // ReadAllRegisters to WriteAllRegisterValues.
48  // ReadAllRegisters will do what is necessary to return a coherent set of
49  // register values for this thread, which
50  // may mean e.g. interrupting a thread that is sitting in a kernel trap. That
51  // is a somewhat disruptive operation,
52  // so these API's should only be used when this behavior is needed.
53 
54  bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
55 
56  bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
57 
58  bool CopyFromRegisterContext(lldb::RegisterContextSP context);
59 
61  uint32_t num) override;
62 
64 
65  uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
66 
67  bool ClearHardwareBreakpoint(uint32_t hw_idx) override;
68 
70 
71  uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size, bool read,
72  bool write) override;
73 
74  bool ClearHardwareWatchpoint(uint32_t hw_index) override;
75 
76  bool HardwareSingleStep(bool enable) override;
77 
78  Status ReadRegisterValueFromMemory(const lldb_private::RegisterInfo *reg_info,
79  lldb::addr_t src_addr, uint32_t src_len,
80  RegisterValue &reg_value) override;
81 
82  Status WriteRegisterValueToMemory(const lldb_private::RegisterInfo *reg_info,
83  lldb::addr_t dst_addr, uint32_t dst_len,
84  const RegisterValue &reg_value) override;
85 
86 protected:
87  void UpdateRegisterContext();
88 
89  lldb::ThreadWP m_thread_wp;
90  lldb::RegisterContextSP m_reg_ctx_sp;
93 
94 private:
97  operator=(const RegisterContextThreadMemory &) = delete;
98 };
99 
100 } // namespace lldb_private
101 
102 #endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTTHREADMEMORY_H
lldb_private::RegisterContextThreadMemory::ClearHardwareWatchpoint
bool ClearHardwareWatchpoint(uint32_t hw_index) override
Definition: RegisterContextThreadMemory.cpp:180
lldb_private::RegisterContextThreadMemory::UpdateRegisterContext
void UpdateRegisterContext()
Definition: RegisterContextThreadMemory.cpp:27
lldb_private::RegisterContextThreadMemory::ReadRegister
bool ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value) override
Definition: RegisterContextThreadMemory.cpp:93
lldb_private::RegisterValue
Definition: RegisterValue.h:28
lldb_private::RegisterContextThreadMemory::m_stop_id
uint32_t m_stop_id
Definition: RegisterContextThreadMemory.h:92
lldb_private::RegisterContextThreadMemory::RegisterContextThreadMemory
RegisterContextThreadMemory(Thread &thread, lldb::addr_t register_data_addr)
Definition: RegisterContextThreadMemory.cpp:20
lldb_private::RegisterContextThreadMemory::operator=
const RegisterContextThreadMemory & operator=(const RegisterContextThreadMemory &)=delete
lldb_private::RegisterContextThreadMemory::NumSupportedHardwareWatchpoints
uint32_t NumSupportedHardwareWatchpoints() override
Definition: RegisterContextThreadMemory.cpp:163
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::RegisterContextThreadMemory::ReadRegisterValueFromMemory
Status ReadRegisterValueFromMemory(const lldb_private::RegisterInfo *reg_info, lldb::addr_t src_addr, uint32_t src_len, RegisterValue &reg_value) override
Definition: RegisterContextThreadMemory.cpp:194
lldb_private::RegisterContextThreadMemory::WriteRegister
bool WriteRegister(const RegisterInfo *reg_info, const RegisterValue &reg_value) override
Definition: RegisterContextThreadMemory.cpp:101
lldb_private::RegisterContextThreadMemory::ConvertRegisterKindToRegisterNumber
uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override
Convert from a given register numbering scheme to the lldb register numbering scheme.
Definition: RegisterContextThreadMemory.cpp:133
lldb_private::RegisterContextThreadMemory::GetRegisterSetCount
size_t GetRegisterSetCount() override
Definition: RegisterContextThreadMemory.cpp:79
lldb_private::RegisterContextThreadMemory::NumSupportedHardwareBreakpoints
uint32_t NumSupportedHardwareBreakpoints() override
Definition: RegisterContextThreadMemory.cpp:141
lldb_private::RegisterContextThreadMemory::m_thread_wp
lldb::ThreadWP m_thread_wp
Definition: RegisterContextThreadMemory.h:89
lldb_private::RegisterContextThreadMemory::m_reg_ctx_sp
lldb::RegisterContextSP m_reg_ctx_sp
Definition: RegisterContextThreadMemory.h:90
lldb_private::Thread
Definition: Thread.h:60
lldb_private::RegisterContextThreadMemory::m_register_data_addr
lldb::addr_t m_register_data_addr
Definition: RegisterContextThreadMemory.h:91
lldb_private::RegisterContextThreadMemory::ClearHardwareBreakpoint
bool ClearHardwareBreakpoint(uint32_t hw_idx) override
Definition: RegisterContextThreadMemory.cpp:156
lldb_private::RegisterContext
Definition: RegisterContext.h:17
lldb::RegisterKind
RegisterKind
Register numbering types.
Definition: lldb-enumerations.h:227
lldb-private.h
lldb_private::RegisterContextThreadMemory::HardwareSingleStep
bool HardwareSingleStep(bool enable) override
Definition: RegisterContextThreadMemory.cpp:187
lldb_private::Status
Definition: Status.h:44
uint32_t
lldb_private::RegisterContextThreadMemory::ReadAllRegisterValues
bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override
Definition: RegisterContextThreadMemory.cpp:109
lldb_private::RegisterContextThreadMemory::GetRegisterInfoAtIndex
const RegisterInfo * GetRegisterInfoAtIndex(size_t reg) override
Definition: RegisterContextThreadMemory.cpp:72
lldb_private::RegisterContextThreadMemory::WriteAllRegisterValues
bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override
Definition: RegisterContextThreadMemory.cpp:117
lldb_private::RegisterContextThreadMemory::GetRegisterSet
const RegisterSet * GetRegisterSet(size_t reg_set) override
Definition: RegisterContextThreadMemory.cpp:86
SymbolContext.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::RegisterContextThreadMemory::CopyFromRegisterContext
bool CopyFromRegisterContext(lldb::RegisterContextSP context)
Definition: RegisterContextThreadMemory.cpp:125
lldb_private::RegisterContextThreadMemory::InvalidateAllRegisters
void InvalidateAllRegisters() override
Definition: RegisterContextThreadMemory.cpp:58
lldb_private::RegisterContextThreadMemory::SetHardwareBreakpoint
uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override
Definition: RegisterContextThreadMemory.cpp:148
lldb_private::RegisterContextThreadMemory::SetHardwareWatchpoint
uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size, bool read, bool write) override
Definition: RegisterContextThreadMemory.cpp:170
lldb_private::RegisterContextThreadMemory::WriteRegisterValueToMemory
Status WriteRegisterValueToMemory(const lldb_private::RegisterInfo *reg_info, lldb::addr_t dst_addr, uint32_t dst_len, const RegisterValue &reg_value) override
Definition: RegisterContextThreadMemory.cpp:206
RegisterContext.h
lldb_private::RegisterContextThreadMemory::GetRegisterCount
size_t GetRegisterCount() override
Definition: RegisterContextThreadMemory.cpp:64
lldb_private::RegisterContextThreadMemory::~RegisterContextThreadMemory
~RegisterContextThreadMemory() override
lldb_private::RegisterContextThreadMemory
Definition: RegisterContextThreadMemory.h:20