Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Break on _NSLockError() to debug ... How to?

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, so that the debugger stops at the point where this error occurs.

How can i make this?

like image 319
Nobik Avatar asked Aug 19 '09 13:08

Nobik


3 Answers

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.

like image 83
Opsimath Avatar answered Nov 17 '22 00:11

Opsimath


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>
like image 41
diciu Avatar answered Nov 17 '22 00:11

diciu


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.
like image 13
Simon Woodside Avatar answered Nov 16 '22 23:11

Simon Woodside