-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BRDA Branch coverage #334
Comments
Perhaps, just terminology confusion and/or unfortunate choice of label names. The 'block id' of the branch record has nothing to do with basic blocks in the code. It is just a name, used to distinguish the branch expression when there is more than one instance - for example, when a template method is instantiated multiple times and the expression is different (say, due to constant propagation) in one or more of them. You can see a similar effect in C code using macros. The 'branch' element is often just an index (coming from subexpression traversal order, in LLVM or GCC, for example) - but it can be a (more useful) user-readable string (see the perl2lcov output, for example). Probably the best way to understand all of this is to write and execute a few small examples - and see what the result looks like. More definitive understanding will come from reading the relevant sections of GCC and/or LLVM source code. |
Thanks for your response. |
Can you describe what you are trying to do (as opposed to asking detailed questions about file content). Reading between the lines: I think you want to keep track either of call sites - possibly to keep a count of the number of times the function was called from each location in the source code, or possibly to keep track of path information/which lines/branches in the function were executed from each call site. For the former: I think you can do it with either LLVM profdata or gcov data (gcno/gcda). I don't think either contains enough information to reconstruct the latter. With respect to the gcov data, I think that you would need to read the elf/dwarf (or hackily parse the source) to find the callers - then simply record the hit count of the corresponding statement or basic block. |
Thanks for your response.
When the judgment condition is true, is the branch number 0 or 1
|
You still haven't said what you are trying to do. Typically, it is easier and faster to start with the goal and then figure out the best way to get there, rather than to incrementally explore details along some path that might not even be a fruitful .one. For gcov-generated data: even IDs are the 'true' side, odd IDs are 'false'. Other tools (e.g., perl, python, llvm-cov, and perhaps others) may name (or number) differently. (You can see this in the regression tests.) |
I'm just confused about the information in the BRDA line, and I am not sure about the block number and branch number. Now I have a basic understanding, thank you very much. |
Exception handling. Taken/not taken. |
This was a question - not an issue - and hasn't seen an update in about a month - so closing this now. |
In the .info file, there is information:
BRDA:<line_number>,<block>,<branch>,<taken>
How should I understand the block number? I have a .info file with some information:
The corresponding source code is:
I understand that a basic block is a sequence of continuous instructions that are not interrupted by branches or jump instructions during program execution. So why does the code here all belong to the same block number 0? How should I understand the basic blocks here?
The text was updated successfully, but these errors were encountered: