調試器,主要用於編程中調試 其中前端
命令 | 快捷功能 |
---|---|
command+shift+y | 暫停/繼續 |
command+y | 開啓/關閉斷點功能 |
command+shift+c | 將光標切換到控制檯 |
command+shift+y | 隱藏/顯示控制檯 |
command+k | 清空控制檯 |
p
、expresion --
、print
: 打印對應類型、地址信息、值 po
、expresion --o --
: 打印對象值面試
附:每次使用p後,lldb會自動分配變量,後邊想繼續使用這個變量,能夠經過$後的數字取該變量編程
e
、expresion
:修改變量,修改後,變量的地址也發生了改變 markdown
出現異常會自動暫停 2. 符號斷點
Symbolic Breakpoint
app
當想知道方法testCalled何時調用時,添加對應的符號斷點 工具
觀察對象、屬性的改變oop
改變時會自動暫停到代碼處並打印old value
和new value
ui
(lldb) tb
Current breakpoints:
1: name = 'objc_exception_throw', locations = 1, resolved = 1, hit count = 0
1.1: where = libobjc.A.dylib`objc_exception_throw, address = 0x00007fff20193fc5, resolved, hit count = 0
2: names = {'[ViewController testCalled]', '[ViewController testCalled]', '[ViewController testCalled]'}, locations = 1, resolved = 1, hit count = 0
2.1: where = LLDBDemo`-[ViewController testCalled] + 23 at ViewController.m:56:5, address = 0x000000010bea5dd7, resolved, hit count = 0
3: file = '/Users/ternence/Documents/技術/面試技術練手Demo/LLDBDemo/LLDBDemo/ViewController.m', line = 21, exact_match = 0, locations = 1, resolved = 1, hit count = 1
3.1: where = LLDBDemo`-[ViewController viewDidLoad] + 51 at ViewController.m:21:33, address = 0x000000010bea5be3, resolved, hit count = 1
(lldb)
複製代碼
bt
thread backtrack
打印當前線程信息(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 3.1
* frame #0: 0x000000010bea5be3 LLDBDemo`-[ViewController viewDidLoad](self=0x00007fb2d7c0cd00, _cmd="viewDidLoad") at ViewController.m:21:33
frame #1: 0x00007fff23f806a9 UIKitCore`-[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 88
frame #2: 0x00007fff23f8504c UIKitCore`-[UIViewController loadViewIfRequired] + 1084
frame #3: 0x00007fff23f85436 UIKitCore`-[UIViewController view] + 27
frame #4: 0x00007fff246ffc73 UIKitCore`-[UIWindow addRootViewControllerViewIfPossible] + 313
frame #5: 0x00007fff246ff362 UIKitCore`-[UIWindow _updateLayerOrderingAndSetLayerHidden:actionBlock:] + 219
frame #6: 0x00007fff24700325 UIKitCore`-[UIWindow _setHidden:forced:] + 362
frame #7: 0x000000010e15a748 UIKit`-[UIWindowAccessibility _orderFrontWithoutMakingKey] + 84
frame #8: 0x00007fff247133a6 UIKitCore`-[UIWindow _mainQueue_makeKeyAndVisible] + 42
frame #9: 0x00007fff24951c05 UIKitCore`-[UIWindowScene _makeKeyAndVisibleIfNeeded] + 202
frame #10: 0x00007fff23b0e80c UIKitCore`+[UIScene _sceneForFBSScene:create:withSession:connectionOptions:] + 1671
frame #11: 0x00007fff246c2df9 UIKitCore`-[UIApplication _connectUISceneFromFBSScene:transitionContext:] + 1114
frame #12: 0x00007fff246c3128 UIKitCore`-[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 289
frame #13: 0x00007fff241a4ab4 UIKitCore`-[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 358
frame #14: 0x00007fff25a1b40b FrontBoardServices`-[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 398
frame #15: 0x00007fff25a43e55 FrontBoardServices`__94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.176 + 102
frame #16: 0x00007fff25a28f12 FrontBoardServices`-[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 209
frame #17: 0x00007fff25a43b28 FrontBoardServices`__94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke + 352
frame #18: 0x000000010c11b74e libdispatch.dylib`_dispatch_client_callout + 8
frame #19: 0x000000010c11e656 libdispatch.dylib`_dispatch_block_invoke_direct + 295
frame #20: 0x00007fff25a695d0 FrontBoardServices`__FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
frame #21: 0x00007fff25a692b6 FrontBoardServices`-[FBSSerialQueue _targetQueue_performNextIfPossible] + 433
frame #22: 0x00007fff25a6977b FrontBoardServices`-[FBSSerialQueue _performNextFromRunLoopSource] + 22
frame #23: 0x00007fff20390ede CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
frame #24: 0x00007fff20390dd6 CoreFoundation`__CFRunLoopDoSource0 + 180
frame #25: 0x00007fff20390300 CoreFoundation`__CFRunLoopDoSources0 + 340
frame #26: 0x00007fff2038a9f7 CoreFoundation`__CFRunLoopRun + 875
frame #27: 0x00007fff2038a1a7 CoreFoundation`CFRunLoopRunSpecific + 567
frame #28: 0x00007fff2b874d85 GraphicsServices`GSEventRunModal + 139
frame #29: 0x00007fff246c14df UIKitCore`-[UIApplication _run] + 912
frame #30: 0x00007fff246c639c UIKitCore`UIApplicationMain + 101
frame #31: 0x000000010bea60e2 LLDBDemo`main(argc=1, argv=0x00007ffee3d59ca0) at main.m:17:12
frame #32: 0x00007fff2025abbd libdyld.dylib`start + 1
(lldb)
複製代碼
執行後,條件語句會指向
els
e裏的NSLog(@"thread have return NO");
spa
Clang項目爲LLVM 項目的C語言系列(C,C ++,Objective C / C ++,OpenCL,CUDA和RenderScript)中的語言提供語言前端和工具基礎結構。提供了與GCC兼容的編譯器驅動程序(clang)和與MSVC兼容的編譯器驅動程序(clang-cl.exe)線程