aboutsummaryrefslogtreecommitdiff
path: root/src/processor/stackwalker_x86.h
blob: 6e0225b45bc44c051caf09aaef606f2ac7516935 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (C) 2006 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// stackwalker_x86.h: x86-specific stackwalker.
//
// Provides stack frames given x86 register context and a memory region
// corresponding to an x86 stack.
//
// Author: Mark Mentovai


#ifndef PROCESSOR_STACKWALKER_X86_H__
#define PROCESSOR_STACKWALKER_X86_H__


#include "google/airbag_types.h"
#include "processor/stackwalker.h"
#include "processor/minidump_format.h"


namespace google_airbag {


class MinidumpContext;
class MinidumpModuleList;


class StackwalkerX86 : public Stackwalker {
 public:
  // context is a MinidumpContext object that gives access to x86-specific
  // register state corresponding to the innermost called frame to be
  // included in the stack.  memory and modules are passed directly through
  // to the base Stackwalker constructor.
  StackwalkerX86(MinidumpContext*    context,
                 MemoryRegion*       memory,
                 MinidumpModuleList* modules);

 private:
  // Implementation of Stackwalker, using x86 context (%ebp, %eip) and
  // stack conventions (saved %ebp at [%ebp], saved %eip at 4[%ebp]).
  virtual bool GetContextFrame(StackFrame* frame);
  virtual bool GetCallerFrame(StackFrame* frame);

  // Stores the CPU context corresponding to the innermost stack frame to
  // be returned by GetContextFrame.
  const MDRawContextX86* context_;

  // Stores the frame pointer returned in the last stack frame returned by
  // GetContextFrame or GetCallerFrame.
  u_int32_t              last_frame_pointer_;
};


} // namespace google_airbag


#endif // PROCESSOR_STACKWALKER_X86_H__