進擊的Bug---那些年我遇到的大坑3

史前圖騰發表於2018-04-01

功能要求:程式正常執行,點選Debugview按鈕除錯介面

  • Bug:測試過程中發現,點選檢視除錯按鈕後,介面報錯,無法顯示檢視層級結構 如下圖

進擊的Bug---那些年我遇到的大坑3

  • 列印結果:
Error:    Unable to capture view hierarchy.
Details:  Log Title: Data source expression execution failure.
Log Details: error evaluating expression “(id)[[(Class)objc_getClass("DBGTargetHub") sharedHub] performRequestWithRequestInBase64:@"YnBsaXN0MDDUAQIDBAUGPD1YJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3ASAAGGoK8QEwcIFxgZGhscKCkqKywvNTY3OjtVJG51bGzTCQoLDBEWV05TLmtleXNaTlMub2JqZWN0c1YkY2xhc3OkDQ4PEIACgAOABIAFpBITFBWABoAHgBGAEoAQXxAXREJHSGllcmFyY2h5UmVxdWVzdFR5cGVfEBxEQkdIaWVyYXJjaHlSZXF1ZXN0UHJlZGljYXRlXxAdREJHSGllcmFyY2h5UmVxdWVzdElkZW50aWZpZXJfEBdEQkdIaWVyYXJjaHlSZXF1ZXN0TmFtZRAB0wkKCx0iFqQeHyAhgAiACYAKgAukIyQlI4AMgA6AD4AMgBBfEBNlbnVtUHJvdmlkZXJDbGFzc2VzXxARaW5jbHVkZUxhenlWYWx1ZXNfEBNzdHJpY3Rlc3RWaXNpYmlsaXR5XxAWb3B0aW9uc1Byb3ZpZGVyQ2xhc3Nlc9IKCy0uoIAN0jAxMjNaJGNsYXNzbmFtZVgkY2xhc3Nlc1dOU0FycmF5ojI0WE5TT2JqZWN0CBAD0jAxODlcTlNEaWN0aW9uYXJ5ojg0XxAkOUYxMUI2RUEtRTQzNS00QkM4LThDQjYtNUU5OTJGRDNFOTA2XxAPSW5pdGlhbCByZXF1ZXN0XxAPTlNLZXllZEFyY2hpdmVy0T4/VHJvb3SAAQAIABEAGgAjAC0AMgA3AE0AUwBaAGIAbQB0AHkAewB9AH8AgQCGAIgAigCMAI4AkACqAMkA6QEDAQUBDAERARMBFQEXARkBHgEgASIBJAEmASgBPgFSAWgBgQGGAYcBiQGOAZkBogGqAa0BtgG3AbkBvgHLAc4B9QIHAhkCHAIhAAAAAAAAAgEAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAiM="]”: error: Execution was interrupted.
The process has been returned to the state before expression evaluation.


Log Method: -[DBGDataSourceConnectionLibViewDebugger _executeLLDBExpression:forRequest:onPotentialThread:iteration:]_block_invoke_2
Method:   -[DBGViewDebugger _initiateInitialRequestWithDataSourceVersion:]_block_invoke
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
2018-04-01 13:40:42.908796+0800 xxx[2105:648229] Error: DBGTargetHub - Failed to unarchive request data with error: Error Domain=NSCocoaErrorDomain Code=4864 "*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0x7b, 0xa, 0x20, 0x20, 0x22, 0x44, 0x42, 0x47)" UserInfo={NSDebugDescription=*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0x7b, 0xa, 0x20, 0x20, 0x22, 0x44, 0x42, 0x47)}
複製程式碼
  • 按照控制檯的列印資訊,是NSKeyedUnarchiver在解壓中出錯導致的.對實際除錯沒有什麼幫助.

  • 在app中先註釋掉多餘的程式碼,不啟動無關的控制器,最後發現只要不載入某個自定義的view,就可以正常除錯了.

  • 仔細檢視該view檔案中的內容,註釋掉.m檔案中initWithFrame:內部的所有方法,仍然無法正常顯示除錯介面.

  • 進一步註釋掉.h檔案的中屬性,嘗試載入,成功了!!!看來問題在.h檔案中.

  • 檢視.h中的內容,逐條註釋掉,察看反應,最後定位到一個屬性上,一個名為text的int型屬性!!!!,當給這個text設定為0時正常,設定為1時就不能正常除錯了:

進擊的Bug---那些年我遇到的大坑3
進擊的Bug---那些年我遇到的大坑3

竟然是這樣的一個錯誤導致的,猜想一下:自定義的view內部在顯示Debug view的時候,預設讀取這個text值後會按照NSString型別來解壓處理,所以導致NSKeyedUnarchiver出錯.

相關文章