2013-05-02 17 views

cevap

18

breakpoint command add komutuyla kolay bir şekilde puslu. Ayrıntılar için help breakpoint command add yazın, ancak bir örnek.

int main() 
{ 
    int i = 0; 
    while (i < 30) 
    { 
     i++; // break here 
    } 
} 

Bu lldb'yi çalıştırın. Birincisi, (böyle örnekler için güzel kestirme ama temelde daha büyük projeler için, bu yüzden kullanışlı değil kaynaklarınızı üzerinde grep vardır) onun içinde bir yerlerde "mola" ile kaynak hattı üzerinde bir kesme noktası koymak

(lldb) br s -p break 
Breakpoint 1: where = a.out`main + 31 at a.c:6, address = 0x0000000100000f5f 

bir kesme noktası ekleme çarptığında

(lldb) br mod -c 'i % 5 == 0' 1 

kesme noktası baskısını i ve backtrace mevcut değerini var: i 5 katları olduğunda durum kesme noktası sadece durur böylece

(lldb) br com add 1 
Enter your debugger command(s). Type 'DONE' to end. 
> p i 
> bt 
> DONE 

ve sonra kullanın:

Process 78674 stopped and was programmatically restarted. 
Process 78674 stopped and was programmatically restarted. 
Process 78674 stopped and was programmatically restarted. 
Process 78674 stopped and was programmatically restarted. 
Process 78674 stopped 
* thread #1: tid = 0x1c03, 0x0000000100000f5f a.out`main + 31 at a.c:6, stop reason = breakpoint 1.1 
    #0: 0x0000000100000f5f a.out`main + 31 at a.c:6 
    3  int i = 0; 
    4  while (i < 30) 
    5  { 
-> 6   i++; // break here 
    7  } 
    8 } 
(int) $25 = 20 
* thread #1: tid = 0x1c03, 0x0000000100000f5f a.out`main + 31 at a.c:6, stop reason = breakpoint 1.1 
    #0: 0x0000000100000f5f a.out`main + 31 at a.c:6 
    #1: 0x00007fff8c2a17e1 libdyld.dylib`start + 1 
+0

Çok teşekkürler ahbap! "Kırılma noktası" nda bir yerde olmalı ve tamamen yanlış ağacı havlıyordum. – PHD

İlgili konular