https://github.com/labath created https://github.com/llvm/llvm-project/pull/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). >From b67f966fb8ccac4bed71701136b95f73ff0d6394 Mon Sep 17 00:00:00 2001 From: Pavel Labath <pa...@labath.sk> Date: Wed, 29 Jan 2025 16:53:04 +0100 Subject: [PATCH] [lldb] Use Function::GetAddress in Module::FindFunctions 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). --- lldb/source/Core/Module.cpp | 5 ++--- .../DWARF/x86/discontinuous-function.s | 20 +++++++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 9601c834d9b8fec..33668c5d20dde41 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 93ea9f33e762df7..197ab9aa14910e7 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: _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits