[Lldb-commits] [PATCH] D65826: Add support for deterministically linked binaries on macOS to lldb.

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 7 12:00:16 PDT 2019

labath added inline comments.

Comment at: lldb/lit/SymbolFile/DWARF/deterministic-build.cpp:6
+// RUN: ZERO_AR_DATE=1 %clang %t.o -g -o %t
+// RUN: %lldb %t -s %S/Inputs/deterministic-build.lldbinit -o exit | FileCheck %s
+// CHECK: int main() { return 0; }
erikchen wrote:
> JDevlieghere wrote:
> > If you check for `stop reason = breakpoint` instead of the source line, you don't have to work around the comments getting printed. You wouldn't even need an  input file anymore either.  
> > 
> > ```
> > // RUN: %lldb %t -o "breakpoint set -name main" -o "run"  -o "exit" | FileCheck %s
> > // CHECK: stop reason = breakpoint
> > ```
> I'm sorry but I don't understand how that would work. Even if object file symbols aren't loaded, lldb is still able to set a breakpoint at main, e.g.:
>  /Users/erikchen/projects/llvm-project/build/bin/lldb --no-lldbinit -S /Users/erikchen/projects/llvm-project/build/tools/lldb/lit/lit-lldb-init /Users/erikchen/projects/llvm-project/build/tools/lldb/lit/SymbolFile/DWARF/Output/deterministic-build.cpp.tmp -o "breakpoint set -name main" -o "run"  -o "exit"
> (lldb) command source -s 0 '/Users/erikchen/projects/llvm-project/build/tools/lldb/lit/lit-lldb-init'
> Executing commands in '/Users/erikchen/projects/llvm-project/build/tools/lldb/lit/lit-lldb-init'.
> (lldb) # LLDB init file for the LIT tests.
> (lldb) settings set symbols.enable-external-lookup false
> (lldb) settings set plugin.process.gdb-remote.packet-timeout 60
> (lldb) settings set interpreter.echo-comment-commands false
> (lldb) target create "/Users/erikchen/projects/llvm-project/build/tools/lldb/lit/SymbolFile/DWARF/Output/deterministic-build.cpp.tmp"
> Current executable set to '/Users/erikchen/projects/llvm-project/build/tools/lldb/lit/SymbolFile/DWARF/Output/deterministic-build.cpp.tmp' (x86_64).
> (lldb) breakpoint set -name main
> error: deterministic-build.cpp.tmp debug map object file '/Users/erikchen/projects/llvm-project/build/tools/lldb/lit/SymbolFile/DWARF/Output/deterministic-build.cpp.tmp.o' has changed (actual time is 2019-08-07 11:40:55.000000000, debug map time is 1969-12-31 16:00:00.000000000) since this executable was linked, file will be ignored
> Breakpoint 1: where = deterministic-build.cpp.tmp`main, address = 0x0000000100000fa0
> (lldb) run
> Process 18131 stopped
> * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
>     frame #0: 0x0000000100000fa0 deterministic-build.cpp.tmp`main
> deterministic-build.cpp.tmp`main:
> ->  0x100000fa0 <+0>: pushq  %rbp
>     0x100000fa1 <+1>: movq   %rsp, %rbp
>     0x100000fa4 <+4>: xorl   %eax, %eax
>     0x100000fa6 <+6>: movl   $0x0, -0x4(%rbp)
> Process 18131 launched: '/Users/erikchen/projects/llvm-project/build/tools/lldb/lit/SymbolFile/DWARF/Output/deterministic-build.cpp.tmp' (x86_64)
> (lldb) exit
Maybe you could set a file+line breakpoint instead of function one. That would only work if line tables get parsed (which live in the .o file if I know my MachO correctly). That way you wouldn't even have to run the process, which means this test might one day work on other systems too (if/when lld is able to link MachO files reasonably).



More information about the lldb-commits mailing list