xcode - How do you add breakpoint actions via the LLDB command line? -
if edit breakpoint xcode, there super-useful option add "action" automatically executed every time breakpoint hit.
how can add such actions lldb command line?
easy peasy breakpoint command add
command. type help breakpoint command add
details here's example.
int main () { int = 0; while (i < 30) { i++; // break here } }
run lldb on this. first, put breakpoint on source line "break" somewhere in (nice shorthand examples has grep on sources, not useful larger projects)
(lldb) br s -p break breakpoint 1: = a.out`main + 31 @ a.c:6, address = 0x0000000100000f5f
add breakpoint condition breakpoint stops when i
multiple of 5:
(lldb) br mod -c 'i % 5 == 0' 1
have breakpoint print current value of i
, backtrace when hits:
(lldb) br com add 1 enter debugger command(s). type 'done' end. > p > bt > done
and use it:
process 78674 stopped , programmatically restarted. process 78674 stopped , programmatically restarted. process 78674 stopped , programmatically restarted. process 78674 stopped , programmatically restarted. process 78674 stopped * thread #1: tid = 0x1c03, 0x0000000100000f5f a.out`main + 31 @ a.c:6, stop reason = breakpoint 1.1 #0: 0x0000000100000f5f a.out`main + 31 @ a.c:6 3 int = 0; 4 while (i < 30) 5 { -> 6 i++; // break here 7 } 8 } (int) $25 = 20 * thread #1: tid = 0x1c03, 0x0000000100000f5f a.out`main + 31 @ a.c:6, stop reason = breakpoint 1.1 #0: 0x0000000100000f5f a.out`main + 31 @ a.c:6 #1: 0x00007fff8c2a17e1 libdyld.dylib`start + 1
Comments
Post a Comment