Skip to content

[lldb] s/GetAddressRange().GetBaseAddress()/GetAddress() #125847

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 1 commit into from
Feb 6, 2025

Conversation

labath
Copy link
Collaborator

@labath labath commented Feb 5, 2025

Three more cases where it's obvious that the code is looking for the address of the function entry point.

Three more cases where it's obvious that the code is looking for the
address of the function entry point.
@labath labath requested a review from jasonmolenda February 5, 2025 12:35
@labath labath requested a review from JDevlieghere as a code owner February 5, 2025 12:35
@llvmbot llvmbot added the lldb label Feb 5, 2025
@@ -468,7 +468,7 @@ static bool DumpAddressOffsetFromFunction(Stream &s, const SymbolContext *sc,
if (func_addr.IsValid()) {
const char *addr_offset_padding = no_padding ? "" : " ";

if (func_addr.GetSection() == format_addr.GetSection()) {
if (func_addr.GetModule() == format_addr.GetModule()) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.. because two parts of the function can be in different sections.

@llvmbot
Copy link
Member

llvmbot commented Feb 5, 2025

@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)

Changes

Three more cases where it's obvious that the code is looking for the address of the function entry point.


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

3 Files Affected:

  • (modified) lldb/source/API/SBFunction.cpp (+1-1)
  • (modified) lldb/source/Core/FormatEntity.cpp (+2-2)
  • (modified) lldb/source/Core/SourceManager.cpp (+2-3)
diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp
index d07594c2e8c010..19861f6af3645e 100644
--- a/lldb/source/API/SBFunction.cpp
+++ b/lldb/source/API/SBFunction.cpp
@@ -144,7 +144,7 @@ SBAddress SBFunction::GetStartAddress() {
 
   SBAddress addr;
   if (m_opaque_ptr)
-    addr.SetAddress(m_opaque_ptr->GetAddressRange().GetBaseAddress());
+    addr.SetAddress(m_opaque_ptr->GetAddress());
   return addr;
 }
 
diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp
index fb7043ac74b8dd..7fe22994d7f7ee 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -450,7 +450,7 @@ static bool DumpAddressOffsetFromFunction(Stream &s, const SymbolContext *sc,
 
     if (sc) {
       if (sc->function) {
-        func_addr = sc->function->GetAddressRange().GetBaseAddress();
+        func_addr = sc->function->GetAddress();
         if (sc->block && !concrete_only) {
           // Check to make sure we aren't in an inline function. If we are, use
           // the inline block range that contains "format_addr" since blocks
@@ -468,7 +468,7 @@ static bool DumpAddressOffsetFromFunction(Stream &s, const SymbolContext *sc,
     if (func_addr.IsValid()) {
       const char *addr_offset_padding = no_padding ? "" : " ";
 
-      if (func_addr.GetSection() == format_addr.GetSection()) {
+      if (func_addr.GetModule() == format_addr.GetModule()) {
         addr_t func_file_addr = func_addr.GetFileAddress();
         addr_t addr_file_addr = format_addr.GetFileAddress();
         if (addr_file_addr > func_file_addr ||
diff --git a/lldb/source/Core/SourceManager.cpp b/lldb/source/Core/SourceManager.cpp
index 27a9edeef4249e..d63d42de14e801 100644
--- a/lldb/source/Core/SourceManager.cpp
+++ b/lldb/source/Core/SourceManager.cpp
@@ -435,9 +435,8 @@ SourceManager::GetDefaultFileAndLine() {
         for (const SymbolContext &sc : sc_list) {
           if (sc.function) {
             lldb_private::LineEntry line_entry;
-            if (sc.function->GetAddressRange()
-                    .GetBaseAddress()
-                    .CalculateSymbolContextLineEntry(line_entry)) {
+            if (sc.function->GetAddress().CalculateSymbolContextLineEntry(
+                    line_entry)) {
               SetDefaultFileAndLine(line_entry.file_sp, line_entry.line);
               return SupportFileAndLine(line_entry.file_sp, m_last_line);
             }

Copy link
Collaborator

@jasonmolenda jasonmolenda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@labath labath merged commit 0cfb98f into llvm:main Feb 6, 2025
9 checks passed
@labath labath deleted the address_range branch February 6, 2025 08:17
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
Three more cases where it's obvious that the code is looking for the
address of the function entry point.
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.

3 participants