Skip to content

[🍒 swift/release/6.1] [lldb] Fix incorrect nullptr check in DumpAddressAndContent (#117219) #9660

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.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
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
38 changes: 19 additions & 19 deletions lldb/source/Core/FormatEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,31 +410,31 @@ static bool DumpAddressAndContent(Stream &s, const SymbolContext *sc,
const Address &addr,
bool print_file_addr_or_load_addr) {
Target *target = Target::GetTargetFromContexts(exe_ctx, sc);

addr_t vaddr = LLDB_INVALID_ADDRESS;
if (exe_ctx && !target->GetSectionLoadList().IsEmpty())
if (target && !target->GetSectionLoadList().IsEmpty())
vaddr = addr.GetLoadAddress(target);
if (vaddr == LLDB_INVALID_ADDRESS)
vaddr = addr.GetFileAddress();
if (vaddr == LLDB_INVALID_ADDRESS)
return false;

if (vaddr != LLDB_INVALID_ADDRESS) {
int addr_width = 0;
if (exe_ctx && target) {
addr_width = target->GetArchitecture().GetAddressByteSize() * 2;
}
if (addr_width == 0)
addr_width = 16;
if (print_file_addr_or_load_addr) {
ExecutionContextScope *exe_scope = nullptr;
if (exe_ctx)
exe_scope = exe_ctx->GetBestExecutionContextScope();
addr.Dump(&s, exe_scope, Address::DumpStyleLoadAddress,
Address::DumpStyleModuleWithFileAddress, 0);
} else {
s.Printf("0x%*.*" PRIx64, addr_width, addr_width, vaddr);
}
return true;
int addr_width = 0;
if (target)
addr_width = target->GetArchitecture().GetAddressByteSize() * 2;
if (addr_width == 0)
addr_width = 16;

if (print_file_addr_or_load_addr) {
ExecutionContextScope *exe_scope =
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr;
addr.Dump(&s, exe_scope, Address::DumpStyleLoadAddress,
Address::DumpStyleModuleWithFileAddress, 0);
} else {
s.Printf("0x%*.*" PRIx64, addr_width, addr_width, vaddr);
}
return false;

return true;
}

static bool DumpAddressOffsetFromFunction(Stream &s, const SymbolContext *sc,
Expand Down