1 //===-- RegisterContextThreadMemory.h ---------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTTHREADMEMORY_H
10 #define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTTHREADMEMORY_H
14 #include "lldb/Symbol/SymbolContext.h"
15 #include "lldb/Target/RegisterContext.h"
16 #include "lldb/lldb-private.h"
18 namespace lldb_private
{
20 class RegisterContextThreadMemory
: public lldb_private::RegisterContext
{
22 RegisterContextThreadMemory(Thread
&thread
, lldb::addr_t register_data_addr
);
24 ~RegisterContextThreadMemory() override
;
26 void InvalidateAllRegisters() override
;
28 size_t GetRegisterCount() override
;
30 const RegisterInfo
*GetRegisterInfoAtIndex(size_t reg
) override
;
32 size_t GetRegisterSetCount() override
;
34 const RegisterSet
*GetRegisterSet(size_t reg_set
) override
;
36 bool ReadRegister(const RegisterInfo
*reg_info
,
37 RegisterValue
®_value
) override
;
39 bool WriteRegister(const RegisterInfo
*reg_info
,
40 const RegisterValue
®_value
) override
;
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.
54 bool ReadAllRegisterValues(lldb::WritableDataBufferSP
&data_sp
) override
;
56 bool WriteAllRegisterValues(const lldb::DataBufferSP
&data_sp
) override
;
58 bool CopyFromRegisterContext(lldb::RegisterContextSP context
);
60 uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind
,
61 uint32_t num
) override
;
63 uint32_t NumSupportedHardwareBreakpoints() override
;
65 uint32_t SetHardwareBreakpoint(lldb::addr_t addr
, size_t size
) override
;
67 bool ClearHardwareBreakpoint(uint32_t hw_idx
) override
;
69 uint32_t NumSupportedHardwareWatchpoints() override
;
71 uint32_t SetHardwareWatchpoint(lldb::addr_t addr
, size_t size
, bool read
,
74 bool ClearHardwareWatchpoint(uint32_t hw_index
) override
;
76 bool HardwareSingleStep(bool enable
) override
;
78 Status
ReadRegisterValueFromMemory(const lldb_private::RegisterInfo
*reg_info
,
79 lldb::addr_t src_addr
, uint32_t src_len
,
80 RegisterValue
®_value
) override
;
82 Status
WriteRegisterValueToMemory(const lldb_private::RegisterInfo
*reg_info
,
83 lldb::addr_t dst_addr
, uint32_t dst_len
,
84 const RegisterValue
®_value
) override
;
87 void UpdateRegisterContext();
89 lldb::ThreadWP m_thread_wp
;
90 lldb::RegisterContextSP m_reg_ctx_sp
;
91 lldb::addr_t m_register_data_addr
;
95 RegisterContextThreadMemory(const RegisterContextThreadMemory
&) = delete;
96 const RegisterContextThreadMemory
&
97 operator=(const RegisterContextThreadMemory
&) = delete;
100 } // namespace lldb_private
102 #endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTTHREADMEMORY_H