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 
24 #include "RegisterContext_s390x.h"
25 
26 using namespace lldb_private;
27 using namespace lldb;
28 
29 // s390x 64-bit general purpose registers.
30 static const uint32_t g_gpr_regnums_s390x[] = {
40  LLDB_INVALID_REGNUM // register sets need to end with this flag
41 };
42 static_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.
48 static const uint32_t g_fpu_regnums_s390x[] = {
54  LLDB_INVALID_REGNUM // register sets need to end with this flag
55 };
56 static_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.
62 enum { k_num_register_sets = 2 };
63 
64 // Register sets for s390x 64-bit.
65 static const RegisterSet g_reg_sets_s390x[k_num_register_sets] = {
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->m_target_arch.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 
111 const RegisterInfo *
113  if (reg < m_reg_info.num_registers)
114  return &GetRegisterInfo()[reg];
115  else
116  return nullptr;
117 }
118 
120  return m_reg_info.num_registers;
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) {
146  ++sets;
147  }
148 
149  return sets;
150 }
151 
154  switch (m_register_info_up->m_target_arch.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 }
lldb_private::RegisterInfoInterface::m_target_arch
lldb_private::ArchSpec m_target_arch
Definition: RegisterInfoInterface.h:65
RegisterContextPOSIX_s390x::GetRegisterSet
const lldb_private::RegisterSet * GetRegisterSet(size_t set) override
Definition: RegisterContextPOSIX_s390x.cpp:152
g_fpu_regnums_s390x
static const uint32_t g_fpu_regnums_s390x[]
Definition: RegisterContextPOSIX_s390x.cpp:48
lldb_private::lldb_f0_s390x
@ lldb_f0_s390x
Definition: lldb-s390x-register-enums.h:55
Scalar.h
lldb_private::lldb_f14_s390x
@ lldb_f14_s390x
Definition: lldb-s390x-register-enums.h:69
lldb_private::lldb_f3_s390x
@ lldb_f3_s390x
Definition: lldb-s390x-register-enums.h:58
lldb_private::lldb_f7_s390x
@ lldb_f7_s390x
Definition: lldb-s390x-register-enums.h:62
LLDB_INVALID_REGNUM
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:91
lldb_private::lldb_f1_s390x
@ lldb_f1_s390x
Definition: lldb-s390x-register-enums.h:56
lldb_private::ArchSpec::GetMachine
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:667
lldb_private::k_last_fpr_s390x
@ k_last_fpr_s390x
Definition: lldb-s390x-register-enums.h:72
lldb_private::lldb_r8_s390x
@ lldb_r8_s390x
Definition: lldb-s390x-register-enums.h:26
g_reg_sets_s390x
static const RegisterSet g_reg_sets_s390x[k_num_register_sets]
Definition: RegisterContextPOSIX_s390x.cpp:65
RegisterContext_s390x.h
lldb_private::lldb_acr11_s390x
@ lldb_acr11_s390x
Definition: lldb-s390x-register-enums.h:45
lldb_private::RegisterInfoInterface
Definition: RegisterInfoInterface.h:21
lldb_private::lldb_acr13_s390x
@ lldb_acr13_s390x
Definition: lldb-s390x-register-enums.h:47
RegisterContextPOSIX_s390x::GetRegisterName
const char * GetRegisterName(unsigned reg)
Definition: RegisterContextPOSIX_s390x.cpp:133
lldb_private::lldb_f2_s390x
@ lldb_f2_s390x
Definition: lldb-s390x-register-enums.h:57
RegisterContextPOSIX_s390x::RegInfo::last_gpr
uint32_t last_gpr
Definition: RegisterContextPOSIX_s390x.h:50
lldb_private::lldb_acr9_s390x
@ lldb_acr9_s390x
Definition: lldb-s390x-register-enums.h:43
RegisterContextPOSIX_s390x::GetRegisterInfo
virtual const lldb_private::RegisterInfo * GetRegisterInfo()
Definition: RegisterContextPOSIX_s390x.cpp:107
lldb_private::lldb_f11_s390x
@ lldb_f11_s390x
Definition: lldb-s390x-register-enums.h:66
lldb_private::lldb_r14_s390x
@ lldb_r14_s390x
Definition: lldb-s390x-register-enums.h:32
lldb_private::lldb_r11_s390x
@ lldb_r11_s390x
Definition: lldb-s390x-register-enums.h:29
lldb_private::lldb_r2_s390x
@ lldb_r2_s390x
Definition: lldb-s390x-register-enums.h:20
RegisterValue.h
lldb_private::lldb_f8_s390x
@ lldb_f8_s390x
Definition: lldb-s390x-register-enums.h:63
lldb_private::lldb_acr0_s390x
@ lldb_acr0_s390x
Definition: lldb-s390x-register-enums.h:34
lldb_private::lldb_acr1_s390x
@ lldb_acr1_s390x
Definition: lldb-s390x-register-enums.h:35
lldb_private::lldb_r9_s390x
@ lldb_r9_s390x
Definition: lldb-s390x-register-enums.h:27
RegisterContextPOSIX_s390x::GetRegisterCount
size_t GetRegisterCount() override
Definition: RegisterContextPOSIX_s390x.cpp:119
RegisterContextPOSIX_s390x::GetRegisterOffset
virtual unsigned GetRegisterOffset(unsigned reg)
Definition: RegisterContextPOSIX_s390x.cpp:123
RegisterContextPOSIX_s390x::IsGPR
bool IsGPR(unsigned reg)
Definition: RegisterContextPOSIX_s390x.cpp:72
lldb_private::lldb_acr15_s390x
@ lldb_acr15_s390x
Definition: lldb-s390x-register-enums.h:49
lldb_private::lldb_acr14_s390x
@ lldb_acr14_s390x
Definition: lldb-s390x-register-enums.h:48
lldb_private::k_num_registers_s390x
@ k_num_registers_s390x
Definition: lldb-s390x-register-enums.h:81
RegisterContextPOSIX_s390x::~RegisterContextPOSIX_s390x
~RegisterContextPOSIX_s390x() override
lldb_private::k_last_gpr_s390x
@ k_last_gpr_s390x
Definition: lldb-s390x-register-enums.h:52
Process.h
lldb_private::lldb_acr7_s390x
@ lldb_acr7_s390x
Definition: lldb-s390x-register-enums.h:41
Target.h
lldb_private::lldb_f9_s390x
@ lldb_f9_s390x
Definition: lldb-s390x-register-enums.h:64
lldb_private::lldb_acr10_s390x
@ lldb_acr10_s390x
Definition: lldb-s390x-register-enums.h:44
lldb_private::lldb_acr8_s390x
@ lldb_acr8_s390x
Definition: lldb-s390x-register-enums.h:42
lldb_private::lldb_r3_s390x
@ lldb_r3_s390x
Definition: lldb-s390x-register-enums.h:21
lldb_private::lldb_r10_s390x
@ lldb_r10_s390x
Definition: lldb-s390x-register-enums.h:28
lldb_private::Thread
Definition: Thread.h:60
RegisterContextPOSIX_s390x::RegInfo::last_fpr
uint32_t last_fpr
Definition: RegisterContextPOSIX_s390x.h:52
lldb_private::lldb_pswa_s390x
@ lldb_pswa_s390x
Definition: lldb-s390x-register-enums.h:51
RegisterContextPOSIX_s390x::Invalidate
void Invalidate()
Definition: RegisterContextPOSIX_s390x.cpp:103
RegisterContextPOSIX_s390x::RegInfo::first_fpr
uint32_t first_fpr
Definition: RegisterContextPOSIX_s390x.h:51
lldb_private::lldb_pswm_s390x
@ lldb_pswm_s390x
Definition: lldb-s390x-register-enums.h:50
RegisterContextPOSIX_s390x::GetRegisterSetCount
size_t GetRegisterSetCount() override
Definition: RegisterContextPOSIX_s390x.cpp:142
RegisterContextPOSIX_s390x::GetRegisterSize
virtual unsigned GetRegisterSize(unsigned reg)
Definition: RegisterContextPOSIX_s390x.cpp:128
RegisterContextPOSIX_s390x::m_register_info_up
std::unique_ptr< lldb_private::RegisterInfoInterface > m_register_info_up
Definition: RegisterContextPOSIX_s390x.h:56
lldb_private::lldb_f4_s390x
@ lldb_f4_s390x
Definition: lldb-s390x-register-enums.h:59
RegisterContextPOSIX_s390x.h
lldb_private::lldb_r13_s390x
@ lldb_r13_s390x
Definition: lldb-s390x-register-enums.h:31
set
set(option_framework FRAMEWORK) endif() if(LLDB_ENABLE_PYTHON) get_target_property(python_bindings_dir swig_wrapper_python BINARY_DIR) set(lldb_python_wrapper $
Definition: API/CMakeLists.txt:9
lldb_private::lldb_acr2_s390x
@ lldb_acr2_s390x
Definition: lldb-s390x-register-enums.h:36
Thread.h
RegisterContextPOSIX_s390x::m_reg_info
RegInfo m_reg_info
Definition: RegisterContextPOSIX_s390x.h:55
RegisterContextPOSIX_s390x::InvalidateAllRegisters
void InvalidateAllRegisters() override
Definition: RegisterContextPOSIX_s390x.cpp:105
RegisterContextPOSIX_s390x::IsRegisterSetAvailable
virtual bool IsRegisterSetAvailable(size_t set_index)
Definition: RegisterContextPOSIX_s390x.cpp:138
RegisterContextPOSIX_s390x::RegInfo::num_registers
uint32_t num_registers
Definition: RegisterContextPOSIX_s390x.h:46
lldb_private::lldb_r4_s390x
@ lldb_r4_s390x
Definition: lldb-s390x-register-enums.h:22
lldb_private::RegisterContext
Definition: RegisterContext.h:17
lldb_private::k_num_gpr_registers_s390x
@ k_num_gpr_registers_s390x
Definition: lldb-s390x-register-enums.h:82
lldb_private::lldb_f12_s390x
@ lldb_f12_s390x
Definition: lldb-s390x-register-enums.h:67
lldb_private::lldb_r15_s390x
@ lldb_r15_s390x
Definition: lldb-s390x-register-enums.h:33
lldb_private::lldb_acr6_s390x
@ lldb_acr6_s390x
Definition: lldb-s390x-register-enums.h:40
lldb_private::lldb_r0_s390x
@ lldb_r0_s390x
Definition: lldb-s390x-register-enums.h:18
RegisterContextPOSIX_s390x::IsFPR
bool IsFPR(unsigned reg)
Definition: RegisterContextPOSIX_s390x.cpp:76
lldb_private::lldb_f10_s390x
@ lldb_f10_s390x
Definition: lldb-s390x-register-enums.h:65
uint32_t
g_gpr_regnums_s390x
static const uint32_t g_gpr_regnums_s390x[]
Definition: RegisterContextPOSIX_s390x.cpp:30
lldb_private::lldb_f5_s390x
@ lldb_f5_s390x
Definition: lldb-s390x-register-enums.h:60
lldb_private::lldb_acr5_s390x
@ lldb_acr5_s390x
Definition: lldb-s390x-register-enums.h:39
RegisterContextPOSIX_s390x::RegInfo::num_gpr_registers
uint32_t num_gpr_registers
Definition: RegisterContextPOSIX_s390x.h:47
RegisterContextPOSIX_s390x::GetRegisterInfoAtIndex
const lldb_private::RegisterInfo * GetRegisterInfoAtIndex(size_t reg) override
Definition: RegisterContextPOSIX_s390x.cpp:112
DataExtractor.h
lldb_private::lldb_r1_s390x
@ lldb_r1_s390x
Definition: lldb-s390x-register-enums.h:19
RegisterContextPOSIX_s390x::RegInfo::num_fpr_registers
uint32_t num_fpr_registers
Definition: RegisterContextPOSIX_s390x.h:48
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::lldb_acr4_s390x
@ lldb_acr4_s390x
Definition: lldb-s390x-register-enums.h:38
k_num_register_sets
@ k_num_register_sets
Definition: RegisterContextPOSIX_s390x.cpp:62
lldb_private::lldb_r6_s390x
@ lldb_r6_s390x
Definition: lldb-s390x-register-enums.h:24
lldb_private::lldb_r7_s390x
@ lldb_r7_s390x
Definition: lldb-s390x-register-enums.h:25
lldb_private::lldb_f13_s390x
@ lldb_f13_s390x
Definition: lldb-s390x-register-enums.h:68
lldb_private::lldb_acr12_s390x
@ lldb_acr12_s390x
Definition: lldb-s390x-register-enums.h:46
lldb_private::lldb_acr3_s390x
@ lldb_acr3_s390x
Definition: lldb-s390x-register-enums.h:37
lldb_private::k_num_fpr_registers_s390x
@ k_num_fpr_registers_s390x
Definition: lldb-s390x-register-enums.h:83
lldb_private::k_first_fpr_s390x
@ k_first_fpr_s390x
Definition: lldb-s390x-register-enums.h:54
lldb_private::lldb_f6_s390x
@ lldb_f6_s390x
Definition: lldb-s390x-register-enums.h:61
lldb
Definition: SBAddress.h:15
RegisterContextPOSIX_s390x::RegisterContextPOSIX_s390x
RegisterContextPOSIX_s390x(lldb_private::Thread &thread, uint32_t concrete_frame_idx, lldb_private::RegisterInfoInterface *register_info)
Definition: RegisterContextPOSIX_s390x.cpp:80
Endian.h
lldb_private::lldb_fpc_s390x
@ lldb_fpc_s390x
Definition: lldb-s390x-register-enums.h:71
lldb_private::lldb_r12_s390x
@ lldb_r12_s390x
Definition: lldb-s390x-register-enums.h:30
lldb_private::lldb_r5_s390x
@ lldb_r5_s390x
Definition: lldb-s390x-register-enums.h:23
DataBufferHeap.h
lldb_private::lldb_f15_s390x
@ lldb_f15_s390x
Definition: lldb-s390x-register-enums.h:70