Search code examples
nasmlldb

Is it possible to use a label as a breakpoint in a nasm file using lldb?


I am struggling with constant changes to a code written in nasm using os x 64 bit. I find it rather boring having to redefine the line where to make a break point every time (because changing the code, the line changes). So I thought of using a break point referring to a label (as I can do using gdb by the way). However, I have noticed that lldb does not allow to use labels in break points when debugging with nasm code. Do any of you use them? If so, how?


Solution

  • If the label survives as a real symbol, lldb should be able to set a breakpoint on the symbol. But if the label doesn't survive (it's a local symbol or whatever), lldb would have to dig it out from the debug info. I don't know how nasm represents labels in the debug info, but if gdb can find them then there's some breadcrumbs that lldb should be able to use as well. If you file a bug with your example that shows the problem at http://bugs.llvm.org somebody there can take a look.

    You might be able to do this task with the current lldb using a "source regular expression" breakpoint (in lldb break set -p). Since labels come first on the line, a regex like ^ *LABELNAME: should just get the definition of the label and not any other references to it in the source.

    More generally, when I have code I know I'm going to want to put a breakpoint on, but I'm still busily editing the code so the line number is changing all the time, I just add a comment like:

    someInterestingFunctionCall() // Set a breakpoint here
    

    Then I do:

    (lldb) break set -p "Set a breakpoint here" -f MySourceFile.c

    That way I can edit the source and move this line around however I need, and the breakpoint will continue to work. nasm supports comments, so you could also just use a comment to tag the line you want to break on.