On 24/05/18 17:46, Gedare Bloom wrote:
On Thu, May 24, 2018 at 9:05 AM, Joel Sherrill <j...@rtems.org> wrote:

On Thu, May 24, 2018, 8:04 AM Gedare Bloom <ged...@rtems.org> wrote:
On Wed, May 23, 2018 at 2:28 AM, Sebastian Huber
<sebastian.hu...@embedded-brains.de> wrote:
On 23/05/18 01:06, Joel Sherrill wrote:
Or we may need to limit ourselves to source line mapping on a per
executable
basis. And generate reports using gcov output if we see methods change
between executables. I have shied away from gcov as the primary format
because I don't see how to do subexpression analysis.

   if (a == 0 || b == 1)

That's one line of source but two sub-expressions. Unless it's changed
recently, the debug info is not at a level of granularity to generate
gcov data that can tell we always too the first sub-expression.

I'm not arguing -- just saying that doing the analysis at the asm level
gives us branch information I don't think we get via source line
analysis and gcov.

Is the --all-blocks option of gcov helpful here?

https://gcc.gnu.org/onlinedocs/gcc/Invoking-Gcov.html#Invoking-Gcov

Yes, that seems like it should work to me.

Can you decipher the gcov output to see if it is working?
Not immediately, but maybe you can put together a simple example of a
subexpr that is 'dead code' to test with/without the option.

It seems that gcov already produces sub-expression branch counts without the -a option:

int ff(int a, int b)
{
        if (a != 0 && b != 0) {
                return 1;
        }

        return 0;
}

int ft(int a, int b)
{
        if (a != 0 && b != 0) {
                return 1;
        }

        return 0;
}

int tf(int a, int b)
{
        if (a != 0 && b != 0) {
                return 1;
        }

        return 0;
}

int tt(int a, int b)
{
        if (a != 0 && b != 0) {
                return 1;
        }

        return 0;
}

int main(void)
{
        ff(0, 0);
        ft(0, 1);
        tf(1, 0);
        tt(1, 1);
        return 0;
}

gcc -fprofile-arcs -ftest-coverage test.c
./a.out
gcov -b -c test.c
File 'test.c'
Lines executed:81.82% of 22
Branches executed:75.00% of 16
Taken at least once:37.50% of 16
Calls executed:100.00% of 4
Creating 'test.c.gcov'

cat test.c.gcov
        -:    0:Source:test.c
        -:    0:Graph:test.gcno
        -:    0:Data:test.gcda
        -:    0:Runs:1
        -:    0:Programs:1
function ff called 1 returned 100% blocks executed 60%
        1:    1:int ff(int a, int b)
        -:    2:{
        1:    3:        if (a != 0 && b != 0) {
branch  0 taken 0 (fallthrough)
branch  1 taken 1
branch  2 never executed
branch  3 never executed
    #####:    4:                return 1;
        -:    5:        }
        -:    6:
        1:    7:        return 0;
        -:    8:}
        -:    9:
function ft called 1 returned 100% blocks executed 60%
        1:   10:int ft(int a, int b)
        -:   11:{
        1:   12:        if (a != 0 && b != 0) {
branch  0 taken 0 (fallthrough)
branch  1 taken 1
branch  2 never executed
branch  3 never executed
    #####:   13:                return 1;
        -:   14:        }
        -:   15:
        1:   16:        return 0;
        -:   17:}
        -:   18:
function tf called 1 returned 100% blocks executed 80%
        1:   19:int tf(int a, int b)
        -:   20:{
        1:   21:        if (a != 0 && b != 0) {
branch  0 taken 1 (fallthrough)
branch  1 taken 0
branch  2 taken 0 (fallthrough)
branch  3 taken 1
    #####:   22:                return 1;
        -:   23:        }
        -:   24:
        1:   25:        return 0;
        -:   26:}
        -:   27:
function tt called 1 returned 100% blocks executed 80%
        1:   28:int tt(int a, int b)
        -:   29:{
        1:   30:        if (a != 0 && b != 0) {
branch  0 taken 1 (fallthrough)
branch  1 taken 0
branch  2 taken 1 (fallthrough)
branch  3 taken 0
        1:   31:                return 1;
        -:   32:        }
        -:   33:
    #####:   34:        return 0;
        -:   35:}
        -:   36:
function main called 1 returned 100% blocks executed 100%
        1:   37:int main(void)
        -:   38:{
        1:   39:        ff(0, 0);
call    0 returned 1
        1:   40:        ft(0, 1);
call    0 returned 1
        1:   41:        tf(1, 0);
call    0 returned 1
        1:   42:        tt(1, 1);
call    0 returned 1
        1:   43:        return 0;
        -:   44:}

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to