Skip to content

Commit 3736de2

Browse files
authored
[lldb] Use Function::GetAddress in Module::FindFunctions (llvm#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).
1 parent 13d0318 commit 3736de2

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

lldb/source/Core/Module.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -919,9 +919,8 @@ void Module::FindFunctions(const RegularExpression &regex,
919919
const SymbolContext &sc = sc_list[i];
920920
if (sc.block)
921921
continue;
922-
file_addr_to_index[sc.function->GetAddressRange()
923-
.GetBaseAddress()
924-
.GetFileAddress()] = i;
922+
file_addr_to_index[sc.function->GetAddress().GetFileAddress()] =
923+
i;
925924
}
926925

927926
FileAddrToIndexMap::const_iterator end = file_addr_to_index.end();

lldb/test/Shell/SymbolFile/DWARF/x86/discontinuous-function.s

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,29 @@
66
# The function bar has been placed "in the middle" of foo, and the function
77
# entry point is deliberately not its lowest address.
88

9-
# RUN: llvm-mc -triple x86_64-pc-linux -filetype=obj %s -o %t
10-
# RUN: %lldb %t -o "image lookup -v -n foo" -o "expr -- &foo" -o exit | FileCheck %s
9+
# RUN: split-file %s %t
10+
# RUN: llvm-mc -triple x86_64-pc-linux -filetype=obj %t/input.s -o %t/input.o
11+
# RUN: %lldb %t/input.o -s %t/commands -o exit | FileCheck %s
1112

12-
# CHECK-LABEL: image lookup
13+
#--- commands
14+
15+
image lookup -v -n foo
16+
# CHECK-LABEL: image lookup -v -n foo
17+
# CHECK: 1 match found in {{.*}}
18+
# CHECK: Summary: input.o`foo
19+
# CHECK: Function: id = {{.*}}, name = "foo", ranges = [0x0000000000000000-0x000000000000000e)[0x0000000000000014-0x000000000000001c)
20+
21+
image lookup -v --regex -n '^foo$'
22+
# CHECK-LABEL: image lookup -v --regex -n '^foo$'
1323
# CHECK: 1 match found in {{.*}}
14-
# CHECK: Summary: {{.*}}`foo
24+
# CHECK: Summary: input.o`foo
1525
# CHECK: Function: id = {{.*}}, name = "foo", ranges = [0x0000000000000000-0x000000000000000e)[0x0000000000000014-0x000000000000001c)
1626

27+
expr -- &foo
1728
# CHECK-LABEL: expr -- &foo
1829
# CHECK: (void (*)()) $0 = 0x0000000000000007
1930

31+
#--- input.s
2032
.text
2133

2234
foo.__part.1:

0 commit comments

Comments
 (0)