2016-12-23 4 views
1

중단 점에 도달하면 성공적으로 파이썬 스크립트를 실행할 수 있습니다. 수행하여LLDB에서 중단 점에 도달했을 때 pyplot을 사용하여 데이터를 표시하는 방법

breakpoint_function (frame, bp_loc, dict) 

그때 내가 lldb에 모듈을 가지고 : here를 설명하고있는 바와 같이 나는이 서명으로 제 기능을 구현하는 파이썬 모듈을 다음

(lldb) command script import "path to my .py file" 

내가 중단 점을 확인하고 그것을 내 함수를 추가 이 같은 :

내 모듈이

012,347,989,393과 같은
(lldb) br com a -F MyModule.breakpoint_function 

2016년 12월 22일 21 : 26 :

사용하여 단지 plt.plot (x)와 plt.show()이처럼 보이는 오류 로그의 시작과 충돌 lldbdb 원인 51.192 lldb을 [32192 : 2025199] *** 어설 션 오류 + [NSUndoManager _endTopLevelGroupings], /Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1256.1/Misc.subproj/NSUndoManager.m:359 2016-12- 22 21 : 26 : 51.192 lldb [32192 : 2025199] + [NSUndoManager (NSInternal) _endTopLevelGroupings]는 주 스레드에서만 호출해도 안전합니다. 2016년 12월 22일 21 : 26 : 51.272 lldb [32,192 : 2,025,199 ( 0 CoreFoundation에서 0x00007fff8da54ae2 __exceptionPreprocess + 178 1 libobjc.A.dylib의 0x00007fff90f7173c objc_exception_throw + 48 2 CoreFoundation에서 0x00007fff8da548ba + [NSException 인상 : 형식 : 인자 :] + 106 3 예비 0x00007fff9145c88c - [NSAssertionHandler handleFailureInMethod : 개체 : 파일 : LINENUMBER : 설명 :] + 198 4 재단 0x00007fff913e24c1 + [NSUndoManager (NSPrivate) _endTopLevelGroupings] + 170 5 AppKit의의 0x00007fff9bfd306a - [NSApplication 실행] + 844 6 _macosx .so 0x00000001256c931e init_macosx + 32153 7 Python 0x000000010e75aa90 PyEval_EvalFrameEx + 13533 8 파이썬 0x000000010e7573c1 PyEval_EvalCodeEx + 1,583 9 파이썬 0x000000010e75d4ae _PyEval_SliceIndex + 342 10 파이썬 0x000000010e75a30c PyEval_EvalFrameEx + 11,609

I는 plt.plot (X) 우선 아무것도 표시 전에 plt.ion()를 호출하고 난 단계별로 계속하면 lldb. 그런 다음 lldb를 종료하면 플롯이 실제로 초 단위로 표시됩니다.

나는 어떤 힌트가 환영받을 (오류 로그와 crashe 원인) 행운 또한 시도 plt.show (블록 = 참)로 matplotlibrc의 백엔드를 변경했습니다.

답변

1

(lldb 중단 점에서) 작동하도록 plt.show()를 가져올 수 없습니다. 그러나 다음 해결 방법은 나를 위해 작동하며 lldb 중단 점 (xcode 7, lldb-340.4.70 포함)에 matplotlib 이미지를 표시합니다.

def bp1(frame, bp_loc, dict): 
    """Use matplotlib in an Xcode breakpoint. 
    Add with: br com add -F cmd.bp1 
    """ 
    import matplotlib.pyplot as plt, numpy as np, sys 
    # The following addition to the path may not be required in your case 
    sys.path.append("/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages") 
    from PIL import Image 

    print ("hit bp1") 
    # Some example plot (sine curve) 
    fig = plt.figure() 
    Fs = 8000 
    f = 5 
    sample = 8000 
    x = np.arange(sample) 
    y = np.sin(2 * np.pi * f * x/Fs) 
    fig.gca().plot(x, y) 

    # Save figure to image 
    fileName = "/Users/<username>/tempwork/lldb_pic.png" 
    fig.savefig(fileName) 

    # Open image from filesystem and show with PIL 
    img = Image.open(fileName) 
    img.show() 
    return True # False = continue execution, True = stop execution in debugger (lldb prompt) 
관련 문제