Add ICorDebugModule4 - Get Module mapping mode (#39865)
authorJuan Hoyos <juan.hoyos@microsoft.com>
Tue, 28 Jul 2020 11:19:58 +0000 (04:19 -0700)
committerGitHub <noreply@github.com>
Tue, 28 Jul 2020 11:19:58 +0000 (04:19 -0700)
* Add IDL for ICorDebugModule4
* Add cached version of the MIDL generated stubs
* Implement ICorDebugModule4
* Align method naming with other methods in ICorDebug

src/coreclr/src/debug/daccess/dacdbiimpl.cpp
src/coreclr/src/debug/daccess/dacdbiimpl.h
src/coreclr/src/debug/di/module.cpp
src/coreclr/src/debug/di/rspriv.h
src/coreclr/src/debug/inc/dacdbiinterface.h
src/coreclr/src/inc/cordebug.idl
src/coreclr/src/pal/prebuilt/idl/cordebug_i.cpp
src/coreclr/src/pal/prebuilt/inc/cordebug.h

index 4bcd6f2..aab4913 100644 (file)
@@ -4272,6 +4272,30 @@ void DacDbiInterfaceImpl::GetModuleSimpleName(VMPTR_Module vmModule, IStringHold
     IfFailThrow(pStrFilename->AssignCopy(convert.GetUnicode()));
 }
 
+HRESULT DacDbiInterfaceImpl::IsModuleMapped(VMPTR_Module pModule, OUT BOOL *isModuleMapped)
+{
+    LOG((LF_CORDB, LL_INFO10000, "DDBII::IMM - TADDR 0x%x\n", pModule));
+    DD_ENTER_MAY_THROW;
+
+    HRESULT hr = S_FALSE;
+    PTR_Module pTargetModule = pModule.GetDacPtr();
+
+    EX_TRY
+    {
+        PTR_PEFile pPEFile = pTargetModule->GetFile();
+        _ASSERTE(pPEFile != NULL);
+
+        if (pPEFile->HasLoadedIL())
+        {
+            *isModuleMapped = pPEFile->GetLoadedIL()->IsMapped();
+            hr = S_OK;
+        }
+    }
+    EX_CATCH_HRESULT(hr);
+
+    return hr;
+}
+
 // Helper to intialize a TargetBuffer from a MemoryRange
 //
 // Arguments:
index 9178e71..219b51d 100644 (file)
@@ -363,6 +363,8 @@ public:
 
     HRESULT GetLoaderHeapMemoryRanges(OUT DacDbiArrayList<COR_MEMORY_RANGE> * pRanges);
 
+    HRESULT IsModuleMapped(VMPTR_Module pModule, OUT BOOL *isModuleMapped);
+
     // retrieves the list of COM interfaces implemented by vmObject, as it is known at
     // the time of the call (the list may change as new interface types become available
     // in the runtime)
index d02dfdd..9554f61 100644 (file)
@@ -1200,6 +1200,10 @@ HRESULT CordbModule::QueryInterface(REFIID id, void **pInterface)
     {
         *pInterface = static_cast<ICorDebugModule3*>(this);
     }
+    else if (id == IID_ICorDebugModule4)
+    {
+        *pInterface = static_cast<ICorDebugModule4*>(this);
+    }
     else if (id == IID_IUnknown)
     {
         *pInterface = static_cast<IUnknown*>(static_cast<ICorDebugModule*>(this));
@@ -2752,6 +2756,24 @@ HRESULT CordbModule::GetJITCompilerFlags(DWORD *pdwFlags )
     return hr;
 }
 
+HRESULT CordbModule::IsMappedLayout(BOOL *isMapped)
+{
+    VALIDATE_POINTER_TO_OBJECT(isMapped, BOOL*);
+    FAIL_IF_NEUTERED(this);
+
+    HRESULT hr = S_OK;
+    CordbProcess *pProcess = GetProcess();
+
+    ATT_REQUIRE_STOPPED_MAY_FAIL(pProcess);
+    PUBLIC_API_BEGIN(pProcess);
+    {
+        hr = pProcess->GetDAC()->IsModuleMapped(m_vmModule, isMapped);
+    }
+    PUBLIC_API_END(hr);
+
+    return hr;
+}
+
 /* ------------------------------------------------------------------------- *
  * CordbCode class
  * ------------------------------------------------------------------------- */
index 1bb48df..4dc93eb 100644 (file)
@@ -4139,7 +4139,8 @@ private:
 class CordbModule : public CordbBase,
                     public ICorDebugModule,
                     public ICorDebugModule2,
-                    public ICorDebugModule3
+                    public ICorDebugModule3,
+                    public ICorDebugModule4
 {
 public:
     CordbModule(CordbProcess *      process,
@@ -4235,6 +4236,11 @@ public:
                                               void** ppObj);
 
     //-----------------------------------------------------------
+    // ICorDebugModule4
+    //-----------------------------------------------------------
+    COM_METHOD IsMappedLayout(BOOL *isMapped);
+
+    //-----------------------------------------------------------
     // Internal members
     //-----------------------------------------------------------
 
index 79405d6..1f99f5f 100644 (file)
@@ -2733,6 +2733,9 @@ public:
     virtual
     HRESULT GetLoaderHeapMemoryRanges(OUT DacDbiArrayList<COR_MEMORY_RANGE> *pRanges) = 0;
 
+    virtual
+    HRESULT IsModuleMapped(VMPTR_Module pModule, OUT BOOL *isModuleMapped) = 0;
+
     // The following tag tells the DD-marshalling tool to stop scanning.
     // END_MARSHAL
 
index 7ab2867..02c98f2 100644 (file)
@@ -5174,6 +5174,30 @@ interface ICorDebugModule3 : IUnknown
 }
 
 /*
+ * ICorDebugModule4 is a logical extension to ICorDebugModule.
+ */
+[
+    object,
+    local,
+    uuid(FF8B8EAF-25CD-4316-8859-84416DE4402E),
+    pointer_default(unique)
+]
+interface ICorDebugModule4 : IUnknown
+{
+    /*
+     * Query to see if the module is loaded into memory in mapped/hydrated format
+     *
+     * Arguments:
+     *     pIsMapped - BOOL to store mapping information. TRUE will represent mapped
+                      format while FALSE represents flat format.
+     * Return Value:
+     *     S_OK in successful case.
+     * Notes:
+     */
+    HRESULT IsMappedLayout([out] BOOL *pIsMapped);
+}
+
+/*
  * ICorDebugRuntimeUnwindableFrame is a specialized interface of ICorDebugFrame for unmanaged methods
  * which requires special knowledge to unwind.  They are not jitted code.  When the debugger sees this type
  * of frames, it should use ICorDebugStackWalk::Next() to unwind, but it should do inspection itself.
index 85d7ab5..5208843 100644 (file)
@@ -8,7 +8,7 @@
  /* File created by MIDL compiler version 8.01.0622 */
 /* at Mon Jan 18 19:14:07 2038
  */
-/* Compiler settings for E:/repos/runtime2/src/coreclr/src/inc/cordebug.idl:
+/* Compiler settings for runtime/src/coreclr/src/inc/cordebug.idl:
     Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.01.0622
     protocol : dce , ms_ext, c_ext, robust
     error checks: allocation ref bounds_check enum stub_data
@@ -289,6 +289,9 @@ MIDL_DEFINE_GUID(IID, IID_ICorDebugNativeFrame2,0x35389FF1,0x3684,0x4c55,0xA2,0x
 MIDL_DEFINE_GUID(IID, IID_ICorDebugModule3,0x86F012BF,0xFF15,0x4372,0xBD,0x30,0xB6,0xF1,0x1C,0xAA,0xE1,0xDD);
 
 
+MIDL_DEFINE_GUID(IID, IID_ICorDebugModule4,0xFF8B8EAF,0x25CD,0x4316,0x88,0x59,0x84,0x41,0x6D,0xE4,0x40,0x2E);
+
+
 MIDL_DEFINE_GUID(IID, IID_ICorDebugRuntimeUnwindableFrame,0x879CAC0A,0x4A53,0x4668,0xB8,0xE3,0xCB,0x84,0x73,0xCB,0x18,0x7F);
 
 
index 3418b8c..b497d14 100644 (file)
@@ -6,7 +6,7 @@
  /* File created by MIDL compiler version 8.01.0622 */
 /* at Mon Jan 18 19:14:07 2038
  */
-/* Compiler settings for E:/repos/runtime2/src/coreclr/src/inc/cordebug.idl:
+/* Compiler settings for runtime/src/coreclr/src/inc/cordebug.idl:
     Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.01.0622
     protocol : dce , ms_ext, c_ext, robust
     error checks: allocation ref bounds_check enum stub_data
@@ -563,6 +563,13 @@ typedef interface ICorDebugModule3 ICorDebugModule3;
 #endif         /* __ICorDebugModule3_FWD_DEFINED__ */
 
 
+#ifndef __ICorDebugModule4_FWD_DEFINED__
+#define __ICorDebugModule4_FWD_DEFINED__
+typedef interface ICorDebugModule4 ICorDebugModule4;
+
+#endif         /* __ICorDebugModule4_FWD_DEFINED__ */
+
+
 #ifndef __ICorDebugRuntimeUnwindableFrame_FWD_DEFINED__
 #define __ICorDebugRuntimeUnwindableFrame_FWD_DEFINED__
 typedef interface ICorDebugRuntimeUnwindableFrame ICorDebugRuntimeUnwindableFrame;
@@ -11691,6 +11698,86 @@ EXTERN_C const IID IID_ICorDebugModule3;
 #endif         /* __ICorDebugModule3_INTERFACE_DEFINED__ */
 
 
+#ifndef __ICorDebugModule4_INTERFACE_DEFINED__
+#define __ICorDebugModule4_INTERFACE_DEFINED__
+
+/* interface ICorDebugModule4 */
+/* [unique][uuid][local][object] */
+
+
+EXTERN_C const IID IID_ICorDebugModule4;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+    MIDL_INTERFACE("FF8B8EAF-25CD-4316-8859-84416DE4402E")
+    ICorDebugModule4 : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE IsMappedLayout(
+            /* [out] */ BOOL *pIsMapped) = 0;
+
+    };
+
+
+#else  /* C style interface */
+
+    typedef struct ICorDebugModule4Vtbl
+    {
+        BEGIN_INTERFACE
+
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+            ICorDebugModule4 * This,
+            /* [in] */ REFIID riid,
+            /* [annotation][iid_is][out] */
+            _COM_Outptr_  void **ppvObject);
+
+        ULONG ( STDMETHODCALLTYPE *AddRef )(
+            ICorDebugModule4 * This);
+
+        ULONG ( STDMETHODCALLTYPE *Release )(
+            ICorDebugModule4 * This);
+
+        HRESULT ( STDMETHODCALLTYPE *IsMappedLayout )(
+            ICorDebugModule4 * This,
+            /* [out] */ BOOL *pIsMapped);
+
+        END_INTERFACE
+    } ICorDebugModule4Vtbl;
+
+    interface ICorDebugModule4
+    {
+        CONST_VTBL struct ICorDebugModule4Vtbl *lpVtbl;
+    };
+
+
+
+#ifdef COBJMACROS
+
+
+#define ICorDebugModule4_QueryInterface(This,riid,ppvObject)   \
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define ICorDebugModule4_AddRef(This)  \
+    ( (This)->lpVtbl -> AddRef(This) )
+
+#define ICorDebugModule4_Release(This) \
+    ( (This)->lpVtbl -> Release(This) )
+
+
+#define ICorDebugModule4_IsMappedLayout(This,pIsMapped)        \
+    ( (This)->lpVtbl -> IsMappedLayout(This,pIsMapped) )
+
+#endif /* COBJMACROS */
+
+
+#endif         /* C style interface */
+
+
+
+
+#endif         /* __ICorDebugModule4_INTERFACE_DEFINED__ */
+
+
 #ifndef __ICorDebugRuntimeUnwindableFrame_INTERFACE_DEFINED__
 #define __ICorDebugRuntimeUnwindableFrame_INTERFACE_DEFINED__
 
@@ -12075,14 +12162,14 @@ EXTERN_C const IID IID_ICorDebugModule;
 #endif         /* __ICorDebugModule_INTERFACE_DEFINED__ */
 
 
-/* interface __MIDL_itf_cordebug_0000_0075 */
+/* interface __MIDL_itf_cordebug_0000_0076 */
 /* [local] */
 
 #pragma warning(pop)
 
 
-extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0075_v0_0_c_ifspec;
-extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0075_v0_0_s_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0076_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0076_v0_0_s_ifspec;
 
 #ifndef __ICorDebugModule2_INTERFACE_DEFINED__
 #define __ICorDebugModule2_INTERFACE_DEFINED__
@@ -15129,15 +15216,15 @@ EXTERN_C const IID IID_ICorDebugBoxValue;
 #endif         /* __ICorDebugBoxValue_INTERFACE_DEFINED__ */
 
 
-/* interface __MIDL_itf_cordebug_0000_0102 */
+/* interface __MIDL_itf_cordebug_0000_0103 */
 /* [local] */
 
 #pragma warning(push)
 #pragma warning(disable:28718)
 
 
-extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0102_v0_0_c_ifspec;
-extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0102_v0_0_s_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0103_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0103_v0_0_s_ifspec;
 
 #ifndef __ICorDebugStringValue_INTERFACE_DEFINED__
 #define __ICorDebugStringValue_INTERFACE_DEFINED__
@@ -15277,14 +15364,14 @@ EXTERN_C const IID IID_ICorDebugStringValue;
 #endif         /* __ICorDebugStringValue_INTERFACE_DEFINED__ */
 
 
-/* interface __MIDL_itf_cordebug_0000_0103 */
+/* interface __MIDL_itf_cordebug_0000_0104 */
 /* [local] */
 
 #pragma warning(pop)
 
 
-extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0103_v0_0_c_ifspec;
-extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0103_v0_0_s_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0104_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0104_v0_0_s_ifspec;
 
 #ifndef __ICorDebugArrayValue_INTERFACE_DEFINED__
 #define __ICorDebugArrayValue_INTERFACE_DEFINED__
@@ -18059,15 +18146,15 @@ EXTERN_C const IID IID_ICorDebugBlockingObjectEnum;
 #endif         /* __ICorDebugBlockingObjectEnum_INTERFACE_DEFINED__ */
 
 
-/* interface __MIDL_itf_cordebug_0000_0127 */
+/* interface __MIDL_itf_cordebug_0000_0128 */
 /* [local] */
 
 #pragma warning(push)
 #pragma warning(disable:28718)
 
 
-extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0127_v0_0_c_ifspec;
-extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0127_v0_0_s_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0128_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0128_v0_0_s_ifspec;
 
 #ifndef __ICorDebugMDA_INTERFACE_DEFINED__
 #define __ICorDebugMDA_INTERFACE_DEFINED__
@@ -18207,7 +18294,7 @@ EXTERN_C const IID IID_ICorDebugMDA;
 #endif         /* __ICorDebugMDA_INTERFACE_DEFINED__ */
 
 
-/* interface __MIDL_itf_cordebug_0000_0128 */
+/* interface __MIDL_itf_cordebug_0000_0129 */
 /* [local] */
 
 #pragma warning(pop)
@@ -18215,8 +18302,8 @@ EXTERN_C const IID IID_ICorDebugMDA;
 #pragma warning(disable:28718)
 
 
-extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0128_v0_0_c_ifspec;
-extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0128_v0_0_s_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0129_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0129_v0_0_s_ifspec;
 
 #ifndef __ICorDebugEditAndContinueErrorInfo_INTERFACE_DEFINED__
 #define __ICorDebugEditAndContinueErrorInfo_INTERFACE_DEFINED__
@@ -18332,14 +18419,14 @@ EXTERN_C const IID IID_ICorDebugEditAndContinueErrorInfo;
 #endif         /* __ICorDebugEditAndContinueErrorInfo_INTERFACE_DEFINED__ */
 
 
-/* interface __MIDL_itf_cordebug_0000_0129 */
+/* interface __MIDL_itf_cordebug_0000_0130 */
 /* [local] */
 
 #pragma warning(pop)
 
 
-extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0129_v0_0_c_ifspec;
-extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0129_v0_0_s_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0130_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_cordebug_0000_0130_v0_0_s_ifspec;
 
 #ifndef __ICorDebugEditAndContinueSnapshot_INTERFACE_DEFINED__
 #define __ICorDebugEditAndContinueSnapshot_INTERFACE_DEFINED__