1 : // Copyright 2012 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 a PDB mutator for adding indexed data addresses and sizes to a
16 : // named PDB stream.
17 :
18 : #ifndef SYZYGY_INSTRUMENT_MUTATORS_ADD_INDEXED_DATA_RANGES_STREAM_H_
19 : #define SYZYGY_INSTRUMENT_MUTATORS_ADD_INDEXED_DATA_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 AddIndexedDataRangesStreamPdbMutator
29 : : public pdb::mutators::AddNamedStreamMutatorImpl<
30 : AddIndexedDataRangesStreamPdbMutator> {
31 : public:
32 : typedef core::AddressRange<core::RelativeAddress, size_t>
33 : RelativeAddressRange;
34 : typedef std::vector<RelativeAddressRange> RelativeAddressRangeVector;
35 :
36 : // Constructor.
37 : // @param indexed_data_ranges A reference to the vector that contains the
38 : // relative addresses associated with the indexed data 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 : // @param stream_name The name to give to the stream we're adding.
42 : AddIndexedDataRangesStreamPdbMutator(
43 : const RelativeAddressRangeVector& indexed_data_ranges,
44 : std::string stream_name)
45 : : indexed_data_ranges_(indexed_data_ranges),
46 E : stream_name_(stream_name) {
47 E : }
48 :
49 : protected:
50 : friend pdb::mutators::AddNamedStreamMutatorImpl<
51 : AddIndexedDataRangesStreamPdbMutator>;
52 : friend pdb::mutators::NamedPdbMutatorImpl<
53 : AddIndexedDataRangesStreamPdbMutator>;
54 :
55 : // Implementation of AddNamedStreamMutatorImpl.
56 : bool AddNamedStreams(const pdb::PdbFile& pdb_file);
57 :
58 : // Implementation of NamedPdbMutatorImpl.
59 : static const char kMutatorName[];
60 :
61 : std::string stream_name_;
62 :
63 : const RelativeAddressRangeVector& indexed_data_ranges_;
64 : };
65 :
66 : } // namespace mutators
67 : } // namespace instrument
68 :
69 : #endif // SYZYGY_INSTRUMENT_MUTATORS_ADD_INDEXED_DATA_RANGES_STREAM_H_
|