44

I'm trying to get LLDB (running in Xcode 4.3.2 with an OS X application) to not stop on certain signals. If I enter

process handle SIGUSR2 -n true -p true -s false

on the debugging console it works fine and LLDB no longer stops on SIGUSR2.

However, if I put

command process handle SIGUSR2 -n true -p true -s false

into ~/.lldbinit it seems to be ignored. Other commands in this file (e.g. alias) work fine.

How can I make LLDB never stop on certain signals?

Daniel Heilper
  • 1,182
  • 2
  • 17
  • 34
puzzle
  • 6,071
  • 1
  • 25
  • 30
  • 1
    I don't think that what you want to do is doable, without an explicit The process is a run-time concept. Maybe there's a useful setting under "settings list" that you can set? – blueberryfields May 03 '12 at 22:24
  • Thanks, that explains why adding the command to ~/.lldbinit did not work :) – puzzle May 04 '12 at 21:42

1 Answers1

61

In case anyone else ever has this question, I finally solved it by adding a breakpoint in NSApplicationMain() (for plain C programs, main() would of course work as well).

I set the breakpoint action to process handle SIGUSR2 -n true -p true -s false, and enabled the "Automatically continue after evaluating" option.

Xcode 4 Breakpoint Screenshot

If anyone has a more elegant solution, I'd be happy to hear.

puzzle
  • 6,071
  • 1
  • 25
  • 30
  • 7
    Just in case... Don't forget to change symbol to `UIApplicationMain` for iOS. – user500 Sep 05 '13 at 15:08
  • Itworks for me. but after my application freezes. Would this be the true behavior? – n0minal Oct 03 '13 at 06:16
  • Telling lldb to ignore certain signals should not cause an application to freeze. Where does your application freeze and how? – puzzle Oct 09 '13 at 18:48
  • 2
    For Swift use "UIApplicationMain" – brunobowden Jan 05 '15 at 01:54
  • You might also just ignore the signal with ```signal(SIGPIPE, SIG_IGN)``` – Laurent Zubiaur Feb 15 '15 at 05:20
  • 1
    Wether you ignore or not the signal will not prevent xcode to stop :( (and btw you should better use sigaction() to ignore a signal) – itMaxence Mar 06 '18 at 13:58
  • 1
    @puzzle could you explain or let a link about the `process handle [signal] -n true -p true -s false` line? Just for the sake of understanding what I'm copy/pasting :) – itMaxence Mar 06 '18 at 14:02
  • 2
    @itMaxence If you enter `help process handle` in your lldb console, you'll get an explanation of all the possible arguments. – puzzle Mar 06 '18 at 22:52
  • In Xcode 13, having a commandline tool as target, setting this breakpoint in ìnt main(...) ...`, I get: "error: invalid target, create a target using the 'target create' command". any hints any one? – shallowThought Dec 07 '21 at 13:11