debugging privileged helper

How do I debug privileged helper? Can someone point me to documentation ?

Three things:

  • Add comprehensive logging (using

    os.log
    ) to your privileged helper. This will help you debug problems that show up in the field.
  • For initial bring up, structure your privileged helper code so that you can debug it in a non-privileged context. There’s two parts to this:

    • Add an internal API your code so that you can test your core code using a standard testing harness (like XCTest).

    • Add command-line options to your tool so that you can debug it directly in Xcode. For example, let’s say your privileged helper tool exists to update a file in a privileged directory. Add a command-line option to override the location of that file so that, during debugging, you can point it to a location that’s not privileged.

  • Once you’ve done the above, you have a lot less debugging to do because you only have to deal with issues that show up when the code is run in the privileged environment. To debug those problems:

    1. Modify your

      launchd
      property list to set
      WaitForDebugger
      . See
      launchd.plist
      man page for details.
    2. Once the tool is paused this way, attach using Debug > Attach to Process by PID or Name, setting Debug Process As to “root”.

    3. You can now set breakpoints and continue execution.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
debugging privileged helper
 
 
Q