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_ANALYZER_H_
16 : #define SYZYGY_REFINERY_ANALYZERS_STACK_ANALYZER_H_
17 :
18 : #include <dia2.h>
19 :
20 : #include "base/macros.h"
21 : #include "base/memory/ref_counted.h"
22 : #include "base/win/scoped_comptr.h"
23 : #include "syzygy/refinery/analyzers/analyzer.h"
24 : #include "syzygy/refinery/process_state/process_state_util.h"
25 : #include "syzygy/refinery/symbols/dia_symbol_provider.h"
26 :
27 m : namespace refinery {
28 :
29 : // fwd.
30 m : class StackWalkHelper;
31 :
32 : // The stack analyzer populates the process state with information resulting
33 : // from walking the stack.
34 : // TODO(manzagop): Introduce a system for managing analyzer order prerequisites?
35 m : class StackAnalyzer : public Analyzer {
36 m : public:
37 m : explicit StackAnalyzer(scoped_refptr<DiaSymbolProvider> symbol_provider);
38 :
39 m : const char* name() const override { return kStackAnalyzerName; }
40 :
41 m : AnalysisResult Analyze(const minidump::Minidump& minidump,
42 m : ProcessState* process_state) override;
43 :
44 m : private:
45 m : AnalysisResult StackWalk(StackRecordPtr stack_record,
46 m : ProcessState* process_state);
47 :
48 : // Inserts data about @p stack_frame into @p process_state.
49 m : bool InsertStackFrameRecord(IDiaStackFrame* stack_frame,
50 m : ProcessState* process_state);
51 :
52 m : static const char kStackAnalyzerName[];
53 :
54 m : scoped_refptr<DiaSymbolProvider> symbol_provider_;
55 m : base::win::ScopedComPtr<IDiaStackWalker> stack_walker_;
56 m : scoped_refptr<StackWalkHelper> stack_walk_helper_;
57 :
58 : // A frame's data is often located relative to the CV_ALLREG_VFRAME. However,
59 : // we observe this is relative to the parent frame's value. For ease of
60 : // access, we store the parent frame's value in the frame's context.
61 m : RegisterInformation* child_frame_context_;
62 :
63 m : DISALLOW_COPY_AND_ASSIGN(StackAnalyzer);
64 m : };
65 :
66 m : } // namespace refinery
67 :
68 : #endif // SYZYGY_REFINERY_ANALYZERS_STACK_ANALYZER_H_
|