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/instrumenter_with_agent.h"
16 :
17 : #include "base/logging.h"
18 :
19 : namespace instrument {
20 : namespace instrumenters {
21 :
22 : bool InstrumenterWithAgent::DoCommandLineParse(
23 E : const base::CommandLine* command_line) {
24 E : if (!Super::DoCommandLineParse(command_line))
25 E : return false;
26 :
27 E : if (!agent_dll_.empty()) {
28 E : LOG(INFO) << "Default agent DLL for " << InstrumentationMode() << " mode "
29 : << "is \"" << agent_dll_ << "\".";
30 : }
31 :
32 : // Parse the custom agent if one is specified.
33 E : if (command_line->HasSwitch("agent")) {
34 E : std::string new_agent_dll = command_line->GetSwitchValueASCII("agent");
35 E : if (new_agent_dll != agent_dll_) {
36 E : agent_dll_ = new_agent_dll;
37 E : LOG(INFO) << "Using custom agent DLL \"" << agent_dll_ << "\".";
38 : }
39 E : }
40 :
41 E : return true;
42 E : }
43 :
44 : bool InstrumenterWithAgent::CheckCommandLineParse(
45 E : const base::CommandLine* command_line) {
46 E : if (agent_dll_.empty()) {
47 E : LOG(ERROR) << "No agent DLL has been specified.";
48 E : return false;
49 : }
50 :
51 E : return Super::CheckCommandLineParse(command_line);
52 E : }
53 :
54 : } // namespace instrumenters
55 : } // namespace instrument
|