Lldb: setting a conditional breakpoint with string equality as a condition

I would like to set a conditional breakpoint with lldb. This is usually done using the option -c:

breakpoint set -f myFile.cpp -l 123 -c 'a==3'

However, in my case, I want to check if the object is equal to a std::stringspecific string value, but does it

breakpoint set -f myFile.cpp -l 123 -c 'a=="hello"'

does not work ... Lldb does not complain (while gdb returns an error), but it ignores the condition line when it reaches the breakpoint and breaks too early ...

This question is similar to this , but with lldb instead of gdb. Solution presented there

breakpoint set -f myFile.cpp -l 123 if strcmp(a, "hello")==0

seems invalid with lldb

Used version of Lldb: 3.4

+4
source share
1 answer
(lldb) br s -n main -c '(int)strcmp("test", var)==0'
Breakpoint 1: where = a.out`main + 11 at a.c:3, address = 0x0000000100000f8b
(lldb) br li
Current breakpoints:
1: name = 'main', locations = 1
Condition: (int)strcmp("test", var)==0

  1.1: where = a.out`main + 11 at a.c:3, address = a.out[0x0000000100000f8b], unresolved, hit count = 0 

(lldb) 

.

(lldb) br s -n main
Breakpoint 1: where = a.out`main + 11 at a.c:3, address = 0x0000000100000f8b
(lldb) br mod -c '(int) strcmp("test", var) == 0'
(lldb) br li
Current breakpoints:
1: name = 'main', locations = 1
Condition: (int) strcmp("test", var) == 0

  1.1: where = a.out`main + 11 at a.c:3, address = a.out[0x0000000100000f8b], unresolved, hit count = 0 

(lldb) 

breakpoint modify / , , ( , ).

+3

All Articles