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 Asan instrumenter.
16 : #ifndef SYZYGY_INSTRUMENT_INSTRUMENTERS_ASAN_INSTRUMENTER_H_
17 : #define SYZYGY_INSTRUMENT_INSTRUMENTERS_ASAN_INSTRUMENTER_H_
18 :
19 : #include <string>
20 :
21 : #include "base/command_line.h"
22 : #include "syzygy/common/asan_parameters.h"
23 : #include "syzygy/instrument/instrumenters/instrumenter_with_agent.h"
24 : #include "syzygy/instrument/transforms/allocation_filter_transform.h"
25 : #include "syzygy/instrument/transforms/asan_transform.h"
26 : #include "syzygy/pe/image_filter.h"
27 : #include "syzygy/pe/pe_relinker.h"
28 :
29 : namespace instrument {
30 : namespace instrumenters {
31 :
32 : class AsanInstrumenter : public InstrumenterWithAgent {
33 : public:
34 : AsanInstrumenter();
35 :
36 E : ~AsanInstrumenter() { }
37 :
38 : protected:
39 : // The name of the agent for this mode of instrumentation.
40 : static const char kAgentDllAsan[];
41 :
42 : // @name InstrumenterWithAgent overrides.
43 : // @{
44 : virtual bool ImageFormatIsSupported(ImageFormat image_format) OVERRIDE;
45 : virtual bool InstrumentImpl() OVERRIDE;
46 E : virtual const char* InstrumentationMode() OVERRIDE { return "asan"; }
47 : virtual bool ParseAdditionalCommandLineArguments(
48 : const CommandLine* command_line) OVERRIDE;
49 : // @}
50 :
51 : // @name Command-line parameters.
52 : // @{
53 : base::FilePath filter_path_;
54 : bool use_interceptors_;
55 : bool remove_redundant_checks_;
56 : bool use_liveness_analysis_;
57 : double instrumentation_rate_;
58 : bool asan_rtl_options_;
59 : // @}
60 :
61 : // Valid if asan_rtl_options_ is true.
62 : common::InflatedAsanParameters asan_params_;
63 :
64 : // The transform for this agent.
65 : scoped_ptr<instrument::transforms::AsanTransform> asan_transform_;
66 :
67 : // The image filter (optional).
68 : scoped_ptr<pe::ImageFilter> filter_;
69 :
70 : // Path to the JSON configuration file for the AllocationFilter transform.
71 : // The AllocationFilter tranform is only applied if this config file is
72 : // specified.
73 : base::FilePath allocation_filter_config_file_path_;
74 :
75 : // The AllocationFilter transform.
76 : // TODO(sebmarchand): Write some integration tests for this.
77 : scoped_ptr<instrument::transforms::AllocationFilterTransform> af_transform_;
78 : };
79 :
80 : } // namespace instrumenters
81 : } // namespace instrument
82 :
83 : #endif // SYZYGY_INSTRUMENT_INSTRUMENTERS_ASAN_INSTRUMENTER_H_
|