2012-03-28 19 views

risposta

207
expr myString = @"Foo" 

(lldb) help expr
Evaluate a C/ObjC/C++ expression in the current program context, using variables currently in scope. This command takes 'raw' input (no need to quote stuff).

Syntax: expression --

Command Options Usage: expression [-f ] [-G ] [-d ] [-u ] -- expression [-o] [-d ] [-u ] -- expression

-G <gdb-format> (--gdb-format <gdb-format>) 
     Specify a format using a GDB format specifier string. 

    -d <boolean> (--dynamic-value <boolean>) 
     Upcast the value resulting from the expression to its dynamic type 
     if available. 

    -f <format> (--format <format>) 
     Specify a format to be used for display. 

    -o (--object-description) 
     Print the object description of the value resulting from the 
     expression. 

    -u <boolean> (--unwind-on-error <boolean>) 
     Clean up program state if the expression causes a crash, breakpoint 
     hit or signal. 

Examples:

expr my_struct->a = my_array[3]
expr -f bin -- (index * 8) + 5
expr char c[] = "foo"; c[0]

IMPORTANT NOTE: Because this command takes 'raw' input, if you use any command options you must use ' -- ' between the end of the command options and the beginning of the raw input.

'expr' is an abbreviation for 'expression'

+1

Infatti, grazie! Un'altra piccola domanda: sto facendo questo per provare a cambiare il testo di un UILabel: "expr myLabel.text = @" ciao! "' Ma ottengo un 'errore: proprietà 'testo' non trovato su oggetto di tipo 'UILabel *' '... Qualche idea? – Eric

+9

'expr (void) [label setText: @" Foo "]' dovrebbe farlo. Dot-Syntax di solito non funzionerà nel debugger. lldb probabilmente lo interpreta come si voleva accedere ad un membro di una c-struct, ma non sono sicuro che questa sia la ragione per cui non funzionerà. Dot-Syntax non funziona nemmeno per 'po'. invece di 'po label.text' devi usare' po [label text] ' –

+0

Cool. Grazie mille Matthias! – Eric

8

La roba seguente funziona per me. Sto usando Xcode 8.

Se si desidera impostare alcune variabili (ad esempio un "dict") su zero e quindi verificare il flusso del codice, è possibile provare quanto segue.

  1. Inserire il punto di interruzione correttamente dopo l'inizializzazione sul valore desiderato.
  2. quindi eseguire "espressione dict = nil" nella riga di comando lldb per cambiarlo. (ad esempio "nil")
  3. Passaggio sopra il punto di interruzione.
  4. Controllare la variabile "dict" nella riga successiva. Sarà zero.

Apparirà come nella console.

(lldb) expression dict = nil 
(NSDictionary *) $5 = nil 
Problemi correlati