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.

Gcov error with arm-none-eabi compiler

Hi,

      I am using arm-none-eabi-gcov compiler & arm-none-eabi-ld linker file with ceedling for unit testing.I am getting below error during compilation.Please give me proper compiler & linker setting .

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

Error message :
Test 'test_led.c'
-----------------
Compiling test_led_runner.c...
arm-none-eabi-gcov: invalid option -- m
Usage: gcov [OPTION]... SOURCE|OBJ...

Print code coverage information.

-h, --help Print this help, then exit
-v, --version Print version number, then exit
-a, --all-blocks Show information for every basic block
-b, --branch-probabilities Include branch probabilities in output
-c, --branch-counts Given counts of branches taken
rather than percentages
-n, --no-output Do not create an output file
-l, --long-file-names Use long output file names for included
source files
-f, --function-summaries Output summaries for each function
-o, --object-directory DIR|FILE Search for object files in DIR or called FILE
-s, --source-prefix DIR Source prefix to elide
-r, --relative-only Only show data for relative sources
-p, --preserve-paths Preserve all pathname components
-u, --unconditional-branches Show unconditional branch counts too
-d, --display-progress Display progress information

For bug reporting instructions, please see:
<gcc.gnu.org/bugs.html>.
ERROR: Shell command failed.
> Shell executed command:
'arm-none-eabi-gcov -c build/test/runners/test_led_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"C:/Ruby23/lib/ruby/gems/2.
3.0/gems/ceedling-0.25.0/vendor/unity/src" -I"C:/Ruby23/lib/ruby/gems/2.3.0/gems
/ceedling-0.25.0/vendor/cmock/src" -I"build/test/mocks" -Dgcov -o build/gcov/out
/test_led_runner.o'
> And exited with status: [1].

rake aborted!
ShellExecutionException: ShellExecutionException

Tasks: TOP => build/gcov/results/test_led.pass => build/gcov/out/test_led.bin =>
build/gcov/out/test_led_runner.o
(See full trace by running task with --trace)

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

ceedling yml file:

:gcov_compiler:
:executable: arm-none-eabi-gcov
:arguments:

- -c ${1}
- -std=c99 - -pedantic
- -g
- -fprofile-arcs
- -ftest-coverage
- -D$: COLLECTION_DEFINES_TEST_AND_VENDOR
- -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
- -Dgcov

- -c ${1} #source code input file (Ruby method call param list sub)

- -o ${2} #object file output (Ruby method call param list sub)

-:gcov_linker:
 :executable: arm-none-eabi-ld 
 :arguments:
 - -ftest-coverage
 - -fprofile-arcs
# - -O0 # never optimize for this
- -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_fixture:
:executable: ${1}
:gcov_report:
:executable: arm-none-eabi-gcov
:arguments:
- -n
- -p
- -b
- -o "$": GCOV_BUILD_OUTPUT_PATH
- "\"${1}\""

  • Hi,

         Please send me gcov linker flag setting for  arm-none-eabi-ld.My previous problem is solved by adding "- -fbranch-probabilities" at compiler.Now i am getting new Error for linker.( arm-none-eabi-ld). 

    Error:

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

    Test 'test_led.c'
    -----------------
    Compiling test_led_runner.c...
    Compiling test_led.c...
    Compiling mock_sysctl.c...
    Compiling mock_gpio.c...
    Compiling unity.c...
    Compiling led.c with coverage...
    Compiling cmock.c...
    Linking test_led.bin...
    arm-none-eabi-ld: unrecognized option '-DTEST'
    arm-none-eabi-ld: use the --help option for usage information
    ERROR: Shell command failed.
    > Shell executed command:
    'arm-none-eabi-ld -lgcov -fprofile-arcs -ftest-coverage -T project1.ld build/gco
    v/out/test_led_runner.o build/gcov/out/test_led.o build/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
    aWare/driverlib" -I"C:/Ruby23/lib/ruby/gems/2.3.0/gems/ceedling-0.25.0/vendor/un
    ity/src" -I"C:/Ruby23/lib/ruby/gems/2.3.0/gems/ceedling-0.25.0/vendor/cmock/src"
    -I"build/test/mocks" lib/gcc-arm-none-eabi-4_8-2014q3/lib/gcc/arm-none-eabi/4.8
    .4/armv7-m/libgcov.a lib/gcc-arm-none-eabi-4_8-2014q3/lib/gcc/arm-none-eabi/4.8.
    4/armv7-m/crtbegin.o lib/gcc-arm-none-eabi-4_8-2014q3/lib/gcc/arm-none-eabi/4.8.
    4/armv7-m/crtend.o lib/gcc-arm-none-eabi-4_8-2014q3/lib/gcc/arm-none-eabi/4.8.4/
    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'
    > And exited with status: [1].

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

    my ceddling yml file:

    :gcov_compiler:
    :executable: arm-none-eabi-gcov
    :arguments:
    - -fbranch-probabilities
    - -fprofile-arcs
    - -ftest-coverage
    - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR
    - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
    - -lgcov
    - -c ${1} #source code input file (Ruby method call param list sub)
    - -o ${2} #object file output (Ruby method call param list sub)
    :gcov_linker:
    :executable: arm-none-eabi-ld
    :arguments:
    - -fprofile-arcs
    - -ftest-coverage
     - -T project1.ld
    - ${1}

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

    - -o ${2}

  • Prashant Kothari said:
    Linking test_led.bin...
    arm-none-eabi-ld: unrecognized option '-DTEST'

    The -D option is not a valid option for the linker executable arm-none-eabi-ld (it is for the compiler though) . You would need to modify your command so the -D option does not get passed if invoking "ld" directly. Please see the GNU Linker documentation for more details.

  • Hi,

          I sets flag as per the GNU Linker document.Now i am getting another error.Please send me proper linker setting.

     Error message:


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


    Test 'test_led.c'
    -----------------
    Compiling test_led_runner.c...
    Compiling test_led.c...
    Compiling mock_sysctl.c...
    Compiling mock_gpio.c...
    Compiling unity.c...
    Compiling led.c with coverage...
    Compiling cmock.c...
    Linking test_led.bin...
    arm-none-eabi-ld: -f may not be used without -shared
    ERROR: Shell command failed.
    > Shell executed command:
    'arm-none-eabi-ld -T project1.ld -fprofile-arcs -ftest-coverage -o build/gcov/ou
    t/test_led.bin build/gcov/out/test_led_runner.o build/gcov/out/test_led.o build/
    gcov/out/mock_sysctl.o build/gcov/out/mock_gpio.o build/gcov/out/unity.o build/g
    cov/out/led.o build/gcov/out/cmock.o lib/gcc-arm-none-eabi-4_8-2014q3/lib/gcc/ar
    m-none-eabi/4.8.4/armv7-m/libgcov.a'
    > And exited with status: [1].

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

    compiler & linker yml file setting:

    :gcov_compiler:
    :executable:      arm-none-eabi-gcov
    :arguments:
    - -fbranch-probabilities
    - -g
    - -fprofile-arcs
    - -ftest-coverage
    - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR
    - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
    - -lgcov
    - -c ${1}             #source code input file (Ruby method call param list sub)
    - -o ${2}            #object file output (Ruby method call param list sub)


    :gcov_linker:
    :executable:       arm-none-eabi-ld
    :arguments:
    - -T project1.ld
    - -fprofile-arcs
    - -ftest-coverage
    - -o ${2}
    - ${1}
    - lib/gcc-arm-none-eabi-4_8-2014q3/lib/gcc/arm-none-eabi/4.8.4/armv7-m/libgcov.a

  • Prashant Kothari said:
    Please send me proper linker setting.

    I'm sorry but I'm not familiar enough with the gcov tool to suggest the recommended options to use. Your best resources for getting pointers on this would be the GCC docs/manuals or the GCC user community.