[Lldb-commits] [lldb] 3736de2 - [lldb] Use Function::GetAddress in Module::FindFunctions (#124938)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Jan 31 00:13:01 PST 2025
Author: Pavel Labath
Date: 2025-01-31T09:12:56+01:00
New Revision: 3736de2e3c20b4ed496a6590bc758ac0e033bd4c
URL: https://github.com/llvm/llvm-project/commit/3736de2e3c20b4ed496a6590bc758ac0e033bd4c
DIFF: https://github.com/llvm/llvm-project/commit/3736de2e3c20b4ed496a6590bc758ac0e033bd4c.diff
LOG: [lldb] Use Function::GetAddress in Module::FindFunctions (#124938)
The original code resulted in a misfire in the symtab vs. debug info
deduplication code, which caused us to return the same function twice
when searching via a regex (for functions whose entry point is also not
the lowest address).
Added:
Modified:
lldb/source/Core/Module.cpp
lldb/test/Shell/SymbolFile/DWARF/x86/discontinuous-function.s
Removed:
################################################################################
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 9601c834d9b8fe..33668c5d20dde4 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -919,9 +919,8 @@ void Module::FindFunctions(const RegularExpression ®ex,
const SymbolContext &sc = sc_list[i];
if (sc.block)
continue;
- file_addr_to_index[sc.function->GetAddressRange()
- .GetBaseAddress()
- .GetFileAddress()] = i;
+ file_addr_to_index[sc.function->GetAddress().GetFileAddress()] =
+ i;
}
FileAddrToIndexMap::const_iterator end = file_addr_to_index.end();
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/discontinuous-function.s b/lldb/test/Shell/SymbolFile/DWARF/x86/discontinuous-function.s
index 93ea9f33e762df..197ab9aa14910e 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/discontinuous-function.s
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/discontinuous-function.s
@@ -6,17 +6,29 @@
# The function bar has been placed "in the middle" of foo, and the function
# entry point is deliberately not its lowest address.
-# RUN: llvm-mc -triple x86_64-pc-linux -filetype=obj %s -o %t
-# RUN: %lldb %t -o "image lookup -v -n foo" -o "expr -- &foo" -o exit | FileCheck %s
+# RUN: split-file %s %t
+# RUN: llvm-mc -triple x86_64-pc-linux -filetype=obj %t/input.s -o %t/input.o
+# RUN: %lldb %t/input.o -s %t/commands -o exit | FileCheck %s
-# CHECK-LABEL: image lookup
+#--- commands
+
+image lookup -v -n foo
+# CHECK-LABEL: image lookup -v -n foo
+# CHECK: 1 match found in {{.*}}
+# CHECK: Summary: input.o`foo
+# CHECK: Function: id = {{.*}}, name = "foo", ranges = [0x0000000000000000-0x000000000000000e)[0x0000000000000014-0x000000000000001c)
+
+image lookup -v --regex -n '^foo$'
+# CHECK-LABEL: image lookup -v --regex -n '^foo$'
# CHECK: 1 match found in {{.*}}
-# CHECK: Summary: {{.*}}`foo
+# CHECK: Summary: input.o`foo
# CHECK: Function: id = {{.*}}, name = "foo", ranges = [0x0000000000000000-0x000000000000000e)[0x0000000000000014-0x000000000000001c)
+expr -- &foo
# CHECK-LABEL: expr -- &foo
# CHECK: (void (*)()) $0 = 0x0000000000000007
+#--- input.s
.text
foo.__part.1:
More information about the lldb-commits
mailing list