Skip to content

Commit b574e63

Browse files
authored
[lldb] Pass execution context to CompilerType::GetByteSize - in CommandObjectMemoryRead (NFC) (#157750)
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
1 parent 7c66302 commit b574e63

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
@@ -365,6 +365,8 @@ class CommandObjectMemoryRead : public CommandObjectParsed {
365365
return;
366366
}
367367

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

@@ -520,7 +522,7 @@ class CommandObjectMemoryRead : public CommandObjectParsed {
520522
--pointer_count;
521523
}
522524

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

643-
auto size_or_err = compiler_type.GetByteSize(nullptr);
645+
auto size_or_err = compiler_type.GetByteSize(exe_scope);
644646
if (!size_or_err) {
645647
result.AppendError(llvm::toString(size_or_err.takeError()));
646648
return;
@@ -800,7 +802,6 @@ class CommandObjectMemoryRead : public CommandObjectParsed {
800802
output_stream_p = &result.GetOutputStream();
801803
}
802804

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

0 commit comments

Comments
 (0)