20

I'm embedding MonoTouch in an Xcode project, and want to stop LLDB debugger from handling SIGBUS signals, since they are used by the mono runtime. How can I do that?

Ergwun
  • 12,579
  • 7
  • 56
  • 83
  • 1
    According to http://stackoverflow.com/questions/10431579/permanently-configuring-lldb-in-xcode-4-3-2-not-to-stop-on-signals, "process handle SIGBUS -n true -p true -s false" should do the trick. – Martin R Aug 16 '12 at 13:41

1 Answers1

44

You can control how lldb intercepts/passes signals with the "process handle" command. For your case, you'd want to do

(lldb) pro hand -p true -s false SIGBUS
NAME        PASS   STOP   NOTIFY
==========  =====  =====  ======
SIGBUS      true   false  true 

now the signals will be passed to your process without lldb getting in the way. The "NOTIFY" field indicates whether lldb should print that the signal was received - the default is that it will be printed in the debugger console but that doesn't seem to be happening right now. But the signal is correctly passed along, which is the important bit.

Jason Molenda
  • 14,835
  • 1
  • 59
  • 61
  • 3
    Is there any way to set this in XCode? – ed22 Jul 15 '15 at 10:57
  • 2
    Add a breakpoint e.g. on main() and then in its breakpoint action add an LLDB command with this line in it, then check the "continue after breakpoint" checkbox. – uliwitness Oct 13 '15 at 21:24
  • 1
    To do this automatically in Xcode, add the command to `~/.lldbinit-Xcode`. If you want this to apply even when using `lldb` from the command line, add the same to `~/.lldbinit` – Buzzy Oct 28 '15 at 21:04
  • 2
    It doesn't work to add it to `~/.lldbinit` because it gives the error `error: No current target; cannot handle signals until you have a valid target and process.` – Jacob Wallström Oct 16 '19 at 10:10
  • I have a similar problem when debugging `swiftc` executable with lldb. On hitting some breakpoints, even though I have applied the suggested change to how lldb handles SIGCHLD (not SIGBUS), it keeps dying. What can I do? Maybe I should file a bug? – Artyom Gevorgyan Oct 23 '20 at 08:02
  • `Process` X `stopped and restarted: thread 1 received signal: SIGCHLD` This is what I keep getting instead of a stop at breakpoint. – Artyom Gevorgyan Oct 23 '20 at 08:08
  • @ArtyomGevorgyan: Your program died. The debugger received SIGCHLD. Setting the debugger to break when your program receives SIGCHLD doesn't help because your program didn't receive SIGCHLD. – Ben Voigt Apr 29 '21 at 16:08