summaryrefslogtreecommitdiff
path: root/src/unwinder/amd64/unwinder_amd64.h
blob: 2d90492654268606731b12fbe0d5a8e517795837 (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
69
70
71
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

// 

#ifndef __unwinder_amd64_h__
#define __unwinder_amd64_h__

#include "unwinder.h"


//---------------------------------------------------------------------------------------
//
// See the comment for the base class code:OOPStackUnwinder.
//

class OOPStackUnwinderAMD64 : public OOPStackUnwinder
{
public:
    // Unwind the given CONTEXT to the caller CONTEXT.  The CONTEXT will be overwritten.  
    static BOOL Unwind(CONTEXT * pContext);

    //
    // Everything below comes from dbghelp.dll.
    //

    static HRESULT VirtualUnwind(__in DWORD HandlerType,
        __in DWORD64 ImageBase,
        __in DWORD64 ControlPc,
        __in _PIMAGE_RUNTIME_FUNCTION_ENTRY FunctionEntry,
        __inout PCONTEXT ContextRecord,
        __out PVOID *HandlerData,
        __out PDWORD64 EstablisherFrame,
        __inout_opt PKNONVOLATILE_CONTEXT_POINTERS ContextPointers,
        __deref_opt_out_opt PEXCEPTION_ROUTINE *HandlerRoutine);

protected:

    static ULONG UnwindOpSlots(__in UNWIND_CODE UnwindCode);

    static HRESULT UnwindEpilogue(__in ULONG64 ImageBase,
                                  __in ULONG64 ControlPc,
                                  __in ULONG EpilogueOffset,
                                  __in _PIMAGE_RUNTIME_FUNCTION_ENTRY FunctionEntry,
                                  __inout PCONTEXT ContextRecord,
                                  __inout_opt PKNONVOLATILE_CONTEXT_POINTERS ContextPointers);

    static HRESULT UnwindPrologue(__in DWORD64 ImageBase,
                                  __in DWORD64 ControlPc,
                                  __in DWORD64 FrameBase,
                                  __in _PIMAGE_RUNTIME_FUNCTION_ENTRY FunctionEntry,
                                  __inout PCONTEXT ContextRecord,
                                  __inout_opt PKNONVOLATILE_CONTEXT_POINTERS ContextPointers,
                                  __deref_out _PIMAGE_RUNTIME_FUNCTION_ENTRY *FinalFunctionEntry);

    static _PIMAGE_RUNTIME_FUNCTION_ENTRY LookupPrimaryFunctionEntry
        (__in _PIMAGE_RUNTIME_FUNCTION_ENTRY FunctionEntry,
         __in DWORD64 ImageBase);

    static _PIMAGE_RUNTIME_FUNCTION_ENTRY SameFunction
        (__in _PIMAGE_RUNTIME_FUNCTION_ENTRY FunctionEntry,
         __in DWORD64 ImageBase,
         __in DWORD64 ControlPc);

    static UNWIND_INFO * GetUnwindInfo(TADDR taUnwindInfo);
};

#endif // __unwinder_amd64_h__