Lldb:设置条件断点与字符串相等作为条件
问题描述:
我想用lldb设置条件断点。Lldb:设置条件断点与字符串相等作为条件
breakpoint set -f myFile.cpp -l 123 -c 'a==3'
然而,在我来说,我想测试一个std::string
对象是等于某个字符串值,但这样做
breakpoint set -f myFile.cpp -l 123 -c 'a=="hello"'
不工作... LLDB:这通常是使用-c
选项来完成不会抱怨(虽然GDB会返回一个错误),但它会在到达断点时忽略条件字符串,并且太早打破...
此问题与this one类似,但使用lldb而不是gdb。该解决方案提出了有
breakpoint set -f myFile.cpp -l 123 if strcmp(a, "hello")==0
似乎并没有有效与LLDB使用
LLDB版本:3.4
答
(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
采用断点号的断点号/表底,如果没有指定(这是我在这里做),默认为最新的断点。