15

lldb で条件付きブレークポイントを設定したいと考えています。これは通常、-cオプションを使用して行われます。

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

ただし、私の場合、std::stringオブジェクトが特定の文字列値と等しいかどうかをテストしたいのですが、これを行っています

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

動作しません... Lldb は文句を言いませんが (gdb はエラーを返します)、ブレークポイントに到達すると条件文字列を無視し、ブレークが早すぎます...</p>

この質問はこれと似ていますが、gdb の代わりに lldb を使用しています。そこで提示された解決策

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

lldb では有効ではないようです

使用される Lldb バージョン: 3.4

4

1 に答える 1

13
(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最後にブレークポイント番号/ブレークポイント番号のリストを取り、何も指定されていない場合はデフォルトで最新のブレークポイントになります (これは私がここで行ったことです)。

于 2016-05-14T02:44:41.370 に答える