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_STACK_FRAME_ANALYZER_H_
16 : #define SYZYGY_REFINERY_ANALYZERS_STACK_FRAME_ANALYZER_H_
17 :
18 : #include <dia2.h>
19 :
20 : #include "base/macros.h"
21 : #include "base/memory/ref_counted.h"
22 : #include "syzygy/refinery/analyzers/analyzer.h"
23 : #include "syzygy/refinery/process_state/process_state_util.h"
24 : #include "syzygy/refinery/symbols/dia_symbol_provider.h"
25 : #include "syzygy/refinery/symbols/symbol_provider.h"
26 : #include "syzygy/refinery/types/type_repository.h"
27 :
28 m : namespace refinery {
29 :
30 : // The stack frame analyzer populates the process state with information
31 : // about the contents of stack frames.
32 m : class StackFrameAnalyzer : public Analyzer {
33 m : public:
34 m : StackFrameAnalyzer(scoped_refptr<DiaSymbolProvider> dia_symbol_provider,
35 m : scoped_refptr<SymbolProvider> symbol_provider);
36 :
37 m : const char* name() const override { return kStackFrameAnalyzerName; }
38 :
39 m : AnalysisResult Analyze(const minidump::Minidump& minidump,
40 m : ProcessState* process_state) override;
41 :
42 m : private:
43 m : bool AnalyzeFrame(StackFrameRecordPtr frame_record,
44 m : ProcessState* process_state);
45 m : bool SetSymbolInformation(Address instruction_pointer,
46 m : ProcessState* process_state);
47 :
48 m : static const char kStackFrameAnalyzerName[];
49 :
50 : // The short term solution for symbols.
51 m : scoped_refptr<DiaSymbolProvider> dia_symbol_provider_;
52 : // The longer term solution for symbols.
53 m : scoped_refptr<SymbolProvider> symbol_provider_;
54 :
55 : // Symbol information for the frame being processed.
56 m : base::win::ScopedComPtr<IDiaSession> dia_session_;
57 m : scoped_refptr<TypeNameIndex> typename_index_;
58 :
59 m : DISALLOW_COPY_AND_ASSIGN(StackFrameAnalyzer);
60 m : };
61 :
62 m : } // namespace refinery
63 :
64 : #endif // SYZYGY_REFINERY_ANALYZERS_STACK_FRAME_ANALYZER_H_
|