2013-05-02 9 views

Antwort

18

Einfach peasy mit dem Befehl breakpoint command add. Geben Sie help breakpoint command add für Details, aber hier ist ein Beispiel.

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

Führen Sie lldb auf diese. Erstens stellen einen Haltepunkt auf der Source-Leitung mit „break“ irgendwo drin (nette Abkürzung für Beispiele wie dieses, aber es hat im Grunde Ihre Quellen grep über, so dass nicht für größere Projekte nützlich)

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

einen Haltepunkt hinzufügen Zustand, so dass die Haltepunkt stoppt erst, wenn i ein Vielfaches von 5:

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

haben den Unterbrechungsdruck den aktuellen Wert von i und Backtrace wenn er trifft:

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

und dann verwenden Sie es:

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

Vielen Dank, Alter! Ich dachte mir, dass es irgendwo im "Breakpoint-Set" sein muss und ich habe den falschen Baum total gebellt. – PHD

Verwandte Themen