aboutsummaryrefslogtreecommitdiff
path: root/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
blob: 161ef040e651a53eaa42e3885c1ede8d8938cd72 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//===-- RegisterContextThreadMemory.h ---------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef lldb_RegisterContextThreadMemory_h_
#define lldb_RegisterContextThreadMemory_h_

#include <vector>

#include "lldb/lldb-private.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Symbol/SymbolContext.h"

namespace lldb_private {
    
class RegisterContextThreadMemory : public lldb_private::RegisterContext
{
public:
    RegisterContextThreadMemory (Thread &thread,
                                 lldb::addr_t register_data_addr);
    
    virtual ~RegisterContextThreadMemory();
    //------------------------------------------------------------------
    // Subclasses must override these functions
    //------------------------------------------------------------------
    virtual void
    InvalidateAllRegisters ();
    
    virtual size_t
    GetRegisterCount ();
    
    virtual const RegisterInfo *
    GetRegisterInfoAtIndex (size_t reg);
    
    virtual size_t
    GetRegisterSetCount ();
    
    virtual const RegisterSet *
    GetRegisterSet (size_t reg_set);
    
    virtual bool
    ReadRegister (const RegisterInfo *reg_info, RegisterValue &reg_value);
    
    virtual bool
    WriteRegister (const RegisterInfo *reg_info, const RegisterValue &reg_value);
    
    // These two functions are used to implement "push" and "pop" of register states.  They are used primarily
    // for expression evaluation, where we need to push a new state (storing the old one in data_sp) and then
    // restoring the original state by passing the data_sp we got from ReadAllRegisters to WriteAllRegisterValues.
    // ReadAllRegisters will do what is necessary to return a coherent set of register values for this thread, which
    // may mean e.g. interrupting a thread that is sitting in a kernel trap.  That is a somewhat disruptive operation,
    // so these API's should only be used when this behavior is needed.
    
    virtual bool
    ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
    
    virtual bool
    WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
    
    bool
    CopyFromRegisterContext (lldb::RegisterContextSP context);
    
    virtual uint32_t
    ConvertRegisterKindToRegisterNumber (lldb::RegisterKind kind, uint32_t num);
    
    //------------------------------------------------------------------
    // Subclasses can override these functions if desired
    //------------------------------------------------------------------
    virtual uint32_t
    NumSupportedHardwareBreakpoints ();
    
    virtual uint32_t
    SetHardwareBreakpoint (lldb::addr_t addr, size_t size);
    
    virtual bool
    ClearHardwareBreakpoint (uint32_t hw_idx);
    
    virtual uint32_t
    NumSupportedHardwareWatchpoints ();
    
    virtual uint32_t
    SetHardwareWatchpoint (lldb::addr_t addr, size_t size, bool read, bool write);
    
    virtual bool
    ClearHardwareWatchpoint (uint32_t hw_index);
    
    virtual bool
    HardwareSingleStep (bool enable);
    
    virtual Error
    ReadRegisterValueFromMemory (const lldb_private::RegisterInfo *reg_info, lldb::addr_t src_addr, uint32_t src_len, RegisterValue &reg_value);
    
    virtual Error
    WriteRegisterValueToMemory (const lldb_private::RegisterInfo *reg_info, lldb::addr_t dst_addr, uint32_t dst_len, const RegisterValue &reg_value);
    
protected:
    void
    UpdateRegisterContext ();
    
    lldb::ThreadWP m_thread_wp;
    lldb::RegisterContextSP m_reg_ctx_sp;
    lldb::addr_t m_register_data_addr;
    uint32_t m_stop_id;
private:
    DISALLOW_COPY_AND_ASSIGN (RegisterContextThreadMemory);
};
} // namespace lldb_private

#endif  // lldb_RegisterContextThreadMemory_h_