Redirect lldb output to file

前端 未结 2 1491
孤城傲影
孤城傲影 2021-02-02 14:49

I\'m using lldb inside Xcode, and one of my variables contains a huge chunk of JSON data. Using po myVar isn\'t much helpful to analyse this data, as it will output

2条回答
  •  花落未央
    2021-02-02 15:03

    Here is a slight modification incorporating some of the comments from above:

    def toFile(debugger, command, result, dict):
        f=open("/Users/user/temp.txt","w")
        debugger.SetOutputFileHandle(f,True);
        debugger.HandleCommand(command)  
        f.close()
        debugger.SetOutputFileHandle(sys.stdout, True)
    

    This allows the command to be supplied as an argument, and reverts the output file handle to stdout after the command is run.

提交回复
热议问题