LLDB mainline
RegisterContextPOSIX_s390x.cpp
Go to the documentation of this file.
1//===-- RegisterContextPOSIX_s390x.cpp ------------------------------------===//
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#include <cerrno>
10#include <cstdint>
11#include <cstring>
12
13#include "lldb/Target/Process.h"
14#include "lldb/Target/Target.h"
15#include "lldb/Target/Thread.h"
18#include "lldb/Utility/Endian.h"
20#include "lldb/Utility/Scalar.h"
21#include "llvm/Support/Compiler.h"
22
25
26using namespace lldb_private;
27using namespace lldb;
28
29// s390x 64-bit general purpose registers.
30static const uint32_t g_gpr_regnums_s390x[] = {
40 LLDB_INVALID_REGNUM // register sets need to end with this flag
41};
42static_assert((sizeof(g_gpr_regnums_s390x) / sizeof(g_gpr_regnums_s390x[0])) -
43 1 ==
45 "g_gpr_regnums_s390x has wrong number of register infos");
46
47// s390x 64-bit floating point registers.
48static const uint32_t g_fpu_regnums_s390x[] = {
54 LLDB_INVALID_REGNUM // register sets need to end with this flag
55};
56static_assert((sizeof(g_fpu_regnums_s390x) / sizeof(g_fpu_regnums_s390x[0])) -
57 1 ==
59 "g_fpu_regnums_s390x has wrong number of register infos");
60
61// Number of register sets provided by this context.
63
64// Register sets for s390x 64-bit.
66 {"General Purpose Registers", "gpr", k_num_gpr_registers_s390x,
68 {"Floating Point Registers", "fpr", k_num_fpr_registers_s390x,
70};
71
73 return reg <= m_reg_info.last_gpr; // GPRs come first.
74}
75
77 return (m_reg_info.first_fpr <= reg && reg <= m_reg_info.last_fpr);
78}
79
81 Thread &thread, uint32_t concrete_frame_idx,
82 RegisterInfoInterface *register_info)
83 : RegisterContext(thread, concrete_frame_idx) {
84 m_register_info_up.reset(register_info);
85
86 switch (register_info->GetTargetArchitecture().GetMachine()) {
87 case llvm::Triple::systemz:
94 break;
95 default:
96 assert(false && "Unhandled target architecture.");
97 break;
98 }
99}
100
102
104
106
108 return m_register_info_up->GetRegisterInfo();
109}
110
111const RegisterInfo *
113 if (reg < m_reg_info.num_registers)
114 return &GetRegisterInfo()[reg];
115 else
116 return nullptr;
117}
118
121}
122
124 assert(reg < m_reg_info.num_registers && "Invalid register number.");
125 return GetRegisterInfo()[reg].byte_offset;
126}
127
129 assert(reg < m_reg_info.num_registers && "Invalid register number.");
130 return GetRegisterInfo()[reg].byte_size;
131}
132
134 assert(reg < m_reg_info.num_registers && "Invalid register offset.");
135 return GetRegisterInfo()[reg].name;
136}
137
139 return set_index < k_num_register_sets;
140}
141
143 size_t sets = 0;
144 for (size_t set = 0; set < k_num_register_sets; ++set) {
145 if (IsRegisterSetAvailable(set))
146 ++sets;
147 }
148
149 return sets;
150}
151
153 if (IsRegisterSetAvailable(set)) {
154 switch (m_register_info_up->GetTargetArchitecture().GetMachine()) {
155 case llvm::Triple::systemz:
156 return &g_reg_sets_s390x[set];
157 default:
158 assert(false && "Unhandled target architecture.");
159 return nullptr;
160 }
161 }
162 return nullptr;
163}
constexpr size_t k_num_register_sets
static const uint32_t g_gpr_regnums_s390x[]
static const uint32_t g_fpu_regnums_s390x[]
static const RegisterSet g_reg_sets_s390x[k_num_register_sets]
virtual bool IsRegisterSetAvailable(size_t set_index)
virtual unsigned GetRegisterSize(unsigned reg)
std::unique_ptr< lldb_private::RegisterInfoInterface > m_register_info_up
const char * GetRegisterName(unsigned reg)
const lldb_private::RegisterSet * GetRegisterSet(size_t set) override
~RegisterContextPOSIX_s390x() override
virtual const lldb_private::RegisterInfo * GetRegisterInfo()
virtual unsigned GetRegisterOffset(unsigned reg)
const lldb_private::RegisterInfo * GetRegisterInfoAtIndex(size_t reg) override
RegisterContextPOSIX_s390x(lldb_private::Thread &thread, uint32_t concrete_frame_idx, lldb_private::RegisterInfoInterface *register_info)
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:701
RegisterInfo interface to patch RegisterInfo structure for archs.
const lldb_private::ArchSpec & GetTargetArchitecture() const
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:87
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
Every register is described in detail including its name, alternate name (optional),...
uint32_t byte_offset
The byte offset in the register context data where this register's value is found.
uint32_t byte_size
Size in bytes of the register.
const char * name
Name of this register, can't be NULL.
Registers are grouped into register sets.