8000 [rust-lldb] Adapt to changes in LLDB APIs by cuviper · Pull Request #4 · rust-lang/llvm-project · GitHub
[go: up one dir, main page]

Skip to content

[rust-lldb] Adapt to changes in LLDB APIs #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Alre 8000 ady on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[rust-lldb] CompilerType::GetByteSize() now returns an optional
  • Loading branch information
cuviper committed Jan 24, 2019
commit 9e6819d920756e287b6f060c81d9235d54524302
2 changes: 1 addition & 1 deletion lldb/source/Plugins/ExpressionParser/Rust/RustParse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ CreateValueInMemory(ExecutionContext &exe_ctx, CompilerType type, Status &error)
}

Process *proc = exe_ctx.GetProcessPtr();
uint64_t size = type.GetByteSize(proc);
uint64_t size = type.GetByteSize(proc).getValueOr(0);
addr_t addr = proc->AllocateMemory(size,
lldb::ePermissionsWritable | lldb::ePermissionsReadable,
error);
Expand Down
30 changes: 21 additions & 9 deletions lldb/source/Symbol/RustASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class RustCLikeEnum : public RustType {
}

uint64_t ByteSize() const override {
return m_underlying_type.GetByteSize(nullptr);
return m_underlying_type.GetByteSize(nullptr).getValueOr(0);
}

bool IsSigned() const {
Expand Down Expand Up @@ -337,7 +337,7 @@ class RustArray : public RustType {
}

uint64_t ByteSize() const override {
return m_elem.GetByteSize(nullptr) * m_length;
return m_elem.GetByteSize(nullptr).getValueOr(0) * m_length;
}

std::string GetCABITypeDeclaration(RustASTContext::TypeNameMap *name_map,
Expand Down Expand Up @@ -804,7 +804,7 @@ class RustTypedef : public RustType {
}

uint64_t ByteSize() const override {
return m_type.GetByteSize(nullptr);
return m_type.GetByteSize(nullptr).getValueOr(0);
}

std::string GetCABITypeDeclaration(RustASTContext::TypeNameMap *name_map,
Expand Down Expand Up @@ -1266,7 +1266,7 @@ RustASTContext::GetArrayElementType(lldb::opaque_compiler_type_t type,
RustArray *array = static_cast<RustType *>(type)->AsArray();
if (array) {
if (stride) {
*stride = array->ElementType().GetByteSize(nullptr);
*stride = array->ElementType().GetByteSize(nullptr).getValueOr(0);
}
return array->ElementType();
}
Expand Down Expand Up @@ -1499,8 +1499,11 @@ CompilerType RustASTContext::GetChildCompilerTypeAtIndex(
uint64_t bit_offset;
CompilerType ret =
GetFieldAtIndex(type, idx, child_name, &bit_offset, nullptr, nullptr);
child_byte_size = ret.GetByteSize(
llvm::Optional<uint64_t> size = ret.GetByteSize(
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr);
if (!size)
return {};
child_byte_size = *size;
child_byte_offset = bit_offset / 8;
return ret;
} else if (RustPointer *ptr = t->AsPointer()) {
Expand All @@ -1525,8 +1528,11 @@ CompilerType RustASTContext::GetChildCompilerTypeAtIndex(

// We have a pointer to an simple type
if (idx == 0 && pointee.GetCompleteType()) {
child_byte_size = pointee.GetByteSize(
llvm::Optional<uint64_t> size = pointee.GetByteSize(
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
if (!size)
return {};
child_byte_size = *size;
child_byte_offset = 0;
return pointee;
}
Expand All @@ -1538,8 +1544,11 @@ CompilerType RustASTContext::GetChildCompilerTypeAtIndex(
char element_name[64];
::snprintf(element_name, sizeof(element_name), "[%zu]", idx);
child_name.assign(element_name);
child_byte_size = element_type.GetByteSize(
llvm::Optional<uint64_t> size = element_type.GetByteSize(
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
if (!size)
return {};
child_byte_size = *size;
child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
return element_type;
}
Expand Down Expand Up @@ -1634,14 +1643,17 @@ bool RustASTContext::DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s,
CompilerType typedef_compiler_type = typ->UnderlyingType();
if (format == eFormatDefault)
format = typedef_compiler_type.GetFormat();
uint64_t typedef_byte_size = typedef_compiler_type.GetByteSize(exe_scope);
llvm::Optional<uint64_t> typedef_byte_size =
typedef_compiler_type.GetByteSize(exe_scope);
if (!typedef_byte_size)
return false;

return typedef_compiler_type.DumpTypeValue(
s,
format, // The format with which to display the element
data, // Data buffer containing all bytes for this type
byte_offset, // Offset into "data" where to grab value from
typedef_byte_size, // Size of this type in bytes
*typedef_byte_size,// Size of this type in bytes
bitfield_bit_size, // Size in bits of a bitfield value, if zero don't
// treat as a bitfield
bitfield_bit_offset, // Offset in bits of a bitfield value if
Expand Down
0