summaryrefslogtreecommitdiff
path: root/src/debug/inc/readonlydatatargetfacade.h
blob: 95c12928c88db5dca05ec383f9a7a10cad3631d5 (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// 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.
//*****************************************************************************
// ReadOnlyDataTargetFacade.h
// 

// 
//*****************************************************************************

#ifndef READONLYDATATARGETFACADE_H_
#define READONLYDATATARGETFACADE_H_

#include <cordebug.h>

//---------------------------------------------------------------------------------------
//  ReadOnlyDataTargetFacade
//  
//  This class is designed to be used as an ICorDebugMutableDataTarget when none is 
//  supplied.  All of the write APIs will fail with CORDBG_E_TARGET_READONLY as required
//  by the data target spec when a write operation is invoked on a read-only data target.
//  The desire here is to merge the error code paths for the case when a write fails,
//  and the case when a write is requested but the data target supplied doesn't
//  implement ICorDebugMutableDataTarget.  
//  
//  Note that this is intended to be used only for the additional APIs defined by
//  ICorDebugMutableDataTarget.  Calling any of the base ICorDebugDataTarget APIs
//  will ASSERT and fail.  An alternative design would be to make this class a wrapper
//  class (similar to DataTargetAdapter) over an existing ICorDebugDataTarget interface.
//  In general, we'd like callers of the data target to differentiate between when they're
//  using read-only APIs and mutation APIs since they need to be aware that the latter often
//  won't be supported by the data target.  Also, that design would have the draw-back 
//  of incuring an extra virtual dispatch on every read API call (makaing debugging more 
//  complex and possibly having a performance impact).
// 
class ReadOnlyDataTargetFacade : public ICorDebugMutableDataTarget
{
public:
    ReadOnlyDataTargetFacade();
    virtual ~ReadOnlyDataTargetFacade() {}

    //
    // IUnknown.
    //        
    virtual HRESULT STDMETHODCALLTYPE QueryInterface(
        REFIID InterfaceId,
        PVOID* Interface);

    virtual ULONG STDMETHODCALLTYPE AddRef();

    virtual ULONG STDMETHODCALLTYPE Release();

    //
    // ICorDebugDataTarget.
    //
    
    virtual HRESULT STDMETHODCALLTYPE GetPlatform( 
        CorDebugPlatform *pPlatform);

    virtual HRESULT STDMETHODCALLTYPE ReadVirtual( 
        CORDB_ADDRESS address,
        BYTE * pBuffer,
        ULONG32 request,
        ULONG32 * pcbRead);

    virtual HRESULT STDMETHODCALLTYPE GetThreadContext(
        DWORD dwThreadID,
        ULONG32 contextFlags,
        ULONG32 contextSize,
        BYTE * context);

    //
    // ICorDebugMutableDataTarget.
    // 

    virtual HRESULT STDMETHODCALLTYPE WriteVirtual( 
        CORDB_ADDRESS address,
        const BYTE * pBuffer,
        ULONG32 request);

    virtual HRESULT STDMETHODCALLTYPE SetThreadContext(
        DWORD dwThreadID,
        ULONG32 contextSize,
        const BYTE * context);

    virtual HRESULT STDMETHODCALLTYPE ContinueStatusChanged(
        DWORD dwThreadId,
        CORDB_CONTINUE_STATUS dwContinueStatus);

private:
    // Reference count.
    LONG m_ref;
};

#include "readonlydatatargetfacade.inl"

#endif //  READONLYDATATARGETFACADE_H_