Skip to content

Commit 9a4c5a5

Browse files
committed
Revert "Re-apply [lldb] Do not use LC_FUNCTION_STARTS data to determine symbol size as symbols are created (llvm#117079)"
This reverts commit ba668eb. Below test started failing again on x86_64 macOS CI. We're unsure if this patch is the exact cause, but since this patch has broken this test before, we speculatively revert it to see if it was indeed the root cause. ``` FAIL: lldb-shell :: Unwind/trap_frame_sym_ctx.test (1692 of 2162) ******************** TEST 'lldb-shell :: Unwind/trap_frame_sym_ctx.test' FAILED ******************** Exit Code: 1 Command Output (stderr): -- RUN: at line 7: /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/bin/clang --target=specify-a-target-or-use-a-_host-substitution --target=x86_64-apple-darwin22.6.0 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -fmodules-cache-path=/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/lldb-test-build.noindex/module-cache-clang/lldb-shell /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/Inputs/call-asm.c /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/Inputs/trap_frame_sym_ctx.s -o /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/tools/lldb/test/Shell/Unwind/Output/trap_frame_sym_ctx.test.tmp + /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/bin/clang --target=specify-a-target-or-use-a-_host-substitution --target=x86_64-apple-darwin22.6.0 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -fmodules-cache-path=/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/lldb-test-build.noindex/module-cache-clang/lldb-shell /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/Inputs/call-asm.c /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/Inputs/trap_frame_sym_ctx.s -o /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/tools/lldb/test/Shell/Unwind/Output/trap_frame_sym_ctx.test.tmp clang: warning: argument unused during compilation: '-fmodules-cache-path=/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/lldb-test-build.noindex/module-cache-clang/lldb-shell' [-Wunused-command-line-argument] RUN: at line 8: /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/bin/lldb --no-lldbinit -S /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/tools/lldb/test/Shell/lit-lldb-init-quiet /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/tools/lldb/test/Shell/Unwind/Output/trap_frame_sym_ctx.test.tmp -s /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test -o exit | /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/bin/FileCheck /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test + /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/bin/lldb --no-lldbinit -S /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/tools/lldb/test/Shell/lit-lldb-init-quiet /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/tools/lldb/test/Shell/Unwind/Output/trap_frame_sym_ctx.test.tmp -s /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test -o exit + /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/bin/FileCheck /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test:21:10: error: CHECK: expected string not found in input ^ <stdin>:26:64: note: scanning from here frame #1: 0x0000000100003ee9 trap_frame_sym_ctx.test.tmp`tramp ^ <stdin>:27:2: note: possible intended match here frame rust-lang#2: 0x00007ff7bfeff6c0 ^ Input file: <stdin> Check file: /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test -dump-input=help explains the following input dump. Input was: <<<<<< . . . 21: 0x100003ed1 <+0>: pushq %rbp 22: 0x100003ed2 <+1>: movq %rsp, %rbp 23: (lldb) thread backtrace -u 24: * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 25: * frame #0: 0x0000000100003ecc trap_frame_sym_ctx.test.tmp`bar 26: frame #1: 0x0000000100003ee9 trap_frame_sym_ctx.test.tmp`tramp check:21'0 X error: no match found 27: frame rust-lang#2: 0x00007ff7bfeff6c0 check:21'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ check:21'1 ? possible intended match 28: frame rust-lang#3: 0x0000000100003ec6 trap_frame_sym_ctx.test.tmp`main + 22 check:21'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 29: frame rust-lang#4: 0x0000000100003ec6 trap_frame_sym_ctx.test.tmp`main + 22 check:21'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 30: frame rust-lang#5: 0x00007ff8193cc41f dyld`start + 1903 check:21'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 31: (lldb) exit check:21'0 ~~~~~~~~~~~~ >>>>>> ```
1 parent 51b74bb commit 9a4c5a5

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

+63
Original file line numberDiff line numberDiff line change
@@ -3775,6 +3775,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
37753775

37763776
SymbolType type = eSymbolTypeInvalid;
37773777
SectionSP symbol_section;
3778+
lldb::addr_t symbol_byte_size = 0;
37783779
bool add_nlist = true;
37793780
bool is_gsym = false;
37803781
bool demangled_is_synthesized = false;
@@ -4360,6 +4361,47 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
43604361

43614362
if (symbol_section) {
43624363
const addr_t section_file_addr = symbol_section->GetFileAddress();
4364+
if (symbol_byte_size == 0 && function_starts_count > 0) {
4365+
addr_t symbol_lookup_file_addr = nlist.n_value;
4366+
// Do an exact address match for non-ARM addresses, else get the
4367+
// closest since the symbol might be a thumb symbol which has an
4368+
// address with bit zero set.
4369+
FunctionStarts::Entry *func_start_entry =
4370+
function_starts.FindEntry(symbol_lookup_file_addr, !is_arm);
4371+
if (is_arm && func_start_entry) {
4372+
// Verify that the function start address is the symbol address
4373+
// (ARM) or the symbol address + 1 (thumb).
4374+
if (func_start_entry->addr != symbol_lookup_file_addr &&
4375+
func_start_entry->addr != (symbol_lookup_file_addr + 1)) {
4376+
// Not the right entry, NULL it out...
4377+
func_start_entry = nullptr;
4378+
}
4379+
}
4380+
if (func_start_entry) {
4381+
func_start_entry->data = true;
4382+
4383+
addr_t symbol_file_addr = func_start_entry->addr;
4384+
if (is_arm)
4385+
symbol_file_addr &= THUMB_ADDRESS_BIT_MASK;
4386+
4387+
const FunctionStarts::Entry *next_func_start_entry =
4388+
function_starts.FindNextEntry(func_start_entry);
4389+
const addr_t section_end_file_addr =
4390+
section_file_addr + symbol_section->GetByteSize();
4391+
if (next_func_start_entry) {
4392+
addr_t next_symbol_file_addr = next_func_start_entry->addr;
4393+
// Be sure the clear the Thumb address bit when we calculate the
4394+
// size from the current and next address
4395+
if (is_arm)
4396+
next_symbol_file_addr &= THUMB_ADDRESS_BIT_MASK;
4397+
symbol_byte_size = std::min<lldb::addr_t>(
4398+
next_symbol_file_addr - symbol_file_addr,
4399+
section_end_file_addr - symbol_file_addr);
4400+
} else {
4401+
symbol_byte_size = section_end_file_addr - symbol_file_addr;
4402+
}
4403+
}
4404+
}
43634405
symbol_value -= section_file_addr;
43644406
}
43654407

@@ -4466,6 +4508,9 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
44664508
if (nlist.n_desc & N_WEAK_REF)
44674509
sym[sym_idx].SetIsWeak(true);
44684510

4511+
if (symbol_byte_size > 0)
4512+
sym[sym_idx].SetByteSize(symbol_byte_size);
4513+
44694514
if (demangled_is_synthesized)
44704515
sym[sym_idx].SetDemangledNameIsSynthesized(true);
44714516

@@ -4584,7 +4629,23 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
45844629
Address symbol_addr;
45854630
if (module_sp->ResolveFileAddress(symbol_file_addr, symbol_addr)) {
45864631
SectionSP symbol_section(symbol_addr.GetSection());
4632+
uint32_t symbol_byte_size = 0;
45874633
if (symbol_section) {
4634+
const addr_t section_file_addr = symbol_section->GetFileAddress();
4635+
const FunctionStarts::Entry *next_func_start_entry =
4636+
function_starts.FindNextEntry(func_start_entry);
4637+
const addr_t section_end_file_addr =
4638+
section_file_addr + symbol_section->GetByteSize();
4639+
if (next_func_start_entry) {
4640+
addr_t next_symbol_file_addr = next_func_start_entry->addr;
4641+
if (is_arm)
4642+
next_symbol_file_addr &= THUMB_ADDRESS_BIT_MASK;
4643+
symbol_byte_size = std::min<lldb::addr_t>(
4644+
next_symbol_file_addr - symbol_file_addr,
4645+
section_end_file_addr - symbol_file_addr);
4646+
} else {
4647+
symbol_byte_size = section_end_file_addr - symbol_file_addr;
4648+
}
45884649
sym[sym_idx].SetID(synthetic_sym_id++);
45894650
// Don't set the name for any synthetic symbols, the Symbol
45904651
// object will generate one if needed when the name is accessed
@@ -4596,6 +4657,8 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
45964657
add_symbol_addr(symbol_addr.GetFileAddress());
45974658
if (symbol_flags)
45984659
sym[sym_idx].SetFlags(symbol_flags);
4660+
if (symbol_byte_size)
4661+
sym[sym_idx].SetByteSize(symbol_byte_size);
45994662
++sym_idx;
46004663
}
46014664
}

0 commit comments

Comments
 (0)