LLDB Breakpoints performance - what should I expect?

I wrote a script that adds a lot of breakpoints to my iOS project. Each breakpoint has a command that calls some logging code and continues without stopping.

During my project execution, those breakpoints are called dozens if not hundreds times a second. Unfortunately, app performance collapsed after adding those breakpoints. It's pretty much unresponsive as executing breakpoints slow things down.


Is this normal? Is performance cost for breakpoints so significant?

I'm pasting below part of my python script from

~/.lldb
:


...
for funcName in funcNames:
  breakpointCommand = f'breakpoint set -n {funcName} -f {fileName}'
  lldb.debugger.HandleCommand(breakpointCommand)
  lldb.debugger.HandleCommand('breakpoint command add --script-type python --python-function devTrackerScripts.breakpoint_callback')
def breakpoint_callback(frame, bp_loc, dict):
   lineEntry = frame.GetLineEntry()
   functionName = frame.GetDisplayFunctionName()
   expression = f'expr -- proofLog(lineEntry: "{lineEntry}", function: "{functionName}")'

   lldb.debugger.HandleCommand(expression)

   return False

Accepted Reply

Is this normal?

Yes.

If I need to do a lot of tracing like this, I usually reach for one of the following:

  • Add the tracing code to my app, so it runs natively.

  • DTrace

DTrace is not supported on iOS but I suspect that the Mac DTrace will happily trace an iOS app running in the simulator (I’ve not tried it though).

Share and Enjoy

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

let myEmail = "eskimo" + "1" + "@apple.com"

Replies

Is this normal?

Yes.

If I need to do a lot of tracing like this, I usually reach for one of the following:

  • Add the tracing code to my app, so it runs natively.

  • DTrace

DTrace is not supported on iOS but I suspect that the Mac DTrace will happily trace an iOS app running in the simulator (I’ve not tried it though).

Share and Enjoy

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

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks! 🙂