Pirama Arumuga Nainar | d285ad0 | 2022-02-08 09:26:56 -0800 | [diff] [blame] | 1 | //===-- RegisterNumber.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_REGISTERNUMBER_H |
| 10 | #define LLDB_TARGET_REGISTERNUMBER_H |
| 11 | |
| 12 | #include "lldb/lldb-private.h" |
| 13 | #include <map> |
| 14 | |
| 15 | /// A class to represent register numbers, and able to convert between |
| 16 | /// different register numbering schemes that may be used in a single |
| 17 | /// debug session. |
| 18 | |
| 19 | class RegisterNumber { |
| 20 | public: |
| 21 | RegisterNumber(lldb_private::Thread &thread, lldb::RegisterKind kind, |
| 22 | uint32_t num); |
| 23 | |
| 24 | // This constructor plus the init() method below allow for the placeholder |
| 25 | // creation of an invalid object initially, possibly to be filled in. It |
| 26 | // would be more consistent to have three Set* methods to set the three data |
| 27 | // that the object needs. |
| 28 | RegisterNumber(); |
| 29 | |
| 30 | void init(lldb_private::Thread &thread, lldb::RegisterKind kind, |
| 31 | uint32_t num); |
| 32 | |
| 33 | const RegisterNumber &operator=(const RegisterNumber &rhs); |
| 34 | |
| 35 | bool operator==(RegisterNumber &rhs); |
| 36 | |
| 37 | bool operator!=(RegisterNumber &rhs); |
| 38 | |
| 39 | bool IsValid() const; |
| 40 | |
| 41 | uint32_t GetAsKind(lldb::RegisterKind kind); |
| 42 | |
| 43 | uint32_t GetRegisterNumber() const; |
| 44 | |
| 45 | lldb::RegisterKind GetRegisterKind() const; |
| 46 | |
| 47 | const char *GetName(); |
| 48 | |
| 49 | private: |
| 50 | typedef std::map<lldb::RegisterKind, uint32_t> Collection; |
| 51 | |
| 52 | lldb::RegisterContextSP m_reg_ctx_sp; |
| 53 | uint32_t m_regnum = LLDB_INVALID_REGNUM; |
| 54 | lldb::RegisterKind m_kind = lldb::kNumRegisterKinds; |
| 55 | Collection m_kind_regnum_map; |
| 56 | const char *m_name = nullptr; |
| 57 | }; |
| 58 | |
| 59 | #endif // LLDB_TARGET_REGISTERNUMBER_H |