1 : // Copyright 2015 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 : #ifndef SYZYGY_REFINERY_ANALYZERS_ANALYZER_H_
16 : #define SYZYGY_REFINERY_ANALYZERS_ANALYZER_H_
17 :
18 : #include "syzygy/minidump/minidump.h"
19 : #include "syzygy/refinery/process_state/process_state.h"
20 :
21 : namespace refinery {
22 :
23 : // The interface implemented by analyzers. Each analyzer is responsible for
24 : // analyzing some part of the minidump and/or the process state. Analyzers will
25 : // for example extract memory/thread/module information from minidumps to
26 : // fill in the appropriate layers in the process state.
27 : // Other analyzers may work solely on the process state, by e.g. coalescing
28 : // overlapping, consistent data in a layer, propagating type information,
29 : // discovering references and the like.
30 : class Analyzer {
31 : public:
32 : enum AnalysisResult {
33 : ANALYSIS_COMPLETE,
34 : ANALYSIS_ITERATE,
35 : ANALYSIS_ERROR,
36 : };
37 :
38 E : virtual ~Analyzer() = 0 {};
39 :
40 : virtual const char* name() const = 0;
41 :
42 : // Analyze @p minidump and update @p process_state. Analysis may involve
43 : // examining @p process_state, and may be an iterative process.
44 : // @param minidump the minidump under analysis.
45 : // @param process_state the process_state that contains the results of the
46 : // analysis.
47 : // @returns an analysis result. An analyzer may not be invoked again after
48 : // it's returned ANALYSIS_COMPLETE. If an analyzer returns ANALYSIS_ERROR
49 : // @p process_state may be inconsistent.
50 : // @note Analysis completes only once all analyzers have returned
51 : // ANALYSIS_COMPLETED.
52 : virtual AnalysisResult Analyze(const minidump::Minidump& minidump,
53 : ProcessState* process_state) = 0;
54 : };
55 :
56 : } // namespace refinery
57 :
58 : #endif // SYZYGY_REFINERY_ANALYZERS_ANALYZER_H_
|