Break on _NSLockError() to debug … How to?

前端 未结 3 701
無奈伤痛
無奈伤痛 2020-12-30 23:34

During debugging the console always spits me an error message: \"Break on _NSLockError() to debug\"

My assumption is: in XCode i have to appear a certain breackpoint

相关标签:
3条回答
  • 2020-12-30 23:51

    To do this automatically for your project in XCode:

    1. In Xcode, Option-Command-B to open the Breakpoints window (or Run>Show>Breakpoints).
    2. Where it says "Double-Click for Symbol", double click... and paste in "_NSLockError".
    3. Click anywhere else in the window, and your new entry will automatically be updated (or just add it manually) with Module = "Foundation" (without the quotes)
    4. Build & Go and you will now drop into the debugger automatically when you hit an automatically-detected deadlock.
    0 讨论(0)
  • 2020-12-31 00:05

    1/ From the menu choose Build -> Build and Debug

    2/ Click the "GDB" icon - you will be switched to the "Debugger console"

    3/ Press Control+C to interrupt your binary. You will get the gdb prompt.

    4/ type in "b _NSLockError" and continue execution after setting the breakpoint.

    (gdb) b _NSLockError
    Breakpoint 8 at 0x911db1a9
    (gdb) c
    Continuing.
    

    5/ you can interact with GDB just as it was running from console, i.e. you can Ctrl+C again and view current breakpoints:

    (gdb) info breakpo
    Num Type           Disp Enb Address    What
    8   breakpoint     keep y   0x911db1a9 <_NSLockError+9>
    
    0 讨论(0)
  • 2020-12-31 00:11

    Using the Xcode 4 GUI:

    1. Open the Breakpoints navigator (Command+6 or View>Navigators>Show Breakpoint Navigator)
    2. Click '+' in bottom left corner and choose 'Add Symbolic Breakpoint...'
    3. Enter '_NSLockError' in the Symbol field
    4. Enter 'Foundation' in the Module field
    5. Click 'Done'

    As above the debugger will break on the lock which results in a deadlock so you can check the callstack and hopefully determine where the original lock occurred.

    0 讨论(0)
提交回复
热议问题