1 : // Copyright 2013 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (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
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 : //
15 : // Declares helper functions for dealing with filters and determining whether or
16 : // not a given block, basic block or instruction should be instrumented or
17 : // transformed.
18 :
19 : #ifndef SYZYGY_BLOCK_GRAPH_FILTER_UTIL_H_
20 : #define SYZYGY_BLOCK_GRAPH_FILTER_UTIL_H_
21 :
22 : #include "syzygy/block_graph/basic_block.h"
23 : #include "syzygy/block_graph/block_graph.h"
24 : #include "syzygy/core/address_filter.h"
25 :
26 m : namespace block_graph {
27 :
28 m : typedef core::AddressFilter<core::RelativeAddress, size_t>
29 m : RelativeAddressFilter;
30 :
31 : // Determines if the given @p block is filtered. A block is filtered if any of
32 : // it's source data is marked in the filter.
33 : // @param filter The filter to be checked.
34 : // @param block The block to be checked.
35 : // @returns true if the block is filtered, false otherwise.
36 m : bool IsFiltered(const RelativeAddressFilter& filter,
37 m : const block_graph::BlockGraph::Block* block);
38 :
39 : // Determines if the given @p basic_block is filtered. A basic block is filtered
40 : // if any of its source data is marked in the filter.
41 : // @param filter The filter to be checked.
42 : // @param basic_block The basic block to be checked.
43 : // @returns true if the basic block is filtered, false otherwise.
44 m : bool IsFiltered(const RelativeAddressFilter& filter,
45 m : const block_graph::BasicBlock* basic_block);
46 m : bool IsFiltered(const RelativeAddressFilter& filter,
47 m : const block_graph::BasicCodeBlock* basic_block);
48 m : bool IsFiltered(const RelativeAddressFilter& filter,
49 m : const block_graph::BasicDataBlock* basic_block);
50 :
51 : // Determines if the given instruction is filtered. An instruction is filtered
52 : // if any of its source data is marked in the given filter.
53 : // @param filter The filter to be checked.
54 : // @param instruction The instruction to be checked.
55 : // @returns true if the instruction is filtered, false otherwise.
56 m : bool IsFiltered(const RelativeAddressFilter& filter,
57 m : const block_graph::Instruction& instruction);
58 :
59 m : } // namespace block_graph
60 :
61 : #endif // SYZYGY_BLOCK_GRAPH_FILTER_UTIL_H_
|