FaceBook/infer-inferTraceBugs命令使用

來源:互聯網
上載者:User
inferTraceBugs 命令

查看看詳細錯誤詳細資料,一般我們可能直接去源碼檔案去看這些檔案,但是infer也為我們提供inferTraceBugs命令來查看.

命令詳細說明:

localhost:ios_hello wuxian$ inferTraceBugs --helpusage: inferTraceBugs [-h] [-o <directory>] [--only-show] [--no-source]                      [--select N] [--max-level N]Explore the error traces in Infer reports.optional arguments:  -h, --help            show this help message and exit  -o <directory>, --out <directory>                        Set the Infer results directory  --only-show           Show the list of reports and exit  --no-source           Do not print code excerpts  --select N            Select bug number N. If omitted, prompts you for                        input.  --max-level N         Level of nested procedure calls to show. Can be "max",                        in which case all levels are shown. If omitted,                        prompts you for input

inferTraceBugs命令定位某個問題的具體資訊,你可以通過上面的參數直接定位,也可以預設然後通過提示一步一步進入詳細資料介面.

我們採用預設的方式(inferTraceBugs)一步一步瞭解該命令的使用方式

執行該命令,首先列舉出所有的問題資訊

localhost:ios_hello wuxian$ inferTraceBugs0. /Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello/HelloWorldApp/AppDelegate.m:20: error: MEMORY_LEAK      memory dynamically allocated to shadowPath by call to CGPathCreateWithRect() at line 20, column 28 is not reachable after line 20, column 51. /Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello/HelloWorldApp/AppDelegate.m:25: error: RESOURCE_LEAK      resource acquired to fp by call to fopen() at line 25, column 8 is not released after line 25, column 52. /Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello/HelloWorldApp/AppDelegate.m:29: warning: PARAMETER_NOT_NULL_CHECKED      Parameter callback is not checked for null, there could be a null pointer dereference: pointer callback could be null and is dereferenced at line 29, column 53. /Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello/HelloWorldApp/AppDelegate.m:34: error: NULL_DEREFERENCE      pointer str last assigned on line 33 could be null and is dereferenced at line 34, column 124. /Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello/HelloWorldApp/AppDelegate.m:39: error: PREMATURE_NIL_TERMINATION_ARGUMENT      pointer str last assigned on line 38 could be nil which results in a call to arrayWithObjects: with 1 arguments instead of 3 (nil indicates that the last argument of this variadic method has been reached) at line 39, column 125. /Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello/HelloWorldApp/Hello.m:20: error: NULL_DEREFERENCE      pointer hello last assigned on line 19 could be null and is dereferenced at line 20, column 126. /Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello/HelloWorldApp/Hello.m:25: warning: IVAR_NOT_NULL_CHECKED      Instance variable hello -> _hello is not checked for null, there could be a null pointer dereference: pointer ret_hello last assigned on line 24 could be null and is dereferenced at line 25, column 127. /Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello/HelloWorldApp/Hello.m:30: warning: PARAMETER_NOT_NULL_CHECKED      Parameter hello is not checked for null, there could be a null pointer dereference: pointer ret_hello last assigned on line 29 could be null and is dereferenced at line 30, column 12
–select

上面的資訊顯示完成後,會有一個互動行,需要你輸入數字,這個數字是上面列舉的問題的序號,你不能輸入超過列舉問題序號的範圍,這個互動行就是沒有設定–select 參數出現的。

Choose report to display (default=0): 

我們輸入正確的數字(本例是0-7為有效值),比如:0

Choose report to display (default=0): 0

然後又有一個提示行 –max-level

設定嵌套調用的等級,暫不知道這個參數實際影響,因為我嘗試不同的值,結果都一樣。

Choose maximum level of nested procedures calls (default=max): max

然後infer會為我們顯示這條問題的詳細資料:

/Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello/HelloWorldApp/AppDelegate.m:20: error: MEMORY_LEAK   memory dynamically allocated to shadowPath by call to CGPathCreateWithRect() at line 20, column 28 is not reachable after line 20, column 5Showing all 2 steps of the trace/Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello/HelloWorldApp/AppDelegate.m:19: start of procedure memory_leak_bug17   @implementation AppDelegate18   19 > -(void) memory_leak_bug {20       CGPathRef shadowPath = CGPathCreateWithRect(self.inputView.bounds, NULL);21   }/Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello/HelloWorldApp/AppDelegate.m:20: 18   19   -(void) memory_leak_bug {20 >     CGPathRef shadowPath = CGPathCreateWithRect(self.inputView.bounds, NULL);21   }22   

上面的互動方式等同於

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.