mavak / trucov

True coverage tool for C / C++
1 stars 1 forks source link

Further normalize control-flow graphs #170

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Description
I think that we could potentially improve the control flow graphs with some 
normalization to condense normal blocks so that you don't have a long list of 
normal blocks in succession (i.e. one for line 89, one for line 90, one for 
line 92, etc.) Could potentially do a check of the block type and as long as 
it's not a branch or start/end block, add the line number to a list, then when 
a non-normal block is encountered as one of the next blocks, just output lines 
89...92. It would make the graphs more readable.

Not sure if this would be something we're interested in for the text reports 
since they only list missing lines/branches.

Any thoughts on this?

Files Affected (new and old)
dot_creator.cpp, dot_creator.h (at least)
Possibly parser class, parser_builder, etc.

Original issue reported on code.google.com by william....@gmail.com on 14 Sep 2010 at 5:18

GoogleCodeExporter commented 9 years ago
I really like that idea.  However, I worry that if the change isn't optional we 
loose some debugging information.  When something is wrong (bad parse, etc) 
it's really nice to look at the raw graph.

So lets at it as an option that is by default enabled.  Maybe just disable the 
graph minimization when --debug is passed in.

Original comment by j.nick.terry@gmail.com on 15 Sep 2010 at 3:04

GoogleCodeExporter commented 9 years ago
So one of the things I'm noticing with this is that when we see control flow 
graphs that show, for example, a separate blocks for lines 80, 81, 82, etc. (or 
even line 81, line 81, line 81) the reason for this separate listing isn't 
visually there until you throw trucov the --show-fake option.

Once --show-fake is used you see a fake arc coming out of the block in question 
and, in every case I've seen, connecting with the end block. So I guess GCC 
isn't grouping them because there are separate (exception?) arcs coming from 
the different blocks.

You can easily see something like this with a statement such as:
std::cout << "Hello, world!" << std::endl << std::cout << "What's up?" << 
std::endl;

If you look at the control flow graph of the line above, you'd see several 
blocks all with the same line number, and with --show-fake you'd see each block 
has a fake arc going to the exit block.

So we could take into consideration a few things if we wanted to further 
simplify the graphs:
- Ignore all fake arcs, look if block is normal (not a branch/end/start block), 
look if destination is normal, and if so, "absorb" it.
- Don't ignore all fake arcs, but instead see if their destinations (and 
number?) are the same between two blocks.

Or did anyone have in mind something else?

My guess is if you're going to use --show-fake, you wouldn't want the 
control-flow graph simplified anyway, so I don't think we'd need to worry about 
both simplifying and maintaining all of the fake arcs/blocks layout?

Original comment by william....@gmail.com on 2 Dec 2010 at 3:46