This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] 使用arm-none-eabi编译器时出现Gcov错误

Guru**** 2587365 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/604924/gcov-error-with-arm-none-eabi-compiler

您好,

   我正在使用带有  ceedling的arm-none-eabi-gcov编译器和arm-none-eabi-ld链接器文件进行单元测试。我在编译时遇到以下错误。请给出正确的编译器和链接器设置。

C:\Users\sameerk5\example-project>rake gcov:all

错误消息:
测试'test_led。c'
--------
正在编译test_led流道...
arm-none-eabi-gcov:无效选项-- m
用法:gcov [选项]... 源|对象...

打印代码覆盖率信息。

-h,-help打印此帮助,然后退出
-v,--version打印版本号,然后退出
-a,--all-blocks显示每个基本块的信息
-b,--branch-probabilities包括输出中的分支概率
-c,--branch-counts给定的分支计数
而不是百分比
-n,--no-output不创建输出文件
-l,--llong文件名将长输出文件名用于included
源文件
-f,--function-summaries每个函数的输出摘要
-o,--object-directory DIR|文件在DIR或被调用文件中搜索目标文件
-s,--source-prefix DIR Source prefix to elide
-r,--relative仅显示相对源的数据
-p,--preserve-paths保留所有路径名组件
-u,--cond条 件分支也显示无条件分支的计数
-d,--display-progress显示进度信息

有关错误报告说明,请参阅:
gcc.gnu.org/bugs.html>。
错误:Shell命令失败。
> Shell执行的命令:
'arm-none-eabi-gcov -c built/test/runs/set_leed_runner.c -mthumb-mcpu=cortex
-m4 -std=c99 -g -fprofile-arcs -ftest-coverage -DTest -DCODE_coverage -i"test"-
i "src"-i" lib/TivaWare"-i" lib/TivaWare/driverlib"-i"-I"C:/Ruby23/lib/ruby/GEMS/2.
3.0 /GEMS/ceedling-GEMS.0/vender/unity/srC" 0.25 -i "C:2.3 /Ruby23/lib/ruby/GEMS/GEMS.0/GEMS./GEMS.
/ceedling-Dgcov 0.25 -o build/gcov/out
/test_led_runner.o'
>并退出,状态为:[1]。

RAKE已中止!
ShellExecutionException: ShellExecutionException

任务:top => built/gcov/results/test_led.pass => built/gcov/out test_led.bin =>
build_gcov/out / test_led跑者.o
(通过使用--trace运行任务来查看完整跟踪)

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

ceedling yml文件:

:gcov_compiler:
:executable:arm-none-eabi-gcov
:参数:

--c ${1}
--std=c99 --pedantic
--g
--fprofile-arc
---FTEST-覆盖范围
-D$:collection_defines_test_and_vendor
-I"$":collection_paths_test_support_source_include_vendor
--Dgcov

--c ${1}#源代码输入文件(Ruby方法调用参数列表子项)

- o ${2}#object文件输出(Ruby方法调用参数列表子项)

-:gcov_linker:
 :可执行文件: arm-none-eabi-ld  
 :参数:
 ---FTEST-覆盖范围
 --fprofile-arc
#--O0 #从不为此进行优化
--T gcc.ld
-${1}
-D$:collection_defines_test_and_vendor
-I"$":collection_paths_test_support_source_include_vendor
-I"$":collection_paths_test_toolchain_include
- lib/gcc-arm-none-eabi-4_8-2014q3/lib/gcc/arm-none-eabi/libgcov.a

--o ${2}
:gcov_夹 具:
:可执行文件:${1}
:gcov_report:
:executable:arm-none-eabi-gcov
:参数:
--n
--p
--b
--o "$":GCOV_build_output_path
-"\"${1}\"

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好,

       请向我发送 arm-none-eabi-ld的gcov链接器标志设置。我以前的问题已通过在编译器中添加“--fbranch-probabilities”得到解决。现在我正在获取链接器的新错误。(arm-none-eabi-ld)。  

    错误:

    C:\Users\sameerk5\example-project>rake gcov:all

    测试'test_led。c'
    --------
    正在编译test_led流道...
    正在编译test_led...
    正在编译mock_sysctl.c....
    正在编译mock_gPIC....
    正在编译unity ...
    正在编译带覆盖范围的LED.c ...
    正在编译cmock.c....
    正在链接test_led.bin...
    arm-none-eabi-ld:无法识别的选项'-DTest'
    arm-none-eabi-ld:使用--help选项获取使用信息
    错误:Shell命令失败。
    > Shell执行的命令:
    'arm-none-eabi-ld -lgcov -fprofile-arces -ftest-coverage -T project1.ld build/GCO
    v/out / test_led_runner.o built/gcov/out / test_led.o built/gcov/out / mock_sysctl.o b
    uild/gcov/out / mock_gPIO.o build/gcov/out / unity .o build/gcov/out /led.o build/gcov
    /out / cmock.o -DTest -DCODE_Coverage -i" test"-i" src"-i" lib/TivaWare"-i" lib/Tiv
    awaer/driverlib"-I" C:2.3 0.25 /Ruby23/lib/rubi/gems/gems/gems.0/gems/ceedling-gema.0/vender/un
    {\f2 /}{\f2 /}{\f2}{\f2}}{\f2 -I}C:{\f2 /Ruby23/lib/ruby/GEMS/GEMS.0/GEMS/GEMS/Ceedling- 2.3 }{\f2 0.25 }{\f2 .0/vendor/cmock/src}
    -i"build_test/mocks" lib/gcc-arm-none-eabi-4_8-2014q3/lib/gcc/gcc/arm-none-eabi/none" 4.8
    .4/armv7-m/libgcov.a 4.8。
    4/armv7-m/crtbegin.o 4.8。
    4/armv7-m/crtend.o lib/gcc-arm-none-eabi-4_8-2014q3/lib/gcc/arm-none-eabi/eabi.4/ 4.8
    armv7-m/crti.o lib/gcc-arm-none-eabi-4_8-2014q3/lib/gcc/arm-none-eabi -o build_g
    COV/OUT / TEST_LED.BIN'(COV/OUT /测试LED .BIN)
    >并退出,状态为:[1]。

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    我的ceddling yml文件:

    :gcov_compiler:
    :executable:arm-none-eabi-gcov
    :参数:
    --fbranch-probabilities
    --fprofile-arc
    ---FTEST-覆盖范围
    -D$:collection_defines_test_and_vendor
    -I"$":collection_paths_test_support_source_include_vendor
    --lgcov
    --c ${1}#源代码输入文件(Ruby方法调用参数列表子项)
    - o ${2}#object文件输出(Ruby方法调用参数列表子项)
    :gcov_linker:
    :可执行文件: arm-none-eabi-ld
    :参数:
    --fprofile-arc
    ---FTEST-覆盖范围
     -T project1.ld
    -${1}

    - 4.8 lib/gcc-arm-none-eabi-4_8-2014q3/lib/gcc/arm-none-eabi/lib.4/armv7-m/libgcov.a  

    --o ${2}

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Linking test_led.bin...(报价用户="Prashant Kothari">链接test_led.bin...)
    arm-none-eabi-ld:无法识别的选项'-DTest'

    D选项不是链接程序可执行文件 arm-none-eabi-ld的有效选项(尽管它是用于编译器)。 您需要修改命令,以便直接调用"ld"时不会传递-D选项。 有关详细信息,请参阅GNU链接器文档。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好,

       我根据 GNU链接器文档设置标志。现在我收到另一个错误。请给我发送正确的链接器设置。

     错误消息:


    C:\Users\sameerk5\example-project>rake gcov:all


    测试'test_led。c'
    --------
    正在编译test_led流道...
    正在编译test_led...
    正在编译mock_sysctl.c....
    正在编译mock_gPIC....
    正在编译unity ...
    正在编译带覆盖范围的LED.c ...
    正在编译cmock.c....
    正在链接test_led.bin...
    arm-none-eabi-ld:-f不能在不使用-shared的情况下使用
    错误:Shell命令失败。
    > Shell执行的命令:
    'arm-none-eabi-ld -T project1.ld -fprofile-arces -ftest-coverage -o build/gcov/ou
    t/test_led.bin built/gcov/out / test_led跑者.o built/gcov/out / test_led。o built/
    gcov/out / mock_sysctl.o built/gcov/out / mock_gPIO.o built/gcov/out / unity .o built/g
    cov/out /led.o build_gcov/out /cmock.o lib/gcc-arm-none-eabi-4_8-2014q3/lib/gcc/ar
    m-none-eabi/arm.4/armv7-m/libgcov.a' 4.8
    >并退出,状态为:[1]。

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    编译器和链接器yml文件设置:

    :gcov_compiler:
    :executable:   arm-none-eabi-gcov
    :参数:
    --fbranch-probabilities
    --g
    --fprofile-arc
    ---FTEST-覆盖范围
    -D$:collection_defines_test_and_vendor
    -I"$":collection_paths_test_support_source_include_vendor
    --lgcov
    --c ${1}       #源代码输入文件(Ruby方法调用参数列表子项)
    --o ${2}       #object文件输出(Ruby方法调用参数列表子项)


    :gcov_linker:
    :可执行文件:   arm-none-eabi-ld
    :参数:
    -T project1.ld
    --fprofile-arc
    ---FTEST-覆盖范围
    --o ${2}
    -${1}
    - 4.8 lib/gcc-arm-none-eabi-4_8-2014q3/lib/gcc/arm-none-eabi/lib.4/armv7-m/libgcov.a

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Prashant Kothari 说:
    请向我发送正确的链接器设置。[/QUOT]

    很抱歉,我对gcov工具的熟悉程度不够,无法建议使用的推荐选项。 获取有关此方面的建议的最佳资源是GCC文档/手册或GCC用户社区。