mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 17:06:46 +00:00
[lldb] Upgrade CompilerType::GetBitSize to return llvm::Expected (#129601)
This patch pushes the error handling boundary for the GetBitSize() methods from Runtime into the Type and CompilerType APIs. This makes it easier to diagnose problems thanks to more meaningful error messages being available. GetBitSize() is often the first thing LLDB asks about a type, so this method is particularly important for a better user experience. rdar://145667239
This commit is contained in:
parent
03da079968
commit
878a64f94a
@ -33,7 +33,7 @@ public:
|
||||
|
||||
virtual ~ExpressionVariable() = default;
|
||||
|
||||
std::optional<uint64_t> GetByteSize() { return m_frozen_sp->GetByteSize(); }
|
||||
llvm::Expected<uint64_t> GetByteSize() { return m_frozen_sp->GetByteSize(); }
|
||||
|
||||
ConstString GetName() { return m_frozen_sp->GetName(); }
|
||||
|
||||
|
@ -391,9 +391,9 @@ public:
|
||||
struct IntegralTemplateArgument;
|
||||
|
||||
/// Return the size of the type in bytes.
|
||||
std::optional<uint64_t> GetByteSize(ExecutionContextScope *exe_scope) const;
|
||||
llvm::Expected<uint64_t> GetByteSize(ExecutionContextScope *exe_scope) const;
|
||||
/// Return the size of the type in bits.
|
||||
std::optional<uint64_t> GetBitSize(ExecutionContextScope *exe_scope) const;
|
||||
llvm::Expected<uint64_t> GetBitSize(ExecutionContextScope *exe_scope) const;
|
||||
|
||||
lldb::Encoding GetEncoding(uint64_t &count) const;
|
||||
|
||||
|
@ -480,7 +480,7 @@ public:
|
||||
|
||||
ConstString GetBaseName();
|
||||
|
||||
std::optional<uint64_t> GetByteSize(ExecutionContextScope *exe_scope);
|
||||
llvm::Expected<uint64_t> GetByteSize(ExecutionContextScope *exe_scope);
|
||||
|
||||
llvm::Expected<uint32_t> GetNumChildren(bool omit_empty_base_classes);
|
||||
|
||||
|
@ -312,7 +312,7 @@ public:
|
||||
|
||||
virtual const llvm::fltSemantics &GetFloatTypeSemantics(size_t byte_size) = 0;
|
||||
|
||||
virtual std::optional<uint64_t>
|
||||
virtual llvm::Expected<uint64_t>
|
||||
GetBitSize(lldb::opaque_compiler_type_t type,
|
||||
ExecutionContextScope *exe_scope) = 0;
|
||||
|
||||
|
@ -180,7 +180,7 @@ class ValueObjectRecognizerSynthesizedValue : public ValueObject {
|
||||
SetName(parent.GetName());
|
||||
}
|
||||
|
||||
std::optional<uint64_t> GetByteSize() override {
|
||||
llvm::Expected<uint64_t> GetByteSize() override {
|
||||
return m_parent->GetByteSize();
|
||||
}
|
||||
lldb::ValueType GetValueType() const override { return m_type; }
|
||||
|
@ -357,7 +357,7 @@ public:
|
||||
virtual bool CanProvideValue();
|
||||
|
||||
// Subclasses must implement the functions below.
|
||||
virtual std::optional<uint64_t> GetByteSize() = 0;
|
||||
virtual llvm::Expected<uint64_t> GetByteSize() = 0;
|
||||
|
||||
virtual lldb::ValueType GetValueType() const = 0;
|
||||
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
static lldb::ValueObjectSP Create(ValueObject &parent, ConstString name,
|
||||
const CompilerType &cast_type);
|
||||
|
||||
std::optional<uint64_t> GetByteSize() override;
|
||||
llvm::Expected<uint64_t> GetByteSize() override;
|
||||
|
||||
llvm::Expected<uint32_t> CalculateNumChildren(uint32_t max) override;
|
||||
|
||||
|
@ -29,7 +29,7 @@ class ValueObjectChild : public ValueObject {
|
||||
public:
|
||||
~ValueObjectChild() override;
|
||||
|
||||
std::optional<uint64_t> GetByteSize() override { return m_byte_size; }
|
||||
llvm::Expected<uint64_t> GetByteSize() override { return m_byte_size; }
|
||||
|
||||
lldb::offset_t GetByteOffset() override { return m_byte_offset; }
|
||||
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
|
||||
Status &&error);
|
||||
|
||||
std::optional<uint64_t> GetByteSize() override;
|
||||
llvm::Expected<uint64_t> GetByteSize() override;
|
||||
|
||||
lldb::ValueType GetValueType() const override;
|
||||
|
||||
|
@ -35,7 +35,7 @@ class ValueObjectDynamicValue : public ValueObject {
|
||||
public:
|
||||
~ValueObjectDynamicValue() override = default;
|
||||
|
||||
std::optional<uint64_t> GetByteSize() override;
|
||||
llvm::Expected<uint64_t> GetByteSize() override;
|
||||
|
||||
ConstString GetTypeName() override;
|
||||
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
const Address &address,
|
||||
const CompilerType &ast_type);
|
||||
|
||||
std::optional<uint64_t> GetByteSize() override;
|
||||
llvm::Expected<uint64_t> GetByteSize() override;
|
||||
|
||||
ConstString GetTypeName() override;
|
||||
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
lldb::RegisterContextSP ®_ctx_sp,
|
||||
uint32_t set_idx);
|
||||
|
||||
std::optional<uint64_t> GetByteSize() override;
|
||||
llvm::Expected<uint64_t> GetByteSize() override;
|
||||
|
||||
lldb::ValueType GetValueType() const override {
|
||||
return lldb::eValueTypeRegisterSet;
|
||||
@ -89,7 +89,7 @@ public:
|
||||
lldb::RegisterContextSP ®_ctx_sp,
|
||||
const RegisterInfo *reg_info);
|
||||
|
||||
std::optional<uint64_t> GetByteSize() override;
|
||||
llvm ::Expected<uint64_t> GetByteSize() override;
|
||||
|
||||
lldb::ValueType GetValueType() const override {
|
||||
return lldb::eValueTypeRegister;
|
||||
|
@ -37,7 +37,7 @@ class ValueObjectSynthetic : public ValueObject {
|
||||
public:
|
||||
~ValueObjectSynthetic() override;
|
||||
|
||||
std::optional<uint64_t> GetByteSize() override;
|
||||
llvm::Expected<uint64_t> GetByteSize() override;
|
||||
|
||||
ConstString GetTypeName() override;
|
||||
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
|
||||
static lldb::ValueObjectSP Create(ValueObject &parent);
|
||||
|
||||
std::optional<uint64_t> GetByteSize() override;
|
||||
llvm::Expected<uint64_t> GetByteSize() override;
|
||||
|
||||
llvm::Expected<uint32_t> CalculateNumChildren(uint32_t max) override;
|
||||
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
|
||||
const lldb::VariableSP &var_sp);
|
||||
|
||||
std::optional<uint64_t> GetByteSize() override;
|
||||
llvm::Expected<uint64_t> GetByteSize() override;
|
||||
|
||||
ConstString GetTypeName() override;
|
||||
|
||||
|
@ -127,8 +127,8 @@ uint64_t SBType::GetByteSize() {
|
||||
LLDB_INSTRUMENT_VA(this);
|
||||
|
||||
if (IsValid())
|
||||
if (std::optional<uint64_t> size =
|
||||
m_opaque_sp->GetCompilerType(false).GetByteSize(nullptr))
|
||||
if (std::optional<uint64_t> size = llvm::expectedToOptional(
|
||||
m_opaque_sp->GetCompilerType(false).GetByteSize(nullptr)))
|
||||
return *size;
|
||||
return 0;
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ size_t SBValue::GetByteSize() {
|
||||
ValueLocker locker;
|
||||
lldb::ValueObjectSP value_sp(GetSP(locker));
|
||||
if (value_sp) {
|
||||
result = value_sp->GetByteSize().value_or(0);
|
||||
result = llvm::expectedToOptional(value_sp->GetByteSize()).value_or(0);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -519,14 +519,14 @@ protected:
|
||||
--pointer_count;
|
||||
}
|
||||
|
||||
std::optional<uint64_t> size = compiler_type.GetByteSize(nullptr);
|
||||
if (!size) {
|
||||
auto size_or_err = compiler_type.GetByteSize(nullptr);
|
||||
if (!size_or_err) {
|
||||
result.AppendErrorWithFormat(
|
||||
"unable to get the byte size of the type '%s'\n",
|
||||
view_as_type_cstr);
|
||||
"unable to get the byte size of the type '%s'\n%s",
|
||||
view_as_type_cstr, llvm::toString(size_or_err.takeError()).c_str());
|
||||
return;
|
||||
}
|
||||
m_format_options.GetByteSizeValue() = *size;
|
||||
m_format_options.GetByteSizeValue() = *size_or_err;
|
||||
|
||||
if (!m_format_options.GetCountValue().OptionWasSet())
|
||||
m_format_options.GetCountValue() = 1;
|
||||
@ -639,15 +639,16 @@ protected:
|
||||
if (!m_format_options.GetFormatValue().OptionWasSet())
|
||||
m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault);
|
||||
|
||||
std::optional<uint64_t> size = compiler_type.GetByteSize(nullptr);
|
||||
if (!size) {
|
||||
result.AppendError("can't get size of type");
|
||||
auto size_or_err = compiler_type.GetByteSize(nullptr);
|
||||
if (!size_or_err) {
|
||||
result.AppendError(llvm::toString(size_or_err.takeError()));
|
||||
return;
|
||||
}
|
||||
bytes_read = *size * m_format_options.GetCountValue().GetCurrentValue();
|
||||
auto size = *size_or_err;
|
||||
bytes_read = size * m_format_options.GetCountValue().GetCurrentValue();
|
||||
|
||||
if (argc > 0)
|
||||
addr = addr + (*size * m_memory_options.m_offset.GetCurrentValue());
|
||||
addr = addr + (size * m_memory_options.m_offset.GetCurrentValue());
|
||||
} else if (m_format_options.GetFormatValue().GetCurrentValue() !=
|
||||
eFormatCString) {
|
||||
data_sp = std::make_shared<DataBufferHeap>(total_byte_size, '\0');
|
||||
@ -1034,8 +1035,8 @@ protected:
|
||||
frame, result_sp)) &&
|
||||
result_sp) {
|
||||
uint64_t value = result_sp->GetValueAsUnsigned(0);
|
||||
std::optional<uint64_t> size =
|
||||
result_sp->GetCompilerType().GetByteSize(nullptr);
|
||||
std::optional<uint64_t> size = llvm::expectedToOptional(
|
||||
result_sp->GetCompilerType().GetByteSize(nullptr));
|
||||
if (!size)
|
||||
return;
|
||||
switch (*size) {
|
||||
|
@ -867,9 +867,10 @@ protected:
|
||||
if (addr_type == eAddressTypeLoad) {
|
||||
// We're in business.
|
||||
// Find out the size of this variable.
|
||||
size = m_option_watchpoint.watch_size.GetCurrentValue() == 0
|
||||
? valobj_sp->GetByteSize().value_or(0)
|
||||
: m_option_watchpoint.watch_size.GetCurrentValue();
|
||||
size =
|
||||
m_option_watchpoint.watch_size.GetCurrentValue() == 0
|
||||
? llvm::expectedToOptional(valobj_sp->GetByteSize()).value_or(0)
|
||||
: m_option_watchpoint.watch_size.GetCurrentValue();
|
||||
}
|
||||
compiler_type = valobj_sp->GetCompilerType();
|
||||
} else {
|
||||
@ -1080,7 +1081,8 @@ protected:
|
||||
/// of the expression, so convert to that if we found a valid type.
|
||||
CompilerType compiler_type(valobj_sp->GetCompilerType());
|
||||
|
||||
std::optional<uint64_t> valobj_size = valobj_sp->GetByteSize();
|
||||
std::optional<uint64_t> valobj_size =
|
||||
llvm::expectedToOptional(valobj_sp->GetByteSize());
|
||||
// Set the type as a uint8_t array if the size being watched is
|
||||
// larger than the ValueObject's size (which is probably the size
|
||||
// of a pointer).
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include "lldb/Utility/DataExtractor.h"
|
||||
#include "lldb/Utility/Endian.h"
|
||||
#include "lldb/Utility/FileSpec.h"
|
||||
#include "lldb/Utility/LLDBLog.h"
|
||||
#include "lldb/Utility/Log.h"
|
||||
#include "lldb/Utility/State.h"
|
||||
#include "lldb/Utility/Stream.h"
|
||||
#include "lldb/lldb-defines.h"
|
||||
@ -223,10 +225,16 @@ uint64_t Value::GetValueByteSize(Status *error_ptr, ExecutionContext *exe_ctx) {
|
||||
case ContextType::Variable: // Variable *
|
||||
{
|
||||
auto *scope = exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr;
|
||||
if (std::optional<uint64_t> size = GetCompilerType().GetByteSize(scope)) {
|
||||
auto size_or_err = GetCompilerType().GetByteSize(scope);
|
||||
if (!size_or_err) {
|
||||
if (error_ptr && error_ptr->Success())
|
||||
*error_ptr = Status::FromError(size_or_err.takeError());
|
||||
else
|
||||
LLDB_LOG_ERRORV(GetLog(LLDBLog::Types), size_or_err.takeError(), "{0}");
|
||||
} else {
|
||||
if (error_ptr)
|
||||
error_ptr->Clear();
|
||||
return *size;
|
||||
return *size_or_err;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -321,8 +329,9 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
|
||||
AddressType address_type = eAddressTypeFile;
|
||||
Address file_so_addr;
|
||||
const CompilerType &ast_type = GetCompilerType();
|
||||
std::optional<uint64_t> type_size = ast_type.GetByteSize(
|
||||
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr);
|
||||
std::optional<uint64_t> type_size =
|
||||
llvm::expectedToOptional(ast_type.GetByteSize(
|
||||
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr));
|
||||
// Nothing to be done for a zero-sized type.
|
||||
if (type_size && *type_size == 0)
|
||||
return error;
|
||||
|
@ -96,16 +96,20 @@ bool TypeFormatImpl_Format::FormatObject(ValueObject *valobj,
|
||||
|
||||
ExecutionContextScope *exe_scope =
|
||||
exe_ctx.GetBestExecutionContextScope();
|
||||
std::optional<uint64_t> size = compiler_type.GetByteSize(exe_scope);
|
||||
if (!size)
|
||||
auto size_or_err = compiler_type.GetByteSize(exe_scope);
|
||||
if (!size_or_err) {
|
||||
LLDB_LOG_ERRORV(
|
||||
GetLog(LLDBLog::Types), size_or_err.takeError(),
|
||||
"Cannot get size of type while formatting object: {0}");
|
||||
return false;
|
||||
}
|
||||
StreamString sstr;
|
||||
compiler_type.DumpTypeValue(
|
||||
&sstr, // The stream to use for display
|
||||
GetFormat(), // Format to display this type with
|
||||
data, // Data to extract from
|
||||
0, // Byte offset into "m_data"
|
||||
*size, // Byte size of item in "m_data"
|
||||
*size_or_err, // Byte size of item in "m_data"
|
||||
valobj->GetBitfieldBitSize(), // Bitfield bit size
|
||||
valobj->GetBitfieldBitOffset(), // Bitfield bit offset
|
||||
exe_scope);
|
||||
|
@ -197,15 +197,15 @@ static lldb::Format GetItemFormatForFormat(lldb::Format format,
|
||||
static std::optional<size_t>
|
||||
CalculateNumChildren(CompilerType container_elem_type, uint64_t num_elements,
|
||||
CompilerType element_type) {
|
||||
std::optional<uint64_t> container_elem_size =
|
||||
container_elem_type.GetByteSize(/* exe_scope */ nullptr);
|
||||
std::optional<uint64_t> container_elem_size = llvm::expectedToOptional(
|
||||
container_elem_type.GetByteSize(/* exe_scope */ nullptr));
|
||||
if (!container_elem_size)
|
||||
return {};
|
||||
|
||||
auto container_size = *container_elem_size * num_elements;
|
||||
|
||||
std::optional<uint64_t> element_size =
|
||||
element_type.GetByteSize(/* exe_scope */ nullptr);
|
||||
std::optional<uint64_t> element_size = llvm::expectedToOptional(
|
||||
element_type.GetByteSize(/* exe_scope */ nullptr));
|
||||
if (!element_size || !*element_size)
|
||||
return {};
|
||||
|
||||
@ -236,10 +236,11 @@ public:
|
||||
nullptr, Status::FromError(num_children_or_err.takeError()));
|
||||
if (idx >= *num_children_or_err)
|
||||
return {};
|
||||
std::optional<uint64_t> size = m_child_type.GetByteSize(nullptr);
|
||||
if (!size)
|
||||
return {};
|
||||
auto offset = idx * *size;
|
||||
auto size_or_err = m_child_type.GetByteSize(nullptr);
|
||||
if (!size_or_err)
|
||||
return ValueObjectConstResult::Create(
|
||||
nullptr, Status::FromError(size_or_err.takeError()));
|
||||
auto offset = idx * *size_or_err;
|
||||
StreamString idx_name;
|
||||
idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
|
||||
ValueObjectSP child_sp(m_backend.GetSyntheticChildAtOffset(
|
||||
|
@ -20,7 +20,8 @@ char ExpressionVariable::ID;
|
||||
ExpressionVariable::ExpressionVariable() : m_flags(0) {}
|
||||
|
||||
uint8_t *ExpressionVariable::GetValueBytes() {
|
||||
std::optional<uint64_t> byte_size = m_frozen_sp->GetByteSize();
|
||||
std::optional<uint64_t> byte_size =
|
||||
llvm::expectedToOptional(m_frozen_sp->GetByteSize());
|
||||
if (byte_size && *byte_size) {
|
||||
if (m_frozen_sp->GetDataExtractor().GetByteSize() < *byte_size) {
|
||||
m_frozen_sp->GetValue().ResizeData(*byte_size);
|
||||
|
@ -78,8 +78,9 @@ public:
|
||||
const bool zero_memory = false;
|
||||
|
||||
lldb::addr_t mem = map.Malloc(
|
||||
m_persistent_variable_sp->GetByteSize().value_or(0), 8,
|
||||
lldb::ePermissionsReadable | lldb::ePermissionsWritable,
|
||||
llvm::expectedToOptional(m_persistent_variable_sp->GetByteSize())
|
||||
.value_or(0),
|
||||
8, lldb::ePermissionsReadable | lldb::ePermissionsWritable,
|
||||
IRMemoryMap::eAllocationPolicyMirror, zero_memory, allocate_error);
|
||||
|
||||
if (!allocate_error.Success()) {
|
||||
@ -116,9 +117,11 @@ public:
|
||||
|
||||
Status write_error;
|
||||
|
||||
map.WriteMemory(mem, m_persistent_variable_sp->GetValueBytes(),
|
||||
m_persistent_variable_sp->GetByteSize().value_or(0),
|
||||
write_error);
|
||||
map.WriteMemory(
|
||||
mem, m_persistent_variable_sp->GetValueBytes(),
|
||||
llvm::expectedToOptional(m_persistent_variable_sp->GetByteSize())
|
||||
.value_or(0),
|
||||
write_error);
|
||||
|
||||
if (!write_error.Success()) {
|
||||
err = Status::FromErrorStringWithFormat(
|
||||
@ -246,7 +249,8 @@ public:
|
||||
map.GetBestExecutionContextScope(),
|
||||
m_persistent_variable_sp.get()->GetCompilerType(),
|
||||
m_persistent_variable_sp->GetName(), location, eAddressTypeLoad,
|
||||
m_persistent_variable_sp->GetByteSize().value_or(0));
|
||||
llvm::expectedToOptional(m_persistent_variable_sp->GetByteSize())
|
||||
.value_or(0));
|
||||
|
||||
if (frame_top != LLDB_INVALID_ADDRESS &&
|
||||
frame_bottom != LLDB_INVALID_ADDRESS && location >= frame_bottom &&
|
||||
@ -291,7 +295,8 @@ public:
|
||||
LLDB_LOGF(log, "Dematerializing %s from 0x%" PRIx64 " (size = %llu)",
|
||||
m_persistent_variable_sp->GetName().GetCString(),
|
||||
(uint64_t)mem,
|
||||
(unsigned long long)m_persistent_variable_sp->GetByteSize()
|
||||
(unsigned long long)llvm::expectedToOptional(
|
||||
m_persistent_variable_sp->GetByteSize())
|
||||
.value_or(0));
|
||||
|
||||
// Read the contents of the spare memory area
|
||||
@ -300,9 +305,11 @@ public:
|
||||
|
||||
Status read_error;
|
||||
|
||||
map.ReadMemory(m_persistent_variable_sp->GetValueBytes(), mem,
|
||||
m_persistent_variable_sp->GetByteSize().value_or(0),
|
||||
read_error);
|
||||
map.ReadMemory(
|
||||
m_persistent_variable_sp->GetValueBytes(), mem,
|
||||
llvm::expectedToOptional(m_persistent_variable_sp->GetByteSize())
|
||||
.value_or(0),
|
||||
read_error);
|
||||
|
||||
if (!read_error.Success()) {
|
||||
err = Status::FromErrorStringWithFormat(
|
||||
@ -383,12 +390,16 @@ public:
|
||||
if (!err.Success()) {
|
||||
dump_stream.Printf(" <could not be read>\n");
|
||||
} else {
|
||||
DataBufferHeap data(m_persistent_variable_sp->GetByteSize().value_or(0),
|
||||
0);
|
||||
DataBufferHeap data(
|
||||
llvm::expectedToOptional(m_persistent_variable_sp->GetByteSize())
|
||||
.value_or(0),
|
||||
0);
|
||||
|
||||
map.ReadMemory(data.GetBytes(), target_address,
|
||||
m_persistent_variable_sp->GetByteSize().value_or(0),
|
||||
err);
|
||||
map.ReadMemory(
|
||||
data.GetBytes(), target_address,
|
||||
llvm::expectedToOptional(m_persistent_variable_sp->GetByteSize())
|
||||
.value_or(0),
|
||||
err);
|
||||
|
||||
if (!err.Success()) {
|
||||
dump_stream.Printf(" <could not be read>\n");
|
||||
@ -529,7 +540,8 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.GetByteSize() < GetByteSize(scope)) {
|
||||
if (data.GetByteSize() <
|
||||
llvm::expectedToOptional(GetByteSize(scope)).value_or(0)) {
|
||||
if (data.GetByteSize() == 0 && !LocationExpressionIsValid()) {
|
||||
err = Status::FromErrorStringWithFormat(
|
||||
"the variable '%s' has no location, "
|
||||
@ -539,7 +551,8 @@ public:
|
||||
err = Status::FromErrorStringWithFormat(
|
||||
"size of variable %s (%" PRIu64
|
||||
") is larger than the ValueObject's size (%" PRIu64 ")",
|
||||
GetName().AsCString(), GetByteSize(scope).value_or(0),
|
||||
GetName().AsCString(),
|
||||
llvm::expectedToOptional(GetByteSize(scope)).value_or(0),
|
||||
data.GetByteSize());
|
||||
}
|
||||
return;
|
||||
@ -632,8 +645,10 @@ public:
|
||||
|
||||
Status extract_error;
|
||||
|
||||
map.GetMemoryData(data, m_temporary_allocation,
|
||||
valobj_sp->GetByteSize().value_or(0), extract_error);
|
||||
map.GetMemoryData(
|
||||
data, m_temporary_allocation,
|
||||
llvm::expectedToOptional(valobj_sp->GetByteSize()).value_or(0),
|
||||
extract_error);
|
||||
|
||||
if (!extract_error.Success()) {
|
||||
err = Status::FromErrorStringWithFormat(
|
||||
@ -776,7 +791,7 @@ private:
|
||||
///
|
||||
/// \returns On success, returns byte size of the type associated
|
||||
/// with this variable. Returns std::nullopt otherwise.
|
||||
virtual std::optional<uint64_t>
|
||||
virtual llvm::Expected<uint64_t>
|
||||
GetByteSize(ExecutionContextScope *scope) const = 0;
|
||||
|
||||
/// Returns 'true' if the location expression associated with this variable
|
||||
@ -817,7 +832,7 @@ public:
|
||||
return ValueObjectVariable::Create(scope, m_variable_sp);
|
||||
}
|
||||
|
||||
std::optional<uint64_t>
|
||||
llvm::Expected<uint64_t>
|
||||
GetByteSize(ExecutionContextScope *scope) const override {
|
||||
return m_variable_sp->GetType()->GetByteSize(scope);
|
||||
}
|
||||
@ -860,12 +875,12 @@ public:
|
||||
return m_valobj_sp;
|
||||
}
|
||||
|
||||
std::optional<uint64_t>
|
||||
llvm::Expected<uint64_t>
|
||||
GetByteSize(ExecutionContextScope *scope) const override {
|
||||
if (m_valobj_sp)
|
||||
return m_valobj_sp->GetCompilerType().GetByteSize(scope);
|
||||
|
||||
return {};
|
||||
return llvm::createStringError("no value object");
|
||||
}
|
||||
|
||||
bool LocationExpressionIsValid() const override {
|
||||
@ -937,12 +952,12 @@ public:
|
||||
if (!exe_scope)
|
||||
exe_scope = map.GetBestExecutionContextScope();
|
||||
|
||||
std::optional<uint64_t> byte_size = m_type.GetByteSize(exe_scope);
|
||||
if (!byte_size) {
|
||||
err = Status::FromErrorStringWithFormat(
|
||||
"can't get size of type \"%s\"", m_type.GetTypeName().AsCString());
|
||||
auto byte_size_or_err = m_type.GetByteSize(exe_scope);
|
||||
if (!byte_size_or_err) {
|
||||
err = Status::FromError(byte_size_or_err.takeError());
|
||||
return;
|
||||
}
|
||||
auto byte_size = *byte_size_or_err;
|
||||
|
||||
std::optional<size_t> opt_bit_align = m_type.GetTypeBitAlign(exe_scope);
|
||||
if (!opt_bit_align) {
|
||||
@ -958,10 +973,10 @@ public:
|
||||
const bool zero_memory = true;
|
||||
|
||||
m_temporary_allocation = map.Malloc(
|
||||
*byte_size, byte_align,
|
||||
byte_size, byte_align,
|
||||
lldb::ePermissionsReadable | lldb::ePermissionsWritable,
|
||||
IRMemoryMap::eAllocationPolicyMirror, zero_memory, alloc_error);
|
||||
m_temporary_allocation_size = *byte_size;
|
||||
m_temporary_allocation_size = byte_size;
|
||||
|
||||
if (!alloc_error.Success()) {
|
||||
err = Status::FromErrorStringWithFormat(
|
||||
@ -1085,7 +1100,8 @@ public:
|
||||
|
||||
ret->ValueUpdated();
|
||||
|
||||
const size_t pvar_byte_size = ret->GetByteSize().value_or(0);
|
||||
const size_t pvar_byte_size =
|
||||
llvm::expectedToOptional(ret->GetByteSize()).value_or(0);
|
||||
uint8_t *pvar_data = ret->GetValueBytes();
|
||||
|
||||
map.ReadMemory(pvar_data, address, pvar_byte_size, read_error);
|
||||
|
@ -1471,7 +1471,7 @@ Status Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
|
||||
char *wd = getcwd(nullptr, 0);
|
||||
if (wd == nullptr) {
|
||||
error = Status::FromErrorStringWithFormat(
|
||||
"cwd does not exist; cannot launch with shell argument expansion");
|
||||
"cwd does not exist: Cannot launch with shell argument expansion");
|
||||
return error;
|
||||
} else {
|
||||
FileSpec working_dir(wd);
|
||||
|
@ -142,7 +142,8 @@ bool ABIMacOSX_arm64::GetArgumentValues(Thread &thread,
|
||||
return false;
|
||||
|
||||
CompilerType value_type = value->GetCompilerType();
|
||||
std::optional<uint64_t> bit_size = value_type.GetBitSize(&thread);
|
||||
std::optional<uint64_t> bit_size =
|
||||
llvm::expectedToOptional(value_type.GetBitSize(&thread));
|
||||
if (!bit_size)
|
||||
return false;
|
||||
|
||||
@ -482,8 +483,8 @@ static bool LoadValueFromConsecutiveGPRRegisters(
|
||||
uint32_t &NGRN, // NGRN (see ABI documentation)
|
||||
uint32_t &NSRN, // NSRN (see ABI documentation)
|
||||
DataExtractor &data) {
|
||||
std::optional<uint64_t> byte_size =
|
||||
value_type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
|
||||
std::optional<uint64_t> byte_size = llvm::expectedToOptional(
|
||||
value_type.GetByteSize(exe_ctx.GetBestExecutionContextScope()));
|
||||
if (!byte_size || *byte_size == 0)
|
||||
return false;
|
||||
|
||||
@ -500,8 +501,8 @@ static bool LoadValueFromConsecutiveGPRRegisters(
|
||||
if (NSRN < 8 && (8 - NSRN) >= homogeneous_count) {
|
||||
if (!base_type)
|
||||
return false;
|
||||
std::optional<uint64_t> base_byte_size =
|
||||
base_type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
|
||||
std::optional<uint64_t> base_byte_size = llvm::expectedToOptional(
|
||||
base_type.GetByteSize(exe_ctx.GetBestExecutionContextScope()));
|
||||
if (!base_byte_size)
|
||||
return false;
|
||||
uint32_t data_offset = 0;
|
||||
@ -635,7 +636,8 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
|
||||
if (!reg_ctx)
|
||||
return return_valobj_sp;
|
||||
|
||||
std::optional<uint64_t> byte_size = return_compiler_type.GetByteSize(&thread);
|
||||
std::optional<uint64_t> byte_size =
|
||||
llvm::expectedToOptional(return_compiler_type.GetByteSize(&thread));
|
||||
if (!byte_size)
|
||||
return return_valobj_sp;
|
||||
|
||||
|
@ -215,7 +215,8 @@ bool ABISysV_arm64::GetArgumentValues(Thread &thread, ValueList &values) const {
|
||||
if (value_type) {
|
||||
bool is_signed = false;
|
||||
size_t bit_width = 0;
|
||||
std::optional<uint64_t> bit_size = value_type.GetBitSize(&thread);
|
||||
std::optional<uint64_t> bit_size =
|
||||
llvm::expectedToOptional(value_type.GetBitSize(&thread));
|
||||
if (!bit_size)
|
||||
return false;
|
||||
if (value_type.IsIntegerOrEnumerationType(is_signed)) {
|
||||
@ -524,8 +525,8 @@ static bool LoadValueFromConsecutiveGPRRegisters(
|
||||
uint32_t &NGRN, // NGRN (see ABI documentation)
|
||||
uint32_t &NSRN, // NSRN (see ABI documentation)
|
||||
DataExtractor &data) {
|
||||
std::optional<uint64_t> byte_size =
|
||||
value_type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
|
||||
std::optional<uint64_t> byte_size = llvm::expectedToOptional(
|
||||
value_type.GetByteSize(exe_ctx.GetBestExecutionContextScope()));
|
||||
|
||||
if (byte_size || *byte_size == 0)
|
||||
return false;
|
||||
@ -543,8 +544,8 @@ static bool LoadValueFromConsecutiveGPRRegisters(
|
||||
if (NSRN < 8 && (8 - NSRN) >= homogeneous_count) {
|
||||
if (!base_type)
|
||||
return false;
|
||||
std::optional<uint64_t> base_byte_size =
|
||||
base_type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
|
||||
std::optional<uint64_t> base_byte_size = llvm::expectedToOptional(
|
||||
base_type.GetByteSize(exe_ctx.GetBestExecutionContextScope()));
|
||||
if (!base_byte_size)
|
||||
return false;
|
||||
uint32_t data_offset = 0;
|
||||
@ -673,7 +674,8 @@ ValueObjectSP ABISysV_arm64::GetReturnValueObjectImpl(
|
||||
if (!reg_ctx)
|
||||
return return_valobj_sp;
|
||||
|
||||
std::optional<uint64_t> byte_size = return_compiler_type.GetByteSize(&thread);
|
||||
std::optional<uint64_t> byte_size =
|
||||
llvm::expectedToOptional(return_compiler_type.GetByteSize(&thread));
|
||||
if (!byte_size)
|
||||
return return_valobj_sp;
|
||||
|
||||
|
@ -1447,7 +1447,8 @@ bool ABIMacOSX_arm::GetArgumentValues(Thread &thread, ValueList &values) const {
|
||||
if (compiler_type) {
|
||||
bool is_signed = false;
|
||||
size_t bit_width = 0;
|
||||
std::optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
|
||||
std::optional<uint64_t> bit_size =
|
||||
llvm::expectedToOptional(compiler_type.GetBitSize(&thread));
|
||||
if (!bit_size)
|
||||
return false;
|
||||
if (compiler_type.IsIntegerOrEnumerationType(is_signed))
|
||||
@ -1553,7 +1554,8 @@ ValueObjectSP ABIMacOSX_arm::GetReturnValueObjectImpl(
|
||||
|
||||
const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfoByName("r0", 0);
|
||||
if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
|
||||
std::optional<uint64_t> bit_width = compiler_type.GetBitSize(&thread);
|
||||
std::optional<uint64_t> bit_width =
|
||||
llvm::expectedToOptional(compiler_type.GetBitSize(&thread));
|
||||
if (!bit_width)
|
||||
return return_valobj_sp;
|
||||
|
||||
@ -1574,7 +1576,7 @@ ValueObjectSP ABIMacOSX_arm::GetReturnValueObjectImpl(
|
||||
reg_ctx->GetRegisterInfoByName("r3", 0);
|
||||
if (r1_reg_info && r2_reg_info && r3_reg_info) {
|
||||
std::optional<uint64_t> byte_size =
|
||||
compiler_type.GetByteSize(&thread);
|
||||
llvm::expectedToOptional(compiler_type.GetByteSize(&thread));
|
||||
if (!byte_size)
|
||||
return return_valobj_sp;
|
||||
ProcessSP process_sp(thread.GetProcess());
|
||||
|
@ -1452,7 +1452,8 @@ bool ABISysV_arm::GetArgumentValues(Thread &thread, ValueList &values) const {
|
||||
size_t bit_width = 0;
|
||||
if (compiler_type.IsIntegerOrEnumerationType(is_signed) ||
|
||||
compiler_type.IsPointerOrReferenceType()) {
|
||||
if (std::optional<uint64_t> size = compiler_type.GetBitSize(&thread))
|
||||
if (std::optional<uint64_t> size =
|
||||
llvm::expectedToOptional(compiler_type.GetBitSize(&thread)))
|
||||
bit_width = *size;
|
||||
} else {
|
||||
// We only handle integer, pointer and reference types currently...
|
||||
@ -1559,8 +1560,10 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
|
||||
|
||||
const RegisterInfo *r0_reg_info =
|
||||
reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1);
|
||||
std::optional<uint64_t> bit_width = compiler_type.GetBitSize(&thread);
|
||||
std::optional<uint64_t> byte_size = compiler_type.GetByteSize(&thread);
|
||||
std::optional<uint64_t> bit_width =
|
||||
llvm::expectedToOptional(compiler_type.GetBitSize(&thread));
|
||||
std::optional<uint64_t> byte_size =
|
||||
llvm::expectedToOptional(compiler_type.GetByteSize(&thread));
|
||||
if (!bit_width || !byte_size)
|
||||
return return_valobj_sp;
|
||||
|
||||
@ -1696,7 +1699,8 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
|
||||
compiler_type.IsHomogeneousAggregate(&base_type);
|
||||
|
||||
if (homogeneous_count > 0 && homogeneous_count <= 4) {
|
||||
std::optional<uint64_t> base_byte_size = base_type.GetByteSize(&thread);
|
||||
std::optional<uint64_t> base_byte_size =
|
||||
llvm::expectedToOptional(base_type.GetByteSize(&thread));
|
||||
if (base_type.IsVectorType()) {
|
||||
if (base_byte_size &&
|
||||
(*base_byte_size == 8 || *base_byte_size == 16)) {
|
||||
@ -1725,7 +1729,7 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
|
||||
|
||||
if (base_type.IsFloatingPointType(float_count, is_complex)) {
|
||||
std::optional<uint64_t> base_byte_size =
|
||||
base_type.GetByteSize(&thread);
|
||||
llvm::expectedToOptional(base_type.GetByteSize(&thread));
|
||||
if (float_count == 2 && is_complex) {
|
||||
if (index != 0 && base_byte_size &&
|
||||
vfp_byte_size != *base_byte_size)
|
||||
|
@ -491,7 +491,8 @@ ValueObjectSP ABISysV_loongarch::GetReturnValueObjectSimple(
|
||||
value.SetCompilerType(compiler_type);
|
||||
|
||||
const uint32_t type_flags = compiler_type.GetTypeInfo();
|
||||
const size_t byte_size = compiler_type.GetByteSize(&thread).value_or(0);
|
||||
const size_t byte_size =
|
||||
llvm::expectedToOptional(compiler_type.GetByteSize(&thread)).value_or(0);
|
||||
const ArchSpec arch = thread.GetProcess()->GetTarget().GetArchitecture();
|
||||
const llvm::Triple::ArchType machine = arch.GetMachine();
|
||||
|
||||
|
@ -801,7 +801,8 @@ ValueObjectSP ABISysV_mips::GetReturnValueObjectImpl(
|
||||
|
||||
// In MIPS register "r2" (v0) holds the integer function return values
|
||||
const RegisterInfo *r2_reg_info = reg_ctx->GetRegisterInfoByName("r2", 0);
|
||||
std::optional<uint64_t> bit_width = return_compiler_type.GetBitSize(&thread);
|
||||
std::optional<uint64_t> bit_width =
|
||||
llvm::expectedToOptional(return_compiler_type.GetBitSize(&thread));
|
||||
if (!bit_width)
|
||||
return return_valobj_sp;
|
||||
if (return_compiler_type.IsIntegerOrEnumerationType(is_signed)) {
|
||||
|
@ -750,7 +750,8 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
|
||||
Target *target = exe_ctx.GetTargetPtr();
|
||||
const ArchSpec target_arch = target->GetArchitecture();
|
||||
ByteOrder target_byte_order = target_arch.GetByteOrder();
|
||||
std::optional<uint64_t> byte_size = return_compiler_type.GetByteSize(&thread);
|
||||
std::optional<uint64_t> byte_size =
|
||||
llvm::expectedToOptional(return_compiler_type.GetByteSize(&thread));
|
||||
if (!byte_size)
|
||||
return return_valobj_sp;
|
||||
const uint32_t type_flags = return_compiler_type.GetTypeInfo(nullptr);
|
||||
@ -959,8 +960,8 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
|
||||
CompilerType field_compiler_type =
|
||||
return_compiler_type.GetFieldAtIndex(
|
||||
idx, name, &field_bit_offset, nullptr, nullptr);
|
||||
std::optional<uint64_t> field_byte_width =
|
||||
field_compiler_type.GetByteSize(&thread);
|
||||
std::optional<uint64_t> field_byte_width = llvm::expectedToOptional(
|
||||
field_compiler_type.GetByteSize(&thread));
|
||||
if (!field_byte_width)
|
||||
return return_valobj_sp;
|
||||
|
||||
@ -1032,7 +1033,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
|
||||
CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
|
||||
idx, name, &field_bit_offset, nullptr, nullptr);
|
||||
std::optional<uint64_t> field_byte_width =
|
||||
field_compiler_type.GetByteSize(&thread);
|
||||
llvm::expectedToOptional(field_compiler_type.GetByteSize(&thread));
|
||||
|
||||
// if we don't know the size of the field (e.g. invalid type), just
|
||||
// bail out
|
||||
|
@ -395,7 +395,8 @@ bool ABISysV_ppc::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();
|
||||
std::optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
|
||||
std::optional<uint64_t> bit_size =
|
||||
llvm::expectedToOptional(compiler_type.GetBitSize(&thread));
|
||||
if (!bit_size)
|
||||
return false;
|
||||
bool is_signed;
|
||||
@ -459,7 +460,7 @@ Status ABISysV_ppc::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
|
||||
"We don't support returning complex values at present");
|
||||
else {
|
||||
std::optional<uint64_t> bit_width =
|
||||
compiler_type.GetBitSize(frame_sp.get());
|
||||
llvm::expectedToOptional(compiler_type.GetBitSize(frame_sp.get()));
|
||||
if (!bit_width) {
|
||||
error = Status::FromErrorString("can't get type size");
|
||||
return error;
|
||||
@ -524,7 +525,7 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectSimple(
|
||||
// Extract the register context so we can read arguments from registers
|
||||
|
||||
std::optional<uint64_t> byte_size =
|
||||
return_compiler_type.GetByteSize(&thread);
|
||||
llvm::expectedToOptional(return_compiler_type.GetByteSize(&thread));
|
||||
if (!byte_size)
|
||||
return return_valobj_sp;
|
||||
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
|
||||
@ -571,7 +572,7 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectSimple(
|
||||
// Don't handle complex yet.
|
||||
} else {
|
||||
std::optional<uint64_t> byte_size =
|
||||
return_compiler_type.GetByteSize(&thread);
|
||||
llvm::expectedToOptional(return_compiler_type.GetByteSize(&thread));
|
||||
if (byte_size && *byte_size <= sizeof(long double)) {
|
||||
const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0);
|
||||
RegisterValue f1_value;
|
||||
@ -605,7 +606,7 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectSimple(
|
||||
thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
|
||||
} else if (type_flags & eTypeIsVector) {
|
||||
std::optional<uint64_t> byte_size =
|
||||
return_compiler_type.GetByteSize(&thread);
|
||||
llvm::expectedToOptional(return_compiler_type.GetByteSize(&thread));
|
||||
if (byte_size && *byte_size > 0) {
|
||||
const RegisterInfo *altivec_reg = reg_ctx->GetRegisterInfoByName("v2", 0);
|
||||
if (altivec_reg) {
|
||||
@ -655,7 +656,8 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectImpl(
|
||||
if (!reg_ctx_sp)
|
||||
return return_valobj_sp;
|
||||
|
||||
std::optional<uint64_t> bit_width = return_compiler_type.GetBitSize(&thread);
|
||||
std::optional<uint64_t> bit_width =
|
||||
llvm::expectedToOptional(return_compiler_type.GetBitSize(&thread));
|
||||
if (!bit_width)
|
||||
return return_valobj_sp;
|
||||
if (return_compiler_type.IsAggregateType()) {
|
||||
@ -698,7 +700,7 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectImpl(
|
||||
CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
|
||||
idx, name, &field_bit_offset, nullptr, nullptr);
|
||||
std::optional<uint64_t> field_bit_width =
|
||||
field_compiler_type.GetBitSize(&thread);
|
||||
llvm::expectedToOptional(field_compiler_type.GetBitSize(&thread));
|
||||
if (!field_bit_width)
|
||||
return return_valobj_sp;
|
||||
|
||||
|
@ -272,7 +272,8 @@ bool ABISysV_ppc64::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();
|
||||
std::optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
|
||||
std::optional<uint64_t> bit_size =
|
||||
llvm::expectedToOptional(compiler_type.GetBitSize(&thread));
|
||||
if (!bit_size)
|
||||
return false;
|
||||
bool is_signed;
|
||||
@ -344,7 +345,7 @@ Status ABISysV_ppc64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
|
||||
"We don't support returning complex values at present");
|
||||
else {
|
||||
std::optional<uint64_t> bit_width =
|
||||
compiler_type.GetBitSize(frame_sp.get());
|
||||
llvm::expectedToOptional(compiler_type.GetBitSize(frame_sp.get()));
|
||||
if (!bit_width) {
|
||||
error = Status::FromErrorString("can't get size of type");
|
||||
return error;
|
||||
@ -568,7 +569,8 @@ private:
|
||||
ReturnValueExtractor(Thread &thread, CompilerType &type,
|
||||
RegisterContext *reg_ctx, ProcessSP process_sp)
|
||||
: m_thread(thread), m_type(type),
|
||||
m_byte_size(m_type.GetByteSize(&thread).value_or(0)),
|
||||
m_byte_size(
|
||||
llvm::expectedToOptional(m_type.GetByteSize(&thread)).value_or(0)),
|
||||
m_data_up(new DataBufferHeap(m_byte_size, 0)), m_reg_ctx(reg_ctx),
|
||||
m_process_sp(process_sp), m_byte_order(process_sp->GetByteOrder()),
|
||||
m_addr_size(
|
||||
@ -644,7 +646,8 @@ private:
|
||||
DataExtractor de(&raw_data, sizeof(raw_data), m_byte_order, m_addr_size);
|
||||
|
||||
lldb::offset_t offset = 0;
|
||||
std::optional<uint64_t> byte_size = type.GetByteSize(m_process_sp.get());
|
||||
std::optional<uint64_t> byte_size =
|
||||
llvm::expectedToOptional(type.GetByteSize(m_process_sp.get()));
|
||||
if (!byte_size)
|
||||
return {};
|
||||
switch (*byte_size) {
|
||||
@ -784,7 +787,7 @@ private:
|
||||
if (m_type.IsHomogeneousAggregate(&elem_type)) {
|
||||
uint32_t type_flags = elem_type.GetTypeInfo();
|
||||
std::optional<uint64_t> elem_size =
|
||||
elem_type.GetByteSize(m_process_sp.get());
|
||||
llvm::expectedToOptional(elem_type.GetByteSize(m_process_sp.get()));
|
||||
if (!elem_size)
|
||||
return {};
|
||||
if (type_flags & eTypeIsComplex || !(type_flags & eTypeIsFloat)) {
|
||||
|
@ -621,7 +621,8 @@ ABISysV_riscv::GetReturnValueObjectSimple(Thread &thread,
|
||||
value.SetCompilerType(compiler_type);
|
||||
|
||||
const uint32_t type_flags = compiler_type.GetTypeInfo();
|
||||
const size_t byte_size = compiler_type.GetByteSize(&thread).value_or(0);
|
||||
const size_t byte_size =
|
||||
llvm::expectedToOptional(compiler_type.GetByteSize(&thread)).value_or(0);
|
||||
const ArchSpec arch = thread.GetProcess()->GetTarget().GetArchitecture();
|
||||
const llvm::Triple::ArchType machine = arch.GetMachine();
|
||||
|
||||
|
@ -356,7 +356,8 @@ 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();
|
||||
std::optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
|
||||
std::optional<uint64_t> bit_size =
|
||||
llvm::expectedToOptional(compiler_type.GetBitSize(&thread));
|
||||
if (!bit_size)
|
||||
return false;
|
||||
bool is_signed;
|
||||
@ -428,7 +429,7 @@ Status ABISysV_s390x::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
|
||||
"We don't support returning complex values at present");
|
||||
else {
|
||||
std::optional<uint64_t> bit_width =
|
||||
compiler_type.GetBitSize(frame_sp.get());
|
||||
llvm::expectedToOptional(compiler_type.GetBitSize(frame_sp.get()));
|
||||
if (!bit_width) {
|
||||
error = Status::FromErrorString("can't get type size");
|
||||
return error;
|
||||
@ -496,7 +497,7 @@ ValueObjectSP ABISysV_s390x::GetReturnValueObjectSimple(
|
||||
if (type_flags & eTypeIsInteger) {
|
||||
// Extract the register context so we can read arguments from registers.
|
||||
std::optional<uint64_t> byte_size =
|
||||
return_compiler_type.GetByteSize(&thread);
|
||||
llvm::expectedToOptional(return_compiler_type.GetByteSize(&thread));
|
||||
if (!byte_size)
|
||||
return return_valobj_sp;
|
||||
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
|
||||
@ -543,7 +544,7 @@ ValueObjectSP ABISysV_s390x::GetReturnValueObjectSimple(
|
||||
// Don't handle complex yet.
|
||||
} else {
|
||||
std::optional<uint64_t> byte_size =
|
||||
return_compiler_type.GetByteSize(&thread);
|
||||
llvm::expectedToOptional(return_compiler_type.GetByteSize(&thread));
|
||||
if (byte_size && *byte_size <= sizeof(long double)) {
|
||||
const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0);
|
||||
RegisterValue f0_value;
|
||||
|
@ -165,7 +165,8 @@ bool ABIMacOSX_i386::GetArgumentValues(Thread &thread,
|
||||
// We currently only support extracting values with Clang QualTypes. Do we
|
||||
// care about others?
|
||||
CompilerType compiler_type(value->GetCompilerType());
|
||||
std::optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
|
||||
std::optional<uint64_t> bit_size =
|
||||
llvm::expectedToOptional(compiler_type.GetBitSize(&thread));
|
||||
if (bit_size) {
|
||||
bool is_signed;
|
||||
if (compiler_type.IsIntegerOrEnumerationType(is_signed))
|
||||
@ -275,7 +276,8 @@ ABIMacOSX_i386::GetReturnValueObjectImpl(Thread &thread,
|
||||
bool is_signed;
|
||||
|
||||
if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
|
||||
std::optional<uint64_t> bit_width = compiler_type.GetBitSize(&thread);
|
||||
std::optional<uint64_t> bit_width =
|
||||
llvm::expectedToOptional(compiler_type.GetBitSize(&thread));
|
||||
if (!bit_width)
|
||||
return return_valobj_sp;
|
||||
unsigned eax_id =
|
||||
|
@ -182,7 +182,8 @@ bool ABISysV_i386::GetArgumentValues(Thread &thread, ValueList &values) const {
|
||||
|
||||
// Currently: Support for extracting values with Clang QualTypes only.
|
||||
CompilerType compiler_type(value->GetCompilerType());
|
||||
std::optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
|
||||
std::optional<uint64_t> bit_size =
|
||||
llvm::expectedToOptional(compiler_type.GetBitSize(&thread));
|
||||
if (bit_size) {
|
||||
bool is_signed;
|
||||
if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
|
||||
@ -392,7 +393,7 @@ ValueObjectSP ABISysV_i386::GetReturnValueObjectSimple(
|
||||
{
|
||||
value.SetValueType(Value::ValueType::Scalar);
|
||||
std::optional<uint64_t> byte_size =
|
||||
return_compiler_type.GetByteSize(&thread);
|
||||
llvm::expectedToOptional(return_compiler_type.GetByteSize(&thread));
|
||||
if (!byte_size)
|
||||
return return_valobj_sp;
|
||||
bool success = false;
|
||||
@ -517,7 +518,7 @@ ValueObjectSP ABISysV_i386::GetReturnValueObjectSimple(
|
||||
} else if (type_flags & eTypeIsVector) // 'Packed'
|
||||
{
|
||||
std::optional<uint64_t> byte_size =
|
||||
return_compiler_type.GetByteSize(&thread);
|
||||
llvm::expectedToOptional(return_compiler_type.GetByteSize(&thread));
|
||||
if (byte_size && *byte_size > 0) {
|
||||
const RegisterInfo *vec_reg = reg_ctx->GetRegisterInfoByName("xmm0", 0);
|
||||
if (vec_reg == nullptr)
|
||||
|
@ -270,7 +270,8 @@ bool ABISysV_x86_64::GetArgumentValues(Thread &thread,
|
||||
// We currently only support extracting values with Clang QualTypes. Do we
|
||||
// care about others?
|
||||
CompilerType compiler_type = value->GetCompilerType();
|
||||
std::optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
|
||||
std::optional<uint64_t> bit_size =
|
||||
llvm::expectedToOptional(compiler_type.GetBitSize(&thread));
|
||||
if (!bit_size)
|
||||
return false;
|
||||
bool is_signed;
|
||||
@ -342,7 +343,7 @@ Status ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
|
||||
"We don't support returning complex values at present");
|
||||
else {
|
||||
std::optional<uint64_t> bit_width =
|
||||
compiler_type.GetBitSize(frame_sp.get());
|
||||
llvm::expectedToOptional(compiler_type.GetBitSize(frame_sp.get()));
|
||||
if (!bit_width) {
|
||||
error = Status::FromErrorString("can't get type size");
|
||||
return error;
|
||||
@ -412,7 +413,7 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple(
|
||||
// Extract the register context so we can read arguments from registers
|
||||
|
||||
std::optional<uint64_t> byte_size =
|
||||
return_compiler_type.GetByteSize(&thread);
|
||||
llvm::expectedToOptional(return_compiler_type.GetByteSize(&thread));
|
||||
if (!byte_size)
|
||||
return return_valobj_sp;
|
||||
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
|
||||
@ -459,7 +460,7 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple(
|
||||
// Don't handle complex yet.
|
||||
} else {
|
||||
std::optional<uint64_t> byte_size =
|
||||
return_compiler_type.GetByteSize(&thread);
|
||||
llvm::expectedToOptional(return_compiler_type.GetByteSize(&thread));
|
||||
if (byte_size && *byte_size <= sizeof(long double)) {
|
||||
const RegisterInfo *xmm0_info =
|
||||
reg_ctx->GetRegisterInfoByName("xmm0", 0);
|
||||
@ -498,7 +499,7 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple(
|
||||
thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
|
||||
} else if (type_flags & eTypeIsVector) {
|
||||
std::optional<uint64_t> byte_size =
|
||||
return_compiler_type.GetByteSize(&thread);
|
||||
llvm::expectedToOptional(return_compiler_type.GetByteSize(&thread));
|
||||
if (byte_size && *byte_size > 0) {
|
||||
const RegisterInfo *altivec_reg =
|
||||
reg_ctx->GetRegisterInfoByName("xmm0", 0);
|
||||
@ -593,7 +594,7 @@ static bool FlattenAggregateType(
|
||||
CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
|
||||
idx, name, &field_bit_offset, nullptr, nullptr);
|
||||
std::optional<uint64_t> field_bit_width =
|
||||
field_compiler_type.GetBitSize(&thread);
|
||||
llvm::expectedToOptional(field_compiler_type.GetBitSize(&thread));
|
||||
|
||||
// if we don't know the size of the field (e.g. invalid type), exit
|
||||
if (!field_bit_width || *field_bit_width == 0) {
|
||||
@ -635,7 +636,8 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
|
||||
if (!reg_ctx_sp)
|
||||
return return_valobj_sp;
|
||||
|
||||
std::optional<uint64_t> bit_width = return_compiler_type.GetBitSize(&thread);
|
||||
std::optional<uint64_t> bit_width =
|
||||
llvm::expectedToOptional(return_compiler_type.GetBitSize(&thread));
|
||||
if (!bit_width)
|
||||
return return_valobj_sp;
|
||||
if (return_compiler_type.IsAggregateType()) {
|
||||
@ -698,7 +700,10 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
|
||||
bool is_complex;
|
||||
|
||||
CompilerType field_compiler_type = aggregate_compiler_types[idx];
|
||||
uint32_t field_byte_width = (uint32_t) (*field_compiler_type.GetByteSize(&thread));
|
||||
uint32_t field_byte_width =
|
||||
(uint32_t)(llvm::expectedToOptional(
|
||||
field_compiler_type.GetByteSize(&thread))
|
||||
.value_or(0));
|
||||
uint32_t field_byte_offset = aggregate_field_offsets[idx];
|
||||
|
||||
uint32_t field_bit_width = field_byte_width * 8;
|
||||
|
@ -275,7 +275,8 @@ bool ABIWindows_x86_64::GetArgumentValues(Thread &thread,
|
||||
return false;
|
||||
|
||||
CompilerType compiler_type = value->GetCompilerType();
|
||||
std::optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
|
||||
std::optional<uint64_t> bit_size =
|
||||
llvm::expectedToOptional(compiler_type.GetBitSize(&thread));
|
||||
if (!bit_size)
|
||||
return false;
|
||||
bool is_signed;
|
||||
@ -347,7 +348,7 @@ Status ABIWindows_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
|
||||
"We don't support returning complex values at present");
|
||||
else {
|
||||
std::optional<uint64_t> bit_width =
|
||||
compiler_type.GetBitSize(frame_sp.get());
|
||||
llvm::expectedToOptional(compiler_type.GetBitSize(frame_sp.get()));
|
||||
if (!bit_width) {
|
||||
error = Status::FromErrorString("can't get type size");
|
||||
return error;
|
||||
@ -418,7 +419,7 @@ ValueObjectSP ABIWindows_x86_64::GetReturnValueObjectSimple(
|
||||
if (type_flags & eTypeIsInteger) {
|
||||
// Extract the register context so we can read arguments from registers
|
||||
std::optional<uint64_t> byte_size =
|
||||
return_compiler_type.GetByteSize(&thread);
|
||||
llvm::expectedToOptional(return_compiler_type.GetByteSize(&thread));
|
||||
if (!byte_size)
|
||||
return return_valobj_sp;
|
||||
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
|
||||
@ -465,7 +466,7 @@ ValueObjectSP ABIWindows_x86_64::GetReturnValueObjectSimple(
|
||||
// Don't handle complex yet.
|
||||
} else {
|
||||
std::optional<uint64_t> byte_size =
|
||||
return_compiler_type.GetByteSize(&thread);
|
||||
llvm::expectedToOptional(return_compiler_type.GetByteSize(&thread));
|
||||
if (byte_size && *byte_size <= sizeof(long double)) {
|
||||
const RegisterInfo *xmm0_info =
|
||||
reg_ctx->GetRegisterInfoByName("xmm0", 0);
|
||||
@ -503,7 +504,7 @@ ValueObjectSP ABIWindows_x86_64::GetReturnValueObjectSimple(
|
||||
thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
|
||||
} else if (type_flags & eTypeIsVector) {
|
||||
std::optional<uint64_t> byte_size =
|
||||
return_compiler_type.GetByteSize(&thread);
|
||||
llvm::expectedToOptional(return_compiler_type.GetByteSize(&thread));
|
||||
if (byte_size && *byte_size > 0) {
|
||||
const RegisterInfo *xmm_reg =
|
||||
reg_ctx->GetRegisterInfoByName("xmm0", 0);
|
||||
@ -564,7 +565,7 @@ static bool FlattenAggregateType(
|
||||
CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
|
||||
idx, name, &field_bit_offset, nullptr, nullptr);
|
||||
std::optional<uint64_t> field_bit_width =
|
||||
field_compiler_type.GetBitSize(&thread);
|
||||
llvm::expectedToOptional(field_compiler_type.GetBitSize(&thread));
|
||||
|
||||
// if we don't know the size of the field (e.g. invalid type), exit
|
||||
if (!field_bit_width || *field_bit_width == 0) {
|
||||
@ -614,7 +615,8 @@ ValueObjectSP ABIWindows_x86_64::GetReturnValueObjectImpl(
|
||||
return return_valobj_sp;
|
||||
}
|
||||
|
||||
std::optional<uint64_t> bit_width = return_compiler_type.GetBitSize(&thread);
|
||||
std::optional<uint64_t> bit_width =
|
||||
llvm::expectedToOptional(return_compiler_type.GetBitSize(&thread));
|
||||
if (!bit_width) {
|
||||
return return_valobj_sp;
|
||||
}
|
||||
|
@ -298,16 +298,17 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
|
||||
}
|
||||
|
||||
lldb::TargetSP target_sp(m_execution_unit.GetTarget());
|
||||
std::optional<uint64_t> bit_size = m_result_type.GetBitSize(target_sp.get());
|
||||
if (!bit_size) {
|
||||
auto bit_size_or_err = m_result_type.GetBitSize(target_sp.get());
|
||||
if (!bit_size_or_err) {
|
||||
lldb_private::StreamString type_desc_stream;
|
||||
m_result_type.DumpTypeDescription(&type_desc_stream);
|
||||
|
||||
LLDB_LOG(log, "Result type has unknown size");
|
||||
|
||||
m_error_stream.Printf("Error [IRForTarget]: Size of result type '%s' "
|
||||
"couldn't be determined\n",
|
||||
type_desc_stream.GetData());
|
||||
"couldn't be determined\n%s",
|
||||
type_desc_stream.GetData(),
|
||||
llvm::toString(bit_size_or_err.takeError()).c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -322,7 +323,8 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
|
||||
|
||||
LLDB_LOG(log, "Creating a new result global: \"{0}\" with size {1}",
|
||||
m_result_name,
|
||||
m_result_type.GetByteSize(target_sp.get()).value_or(0));
|
||||
llvm::expectedToOptional(m_result_type.GetByteSize(target_sp.get()))
|
||||
.value_or(0));
|
||||
|
||||
// Construct a new result global and set up its metadata
|
||||
|
||||
@ -1035,7 +1037,8 @@ bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) {
|
||||
}
|
||||
|
||||
auto *target = m_execution_unit.GetTarget().get();
|
||||
std::optional<uint64_t> value_size = compiler_type.GetByteSize(target);
|
||||
std::optional<uint64_t> value_size =
|
||||
llvm::expectedToOptional(compiler_type.GetByteSize(target));
|
||||
if (!value_size)
|
||||
return false;
|
||||
std::optional<size_t> opt_alignment = compiler_type.GetTypeBitAlign(target);
|
||||
|
@ -123,7 +123,8 @@ bool lldb_private::formatters::WCharStringSummaryProvider(
|
||||
return false;
|
||||
|
||||
// Safe to pass nullptr for exe_scope here.
|
||||
std::optional<uint64_t> size = wchar_compiler_type.GetBitSize(nullptr);
|
||||
std::optional<uint64_t> size =
|
||||
llvm::expectedToOptional(wchar_compiler_type.GetBitSize(nullptr));
|
||||
if (!size)
|
||||
return false;
|
||||
const uint32_t wchar_size = *size;
|
||||
@ -183,7 +184,8 @@ bool lldb_private::formatters::WCharSummaryProvider(
|
||||
return false;
|
||||
|
||||
// Safe to pass nullptr for exe_scope here.
|
||||
std::optional<uint64_t> size = wchar_compiler_type.GetBitSize(nullptr);
|
||||
std::optional<uint64_t> size =
|
||||
llvm::expectedToOptional(wchar_compiler_type.GetBitSize(nullptr));
|
||||
if (!size)
|
||||
return false;
|
||||
const uint32_t wchar_size = *size;
|
||||
|
@ -110,8 +110,8 @@ ValueObjectSP GenericBitsetFrontEnd::GetChildAtIndex(uint32_t idx) {
|
||||
ValueObjectSP chunk;
|
||||
// For small bitsets __first_ is not an array, but a plain size_t.
|
||||
if (m_first->GetCompilerType().IsArrayType(&type)) {
|
||||
std::optional<uint64_t> bit_size =
|
||||
type.GetBitSize(ctx.GetBestExecutionContextScope());
|
||||
std::optional<uint64_t> bit_size = llvm::expectedToOptional(
|
||||
type.GetBitSize(ctx.GetBestExecutionContextScope()));
|
||||
if (!bit_size || *bit_size == 0)
|
||||
return {};
|
||||
chunk = m_first->GetChildAtIndex(idx / *bit_size);
|
||||
@ -122,8 +122,8 @@ ValueObjectSP GenericBitsetFrontEnd::GetChildAtIndex(uint32_t idx) {
|
||||
if (!type || !chunk)
|
||||
return {};
|
||||
|
||||
std::optional<uint64_t> bit_size =
|
||||
type.GetBitSize(ctx.GetBestExecutionContextScope());
|
||||
std::optional<uint64_t> bit_size = llvm::expectedToOptional(
|
||||
type.GetBitSize(ctx.GetBestExecutionContextScope()));
|
||||
if (!bit_size || *bit_size == 0)
|
||||
return {};
|
||||
size_t chunk_idx = idx % *bit_size;
|
||||
|
@ -501,8 +501,8 @@ ExtractLibcxxStringInfo(ValueObject &valobj) {
|
||||
// likely that the string isn't initialized and we're reading garbage.
|
||||
ExecutionContext exe_ctx(location_sp->GetExecutionContextRef());
|
||||
const std::optional<uint64_t> max_bytes =
|
||||
location_sp->GetCompilerType().GetByteSize(
|
||||
exe_ctx.GetBestExecutionContextScope());
|
||||
llvm::expectedToOptional(location_sp->GetCompilerType().GetByteSize(
|
||||
exe_ctx.GetBestExecutionContextScope()));
|
||||
if (!max_bytes || size > *max_bytes)
|
||||
return {};
|
||||
|
||||
|
@ -88,8 +88,11 @@ lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::Update() {
|
||||
if (!m_element_type.IsValid())
|
||||
return lldb::ChildCacheState::eRefetch;
|
||||
|
||||
if (std::optional<uint64_t> size = m_element_type.GetByteSize(nullptr)) {
|
||||
m_element_size = *size;
|
||||
llvm::Expected<uint64_t> size_or_err = m_element_type.GetByteSize(nullptr);
|
||||
if (!size_or_err)
|
||||
LLDB_LOG_ERRORV(GetLog(LLDBLog::Types), size_or_err.takeError(), "{0}");
|
||||
else {
|
||||
m_element_size = *size_or_err;
|
||||
// Store raw pointers or end up with a circular dependency.
|
||||
m_start = m_backend.GetChildMemberWithName("__begin_").get();
|
||||
}
|
||||
|
@ -137,7 +137,8 @@ lldb_private::formatters::LibcxxStdProxyArraySyntheticFrontEnd::Update() {
|
||||
return ChildCacheState::eRefetch;
|
||||
|
||||
m_element_type = type.GetTypeTemplateArgument(0);
|
||||
if (std::optional<uint64_t> size = m_element_type.GetByteSize(nullptr))
|
||||
if (std::optional<uint64_t> size =
|
||||
llvm::expectedToOptional(m_element_type.GetByteSize(nullptr)))
|
||||
m_element_size = *size;
|
||||
|
||||
if (m_element_size == 0)
|
||||
@ -152,7 +153,8 @@ lldb_private::formatters::LibcxxStdProxyArraySyntheticFrontEnd::Update() {
|
||||
return ChildCacheState::eRefetch;
|
||||
|
||||
m_element_type_size_t = type.GetTypeTemplateArgument(0);
|
||||
if (std::optional<uint64_t> size = m_element_type_size_t.GetByteSize(nullptr))
|
||||
if (std::optional<uint64_t> size =
|
||||
llvm::expectedToOptional(m_element_type_size_t.GetByteSize(nullptr)))
|
||||
m_element_size_size_t = *size;
|
||||
|
||||
if (m_element_size_size_t == 0)
|
||||
|
@ -123,7 +123,8 @@ lldb_private::formatters::LibcxxStdSliceArraySyntheticFrontEnd::Update() {
|
||||
return ChildCacheState::eRefetch;
|
||||
|
||||
m_element_type = type.GetTypeTemplateArgument(0);
|
||||
if (std::optional<uint64_t> size = m_element_type.GetByteSize(nullptr))
|
||||
if (std::optional<uint64_t> size =
|
||||
llvm::expectedToOptional(m_element_type.GetByteSize(nullptr)))
|
||||
m_element_size = *size;
|
||||
|
||||
if (m_element_size == 0)
|
||||
|
@ -102,8 +102,11 @@ lldb_private::formatters::LibcxxStdSpanSyntheticFrontEnd::Update() {
|
||||
m_element_type = data_type_finder_sp->GetCompilerType().GetPointeeType();
|
||||
|
||||
// Get element size.
|
||||
if (std::optional<uint64_t> size = m_element_type.GetByteSize(nullptr)) {
|
||||
m_element_size = *size;
|
||||
llvm::Expected<uint64_t> size_or_err = m_element_type.GetByteSize(nullptr);
|
||||
if (!size_or_err)
|
||||
LLDB_LOG_ERRORV(GetLog(LLDBLog::Types), size_or_err.takeError(), "{0}");
|
||||
else {
|
||||
m_element_size = *size_or_err;
|
||||
|
||||
// Get data.
|
||||
if (m_element_size > 0) {
|
||||
|
@ -104,7 +104,8 @@ lldb_private::formatters::LibcxxStdValarraySyntheticFrontEnd::Update() {
|
||||
return ChildCacheState::eRefetch;
|
||||
|
||||
m_element_type = type.GetTypeTemplateArgument(0);
|
||||
if (std::optional<uint64_t> size = m_element_type.GetByteSize(nullptr))
|
||||
if (std::optional<uint64_t> size =
|
||||
llvm::expectedToOptional(m_element_type.GetByteSize(nullptr)))
|
||||
m_element_size = *size;
|
||||
|
||||
if (m_element_size == 0)
|
||||
|
@ -97,10 +97,13 @@ LibcxxVariantGetIndexValidity(ValueObjectSP &impl_sp) {
|
||||
// the byte size.
|
||||
CompilerType index_type = index_sp->GetCompilerType();
|
||||
|
||||
std::optional<uint64_t> index_type_bytes = index_type.GetByteSize(nullptr);
|
||||
if (!index_type_bytes)
|
||||
return LibcxxVariantIndexValidity::Invalid;
|
||||
|
||||
llvm::Expected<uint64_t> index_type_bytes = index_type.GetByteSize(nullptr);
|
||||
if (!index_type_bytes) {
|
||||
LLDB_LOG_ERRORV(GetLog(LLDBLog::Types), index_type_bytes.takeError(),
|
||||
"{0}");
|
||||
if (!index_type_bytes)
|
||||
return LibcxxVariantIndexValidity::Invalid;
|
||||
}
|
||||
uint64_t npos_value = VariantNposValue(*index_type_bytes);
|
||||
uint64_t index_value = index_sp->GetValueAsUnsigned(0);
|
||||
|
||||
|
@ -137,8 +137,11 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::Update() {
|
||||
return lldb::ChildCacheState::eRefetch;
|
||||
|
||||
m_element_type = data_sp->GetCompilerType().GetPointeeType();
|
||||
if (std::optional<uint64_t> size = m_element_type.GetByteSize(nullptr)) {
|
||||
m_element_size = *size;
|
||||
llvm::Expected<uint64_t> size_or_err = m_element_type.GetByteSize(nullptr);
|
||||
if (!size_or_err)
|
||||
LLDB_LOG_ERRORV(GetLog(LLDBLog::Types), size_or_err.takeError(), "{0}");
|
||||
else {
|
||||
m_element_size = *size_or_err;
|
||||
|
||||
if (m_element_size > 0) {
|
||||
// store raw pointers or end up with a circular dependency
|
||||
@ -198,7 +201,8 @@ lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetChildAtIndex(
|
||||
return {};
|
||||
mask = 1 << bit_index;
|
||||
bool bit_set = ((byte & mask) != 0);
|
||||
std::optional<uint64_t> size = m_bool_type.GetByteSize(nullptr);
|
||||
std::optional<uint64_t> size =
|
||||
llvm::expectedToOptional(m_bool_type.GetByteSize(nullptr));
|
||||
if (!size)
|
||||
return {};
|
||||
WritableDataBufferSP buffer_sp(new DataBufferHeap(*size, 0));
|
||||
|
@ -309,7 +309,8 @@ bool lldb_private::formatters::LibStdcppWStringSummaryProvider(
|
||||
return false;
|
||||
|
||||
// Safe to pass nullptr for exe_scope here.
|
||||
std::optional<uint64_t> size = wchar_compiler_type.GetBitSize(nullptr);
|
||||
std::optional<uint64_t> size =
|
||||
llvm::expectedToOptional(wchar_compiler_type.GetBitSize(nullptr));
|
||||
if (!size)
|
||||
return false;
|
||||
const uint32_t wchar_size = *size;
|
||||
|
@ -101,7 +101,8 @@ lldb::ChildCacheState LibStdcppUniquePtrSyntheticFrontEnd::Update() {
|
||||
// storage due to no_unique_address, so infer the actual size from the total
|
||||
// size of the unique_ptr class. If sizeof(unique_ptr) == sizeof(void*) then
|
||||
// the deleter is empty and should be hidden.
|
||||
if (tuple_sp->GetByteSize() > ptr_obj->GetByteSize()) {
|
||||
if (llvm::expectedToOptional(tuple_sp->GetByteSize()).value_or(0) >
|
||||
llvm::expectedToOptional(ptr_obj->GetByteSize()).value_or(0)) {
|
||||
ValueObjectSP del_obj = tuple_frontend->GetChildAtIndex(1);
|
||||
if (del_obj)
|
||||
m_del_obj = del_obj->Clone(ConstString("deleter")).get();
|
||||
|
@ -722,7 +722,7 @@ void ClassDescriptorV2::iVarsStorage::fill(AppleObjCRuntimeV2 &runtime,
|
||||
"name = {0}, encoding = {1}, offset_ptr = {2:x}, size = "
|
||||
"{3}, type_size = {4}",
|
||||
name, type, offset_ptr, size,
|
||||
ivar_type.GetByteSize(nullptr).value_or(0));
|
||||
expectedToOptional(ivar_type.GetByteSize(nullptr)).value_or(0));
|
||||
Scalar offset_scalar;
|
||||
Status error;
|
||||
const int offset_ptr_size = 4;
|
||||
|
@ -116,7 +116,8 @@ CompilerType RegisterTypeBuilderClang::GetRegisterType(
|
||||
type_system->SetIsPacked(fields_type);
|
||||
|
||||
// This should be true if RegisterFlags padded correctly.
|
||||
assert(*fields_type.GetByteSize(nullptr) == flags.GetSize());
|
||||
assert(llvm::expectedToOptional(fields_type.GetByteSize(nullptr))
|
||||
.value_or(0) == flags.GetSize());
|
||||
}
|
||||
|
||||
return fields_type;
|
||||
|
@ -437,14 +437,11 @@ SymbolFileCTF::CreateArray(const CTFArray &ctf_array) {
|
||||
llvm::formatv("Could not find array element type: {0}", ctf_array.type),
|
||||
llvm::inconvertibleErrorCode());
|
||||
|
||||
std::optional<uint64_t> element_size = element_type->GetByteSize(nullptr);
|
||||
if (!element_size)
|
||||
return llvm::make_error<llvm::StringError>(
|
||||
llvm::formatv("could not get element size of type: {0}",
|
||||
ctf_array.type),
|
||||
llvm::inconvertibleErrorCode());
|
||||
auto element_size_or_err = element_type->GetByteSize(nullptr);
|
||||
if (!element_size_or_err)
|
||||
return element_size_or_err.takeError();
|
||||
|
||||
uint64_t size = ctf_array.nelems * *element_size;
|
||||
uint64_t size = ctf_array.nelems * *element_size_or_err;
|
||||
|
||||
CompilerType compiler_type = m_ast->CreateArrayType(
|
||||
element_type->GetFullCompilerType(), ctf_array.nelems,
|
||||
@ -544,7 +541,8 @@ bool SymbolFileCTF::CompleteType(CompilerType &compiler_type) {
|
||||
for (const CTFRecord::Field &field : ctf_record->fields) {
|
||||
Type *field_type = ResolveTypeUID(field.type);
|
||||
assert(field_type && "field must be complete");
|
||||
const uint32_t field_size = field_type->GetByteSize(nullptr).value_or(0);
|
||||
const uint32_t field_size =
|
||||
llvm::expectedToOptional(field_type->GetByteSize(nullptr)).value_or(0);
|
||||
TypeSystemClang::AddFieldToRecordType(compiler_type, field.name,
|
||||
field_type->GetFullCompilerType(),
|
||||
eAccessPublic, field_size);
|
||||
|
@ -290,9 +290,10 @@ TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
|
||||
|
||||
SymbolFileDWARF *dwarf = die.GetDWARF();
|
||||
auto type_sp = dwarf->MakeType(
|
||||
die.GetID(), pcm_type_sp->GetName(), pcm_type_sp->GetByteSize(nullptr),
|
||||
nullptr, LLDB_INVALID_UID, Type::eEncodingInvalid,
|
||||
&pcm_type_sp->GetDeclaration(), type, Type::ResolveState::Forward,
|
||||
die.GetID(), pcm_type_sp->GetName(),
|
||||
llvm::expectedToOptional(pcm_type_sp->GetByteSize(nullptr)), nullptr,
|
||||
LLDB_INVALID_UID, Type::eEncodingInvalid, &pcm_type_sp->GetDeclaration(),
|
||||
type, Type::ResolveState::Forward,
|
||||
TypePayloadClang(GetOwningClangModule(die)));
|
||||
clang::TagDecl *tag_decl = TypeSystemClang::GetAsTagDecl(type);
|
||||
if (tag_decl) {
|
||||
@ -1463,7 +1464,8 @@ DWARFASTParserClang::ParseArrayType(const DWARFDIE &die,
|
||||
bit_stride = array_info->bit_stride;
|
||||
}
|
||||
if (byte_stride == 0 && bit_stride == 0)
|
||||
byte_stride = element_type->GetByteSize(nullptr).value_or(0);
|
||||
byte_stride = llvm::expectedToOptional(element_type->GetByteSize(nullptr))
|
||||
.value_or(0);
|
||||
CompilerType array_element_type = element_type->GetForwardCompilerType();
|
||||
TypeSystemClang::RequireCompleteType(array_element_type);
|
||||
|
||||
@ -1515,7 +1517,7 @@ TypeSP DWARFASTParserClang::ParsePointerToMemberType(
|
||||
class_clang_type, pointee_clang_type);
|
||||
|
||||
if (std::optional<uint64_t> clang_type_size =
|
||||
clang_type.GetByteSize(nullptr)) {
|
||||
llvm::expectedToOptional(clang_type.GetByteSize(nullptr))) {
|
||||
return dwarf->MakeType(die.GetID(), attrs.name, *clang_type_size, nullptr,
|
||||
LLDB_INVALID_UID, Type::eEncodingIsUID, nullptr,
|
||||
clang_type, Type::ResolveState::Forward);
|
||||
@ -1976,7 +1978,8 @@ private:
|
||||
static std::optional<clang::APValue> MakeAPValue(const clang::ASTContext &ast,
|
||||
CompilerType clang_type,
|
||||
uint64_t value) {
|
||||
std::optional<uint64_t> bit_width = clang_type.GetBitSize(nullptr);
|
||||
std::optional<uint64_t> bit_width =
|
||||
llvm::expectedToOptional(clang_type.GetBitSize(nullptr));
|
||||
if (!bit_width)
|
||||
return std::nullopt;
|
||||
|
||||
@ -2246,9 +2249,10 @@ bool DWARFASTParserClang::CompleteEnumType(const DWARFDIE &die,
|
||||
|
||||
if (TypeSystemClang::StartTagDeclarationDefinition(clang_type)) {
|
||||
if (die.HasChildren())
|
||||
ParseChildEnumerators(clang_type,
|
||||
clang_type.IsEnumerationIntegerTypeSigned(),
|
||||
type->GetByteSize(nullptr).value_or(0), die);
|
||||
ParseChildEnumerators(
|
||||
clang_type, clang_type.IsEnumerationIntegerTypeSigned(),
|
||||
llvm::expectedToOptional(type->GetByteSize(nullptr)).value_or(0),
|
||||
die);
|
||||
|
||||
TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
|
||||
}
|
||||
@ -2981,7 +2985,7 @@ void DWARFASTParserClang::ParseSingleMember(
|
||||
} else {
|
||||
auto byte_size = attrs.byte_size;
|
||||
if (!byte_size)
|
||||
byte_size = member_type->GetByteSize(nullptr);
|
||||
byte_size = llvm::expectedToOptional(member_type->GetByteSize(nullptr));
|
||||
|
||||
ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
|
||||
if (objfile->GetByteOrder() == eByteOrderLittle) {
|
||||
@ -3042,7 +3046,7 @@ void DWARFASTParserClang::ParseSingleMember(
|
||||
// TODO: we shouldn't silently ignore the bit_size if we fail
|
||||
// to GetByteSize.
|
||||
if (std::optional<uint64_t> clang_type_size =
|
||||
member_type->GetByteSize(nullptr)) {
|
||||
llvm::expectedToOptional(member_type->GetByteSize(nullptr))) {
|
||||
this_field_info.bit_size = *clang_type_size * character_width;
|
||||
}
|
||||
|
||||
@ -3851,7 +3855,9 @@ void DWARFASTParserClang::ParseRustVariantPart(
|
||||
m_ast.AddFieldToRecordType(
|
||||
field_type, "$discr$", discriminant_type->GetFullCompilerType(),
|
||||
lldb::eAccessPublic, variants.discriminant().byte_offset);
|
||||
offset += discriminant_type->GetByteSize(nullptr).value_or(0);
|
||||
offset +=
|
||||
llvm::expectedToOptional(discriminant_type->GetByteSize(nullptr))
|
||||
.value_or(0);
|
||||
}
|
||||
|
||||
m_ast.AddFieldToRecordType(field_type, "value",
|
||||
|
@ -2077,8 +2077,9 @@ SymbolFileDWARF::GlobalVariableMap &SymbolFileDWARF::GetGlobalAranges() {
|
||||
location_result->GetScalar().ULongLong();
|
||||
lldb::addr_t byte_size = 1;
|
||||
if (var_sp->GetType())
|
||||
byte_size =
|
||||
var_sp->GetType()->GetByteSize(nullptr).value_or(0);
|
||||
byte_size = llvm::expectedToOptional(
|
||||
var_sp->GetType()->GetByteSize(nullptr))
|
||||
.value_or(0);
|
||||
m_global_aranges_up->Append(GlobalVariableMap::Entry(
|
||||
file_addr, byte_size, var_sp.get()));
|
||||
}
|
||||
@ -3622,9 +3623,11 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
|
||||
DWARFFormValue::IsDataForm(const_value_form.Form());
|
||||
if (use_type_size_for_value && type_sp->GetType()) {
|
||||
DWARFExpression *location = location_list.GetMutableExpressionAtAddress();
|
||||
location->UpdateValue(const_value_form.Unsigned(),
|
||||
type_sp->GetType()->GetByteSize(nullptr).value_or(0),
|
||||
die.GetCU()->GetAddressByteSize());
|
||||
location->UpdateValue(
|
||||
const_value_form.Unsigned(),
|
||||
llvm::expectedToOptional(type_sp->GetType()->GetByteSize(nullptr))
|
||||
.value_or(0),
|
||||
die.GetCU()->GetAddressByteSize());
|
||||
}
|
||||
|
||||
return std::make_shared<Variable>(
|
||||
|
@ -552,8 +552,8 @@ lldb::TypeSP SymbolFileNativePDB::CreateModifierType(PdbTypeSymId type_id,
|
||||
lldb::TypeSP modified_type = GetOrCreateType(mr.ModifiedType);
|
||||
|
||||
return MakeType(toOpaqueUid(type_id), ConstString(name),
|
||||
modified_type->GetByteSize(nullptr), nullptr,
|
||||
LLDB_INVALID_UID, Type::eEncodingIsUID, decl, ct,
|
||||
llvm::expectedToOptional(modified_type->GetByteSize(nullptr)),
|
||||
nullptr, LLDB_INVALID_UID, Type::eEncodingIsUID, decl, ct,
|
||||
Type::ResolveState::Full);
|
||||
}
|
||||
|
||||
@ -670,10 +670,11 @@ lldb::TypeSP SymbolFileNativePDB::CreateTagType(PdbTypeSymId type_id,
|
||||
Declaration decl;
|
||||
TypeSP underlying_type = GetOrCreateType(er.UnderlyingType);
|
||||
|
||||
return MakeType(toOpaqueUid(type_id), ConstString(uname),
|
||||
underlying_type->GetByteSize(nullptr), nullptr,
|
||||
LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl,
|
||||
ct, lldb_private::Type::ResolveState::Forward);
|
||||
return MakeType(
|
||||
toOpaqueUid(type_id), ConstString(uname),
|
||||
llvm::expectedToOptional(underlying_type->GetByteSize(nullptr)), nullptr,
|
||||
LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl, ct,
|
||||
lldb_private::Type::ResolveState::Forward);
|
||||
}
|
||||
|
||||
TypeSP SymbolFileNativePDB::CreateArrayType(PdbTypeSymId type_id,
|
||||
@ -1915,11 +1916,12 @@ TypeSP SymbolFileNativePDB::CreateTypedef(PdbGlobalSymId id) {
|
||||
ts->GetNativePDBParser()->GetOrCreateTypedefDecl(id);
|
||||
|
||||
Declaration decl;
|
||||
return MakeType(
|
||||
toOpaqueUid(id), ConstString(udt.Name), target_type->GetByteSize(nullptr),
|
||||
nullptr, target_type->GetID(), lldb_private::Type::eEncodingIsTypedefUID,
|
||||
decl, target_type->GetForwardCompilerType(),
|
||||
lldb_private::Type::ResolveState::Forward);
|
||||
return MakeType(toOpaqueUid(id), ConstString(udt.Name),
|
||||
llvm::expectedToOptional(target_type->GetByteSize(nullptr)),
|
||||
nullptr, target_type->GetID(),
|
||||
lldb_private::Type::eEncodingIsTypedefUID, decl,
|
||||
target_type->GetForwardCompilerType(),
|
||||
lldb_private::Type::ResolveState::Forward);
|
||||
}
|
||||
|
||||
TypeSP SymbolFileNativePDB::GetOrCreateTypedef(PdbGlobalSymId id) {
|
||||
|
@ -4769,7 +4769,7 @@ TypeSystemClang::GetFloatTypeSemantics(size_t byte_size) {
|
||||
return llvm::APFloatBase::Bogus();
|
||||
}
|
||||
|
||||
std::optional<uint64_t>
|
||||
llvm::Expected<uint64_t>
|
||||
TypeSystemClang::GetObjCBitSize(QualType qual_type,
|
||||
ExecutionContextScope *exe_scope) {
|
||||
assert(qual_type->isObjCObjectOrInterfaceType());
|
||||
@ -4802,11 +4802,14 @@ TypeSystemClang::GetObjCBitSize(QualType qual_type,
|
||||
getASTContext().getTypeSize(getASTContext().ObjCBuiltinClassTy);
|
||||
}
|
||||
|
||||
std::optional<uint64_t>
|
||||
llvm::Expected<uint64_t>
|
||||
TypeSystemClang::GetBitSize(lldb::opaque_compiler_type_t type,
|
||||
ExecutionContextScope *exe_scope) {
|
||||
const bool base_name_only = true;
|
||||
if (!GetCompleteType(type))
|
||||
return std::nullopt;
|
||||
return llvm::createStringError(
|
||||
"could not complete type %s",
|
||||
GetTypeName(type, base_name_only).AsCString(""));
|
||||
|
||||
clang::QualType qual_type(GetCanonicalQualType(type));
|
||||
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
||||
@ -4832,7 +4835,9 @@ TypeSystemClang::GetBitSize(lldb::opaque_compiler_type_t type,
|
||||
return bit_size;
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
return llvm::createStringError(
|
||||
"could not get size of type %s",
|
||||
GetTypeName(type, base_name_only).AsCString(""));
|
||||
}
|
||||
|
||||
std::optional<size_t>
|
||||
@ -6301,12 +6306,14 @@ llvm::Expected<CompilerType> TypeSystemClang::GetChildCompilerTypeAtIndex(
|
||||
child_byte_offset = bit_offset / 8;
|
||||
CompilerType base_class_clang_type = GetType(base_class->getType());
|
||||
child_name = base_class_clang_type.GetTypeName().AsCString("");
|
||||
std::optional<uint64_t> size =
|
||||
auto size_or_err =
|
||||
base_class_clang_type.GetBitSize(get_exe_scope());
|
||||
if (!size)
|
||||
return llvm::createStringError("no size info for base class");
|
||||
if (!size_or_err)
|
||||
return llvm::joinErrors(
|
||||
llvm::createStringError("no size info for base class"),
|
||||
size_or_err.takeError());
|
||||
|
||||
uint64_t base_class_clang_type_bit_size = *size;
|
||||
uint64_t base_class_clang_type_bit_size = *size_or_err;
|
||||
|
||||
// Base classes bit sizes should be a multiple of 8 bits in size
|
||||
assert(base_class_clang_type_bit_size % 8 == 0);
|
||||
@ -6334,12 +6341,13 @@ llvm::Expected<CompilerType> TypeSystemClang::GetChildCompilerTypeAtIndex(
|
||||
// alignment (field_type_info.second) from the AST context.
|
||||
CompilerType field_clang_type = GetType(field->getType());
|
||||
assert(field_idx < record_layout.getFieldCount());
|
||||
std::optional<uint64_t> size =
|
||||
field_clang_type.GetByteSize(get_exe_scope());
|
||||
if (!size)
|
||||
return llvm::createStringError("no size info for field");
|
||||
auto size_or_err = field_clang_type.GetByteSize(get_exe_scope());
|
||||
if (!size_or_err)
|
||||
return llvm::joinErrors(
|
||||
llvm::createStringError("no size info for field"),
|
||||
size_or_err.takeError());
|
||||
|
||||
child_byte_size = *size;
|
||||
child_byte_size = *size_or_err;
|
||||
const uint32_t child_bit_size = child_byte_size * 8;
|
||||
|
||||
// Figure out the field offset within the current struct/union/class
|
||||
@ -6509,12 +6517,12 @@ llvm::Expected<CompilerType> TypeSystemClang::GetChildCompilerTypeAtIndex(
|
||||
|
||||
// We have a pointer to an simple type
|
||||
if (idx == 0 && pointee_clang_type.GetCompleteType()) {
|
||||
if (std::optional<uint64_t> size =
|
||||
pointee_clang_type.GetByteSize(get_exe_scope())) {
|
||||
child_byte_size = *size;
|
||||
child_byte_offset = 0;
|
||||
return pointee_clang_type;
|
||||
}
|
||||
auto size_or_err = pointee_clang_type.GetByteSize(get_exe_scope());
|
||||
if (!size_or_err)
|
||||
return size_or_err.takeError();
|
||||
child_byte_size = *size_or_err;
|
||||
child_byte_offset = 0;
|
||||
return pointee_clang_type;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6532,12 +6540,12 @@ llvm::Expected<CompilerType> TypeSystemClang::GetChildCompilerTypeAtIndex(
|
||||
::snprintf(element_name, sizeof(element_name), "[%" PRIu64 "]",
|
||||
static_cast<uint64_t>(idx));
|
||||
child_name.assign(element_name);
|
||||
if (std::optional<uint64_t> size =
|
||||
element_type.GetByteSize(get_exe_scope())) {
|
||||
child_byte_size = *size;
|
||||
child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
|
||||
return element_type;
|
||||
}
|
||||
auto size_or_err = element_type.GetByteSize(get_exe_scope());
|
||||
if (!size_or_err)
|
||||
return size_or_err.takeError();
|
||||
child_byte_size = *size_or_err;
|
||||
child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
|
||||
return element_type;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6551,12 +6559,12 @@ llvm::Expected<CompilerType> TypeSystemClang::GetChildCompilerTypeAtIndex(
|
||||
CompilerType element_type = GetType(array->getElementType());
|
||||
if (element_type.GetCompleteType()) {
|
||||
child_name = std::string(llvm::formatv("[{0}]", idx));
|
||||
if (std::optional<uint64_t> size =
|
||||
element_type.GetByteSize(get_exe_scope())) {
|
||||
child_byte_size = *size;
|
||||
child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
|
||||
return element_type;
|
||||
}
|
||||
auto size_or_err = element_type.GetByteSize(get_exe_scope());
|
||||
if (!size_or_err)
|
||||
return size_or_err.takeError();
|
||||
child_byte_size = *size_or_err;
|
||||
child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
|
||||
return element_type;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6590,12 +6598,12 @@ llvm::Expected<CompilerType> TypeSystemClang::GetChildCompilerTypeAtIndex(
|
||||
|
||||
// We have a pointer to an simple type
|
||||
if (idx == 0) {
|
||||
if (std::optional<uint64_t> size =
|
||||
pointee_clang_type.GetByteSize(get_exe_scope())) {
|
||||
child_byte_size = *size;
|
||||
child_byte_offset = 0;
|
||||
return pointee_clang_type;
|
||||
}
|
||||
auto size_or_err = pointee_clang_type.GetByteSize(get_exe_scope());
|
||||
if (!size_or_err)
|
||||
return size_or_err.takeError();
|
||||
child_byte_size = *size_or_err;
|
||||
child_byte_offset = 0;
|
||||
return pointee_clang_type;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -6628,12 +6636,12 @@ llvm::Expected<CompilerType> TypeSystemClang::GetChildCompilerTypeAtIndex(
|
||||
|
||||
// We have a pointer to an simple type
|
||||
if (idx == 0) {
|
||||
if (std::optional<uint64_t> size =
|
||||
pointee_clang_type.GetByteSize(get_exe_scope())) {
|
||||
child_byte_size = *size;
|
||||
child_byte_offset = 0;
|
||||
return pointee_clang_type;
|
||||
}
|
||||
auto size_or_err = pointee_clang_type.GetByteSize(get_exe_scope());
|
||||
if (!size_or_err)
|
||||
return size_or_err.takeError();
|
||||
child_byte_size = *size_or_err;
|
||||
child_byte_offset = 0;
|
||||
return pointee_clang_type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -827,15 +827,17 @@ public:
|
||||
|
||||
const llvm::fltSemantics &GetFloatTypeSemantics(size_t byte_size) override;
|
||||
|
||||
std::optional<uint64_t> GetByteSize(lldb::opaque_compiler_type_t type,
|
||||
ExecutionContextScope *exe_scope) {
|
||||
if (std::optional<uint64_t> bit_size = GetBitSize(type, exe_scope))
|
||||
return (*bit_size + 7) / 8;
|
||||
return std::nullopt;
|
||||
llvm::Expected<uint64_t> GetByteSize(lldb::opaque_compiler_type_t type,
|
||||
ExecutionContextScope *exe_scope) {
|
||||
auto bit_size_or_err = GetBitSize(type, exe_scope);
|
||||
if (!bit_size_or_err)
|
||||
return bit_size_or_err.takeError();
|
||||
return (*bit_size_or_err + 7) / 8;
|
||||
}
|
||||
|
||||
std::optional<uint64_t> GetBitSize(lldb::opaque_compiler_type_t type,
|
||||
ExecutionContextScope *exe_scope) override;
|
||||
llvm::Expected<uint64_t>
|
||||
GetBitSize(lldb::opaque_compiler_type_t type,
|
||||
ExecutionContextScope *exe_scope) override;
|
||||
|
||||
lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type,
|
||||
uint64_t &count) override;
|
||||
@ -1185,8 +1187,8 @@ private:
|
||||
/// on creation of a new instance.
|
||||
void LogCreation() const;
|
||||
|
||||
std::optional<uint64_t> GetObjCBitSize(clang::QualType qual_type,
|
||||
ExecutionContextScope *exe_scope);
|
||||
llvm::Expected<uint64_t> GetObjCBitSize(clang::QualType qual_type,
|
||||
ExecutionContextScope *exe_scope);
|
||||
|
||||
// Classes that inherit from TypeSystemClang can see and modify these
|
||||
std::string m_target_triple;
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "lldb/Utility/ConstString.h"
|
||||
#include "lldb/Utility/DataBufferHeap.h"
|
||||
#include "lldb/Utility/DataExtractor.h"
|
||||
#include "lldb/Utility/LLDBLog.h"
|
||||
#include "lldb/Utility/Log.h"
|
||||
#include "lldb/Utility/Scalar.h"
|
||||
#include "lldb/Utility/Stream.h"
|
||||
#include "lldb/Utility/StreamString.h"
|
||||
@ -769,19 +771,20 @@ CompilerType::GetBasicTypeFromAST(lldb::BasicType basic_type) const {
|
||||
}
|
||||
// Exploring the type
|
||||
|
||||
std::optional<uint64_t>
|
||||
llvm::Expected<uint64_t>
|
||||
CompilerType::GetBitSize(ExecutionContextScope *exe_scope) const {
|
||||
if (IsValid())
|
||||
if (auto type_system_sp = GetTypeSystem())
|
||||
return type_system_sp->GetBitSize(m_type, exe_scope);
|
||||
return {};
|
||||
return llvm::createStringError("Invalid type: Cannot determine size");
|
||||
}
|
||||
|
||||
std::optional<uint64_t>
|
||||
llvm::Expected<uint64_t>
|
||||
CompilerType::GetByteSize(ExecutionContextScope *exe_scope) const {
|
||||
if (std::optional<uint64_t> bit_size = GetBitSize(exe_scope))
|
||||
return (*bit_size + 7) / 8;
|
||||
return {};
|
||||
auto bit_size_or_err = GetBitSize(exe_scope);
|
||||
if (!bit_size_or_err)
|
||||
return bit_size_or_err.takeError();
|
||||
return (*bit_size_or_err + 7) / 8;
|
||||
}
|
||||
|
||||
std::optional<size_t>
|
||||
@ -1104,10 +1107,18 @@ bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data,
|
||||
if (encoding == lldb::eEncodingInvalid || count != 1)
|
||||
return false;
|
||||
|
||||
std::optional<uint64_t> byte_size = GetByteSize(exe_scope);
|
||||
auto byte_size_or_err = GetByteSize(exe_scope);
|
||||
if (!byte_size_or_err) {
|
||||
LLDB_LOG_ERRORV(
|
||||
GetLog(LLDBLog::Types), byte_size_or_err.takeError(),
|
||||
"Cannot get value as scalar: Cannot determine type size: {0}");
|
||||
return false;
|
||||
}
|
||||
uint64_t byte_size = *byte_size_or_err;
|
||||
|
||||
// A bit or byte size of 0 is not a bug, but it doesn't make sense to read a
|
||||
// scalar of zero size.
|
||||
if (!byte_size || *byte_size == 0)
|
||||
if (byte_size == 0)
|
||||
return false;
|
||||
|
||||
lldb::offset_t offset = data_byte_offset;
|
||||
@ -1117,15 +1128,15 @@ bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data,
|
||||
case lldb::eEncodingVector:
|
||||
break;
|
||||
case lldb::eEncodingUint:
|
||||
if (*byte_size <= sizeof(unsigned long long)) {
|
||||
uint64_t uval64 = data.GetMaxU64(&offset, *byte_size);
|
||||
if (*byte_size <= sizeof(unsigned int)) {
|
||||
if (byte_size <= sizeof(unsigned long long)) {
|
||||
uint64_t uval64 = data.GetMaxU64(&offset, byte_size);
|
||||
if (byte_size <= sizeof(unsigned int)) {
|
||||
value = (unsigned int)uval64;
|
||||
return true;
|
||||
} else if (*byte_size <= sizeof(unsigned long)) {
|
||||
} else if (byte_size <= sizeof(unsigned long)) {
|
||||
value = (unsigned long)uval64;
|
||||
return true;
|
||||
} else if (*byte_size <= sizeof(unsigned long long)) {
|
||||
} else if (byte_size <= sizeof(unsigned long long)) {
|
||||
value = (unsigned long long)uval64;
|
||||
return true;
|
||||
} else
|
||||
@ -1134,15 +1145,15 @@ bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data,
|
||||
break;
|
||||
|
||||
case lldb::eEncodingSint:
|
||||
if (*byte_size <= sizeof(long long)) {
|
||||
int64_t sval64 = data.GetMaxS64(&offset, *byte_size);
|
||||
if (*byte_size <= sizeof(int)) {
|
||||
if (byte_size <= sizeof(long long)) {
|
||||
int64_t sval64 = data.GetMaxS64(&offset, byte_size);
|
||||
if (byte_size <= sizeof(int)) {
|
||||
value = (int)sval64;
|
||||
return true;
|
||||
} else if (*byte_size <= sizeof(long)) {
|
||||
} else if (byte_size <= sizeof(long)) {
|
||||
value = (long)sval64;
|
||||
return true;
|
||||
} else if (*byte_size <= sizeof(long long)) {
|
||||
} else if (byte_size <= sizeof(long long)) {
|
||||
value = (long long)sval64;
|
||||
return true;
|
||||
} else
|
||||
@ -1151,10 +1162,10 @@ bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data,
|
||||
break;
|
||||
|
||||
case lldb::eEncodingIEEE754:
|
||||
if (*byte_size <= sizeof(long double)) {
|
||||
if (byte_size <= sizeof(long double)) {
|
||||
uint32_t u32;
|
||||
uint64_t u64;
|
||||
if (*byte_size == sizeof(float)) {
|
||||
if (byte_size == sizeof(float)) {
|
||||
if (sizeof(float) == sizeof(uint32_t)) {
|
||||
u32 = data.GetU32(&offset);
|
||||
value = *((float *)&u32);
|
||||
@ -1164,7 +1175,7 @@ bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data,
|
||||
value = *((float *)&u64);
|
||||
return true;
|
||||
}
|
||||
} else if (*byte_size == sizeof(double)) {
|
||||
} else if (byte_size == sizeof(double)) {
|
||||
if (sizeof(double) == sizeof(uint32_t)) {
|
||||
u32 = data.GetU32(&offset);
|
||||
value = *((double *)&u32);
|
||||
@ -1174,7 +1185,7 @@ bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data,
|
||||
value = *((double *)&u64);
|
||||
return true;
|
||||
}
|
||||
} else if (*byte_size == sizeof(long double)) {
|
||||
} else if (byte_size == sizeof(long double)) {
|
||||
if (sizeof(long double) == sizeof(uint32_t)) {
|
||||
u32 = data.GetU32(&offset);
|
||||
value = *((long double *)&u32);
|
||||
|
@ -455,14 +455,18 @@ Type *Type::GetEncodingType() {
|
||||
return m_encoding_type;
|
||||
}
|
||||
|
||||
std::optional<uint64_t> Type::GetByteSize(ExecutionContextScope *exe_scope) {
|
||||
llvm::Expected<uint64_t> Type::GetByteSize(ExecutionContextScope *exe_scope) {
|
||||
if (m_byte_size_has_value)
|
||||
return static_cast<uint64_t>(m_byte_size);
|
||||
|
||||
switch (m_encoding_uid_type) {
|
||||
case eEncodingInvalid:
|
||||
return llvm::createStringError("could not get type size: invalid encoding");
|
||||
|
||||
case eEncodingIsSyntheticUID:
|
||||
break;
|
||||
return llvm::createStringError(
|
||||
"could not get type size: synthetic encoding");
|
||||
|
||||
case eEncodingIsUID:
|
||||
case eEncodingIsConstUID:
|
||||
case eEncodingIsRestrictUID:
|
||||
@ -472,18 +476,18 @@ std::optional<uint64_t> Type::GetByteSize(ExecutionContextScope *exe_scope) {
|
||||
Type *encoding_type = GetEncodingType();
|
||||
if (encoding_type)
|
||||
if (std::optional<uint64_t> size =
|
||||
encoding_type->GetByteSize(exe_scope)) {
|
||||
llvm::expectedToOptional(encoding_type->GetByteSize(exe_scope))) {
|
||||
m_byte_size = *size;
|
||||
m_byte_size_has_value = true;
|
||||
return static_cast<uint64_t>(m_byte_size);
|
||||
}
|
||||
|
||||
if (std::optional<uint64_t> size =
|
||||
GetLayoutCompilerType().GetByteSize(exe_scope)) {
|
||||
m_byte_size = *size;
|
||||
m_byte_size_has_value = true;
|
||||
return static_cast<uint64_t>(m_byte_size);
|
||||
}
|
||||
auto size_or_err = GetLayoutCompilerType().GetByteSize(exe_scope);
|
||||
if (!size_or_err)
|
||||
return size_or_err.takeError();
|
||||
m_byte_size = *size_or_err;
|
||||
m_byte_size_has_value = true;
|
||||
return static_cast<uint64_t>(m_byte_size);
|
||||
} break;
|
||||
|
||||
// If we are a pointer or reference, then this is just a pointer size;
|
||||
@ -498,7 +502,8 @@ std::optional<uint64_t> Type::GetByteSize(ExecutionContextScope *exe_scope) {
|
||||
}
|
||||
} break;
|
||||
}
|
||||
return {};
|
||||
return llvm::createStringError(
|
||||
"could not get type size: unexpected encoding");
|
||||
}
|
||||
|
||||
llvm::Expected<uint32_t> Type::GetNumChildren(bool omit_empty_base_classes) {
|
||||
@ -539,7 +544,9 @@ bool Type::ReadFromMemory(ExecutionContext *exe_ctx, lldb::addr_t addr,
|
||||
}
|
||||
|
||||
const uint64_t byte_size =
|
||||
GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr)
|
||||
llvm::expectedToOptional(
|
||||
GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope()
|
||||
: nullptr))
|
||||
.value_or(0);
|
||||
if (data.GetByteSize() < byte_size) {
|
||||
lldb::DataBufferSP data_sp(new DataBufferHeap(byte_size, '\0'));
|
||||
|
@ -1480,7 +1480,9 @@ lldb::ValueObjectSP StackFrame::GuessValueForAddress(lldb::addr_t addr) {
|
||||
namespace {
|
||||
ValueObjectSP GetValueForOffset(StackFrame &frame, ValueObjectSP &parent,
|
||||
int64_t offset) {
|
||||
if (offset < 0 || uint64_t(offset) >= parent->GetByteSize()) {
|
||||
if (offset < 0 ||
|
||||
uint64_t(offset) >=
|
||||
llvm::expectedToOptional(parent->GetByteSize()).value_or(0)) {
|
||||
return ValueObjectSP();
|
||||
}
|
||||
|
||||
@ -1497,7 +1499,8 @@ ValueObjectSP GetValueForOffset(StackFrame &frame, ValueObjectSP &parent,
|
||||
}
|
||||
|
||||
int64_t child_offset = child_sp->GetByteOffset();
|
||||
int64_t child_size = child_sp->GetByteSize().value_or(0);
|
||||
int64_t child_size =
|
||||
llvm::expectedToOptional(child_sp->GetByteSize()).value_or(0);
|
||||
|
||||
if (offset >= child_offset && offset < (child_offset + child_size)) {
|
||||
return GetValueForOffset(frame, child_sp, offset - child_offset);
|
||||
@ -1529,9 +1532,13 @@ ValueObjectSP GetValueForDereferincingOffset(StackFrame &frame,
|
||||
return ValueObjectSP();
|
||||
}
|
||||
|
||||
if (offset >= 0 && uint64_t(offset) >= pointee->GetByteSize()) {
|
||||
int64_t index = offset / pointee->GetByteSize().value_or(1);
|
||||
offset = offset % pointee->GetByteSize().value_or(1);
|
||||
if (offset >= 0 &&
|
||||
uint64_t(offset) >=
|
||||
llvm::expectedToOptional(pointee->GetByteSize()).value_or(0)) {
|
||||
uint64_t size =
|
||||
llvm::expectedToOptional(pointee->GetByteSize()).value_or(1);
|
||||
int64_t index = offset / size;
|
||||
offset = offset % size;
|
||||
const bool can_create = true;
|
||||
pointee = base->GetSyntheticArrayMember(index, can_create);
|
||||
}
|
||||
|
@ -2096,10 +2096,13 @@ lldb::ValueObjectSP Thread::GetSiginfoValue() {
|
||||
return ValueObjectConstResult::Create(
|
||||
&target, Status::FromErrorString("no siginfo_t for the platform"));
|
||||
|
||||
std::optional<uint64_t> type_size = type.GetByteSize(nullptr);
|
||||
assert(type_size);
|
||||
auto type_size_or_err = type.GetByteSize(nullptr);
|
||||
if (!type_size_or_err)
|
||||
return ValueObjectConstResult::Create(
|
||||
&target, Status::FromError(type_size_or_err.takeError()));
|
||||
|
||||
llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> data =
|
||||
GetSiginfo(*type_size);
|
||||
GetSiginfo(*type_size_or_err);
|
||||
if (!data)
|
||||
return ValueObjectConstResult::Create(&target,
|
||||
Status::FromError(data.takeError()));
|
||||
|
@ -677,8 +677,8 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx,
|
||||
ExecutionContext exe_ctx(GetExecutionContextRef());
|
||||
|
||||
std::optional<uint64_t> item_type_size =
|
||||
pointee_or_element_compiler_type.GetByteSize(
|
||||
exe_ctx.GetBestExecutionContextScope());
|
||||
llvm::expectedToOptional(pointee_or_element_compiler_type.GetByteSize(
|
||||
exe_ctx.GetBestExecutionContextScope()));
|
||||
if (!item_type_size)
|
||||
return 0;
|
||||
const uint64_t bytes = item_count * *item_type_size;
|
||||
@ -794,7 +794,7 @@ bool ValueObject::SetData(DataExtractor &data, Status &error) {
|
||||
uint64_t count = 0;
|
||||
const Encoding encoding = GetCompilerType().GetEncoding(count);
|
||||
|
||||
const size_t byte_size = GetByteSize().value_or(0);
|
||||
const size_t byte_size = llvm::expectedToOptional(GetByteSize()).value_or(0);
|
||||
|
||||
Value::ValueType value_type = m_value.GetValueType();
|
||||
|
||||
@ -1224,7 +1224,8 @@ void ValueObject::SetValueFromInteger(const llvm::APInt &value, Status &error) {
|
||||
// Verify the proposed new value is the right size.
|
||||
lldb::TargetSP target = GetTargetSP();
|
||||
uint64_t byte_size = 0;
|
||||
if (auto temp = GetCompilerType().GetByteSize(target.get()))
|
||||
if (auto temp =
|
||||
llvm::expectedToOptional(GetCompilerType().GetByteSize(target.get())))
|
||||
byte_size = temp.value();
|
||||
if (value.getBitWidth() != byte_size * CHAR_BIT) {
|
||||
error = Status::FromErrorString(
|
||||
@ -1287,7 +1288,8 @@ void ValueObject::SetValueFromInteger(lldb::ValueObjectSP new_val_sp,
|
||||
if (success) {
|
||||
lldb::TargetSP target = GetTargetSP();
|
||||
uint64_t num_bits = 0;
|
||||
if (auto temp = new_val_sp->GetCompilerType().GetBitSize(target.get()))
|
||||
if (auto temp = llvm::expectedToOptional(
|
||||
new_val_sp->GetCompilerType().GetBitSize(target.get())))
|
||||
num_bits = temp.value();
|
||||
SetValueFromInteger(llvm::APInt(num_bits, int_val), error);
|
||||
} else
|
||||
@ -1679,7 +1681,7 @@ bool ValueObject::SetValueFromCString(const char *value_str, Status &error) {
|
||||
uint64_t count = 0;
|
||||
const Encoding encoding = GetCompilerType().GetEncoding(count);
|
||||
|
||||
const size_t byte_size = GetByteSize().value_or(0);
|
||||
const size_t byte_size = llvm::expectedToOptional(GetByteSize()).value_or(0);
|
||||
|
||||
Value::ValueType value_type = m_value.GetValueType();
|
||||
|
||||
@ -1863,13 +1865,15 @@ ValueObjectSP ValueObject::GetSyntheticBitFieldChild(uint32_t from, uint32_t to,
|
||||
uint32_t bit_field_offset = from;
|
||||
if (GetDataExtractor().GetByteOrder() == eByteOrderBig)
|
||||
bit_field_offset =
|
||||
GetByteSize().value_or(0) * 8 - bit_field_size - bit_field_offset;
|
||||
llvm::expectedToOptional(GetByteSize()).value_or(0) * 8 -
|
||||
bit_field_size - bit_field_offset;
|
||||
// We haven't made a synthetic array member for INDEX yet, so lets make
|
||||
// one and cache it for any future reference.
|
||||
ValueObjectChild *synthetic_child = new ValueObjectChild(
|
||||
*this, GetCompilerType(), index_const_str, GetByteSize().value_or(0),
|
||||
0, bit_field_size, bit_field_offset, false, false,
|
||||
eAddressTypeInvalid, 0);
|
||||
*this, GetCompilerType(), index_const_str,
|
||||
llvm::expectedToOptional(GetByteSize()).value_or(0), 0,
|
||||
bit_field_size, bit_field_offset, false, false, eAddressTypeInvalid,
|
||||
0);
|
||||
|
||||
// Cache the value if we got one back...
|
||||
if (synthetic_child) {
|
||||
@ -1904,8 +1908,8 @@ ValueObjectSP ValueObject::GetSyntheticChildAtOffset(
|
||||
return {};
|
||||
|
||||
ExecutionContext exe_ctx(GetExecutionContextRef());
|
||||
std::optional<uint64_t> size =
|
||||
type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
|
||||
std::optional<uint64_t> size = llvm::expectedToOptional(
|
||||
type.GetByteSize(exe_ctx.GetBestExecutionContextScope()));
|
||||
if (!size)
|
||||
return {};
|
||||
ValueObjectChild *synthetic_child =
|
||||
@ -1946,8 +1950,8 @@ ValueObjectSP ValueObject::GetSyntheticBase(uint32_t offset,
|
||||
const bool is_base_class = true;
|
||||
|
||||
ExecutionContext exe_ctx(GetExecutionContextRef());
|
||||
std::optional<uint64_t> size =
|
||||
type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
|
||||
std::optional<uint64_t> size = llvm::expectedToOptional(
|
||||
type.GetByteSize(exe_ctx.GetBestExecutionContextScope()));
|
||||
if (!size)
|
||||
return {};
|
||||
ValueObjectChild *synthetic_child =
|
||||
@ -2999,8 +3003,10 @@ ValueObjectSP ValueObject::Cast(const CompilerType &compiler_type) {
|
||||
|
||||
ExecutionContextScope *exe_scope =
|
||||
ExecutionContext(GetExecutionContextRef()).GetBestExecutionContextScope();
|
||||
if (compiler_type.GetByteSize(exe_scope) <=
|
||||
GetCompilerType().GetByteSize(exe_scope) ||
|
||||
if (llvm::expectedToOptional(compiler_type.GetByteSize(exe_scope))
|
||||
.value_or(0) <=
|
||||
llvm::expectedToOptional(GetCompilerType().GetByteSize(exe_scope))
|
||||
.value_or(0) ||
|
||||
m_value.GetValueType() == Value::ValueType::LoadAddress)
|
||||
return DoCast(compiler_type);
|
||||
|
||||
@ -3225,9 +3231,10 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
|
||||
lldb::TargetSP target = GetTargetSP();
|
||||
uint64_t type_byte_size = 0;
|
||||
uint64_t val_byte_size = 0;
|
||||
if (auto temp = type.GetByteSize(target.get()))
|
||||
if (auto temp = llvm::expectedToOptional(type.GetByteSize(target.get())))
|
||||
type_byte_size = temp.value();
|
||||
if (auto temp = GetCompilerType().GetByteSize(target.get()))
|
||||
if (auto temp =
|
||||
llvm::expectedToOptional(GetCompilerType().GetByteSize(target.get())))
|
||||
val_byte_size = temp.value();
|
||||
|
||||
if (is_pointer) {
|
||||
@ -3377,7 +3384,7 @@ lldb::ValueObjectSP ValueObject::CastToEnumType(CompilerType type) {
|
||||
|
||||
lldb::TargetSP target = GetTargetSP();
|
||||
uint64_t byte_size = 0;
|
||||
if (auto temp = type.GetByteSize(target.get()))
|
||||
if (auto temp = llvm::expectedToOptional(type.GetByteSize(target.get())))
|
||||
byte_size = temp.value();
|
||||
|
||||
if (is_float) {
|
||||
@ -3653,7 +3660,7 @@ ValueObject::CreateValueObjectFromAPInt(lldb::TargetSP target,
|
||||
llvm::StringRef name) {
|
||||
ExecutionContext exe_ctx(target.get(), false);
|
||||
uint64_t byte_size = 0;
|
||||
if (auto temp = type.GetByteSize(target.get()))
|
||||
if (auto temp = llvm::expectedToOptional(type.GetByteSize(target.get())))
|
||||
byte_size = temp.value();
|
||||
lldb::DataExtractorSP data_sp = std::make_shared<DataExtractor>(
|
||||
reinterpret_cast<const void *>(v.getRawData()), byte_size,
|
||||
@ -3681,7 +3688,8 @@ ValueObject::CreateValueObjectFromBool(lldb::TargetSP target, bool value,
|
||||
}
|
||||
ExecutionContext exe_ctx(target.get(), false);
|
||||
uint64_t byte_size = 0;
|
||||
if (auto temp = target_type.GetByteSize(target.get()))
|
||||
if (auto temp =
|
||||
llvm::expectedToOptional(target_type.GetByteSize(target.get())))
|
||||
byte_size = temp.value();
|
||||
lldb::DataExtractorSP data_sp = std::make_shared<DataExtractor>(
|
||||
reinterpret_cast<const void *>(&value), byte_size, exe_ctx.GetByteOrder(),
|
||||
@ -3699,7 +3707,7 @@ lldb::ValueObjectSP ValueObject::CreateValueObjectFromNullptr(
|
||||
uintptr_t zero = 0;
|
||||
ExecutionContext exe_ctx(target.get(), false);
|
||||
uint64_t byte_size = 0;
|
||||
if (auto temp = type.GetByteSize(target.get()))
|
||||
if (auto temp = llvm::expectedToOptional(type.GetByteSize(target.get())))
|
||||
byte_size = temp.value();
|
||||
lldb::DataExtractorSP data_sp = std::make_shared<DataExtractor>(
|
||||
reinterpret_cast<const void *>(zero), byte_size, exe_ctx.GetByteOrder(),
|
||||
|
@ -49,7 +49,7 @@ llvm::Expected<uint32_t> ValueObjectCast::CalculateNumChildren(uint32_t max) {
|
||||
return *children_count <= max ? *children_count : max;
|
||||
}
|
||||
|
||||
std::optional<uint64_t> ValueObjectCast::GetByteSize() {
|
||||
llvm::Expected<uint64_t> ValueObjectCast::GetByteSize() {
|
||||
ExecutionContext exe_ctx(GetExecutionContextRef());
|
||||
return m_value.GetValueByteSize(nullptr, &exe_ctx);
|
||||
}
|
||||
|
@ -203,14 +203,18 @@ lldb::ValueType ValueObjectConstResult::GetValueType() const {
|
||||
return eValueTypeConstResult;
|
||||
}
|
||||
|
||||
std::optional<uint64_t> ValueObjectConstResult::GetByteSize() {
|
||||
llvm::Expected<uint64_t> ValueObjectConstResult::GetByteSize() {
|
||||
ExecutionContext exe_ctx(GetExecutionContextRef());
|
||||
if (!m_byte_size) {
|
||||
if (auto size = GetCompilerType().GetByteSize(
|
||||
exe_ctx.GetBestExecutionContextScope()))
|
||||
SetByteSize(*size);
|
||||
auto size_or_err =
|
||||
GetCompilerType().GetByteSize(exe_ctx.GetBestExecutionContextScope());
|
||||
if (!size_or_err)
|
||||
return size_or_err;
|
||||
SetByteSize(*size_or_err);
|
||||
}
|
||||
return m_byte_size;
|
||||
if (m_byte_size)
|
||||
return *m_byte_size;
|
||||
return llvm::createStringError("unknown size of const result");
|
||||
}
|
||||
|
||||
void ValueObjectConstResult::SetByteSize(size_t size) { m_byte_size = size; }
|
||||
|
@ -98,7 +98,7 @@ ValueObjectDynamicValue::CalculateNumChildren(uint32_t max) {
|
||||
return m_parent->GetNumChildren(max);
|
||||
}
|
||||
|
||||
std::optional<uint64_t> ValueObjectDynamicValue::GetByteSize() {
|
||||
llvm::Expected<uint64_t> ValueObjectDynamicValue::GetByteSize() {
|
||||
const bool success = UpdateValueIfNeeded(false);
|
||||
if (success && m_dynamic_type_info.HasType()) {
|
||||
ExecutionContext exe_ctx(GetExecutionContextRef());
|
||||
@ -248,7 +248,8 @@ bool ValueObjectDynamicValue::UpdateValue() {
|
||||
// If we found a host address but it doesn't fit in the buffer, there's
|
||||
// nothing we can do.
|
||||
if (local_buffer.size() <
|
||||
m_dynamic_type_info.GetCompilerType().GetByteSize(exe_scope)) {
|
||||
llvm::expectedToOptional(
|
||||
m_dynamic_type_info.GetCompilerType().GetByteSize(exe_scope))) {
|
||||
SetValueIsValid(false);
|
||||
return false;
|
||||
}
|
||||
|
@ -143,10 +143,14 @@ llvm::Expected<uint32_t> ValueObjectMemory::CalculateNumChildren(uint32_t max) {
|
||||
return *child_count <= max ? *child_count : max;
|
||||
}
|
||||
|
||||
std::optional<uint64_t> ValueObjectMemory::GetByteSize() {
|
||||
llvm::Expected<uint64_t> ValueObjectMemory::GetByteSize() {
|
||||
ExecutionContext exe_ctx(GetExecutionContextRef());
|
||||
if (m_type_sp)
|
||||
return m_type_sp->GetByteSize(exe_ctx.GetBestExecutionContextScope());
|
||||
if (m_type_sp) {
|
||||
if (auto size =
|
||||
m_type_sp->GetByteSize(exe_ctx.GetBestExecutionContextScope()))
|
||||
return *size;
|
||||
return llvm::createStringError("could not get byte size of memory object");
|
||||
}
|
||||
return m_compiler_type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ ValueObjectRegisterSet::CalculateNumChildren(uint32_t max) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::optional<uint64_t> ValueObjectRegisterSet::GetByteSize() { return 0; }
|
||||
llvm::Expected<uint64_t> ValueObjectRegisterSet::GetByteSize() { return 0; }
|
||||
|
||||
bool ValueObjectRegisterSet::UpdateValue() {
|
||||
m_error.Clear();
|
||||
@ -226,7 +226,7 @@ ValueObjectRegister::CalculateNumChildren(uint32_t max) {
|
||||
return *children_count <= max ? *children_count : max;
|
||||
}
|
||||
|
||||
std::optional<uint64_t> ValueObjectRegister::GetByteSize() {
|
||||
llvm::Expected<uint64_t> ValueObjectRegister::GetByteSize() {
|
||||
return m_reg_info.byte_size;
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ bool ValueObjectSynthetic::MightHaveChildren() {
|
||||
return (m_might_have_children != eLazyBoolNo);
|
||||
}
|
||||
|
||||
std::optional<uint64_t> ValueObjectSynthetic::GetByteSize() {
|
||||
llvm::Expected<uint64_t> ValueObjectSynthetic::GetByteSize() {
|
||||
return m_parent->GetByteSize();
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
|
||||
~ValueObjectVTableChild() override = default;
|
||||
|
||||
std::optional<uint64_t> GetByteSize() override { return m_addr_size; };
|
||||
llvm::Expected<uint64_t> GetByteSize() override { return m_addr_size; };
|
||||
|
||||
llvm::Expected<uint32_t> CalculateNumChildren(uint32_t max) override {
|
||||
return 0;
|
||||
@ -154,10 +154,10 @@ ValueObjectVTable::ValueObjectVTable(ValueObject &parent)
|
||||
SetFormat(eFormatPointer);
|
||||
}
|
||||
|
||||
std::optional<uint64_t> ValueObjectVTable::GetByteSize() {
|
||||
llvm::Expected<uint64_t> ValueObjectVTable::GetByteSize() {
|
||||
if (m_vtable_symbol)
|
||||
return m_vtable_symbol->GetByteSize();
|
||||
return std::nullopt;
|
||||
return llvm::createStringError("no symbol for vtable");
|
||||
}
|
||||
|
||||
llvm::Expected<uint32_t> ValueObjectVTable::CalculateNumChildren(uint32_t max) {
|
||||
|
@ -110,14 +110,10 @@ ValueObjectVariable::CalculateNumChildren(uint32_t max) {
|
||||
return *child_count <= max ? *child_count : max;
|
||||
}
|
||||
|
||||
std::optional<uint64_t> ValueObjectVariable::GetByteSize() {
|
||||
llvm::Expected<uint64_t> ValueObjectVariable::GetByteSize() {
|
||||
ExecutionContext exe_ctx(GetExecutionContextRef());
|
||||
|
||||
CompilerType type(GetCompilerType());
|
||||
|
||||
if (!type.IsValid())
|
||||
return {};
|
||||
|
||||
return type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
# RUN: llvm-mc --triple x86_64-pc-linux %s --filetype=obj -o %t
|
||||
# RUN: %lldb %t -o "target variable x" -o exit 2>&1 | FileCheck %s
|
||||
|
||||
# CHECK: Unable to determine byte size.
|
||||
# CHECK: Invalid type: Cannot determine size
|
||||
|
||||
# This tests a fix for a crash. If things are working we don't get a segfault.
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
# RUN: ld.lld %t.o -o %t
|
||||
# RUN: %lldb %t -o "target variable e" -b | FileCheck %s
|
||||
|
||||
# CHECK: error: Unable to determine byte size.
|
||||
# CHECK: error: Invalid type: Cannot determine size
|
||||
|
||||
.type e,@object # @e
|
||||
.section .rodata,"a",@progbits
|
||||
|
@ -68,7 +68,8 @@ public:
|
||||
}
|
||||
|
||||
EXPECT_EQ(total_offset, offset * 8);
|
||||
EXPECT_EQ(field_type.GetByteSize(nullptr), std::optional<uint64_t>(size));
|
||||
EXPECT_EQ(llvm::expectedToOptional(field_type.GetByteSize(nullptr)),
|
||||
std::optional<uint64_t>(size));
|
||||
}
|
||||
|
||||
void ExpectFields(const CompilerType &container,
|
||||
|
Loading…
x
Reference in New Issue
Block a user