1 : // Copyright 2012 Google Inc.
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 a PDB mutator for adding basic-block addresses and sizes to a
16 : // named PDB stream.
17 :
18 : #ifndef SYZYGY_INSTRUMENT_MUTATORS_ADD_BB_RANGES_STREAM_H_
19 : #define SYZYGY_INSTRUMENT_MUTATORS_ADD_BB_RANGES_STREAM_H_
20 :
21 : #include "syzygy/core/address.h"
22 : #include "syzygy/core/address_space.h"
23 : #include "syzygy/pdb/mutators/add_named_stream_mutator.h"
24 :
25 : namespace instrument {
26 : namespace mutators {
27 :
28 : class AddBasicBlockRangesStreamPdbMutator
29 : : public pdb::mutators::AddNamedStreamMutatorImpl<
30 : AddBasicBlockRangesStreamPdbMutator> {
31 : public:
32 : typedef core::AddressRange<core::RelativeAddress, size_t>
33 : RelativeAddressRange;
34 : typedef std::vector<RelativeAddressRange> RelativeAddressRangeVector;
35 :
36 : // Constructor.
37 : // @param bb_ranges a reference to the vector that contains the
38 : // relative addresses associated with the basic blocks in an image. This
39 : // need not be populated at the time of construction, so long as it exists
40 : // before MutatePdb is called.
41 E : AddBasicBlockRangesStreamPdbMutator(
42 : const RelativeAddressRangeVector& bb_ranges)
43 : : bb_ranges_(bb_ranges) {
44 E : }
45 :
46 : protected:
47 : friend pdb::mutators::AddNamedStreamMutatorImpl<
48 : AddBasicBlockRangesStreamPdbMutator>;
49 : friend pdb::mutators::NamedPdbMutatorImpl<
50 : AddBasicBlockRangesStreamPdbMutator>;
51 :
52 : // Implementation of AddNamedStreamMutatorImpl.
53 : bool AddNamedStreams(const pdb::PdbFile& pdb_file);
54 :
55 : // Implementation of NamedPdbMutatorImpl.
56 : static const char kMutatorName[];
57 :
58 : const RelativeAddressRangeVector& bb_ranges_;
59 : };
60 :
61 : } // namespace mutators
62 : } // namespace instrument
63 :
64 : #endif // SYZYGY_INSTRUMENT_MUTATORS_ADD_BB_RANGES_STREAM_H_
|