OLD | NEW |
1 // Copyright 2017 Google Inc. All Rights Reserved. | 1 // Copyright 2017 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 } | 194 } |
195 | 195 |
196 bool AFLTransform::OnBlock(const TransformPolicyInterface* policy, | 196 bool AFLTransform::OnBlock(const TransformPolicyInterface* policy, |
197 BlockGraph* block_graph, | 197 BlockGraph* block_graph, |
198 BlockGraph::Block* block) { | 198 BlockGraph::Block* block) { |
199 total_blocks_++; | 199 total_blocks_++; |
200 | 200 |
201 if (block->type() != BlockGraph::CODE_BLOCK) | 201 if (block->type() != BlockGraph::CODE_BLOCK) |
202 return true; | 202 return true; |
203 | 203 |
| 204 // We exclude gap blocks early to not bias the percentage of instrumentation. |
| 205 // Some binaries have a lot of them and give the impression of a poor |
| 206 // instrumentation ratio when it is actually not the case. |
| 207 // It also avoids to have stdout flooded when using the verbose mode and |
| 208 // not forcing decomposition (as the PE policy rejects gap blocks). |
| 209 if (block->attributes() & BlockGraph::GAP_BLOCK) |
| 210 return true; |
| 211 |
204 total_code_blocks_++; | 212 total_code_blocks_++; |
205 | 213 |
206 // Use the policy to skip blocks that aren't eligible for basic block | 214 // Use the policy to skip blocks that aren't eligible for basic block |
207 // decomposition. Let the user be able to override it though. | 215 // decomposition. Let the user be able to override it though. |
208 if (!force_decompose_) { | 216 if (!force_decompose_) { |
209 if (!policy->BlockIsSafeToBasicBlockDecompose(block)) { | 217 if (!policy->BlockIsSafeToBasicBlockDecompose(block)) { |
210 VLOG(1) << "Not instrumenting " << block->name(); | 218 VLOG(1) << "Not instrumenting " << block->name(); |
211 return true; | 219 return true; |
212 } | 220 } |
213 } | 221 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 } else { | 340 } else { |
333 bb_ranges_.push_back(source_range); | 341 bb_ranges_.push_back(source_range); |
334 } | 342 } |
335 } | 343 } |
336 | 344 |
337 return true; | 345 return true; |
338 } | 346 } |
339 | 347 |
340 } // namespace transforms | 348 } // namespace transforms |
341 } // namespace instrument | 349 } // namespace instrument |
OLD | NEW |