Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I setup an LLDB breakpoint firing every 10th time?

To debug the values of high frequency timers or sensors it would be useful to configure a breakpoint that only fires every x times. What's the best way to accomplish this?

I tried the "Ignore x times before stopping" option in Xcode but that only works for the first time. Can I reset this counter using an LLDB command?

like image 804
Ortwin Gentz Avatar asked Oct 18 '22 22:10

Ortwin Gentz


1 Answers

You can reset the ignore counter at any time with:

(lldb) break modify -i <NEW_VALUE> <BKPT_SPECIFICATION>

Note, a breakpoint which doesn't satisfy its "ignore count" is not considered to be hit, so its breakpoint command does NOT get run. So if you wanted to stop every tenth the time you hit the breakpoint automatically, just do:

    (lldb) break set -l 10 -i 10 -N my_bkpt
    Breakpoint 1: where = foo`main + 46 at foo.c:10, address = 0x0000000100000f5e
    (lldb) break com add
    Enter your debugger command(s).  Type 'DONE' to end.
    > break modify -i 10 my_bkpt 
    > DONE
    (lldb)

Then just hit "continue" at each stop and you will hit the breakpoint once every 10 times.

Note, I used the ability to name the breakpoint (the -N option) so I didn't have to know the breakpoint number in the breakpoint command that I added. That's convenient if you're going to store these breakpoints in a command file, etc.


Ref: Apple docs on Managing breakpoints. You can also do help breakpoint set command for a complete list of available options

like image 63
Jim Ingham Avatar answered Oct 20 '22 23:10

Jim Ingham