配置ndk-build的覆盖率

lar*_*aca 6 gcc android-ndk coverity

我想使用覆盖率进行静态分析,我需要它用于c ++.由于我的项目使用Android NDK,我将编译器配置为:

cov-configure –comptype gcc –compiler ~/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc-4.6
Run Code Online (Sandbox Code Playgroud)

然后我跑了 cov-build –dir coverity ndk-build –j8 NDK_DEBUG=1

一切都在建立,但我有一个警告

*[*WARNING] No files were emitted. This may be due to a problem with your configuration
or because no files were actually compiled by your build command.
Please make sure you have configured the compilers actually used in the compilation.**
Run Code Online (Sandbox Code Playgroud)

所以我忽略了警告并跑了

cov-analyze –dir coverity –all
**Coverity Static Analysis for C/C++ version 6.6.1 on Linux 2.6.38-8-server x86_64
Internal version numbers: d614fc01a4 p-eureka-push-15003.308

Looking for translation units
Error: no matching translation units.**
Run Code Online (Sandbox Code Playgroud)

我的编译器配置正确吗?有人为之前为Android NDK配置了编译器吗?

OlP*_*lPo 6

你表示编译器是〜/ android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc-4.6

确保这是命令中正确的完整路径(可能替换'〜'?),arm-linux-androideabi-gcc-4.6正是用于编译的内容.

我有同样的问题,因为Coverity期望使用GCC,但我的构建使用cc!

然后我设置:

~/coverity-current/bin/cov-configure --compiler /usr/bin/cc --comptype gcc
Run Code Online (Sandbox Code Playgroud)

它显示:

[WARNING] A template configuration is recommended for this compiler.
Add "--template" to your command line, or use one of the
template configuration shortcut command lines below:

  cov-configure --gcc      # GNU C/C++ compiler (gcc/g++)
  cov-configure --msvc     # Microsoft C/C++ compiler (cl)
  cov-configure --java     # Sun Java compiler (javac)

You must remove the specific configuration before re-running with "--template".
* Configuring /usr/bin/cc as a C compiler
[WARNING] Config gcc-config-2 already exists for cc gcc gcc-4.8 as gcc and will be reused. 
* Configuring /usr/bin/cc as a C++ compiler
[WARNING] Config g++-config-2 already exists for cc gcc gcc-4.8 as g++ and will be reused. 

Generated coverity_config.xml at location /home/default/cov-analysis-linux64-X.X.X/config/coverity_config.xml
Successfully generated configuration for the compilers: cc gcc gcc-4.8
Run Code Online (Sandbox Code Playgroud)

cov-build命令是:

../../coverity-current/bin/cov-build --dir ~/build_cov/myapp/cov-log-all-output make -C ~/build_cov/myapp
Run Code Online (Sandbox Code Playgroud)

结果:

../../coverity-current/bin/cov-build --dir ~/build_cov/myapp/cov-log-all-output make -C ~/build_cov/myapp

[...]

76 C/C++ compilation units (100%) are ready for analysis
The cov-build utility completed successfully.
Run Code Online (Sandbox Code Playgroud)

你在cov-log-all-output/c/emit/pcname /中有一个更大的emit-db文件


小智 1

在 coverity/build-log.txt 中,您应该看到构建期间执行的所有命令(查找“EXECUTING:”)。仔细检查编译器命令是否与您指定给 cov-configure 的编译器匹配。您可以配置多个编译器,并且配置通用 gcc(“cov-configure --gcc”)可能会很有用。

请记住,如果您的 ndk-build 实际上没有构建任何内容,那么 cov-build 将给出类似的消息。换句话说,该消息并不总是表明存在问题 - 构建可能已完成但实际上并未编译任何文件。