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 : #include "syzygy/instrument/instrumenters/bbentry_instrumenter.h"
16 :
17 : #include "base/file_util.h"
18 : #include "base/logging.h"
19 : #include "syzygy/common/application.h"
20 : #include "syzygy/pe/image_filter.h"
21 :
22 : namespace instrument {
23 : namespace instrumenters {
24 :
25 : const char BasicBlockEntryInstrumenter::kAgentDllBasicBlockEntry[] =
26 : "basic_block_entry_client.dll";
27 :
28 : BasicBlockEntryInstrumenter::BasicBlockEntryInstrumenter()
29 E : : inline_fast_path_(false) {
30 E : agent_dll_ = kAgentDllBasicBlockEntry;
31 E : }
32 :
33 E : bool BasicBlockEntryInstrumenter::InstrumentImpl() {
34 : bbentry_transform_.reset(
35 E : new instrument::transforms::BasicBlockEntryHookTransform());
36 E : bbentry_transform_->set_instrument_dll_name(agent_dll_);
37 E : bbentry_transform_->set_inline_fast_path(inline_fast_path_);
38 E : bbentry_transform_->set_src_ranges_for_thunks(debug_friendly_);
39 E : relinker_->AppendTransform(bbentry_transform_.get());
40 :
41 : add_bb_addr_stream_mutator_.reset(new
42 : instrument::mutators::AddIndexedDataRangesStreamPdbMutator(
43 : bbentry_transform_->bb_ranges(),
44 E : common::kBasicBlockRangesStreamName));
45 E : relinker_->AppendPdbMutator(add_bb_addr_stream_mutator_.get());
46 :
47 E : return true;
48 E : }
49 :
50 : bool BasicBlockEntryInstrumenter::ParseAdditionalCommandLineArguments(
51 E : const CommandLine* command_line) {
52 : // Parse the additional command line arguments.
53 E : inline_fast_path_ = command_line->HasSwitch("inline-fast-path");
54 :
55 E : return true;
56 E : }
57 :
58 : } // namespace instrumenters
59 : } // namespace instrument
|