summaryrefslogtreecommitdiff
path: root/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp')
-rw-r--r--source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp56
1 files changed, 29 insertions, 27 deletions
diff --git a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
index 31e2825c0fa2..d8056ea7d356 100644
--- a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
+++ b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
@@ -9,16 +9,11 @@
#include "ABISysV_s390x.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
-// Project includes
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectMemory.h"
@@ -32,6 +27,7 @@
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Status.h"
using namespace lldb;
@@ -206,11 +202,8 @@ size_t ABISysV_s390x::GetRedZoneSize() const { return 0; }
ABISP
ABISysV_s390x::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
- static ABISP g_abi_sp;
if (arch.GetTriple().getArch() == llvm::Triple::systemz) {
- if (!g_abi_sp)
- g_abi_sp.reset(new ABISysV_s390x(process_sp));
- return g_abi_sp;
+ return ABISP(new ABISysV_s390x(process_sp));
}
return ABISP();
}
@@ -383,18 +376,19 @@ bool ABISysV_s390x::GetArgumentValues(Thread &thread, ValueList &values) const {
// We currently only support extracting values with Clang QualTypes. Do we
// care about others?
CompilerType compiler_type = value->GetCompilerType();
- if (!compiler_type)
+ llvm::Optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
+ if (!bit_size)
return false;
bool is_signed;
if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
- ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread),
- is_signed, thread, argument_register_ids,
- current_argument_register, current_stack_argument);
+ ReadIntegerArgument(value->GetScalar(), *bit_size, is_signed, thread,
+ argument_register_ids, current_argument_register,
+ current_stack_argument);
} else if (compiler_type.IsPointerType()) {
- ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread),
- false, thread, argument_register_ids,
- current_argument_register, current_stack_argument);
+ ReadIntegerArgument(value->GetScalar(), *bit_size, false, thread,
+ argument_register_ids, current_argument_register,
+ current_stack_argument);
}
}
@@ -452,8 +446,13 @@ Status ABISysV_s390x::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
error.SetErrorString(
"We don't support returning complex values at present");
else {
- size_t bit_width = compiler_type.GetBitSize(frame_sp.get());
- if (bit_width <= 64) {
+ llvm::Optional<uint64_t> bit_width =
+ compiler_type.GetBitSize(frame_sp.get());
+ if (!bit_width) {
+ error.SetErrorString("can't get type size");
+ return error;
+ }
+ if (*bit_width <= 64) {
const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0);
RegisterValue f0_value;
DataExtractor data;
@@ -513,13 +512,15 @@ ValueObjectSP ABISysV_s390x::GetReturnValueObjectSimple(
bool success = false;
if (type_flags & eTypeIsInteger) {
- // Extract the register context so we can read arguments from registers
-
- const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
+ // Extract the register context so we can read arguments from registers.
+ llvm::Optional<uint64_t> byte_size =
+ return_compiler_type.GetByteSize(nullptr);
+ if (!byte_size)
+ return return_valobj_sp;
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
reg_ctx->GetRegisterInfoByName("r2", 0), 0);
const bool is_signed = (type_flags & eTypeIsSigned) != 0;
- switch (byte_size) {
+ switch (*byte_size) {
default:
break;
@@ -559,21 +560,22 @@ ValueObjectSP ABISysV_s390x::GetReturnValueObjectSimple(
if (type_flags & eTypeIsComplex) {
// Don't handle complex yet.
} else {
- const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
- if (byte_size <= sizeof(long double)) {
+ llvm::Optional<uint64_t> byte_size =
+ return_compiler_type.GetByteSize(nullptr);
+ if (byte_size && *byte_size <= sizeof(long double)) {
const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0);
RegisterValue f0_value;
if (reg_ctx->ReadRegister(f0_info, f0_value)) {
DataExtractor data;
if (f0_value.GetData(data)) {
lldb::offset_t offset = 0;
- if (byte_size == sizeof(float)) {
+ if (*byte_size == sizeof(float)) {
value.GetScalar() = (float)data.GetFloat(&offset);
success = true;
- } else if (byte_size == sizeof(double)) {
+ } else if (*byte_size == sizeof(double)) {
value.GetScalar() = (double)data.GetDouble(&offset);
success = true;
- } else if (byte_size == sizeof(long double)) {
+ } else if (*byte_size == sizeof(long double)) {
// Don't handle long double yet.
}
}