2017-02-22 20 views
0

剛剛切換到lldb,我試圖做相當於gdb的watch i,因爲我在代碼中的for循環內。看着變量我在一個for循環與lldb

(lldb) f 
frame #0: 0x0000000100000664 a.out`MaxPairwiseProduct(numbers=size=5) + 4 at max_pairwise_product.cpp:19 [opt] 
    16  // Find max value in vector 
    17  
    18  for (int i=1; i<numbers.size(); i++) { 
-> 19  if (numbers[i] > numbers[i-1]) { 
    20   second_max = max; 
    21   max = numbers[i]; 
    22   if (numbers[i] < max && numbers[i] > second_max) 
(lldb) 

正如您在上面看到的,int i已經被聲明。

檢查其觀察點我有產量

(lldb) watchpoint list -b 
Number of supported hardware watchpoints: 4 
No watchpoints currently set. 
(lldb) 

現在試圖將觀察點設置爲我(根據lldb reference)我得到

(lldb) wa s v i 
error: Watchpoint creation failed (addr=0xffffffffffffffff, size=0, variable expression='i'). 
error: cannot set a watchpoint with watch_size of 0 
(lldb) 

我不明白這是爲什麼,是該變量已被聲明。谷歌搜索錯誤並沒有什麼幫助,因爲大多數問題似乎都與最大數量的觀察點有關,而我的情況並非如上所述。任何幫助將非常感激!

回答

0

我改變了我是編譯程序clang++ -Wall -g -o max_pairwise max_pairwise.cpp的方式,並開始向我展示正確的信息,包括跟蹤i

+0

值。這可能是一個壞的錯誤信息(而不是給人一種錯誤提示信息)當引用的變量在當前位置不可用時。你重建的命令行示例沒有任何優化,我猜你在第一個例子中已經有了它。或者你在兩次運行之間的程序中的另一點停下來。儘管如此,你肯定應該得到關於問題的錯誤信息,而不是這種行爲,但觀察點在lldb中有點粗糙。 –