2012-03-28 4 views

答えて

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

本当に感謝!もう少し質問があります:私はUILabelのテキストを変更しようとしています: '' expr myLabel.text = @ "hello!" ''しかし、エラー:プロパティ 'text'がタイプのオブジェクトに見つかりません'UILabel *' '...どんな考え? – Eric

+9

'expr(void)[label setText:@" Foo "]'それを行うべきです。通常、Dot-Syntaxはデバッガでは動作しません。 lldbはおそらくc-structのメンバにアクセスしたいと考えていると解釈しますが、これがうまく動作しないのかどうかはわかりません。 Dot-Syntaxは 'po'でも動作しません。 'po label.text'の代わりに' po [label text] ' –

+0

Coolを使う必要があります。ありがとうたくさんのマティアス! – Eric

8

次のものが私のために動作します。 私はXcode 8を使用しています。

いくつかの変数(たとえば "dict")をnilに設定してコードフローをテストする場合は、次のように試してみてください。

  1. 初期化した後にブレークポイントを適切な値に設定します。
  2. 次に、lldbコマンドラインで "expression dict = nil"を実行して変更します。 (たとえば、 "nil")
  3. ブレークポイントを超えるステップ。
  4. 次の行の変数 "dict"を確認してください。それは無用です。

コンソールのように見えます。

(lldb) expression dict = nil 
(NSDictionary *) $5 = nil 
関連する問題