Why isn't lldb setting my breakpoint correctly?

Viewed 17

I've got a chunk of some assembly and am assembling it on osx like this:

as -g -o tallest.o tallest.s
ld --static -o tallest tallest.o

I fire up lldb, set a breakpoint at line 57 in tallest.s and check the info on the set breakpoint. The info is wrong.

chris@goldfish chapter07 % lldb tallest              
(lldb) target create "tallest"
Current executable set to '/Users/chris/Dev/assembly/learning-assembly/chapter07/tallest' (x86_64).
(lldb) break set -f tallest.s -l 57
Breakpoint 1: where = tallest`endloop, address = 0x0000000100003fa9
(lldb) break list 1 --verbose
1: file = 'tallest.s', line = 57, exact_match = 0
    1.1: 
      module = /Users/chris/Dev/assembly/learning-assembly/chapter07/tallest
      compile unit = tallest.s
      location = /Users/chris/Dev/assembly/learning-assembly/chapter07/tallest.s:64
      address = tallest[0x0000000100003fa9]
      resolved = false
      hardware = false
      hit count = 0   


(lldb) 

Notice that the break point is set at line 64, not line 57 as requested. This isn't always broken. Here's an example from the same debug session that works on line 54:

(lldb) break set -f tallest.s -l 54
Breakpoint 2: where = tallest`mainloop, address = 0x0000000100003f99
(lldb) break list 2 --verbose
2: file = 'tallest.s', line = 54, exact_match = 0
    2.1: 
      module = /Users/chris/Dev/assembly/learning-assembly/chapter07/tallest
      compile unit = tallest.s
      location = /Users/chris/Dev/assembly/learning-assembly/chapter07/tallest.s:54
      address = tallest[0x0000000100003f99]
      resolved = false
      hardware = false
      hit count = 0   


(lldb) 

Running the code, lldb stops at lines 54 and 64. If I try to step from 54 to 57, it shows me this on stopping:

(lldb) n
Process 59180 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
    frame #0: 0x0000000100003f9d tallest`mainloop + 4
tallest`mainloop:
->  0x100003f9d <+4>:  cmpq   %rax, %rdi
    0x100003fa0 <+7>:  jge    0x100003fa9               ; endloop
    0x100003fa6 <+13>: movq   %rax, %rdi

tallest`endloop:
    0x100003fa9 <+0>:  addq   $0x28, %rbx
Target 0: (tallest) stopped.
(lldb)

That's not my assembly code from tallest.s. I expect it is just what lldb disassembled. The question would be what can I do to my code or build process to make it more likely that lldb can list my code when it stops at a breakpoint?

Based on Jim Ingham's comment, I ran the lldb source info -f tallest.s command which listed only some of my source lines. For example lines 57, 58, and 61 are missing from the output.

0 Answers
Related