summaryrefslogtreecommitdiff
path: root/src/debug/inc/eventredirection.h
blob: 67ea271ea4128bbd5489c792f376a50dbb6df894 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//*****************************************************************************

// 
// NativePipeline.h
//
// define control block for redirecting events.
//*****************************************************************************

#ifndef _EVENTREDIRECTION_H
#define _EVENTREDIRECTION_H

//---------------------------------------------------------------------------------------
// Control block for redirecting events.
// Motivation here is that only 1 process can be the real OS debugger. So if we want a windbg
// attached to an ICorDebug debuggee, then that windbg is the real debugger and it forwards events 
// to the mdbg process.
//
// Terminology:
//   Server: a windbg extension (StrikeRS) that is the real OS debugger, and it forwards native debug
//           events (just exceptions currently) to the client
//   Client: ICorDebug, which gets events via shimmed call to WaitForDebugEvent, etc.
//
// Control block lives in Client's process space. All handles are valid in client.
// Sever does Read/WriteProcessMemory 
struct RedirectionBlock
{
    // Version of the control block. Initialized by client, verified by server.
    // Latest value is EVENT_REDIRECTION_CURRENT_VERSION
    DWORD m_versionCookie;

    // 
    // Counters. After each WFDE/CDE pair, these counters should be in sync.
    //

    // increment after WFDE 
    DWORD m_counterAvailable;
    DWORD m_counterConsumed;

    //
    // Data for WaitForDebugEvent. (Server writes; Client reads)
    //
    DWORD m_dwProcessId;
    DWORD m_dwThreadId;

    // Different sizes on different platforms
    EXCEPTION_RECORD m_record;
    BOOL m_dwFirstChance;

    //
    // Data for ContinueDebugEvent. (Client writes, server reads)
    //

    // Continuation status argument to ContinueDebugEvent
    DWORD m_ContinuationStatus;


    //
    // Coordination events. These are handles in client space; server duplicates out.
    //

    // Server signals when WFDE Data is ready. 
    HANDLE m_hEventAvailable;

    // Server signals when CDE data is ready.
    HANDLE m_hEventConsumed;

    // Client signals before it deletes this block. This corresponds to client calling DebugActiveProcessStop.
    // Thus server can check if signalled to know if accessing this block (which lives in client space) is safe.
    // This is Synchronized because client only detaches if the debuggee is stopped, in which case the server
    // isn't in the middle of sending an event.
    HANDLE m_hDetachEvent;
};


// Current version.
#define EVENT_REDIRECTION_CURRENT_VERSION ((DWORD) 4)



#endif // _EVENTREDIRECTION_H