• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- RegisterCheckpoint.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_TARGET_REGISTERCHECKPOINT_H
10 #define LLDB_TARGET_REGISTERCHECKPOINT_H
11 
12 #include "lldb/Target/StackID.h"
13 #include "lldb/Utility/UserID.h"
14 #include "lldb/lldb-private.h"
15 
16 namespace lldb_private {
17 
18 // Inherit from UserID in case pushing/popping all register values can be done
19 // using a 64 bit integer that holds a baton/cookie instead of actually having
20 // to read all register values into a buffer
21 class RegisterCheckpoint : public UserID {
22 public:
23   enum class Reason {
24     // An expression is about to be run on the thread if the protocol that
25     // talks to the debuggee supports checkpointing the registers using a
26     // push/pop then the UserID base class in the RegisterCheckpoint can be
27     // used to store the baton/cookie that refers to the remote saved state.
28     eExpression,
29     // The register checkpoint wants the raw register bytes, so they must be
30     // read into m_data_sp, or the save/restore checkpoint should fail.
31     eDataBackup
32   };
33 
RegisterCheckpoint(Reason reason)34   RegisterCheckpoint(Reason reason)
35       : UserID(0), m_data_sp(), m_reason(reason) {}
36 
~RegisterCheckpoint()37   ~RegisterCheckpoint() {}
38 
GetData()39   lldb::DataBufferSP &GetData() { return m_data_sp; }
40 
GetData()41   const lldb::DataBufferSP &GetData() const { return m_data_sp; }
42 
43 protected:
44   lldb::DataBufferSP m_data_sp;
45   Reason m_reason;
46 
47   // Make RegisterCheckpointSP if you wish to share the data in this class.
48   RegisterCheckpoint(const RegisterCheckpoint &) = delete;
49   const RegisterCheckpoint &operator=(const RegisterCheckpoint &) = delete;
50 };
51 
52 } // namespace lldb_private
53 
54 #endif // LLDB_TARGET_REGISTERCHECKPOINT_H
55