2016-07-01 12 views
0

XcodeのLLDBで使用するPythonスクリプトを作成しています。 。PythonスクリプトでのLLDBコマンドの使用

import lldb 

def say_hello(debugger, command, result, dict): 
    print command 

def __lldb_init_module (debugger, dict): 
    debugger.HandleCommand('command script add -f sayhello.say_hello hello') 

私が何をしたいのですがどのようなPythonスクリプトでLLDBのXCUIApplication()debugDescription関数の出力を使用することができます:私はこの単純なスクリプト起動して実行を持っています。したがって、どちらかの方法があります:

a)Pythonスクリプト内のXCUIApplication()にアクセスします。

b)XCUIApplication()。debugDescriptionをPythonスクリプトのsay_hello関数への入力として渡します。

答えて

1

IIRC XCUIApplicationは、XCTestフレームワークによって提供される関数なので、デバッグしているプログラムの関数です。 SBTargetまたはSBFrameのいずれかで "EvaluateExpression" APIを使用して、他の関数と同じ方法で呼び出すことができます。式を評価した結果はSBValueで返され、必要なものをSBValueで印刷することができます。

注意、あなたは非常に古いXcodeの(6.xの)をサポートする必要がある場合を除き、Pythonコマンドの新しいフォームを使用する方が便利です:

def command_function(debugger, command, exe_ctx, result, internal_dict): 

exe_ctxコマンドでSBExecutionContextですが走っています。このようにすれば、次のようにすることができます:

def command_function(debugger, command, exe_ctx, result, internal_dict): 
    options = lldb.SBExpressionOptions() 
    thread = exe_ctx.GetThread() 
    if thread.IsValid(): 
     value = thread.GetFrameAtIndex(0).EvaluateExpression("XCUIApplication().debugDescription", options) 
     if value.GetError().Success(): 
      # Do whatever you want with the result of the expression 
関連する問題