FaceBook/infer-Debug模式

Debug mode

参数

--debug--frontend_debug --debug

例如我们用debug模式分析iOS项目:

infer --debug -i -- xcodebuild -target HelloWorldApp -configuration Debug -sdk iphonesimulator

Starting analysis (Infer version v0.1.0)

make -k -j 4

/Users/wuxian/Downloads/infer-osx-v0.1.0/infer/infer/bin/InferAnalyze -allow_specs_cleanup -models /Users/wuxian/Downloads/infer-osx-v0.1.0/infer/infer/bin/../lib/java/models.jar -developer_mode -html -dotty -print_types -trace_error -project_root /Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello -results_dir '/Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello/infer-out' -cluster xcl1.cluster >cl1
/Users/wuxian/Downloads/infer-osx-v0.1.0/infer/infer/bin/InferAnalyze -allow_specs_cleanup -models /Users/wuxian/Downloads/infer-osx-v0.1.0/infer/infer/bin/../lib/java/models.jar -developer_mode -html -dotty -print_types -trace_error -project_root /Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello -results_dir '/Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello/infer-out' -cluster xcl3.cluster >cl3
/Users/wuxian/Downloads/infer-osx-v0.1.0/infer/infer/bin/InferAnalyze -allow_specs_cleanup -models /Users/wuxian/Downloads/infer-osx-v0.1.0/infer/infer/bin/../lib/java/models.jar -developer_mode -html -dotty -print_types -trace_error -project_root /Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello -results_dir '/Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello/infer-out' -cluster xcl4.cluster >cl4
/Users/wuxian/Downloads/infer-osx-v0.1.0/infer/infer/bin/InferAnalyze -allow_specs_cleanup -models /Users/wuxian/Downloads/infer-osx-v0.1.0/infer/infer/bin/../lib/java/models.jar -developer_mode -html -dotty -print_types -trace_error -project_root /Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello -results_dir '/Users/wuxian/Downloads/infer-osx-v0.1.0/infer/examples/ios_hello/infer-out' -cluster xcl2.cluster >cl2
echo "Analysis done"
Analysis done

4 files analyzed


/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 5

/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 5

/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 5

/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 12

/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 12

/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 12

/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 12

/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

输出的过程会有更多更详细的洗漱打印出来,且在结果目录下会生成更多的文件,多出来一些.dot和.html后缀的文件.

58deMacBook-Pro:infer-out wuxian$ tree
.
├── bugs.txt
├── captured
│   ├── AppDelegate.m.D2AC
│   │   ├── AppDelegate.m.cfg
│   │   ├── AppDelegate.m.cg
│   │   ├── AppDelegate.m.stats
│   │   ├── AppDelegate.m.tenv
│   │   ├── AppDelegate_application:didFinishLaunchingWithOptions:.dot
│   │   ├── AppDelegate_application:didFinishLaunchingWithOptions:.html
│   │   ├── AppDelegate_applicationDidBecomeActive:.dot
│   │   ├── AppDelegate_applicationDidBecomeActive:.html
│   │   ├── AppDelegate_applicationDidEnterBackground:.dot
│   │   ├── AppDelegate_applicationDidEnterBackground:.html
│   │   ├── AppDelegate_applicationWillEnterForeground:.dot
│   │   ├── AppDelegate_applicationWillEnterForeground:.html
│   │   ├── AppDelegate_applicationWillResignActive:.dot
│   │   ├── AppDelegate_applicationWillResignActive:.html
│   │   ├── AppDelegate_applicationWillTerminate:.dot
│   │   ├── AppDelegate_applicationWillTerminate:.html
│   │   ├── AppDelegate_memory_leak_bug.dot
│   │   ├── AppDelegate_memory_leak_bug.html
│   │   ├── AppDelegate_npe_in_array_literal_bug.dot
│   │   ├── AppDelegate_npe_in_array_literal_bug.html
│   │   ├── AppDelegate_parameter_not_null_checked_block_bug:.dot
│   │   ├── AppDelegate_parameter_not_null_checked_block_bug:.html
│   │   ├── AppDelegate_premature_nil_termination_argument_bug.dot
│   │   ├── AppDelegate_premature_nil_termination_argument_bug.html
│   │   ├── AppDelegate_resource_leak_bug.dot
│   │   ├── AppDelegate_resource_leak_bug.html
│   │   ├── AppDelegate_setWindow:.dot
│   │   ├── AppDelegate_setWindow:.html
│   │   ├── AppDelegate_window.dot
│   │   ├── AppDelegate_window.html
│   │   └── nodes
│   │       ├── node207.html
│   │       ├── node208.html
│   │       ├── node209.html
│   │       ├── node210.html
│   │       ├── node211.html
│   │       ├── node212.html
│   │       ├── node213.html
│   │       ├── node215.html
│   │       ├── node216.html
│   │       ├── node218.html
│   │       ├── node219.html
│   │       ├── node220.html
│   │       ├── node222.html
│   │       ├── node223.html
│   │       ├── node224.html
│   │       ├── node234.html
│   │       ├── node235.html
│   │       ├── node236.html
│   │       ├── node237.html
│   │       ├── node238.html
│   │       ├── node239.html
│   │       ├── node240.html
│   │       ├── node241.html
│   │       ├── node242.html
│   │       ├── node243.html
│   │       ├── node244.html
│   │       ├── node245.html
│   │       ├── node246.html
│   │       ├── node247.html
│   │       ├── node248.html
│   │       ├── node249.html
│   │       ├── node250.html
│   │       ├── node251.html
│   │       ├── node252.html
│   │       └── node253.html
│   ├── AppDelegate.m.D2AC.html
│   ├── Hello.m.D2AC
│   │   ├── Hello.m.cfg
│   │   ├── Hello.m.cg
│   │   ├── Hello.m.stats
│   │   ├── Hello.m.tenv
│   │   ├── Hello_hello.dot
│   │   ├── Hello_hello.html
│   │   ├── Hello_ivar_not_nullable_bug:.dot
│   │   ├── Hello_ivar_not_nullable_bug:.html
│   │   ├── Hello_null_dereference_bug.dot
│   │   ├── Hello_null_dereference_bug.html
│   │   ├── Hello_parameter_not_null_checked_bug:.dot
│   │   ├── Hello_parameter_not_null_checked_bug:.html
│   │   ├── Hello_return_hello.dot
│   │   ├── Hello_return_hello.html
│   │   ├── Hello_s.dot
│   │   ├── Hello_s.html
│   │   ├── Hello_setHello:.dot
│   │   ├── Hello_setHello:.html
│   │   ├── Hello_setS:.dot
│   │   ├── Hello_setS:.html
│   │   └── nodes
│   │       ├── node180.html
│   │       ├── node181.html
│   │       ├── node182.html
│   │       ├── node183.html
│   │       ├── node185.html
│   │       ├── node186.html
│   │       ├── node187.html
│   │       ├── node188.html
│   │       ├── node189.html
│   │       ├── node190.html
│   │       ├── node191.html
│   │       ├── node192.html
│   │       ├── node193.html
│   │       ├── node194.html
│   │       ├── node195.html
│   │       ├── node196.html
│   │       ├── node197.html
│   │       ├── node198.html
│   │       ├── node199.html
│   │       ├── node200.html
│   │       ├── node201.html
│   │       ├── node202.html
│   │       ├── node203.html
│   │       ├── node204.html
│   │       ├── node205.html
│   │       ├── node206.html
│   │       ├── node207.html
│   │       ├── node208.html
│   │       ├── node209.html
│   │       └── node210.html
│   ├── Hello.m.D2AC.html
│   ├── ViewController.m.D2AC
│   │   ├── ViewController.m.cfg
│   │   ├── ViewController.m.cg
│   │   ├── ViewController.m.stats
│   │   ├── ViewController.m.tenv
│   │   ├── ViewController_didReceiveMemoryWarning.dot
│   │   ├── ViewController_didReceiveMemoryWarning.html
│   │   ├── ViewController_viewDidLoad.dot
│   │   ├── ViewController_viewDidLoad.html
│   │   └── nodes
│   │       ├── node207.html
│   │       ├── node208.html
│   │       ├── node209.html
│   │       ├── node210.html
│   │       ├── node211.html
│   │       └── node212.html
│   ├── ViewController.m.D2AC.html
│   ├── main.m.D2AC
│   │   ├── main.m.cfg
│   │   ├── main.m.cg
│   │   ├── main.m.stats
│   │   ├── main.m.tenv
│   │   ├── main{A662}.dot
│   │   ├── main{A662}.html
│   │   └── nodes
│   │       ├── node207.html
│   │       ├── node208.html
│   │       └── node210.html
│   └── main.m.D2AC.html
├── log
│   ├── analyzer_err
│   └── analyzer_out
├── multicore
│   ├── Makefile
│   ├── cl1
│   ├── cl2
│   ├── cl3
│   ├── cl4
│   ├── xcl1.cluster
│   ├── xcl2.cluster
│   ├── xcl3.cluster
│   └── xcl4.cluster
├── procs.csv
├── report.csv
├── report.json
├── sources
│   ├── AppDelegate.m.D2AC
│   ├── Hello.m.D2AC
│   ├── ViewController.m.D2AC
│   └── main.m.D2AC
├── specs
│   ├── AppDelegate_application:didFinishLaunchingWithOptions:.specs
│   ├── AppDelegate_applicationDidBecomeActive:.specs
│   ├── AppDelegate_applicationDidEnterBackground:.specs
│   ├── AppDelegate_applicationWillEnterForeground:.specs
│   ├── AppDelegate_applicationWillResignActive:.specs
│   ├── AppDelegate_applicationWillTerminate:.specs
│   ├── AppDelegate_memory_leak_bug.specs
│   ├── AppDelegate_npe_in_array_literal_bug.specs
│   ├── AppDelegate_parameter_not_null_checked_block_bug:.specs
│   ├── AppDelegate_premature_nil_termination_argument_bug.specs
│   ├── AppDelegate_resource_leak_bug.specs
│   ├── AppDelegate_setWindow:.specs
│   ├── AppDelegate_window.specs
│   ├── Hello_hello.specs
│   ├── Hello_ivar_not_nullable_bug:.specs
│   ├── Hello_null_dereference_bug.specs
│   ├── Hello_parameter_not_null_checked_bug:.specs
│   ├── Hello_return_hello.specs
│   ├── Hello_s.specs
│   ├── Hello_setHello:.specs
│   ├── Hello_setS:.specs
│   ├── ViewController_didReceiveMemoryWarning.specs
│   ├── ViewController_viewDidLoad.specs
│   └── main{A662}.specs
├── stats.json
└── timing.dot

我们去captured/目录下打开一个html文件,如下:

FaceBook/infer-Debug模式_第1张图片

且每一个方法后来都有镜像的连接,点进入可以看到更详细的信息.

总结

Debug模式下生成的结果文件更详细,且有html格式,易读,推荐打开debug模式.但希望facebook出一份更详细的介绍文档,不然很难理解。

你可能感兴趣的:(测试工程师成长之路)