Skip to content

[lldb] Eliminate check for HasLoadedSections (NFC) #145366

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

JDevlieghere
Copy link
Member

We can omit the call to Target::HasLoadedSections as Address::HasLoadedSections already "does the right thing" and returns LLDB_INVALID_ADDRESS if no sections are loaded.

We can omit the call to Target::HasLoadedSections as
Address::HasLoadedSections already "does the right thing" and returns
LLDB_INVALID_ADDRESS if no sections are loaded.
@JDevlieghere JDevlieghere requested a review from jimingham June 23, 2025 17:18
@llvmbot llvmbot added the lldb label Jun 23, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 23, 2025

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

Changes

We can omit the call to Target::HasLoadedSections as Address::HasLoadedSections already "does the right thing" and returns LLDB_INVALID_ADDRESS if no sections are loaded.


Full diff: https://github.com/llvm/llvm-project/pull/145366.diff

1 Files Affected:

  • (modified) lldb/source/Core/FormatEntity.cpp (+1-3)
diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp
index 8e3c3c18863fa..ca389bc88cf79 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -470,9 +470,7 @@ static bool DumpAddressAndContent(Stream &s, const SymbolContext *sc,
                                   bool print_file_addr_or_load_addr) {
   Target *target = Target::GetTargetFromContexts(exe_ctx, sc);
 
-  addr_t vaddr = LLDB_INVALID_ADDRESS;
-  if (target && target->HasLoadedSections())
-    vaddr = addr.GetLoadAddress(target);
+  addr_t vaddr = addr.GetLoadAddress(target);
   if (vaddr == LLDB_INVALID_ADDRESS)
     vaddr = addr.GetFileAddress();
   if (vaddr == LLDB_INVALID_ADDRESS)

@JDevlieghere
Copy link
Member Author

CI checks failed due to #143739

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants