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_IMPL_H_
16 : #define SYZYGY_REFINERY_ANALYZERS_STACK_FRAME_ANALYZER_IMPL_H_
17 :
18 : #include <dia2.h>
19 :
20 : #include "base/macros.h"
21 : #include "base/memory/ref_counted.h"
22 : #include "syzygy/refinery/process_state/layer_data.h"
23 : #include "syzygy/refinery/process_state/process_state.h"
24 : #include "syzygy/refinery/process_state/process_state_util.h"
25 : #include "syzygy/refinery/types/type_repository.h"
26 :
27 m : namespace refinery {
28 :
29 : // A stack frame data analyzer analyzes data in the context of a stack frame and
30 : // populates a process state's typed block layer with the findings.
31 : // @note Until we move away from using DIA for stack frame symbol information,
32 : // this class also handles joining an IDiaSymbol to a Type via symbol name.
33 m : class StackFrameDataAnalyzer {
34 m : public:
35 m : StackFrameDataAnalyzer(StackFrameRecordPtr frame_record,
36 m : scoped_refptr<TypeNameIndex> typename_index,
37 m : ModuleId module_id,
38 m : ProcessState* process_state);
39 :
40 : // Analyze @p data in the context of the frame record to populate the process
41 : // state's typed block layer.
42 : // @pre data is of type SymTagData.
43 : // @param data the dia symbol of type SymTagData to analyze.
44 : // @returns true on success analysis, false otherwise.
45 : // @note Successful analysis does not necessarily mean modifying the process
46 : // state.
47 m : bool Analyze(IDiaSymbol* data);
48 :
49 m : private:
50 m : bool GetAddressRange(IDiaSymbol* data, TypePtr type, AddressRange* range);
51 m : bool GetAddressRangeRegRel(IDiaSymbol* data,
52 m : TypePtr type,
53 m : AddressRange* range);
54 :
55 m : StackFrameRecordPtr frame_record_;
56 m : scoped_refptr<TypeNameIndex> typename_index_;
57 m : ModuleId module_id_;
58 : // Not owned. Must outlive the StackFrameDataAnalyzer.
59 m : ProcessState* process_state_;
60 :
61 m : DISALLOW_COPY_AND_ASSIGN(StackFrameDataAnalyzer);
62 m : };
63 :
64 m : } // namespace refinery
65 :
66 : #endif // SYZYGY_REFINERY_ANALYZERS_STACK_FRAME_ANALYZER_IMPL_H_
|