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 the basic block entry instrumenter.
16 : #ifndef SYZYGY_INSTRUMENT_INSTRUMENTERS_BBENTRY_INSTRUMENTER_H_
17 : #define SYZYGY_INSTRUMENT_INSTRUMENTERS_BBENTRY_INSTRUMENTER_H_
18 :
19 : #include <string>
20 :
21 : #include "base/command_line.h"
22 : #include "syzygy/instrument/instrumenters/instrumenter_with_agent.h"
23 : #include "syzygy/instrument/mutators/add_indexed_data_ranges_stream.h"
24 : #include "syzygy/instrument/transforms/basic_block_entry_hook_transform.h"
25 : #include "syzygy/pe/pe_relinker.h"
26 :
27 : namespace instrument {
28 : namespace instrumenters {
29 :
30 : class BasicBlockEntryInstrumenter : public InstrumenterWithAgent {
31 : public:
32 : typedef InstrumenterWithAgent Super;
33 :
34 : BasicBlockEntryInstrumenter();
35 E : ~BasicBlockEntryInstrumenter() { }
36 :
37 : protected:
38 : // The name of the agent for this mode of instrumentation.
39 : static const char kAgentDllBasicBlockEntry[];
40 :
41 : // @name InstrumenterWithAgent overrides.
42 : // @{
43 : bool InstrumentPrepare() override;
44 : bool InstrumentImpl() override;
45 i : const char* InstrumentationMode() override { return "bbentry"; }
46 : // @}
47 :
48 : // @name Super overrides.
49 : // @{
50 : bool DoCommandLineParse(const base::CommandLine* command_line) override;
51 : // @}
52 :
53 : // @name Command-line parameters.
54 : // @{
55 : bool inline_fast_path_;
56 : // @}
57 :
58 : // The transform for this agent.
59 : scoped_ptr<instrument::transforms::BasicBlockEntryHookTransform>
60 : bbentry_transform_;
61 :
62 : // The PDB mutator for this agent.
63 : scoped_ptr<instrument::mutators::AddIndexedDataRangesStreamPdbMutator>
64 : add_bb_addr_stream_mutator_;
65 : };
66 :
67 : } // namespace instrumenters
68 : } // namespace instrument
69 :
70 : #endif // SYZYGY_INSTRUMENT_INSTRUMENTERS_BBENTRY_INSTRUMENTER_H_
|