Skip to content

Commit 6833b6c

Browse files
committed
[lldb] Pass execution context to CompilerType::GetByteSize - in CommandObjectMemoryRead (NFC)
Some type systems require an execution context be available when working with types (ex: Swift). This fixes `memory read --type` to support such type systems, by passing in an execution context to `GetByteSize()`, instead of passing null. rdar://158968545 (cherry picked from commit b574e63)
1 parent ab98fa0 commit 6833b6c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lldb/source/Commands/CommandObjectMemory.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ class CommandObjectMemoryRead : public CommandObjectParsed {
364364
return;
365365
}
366366

367+
ExecutionContextScope *exe_scope = m_exe_ctx.GetBestExecutionContextScope();
368+
367369
CompilerType compiler_type;
368370
Status error;
369371

@@ -519,7 +521,7 @@ class CommandObjectMemoryRead : public CommandObjectParsed {
519521
--pointer_count;
520522
}
521523

522-
auto size_or_err = compiler_type.GetByteSize(nullptr);
524+
auto size_or_err = compiler_type.GetByteSize(exe_scope);
523525
if (!size_or_err) {
524526
result.AppendErrorWithFormat(
525527
"unable to get the byte size of the type '%s'\n%s",
@@ -639,7 +641,7 @@ class CommandObjectMemoryRead : public CommandObjectParsed {
639641
if (!m_format_options.GetFormatValue().OptionWasSet())
640642
m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault);
641643

642-
auto size_or_err = compiler_type.GetByteSize(nullptr);
644+
auto size_or_err = compiler_type.GetByteSize(exe_scope);
643645
if (!size_or_err) {
644646
result.AppendError(llvm::toString(size_or_err.takeError()));
645647
return;
@@ -799,7 +801,6 @@ class CommandObjectMemoryRead : public CommandObjectParsed {
799801
output_stream_p = &result.GetOutputStream();
800802
}
801803

802-
ExecutionContextScope *exe_scope = m_exe_ctx.GetBestExecutionContextScope();
803804
if (compiler_type.GetOpaqueQualType()) {
804805
for (uint32_t i = 0; i < item_count; ++i) {
805806
addr_t item_addr = addr + (i * item_byte_size);

0 commit comments

Comments
 (0)