aboutsummaryrefslogtreecommitdiff
path: root/source/Plugins/Process/Utility/RegisterContextMemory.h
blob: 8bba52c627f3c960fb3b77e0b8ad6ed8575d409b (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
//===-- RegisterContextMemory.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_RegisterContextMemory_h_
#define lldb_RegisterContextMemory_h_

// C Includes
// C++ Includes
#include <vector>

// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Target/RegisterContext.h"

class DynamicRegisterInfo;

class RegisterContextMemory : public lldb_private::RegisterContext
{
public:
    //------------------------------------------------------------------
    // Constructors and Destructors
    //------------------------------------------------------------------
    RegisterContextMemory (lldb_private::Thread &thread,
                            uint32_t concrete_frame_idx,
                            DynamicRegisterInfo &reg_info,
                            lldb::addr_t reg_data_addr);

    virtual
    ~RegisterContextMemory ();

    //------------------------------------------------------------------
    // Subclasses must override these functions
    //------------------------------------------------------------------
    virtual void
    InvalidateAllRegisters ();

    virtual size_t
    GetRegisterCount ();

    virtual const lldb_private::RegisterInfo *
    GetRegisterInfoAtIndex (size_t reg);

    virtual size_t
    GetRegisterSetCount ();

    virtual const lldb_private::RegisterSet *
    GetRegisterSet (size_t reg_set);

    virtual uint32_t
    ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num);

    
    //------------------------------------------------------------------
    // If all of the thread register are in a contiguous buffer in 
    // memory, then the default ReadRegister/WriteRegister and
    // ReadAllRegisterValues/WriteAllRegisterValues will work. If thread
    // registers are not contiguous, clients will want to subclass this
    // class and modify the read/write functions as needed.
    //------------------------------------------------------------------

    virtual bool
    ReadRegister (const lldb_private::RegisterInfo *reg_info, 
                  lldb_private::RegisterValue &reg_value);
    
    virtual bool
    WriteRegister (const lldb_private::RegisterInfo *reg_info, 
                   const lldb_private::RegisterValue &reg_value);
    
    virtual bool
    ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
    
    virtual bool
    WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);

    void
    SetAllRegisterData  (const lldb::DataBufferSP &data_sp);
protected:
    
    void
    SetAllRegisterValid (bool b);

    DynamicRegisterInfo &m_reg_infos;
    std::vector<bool> m_reg_valid;
    lldb_private::DataExtractor m_reg_data;
    lldb::addr_t m_reg_data_addr; // If this is valid, then we have a register context that is stored in memmory

private:
    //------------------------------------------------------------------
    // For RegisterContextMemory only
    //------------------------------------------------------------------
    DISALLOW_COPY_AND_ASSIGN (RegisterContextMemory);
};

#endif  // lldb_RegisterContextMemory_h_