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 : // An interface used to simulate block events.
16 :
17 : #ifndef SYZYGY_SIMULATE_SIMULATION_EVENT_HANDLER_H_
18 : #define SYZYGY_SIMULATE_SIMULATION_EVENT_HANDLER_H_
19 :
20 : #include "base/time/time.h"
21 : #include "syzygy/block_graph/block_graph.h"
22 : #include "syzygy/trace/protocol/call_trace_defs.h"
23 :
24 m : namespace simulate {
25 :
26 : // This pure virtual interface handles the event dispatching of other
27 : // Simulation classes. It's supposed to be used by Simulator, and each
28 : // On... function to be the rough equivalent to another function
29 : // in ParseEventHandler.
30 m : class SimulationEventHandler {
31 m : public:
32 : // Issued once, prior to the first OnFunctionEntry event in each
33 : // instrumented module.
34 : // @param time The entry time of this process.
35 : // @param default_page_size The page size to be used, or 0 to use a default
36 : // page size.
37 m : virtual void OnProcessStarted(base::Time time, size_t default_page_size) = 0;
38 :
39 : // Issued for all function entry traces.
40 : // @param time The entry time of this function.
41 : // @param block_start The first relative address of the code block.
42 : // @param block Information about the function block.
43 m : virtual void OnFunctionEntry(
44 m : base::Time time,
45 m : const block_graph::BlockGraph::Block* block) = 0;
46 :
47 : // Serializes the data to JSON.
48 : // @param output The output FILE.
49 : // @param pretty_print Pretty printing on the JSON file.
50 : // @returns true on success, false on failure.
51 m : virtual bool SerializeToJSON(FILE* output, bool pretty_print) = 0;
52 m : };
53 :
54 m : } // namespace simulate
55 :
56 : #endif // SYZYGY_SIMULATE_SIMULATION_EVENT_HANDLER_H_
|