mscoree: Add ICorDebug interface support.

This commit is contained in:
Alistair Leslie-Hughes 2011-09-27 09:06:18 +10:00 committed by Alexandre Julliard
parent 6861f4c252
commit bef72c4884
13 changed files with 385 additions and 33 deletions

View File

@ -4,6 +4,7 @@ IMPORTS = dbghelp uuid shell32 advapi32 ole32 oleaut32 shlwapi
C_SRCS = \
assembly.c \
config.c \
cordebug.c \
corruntimehost.c \
metadata.c \
metahost.c \

View File

@ -27,8 +27,10 @@
#include "winver.h"
#include "dbghelp.h"
#include "ole2.h"
#include "mscoree.h"
#include "corhdr.h"
#include "metahost.h"
#include "cordebug.h"
#include "wine/list.h"
#include "mscoree_private.h"

View File

@ -27,7 +27,10 @@
#include "winreg.h"
#include "ole2.h"
#include "msxml2.h"
#include "mscoree.h"
#include "corhdr.h"
#include "metahost.h"
#include "cordebug.h"
#include "wine/list.h"
#include "mscoree_private.h"
#include "shlwapi.h"

177
dlls/mscoree/cordebug.c Normal file
View File

@ -0,0 +1,177 @@
/*
*
* Copyright 2011 Alistair Leslie-Hughes
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winnls.h"
#include "winreg.h"
#include "ole2.h"
#include "shellapi.h"
#include "mscoree.h"
#include "corhdr.h"
#include "metahost.h"
#include "cordebug.h"
#include "wine/list.h"
#include "mscoree_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL( mscoree );
static inline RuntimeHost *impl_from_ICorDebug( ICorDebug *iface )
{
return CONTAINING_RECORD(iface, RuntimeHost, ICorDebug_iface);
}
/*** IUnknown methods ***/
static HRESULT WINAPI CorDebug_QueryInterface(ICorDebug *iface, REFIID riid, void **ppvObject)
{
RuntimeHost *This = impl_from_ICorDebug( iface );
TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
if ( IsEqualGUID( riid, &IID_ICorDebug ) ||
IsEqualGUID( riid, &IID_IUnknown ) )
{
*ppvObject = &This->ICorDebug_iface;
}
else
{
FIXME("Unsupported interface %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
ICorDebug_AddRef( iface );
return S_OK;
}
static ULONG WINAPI CorDebug_AddRef(ICorDebug *iface)
{
RuntimeHost *This = impl_from_ICorDebug( iface );
return ICorRuntimeHost_AddRef(&This->ICorRuntimeHost_iface);
}
static ULONG WINAPI CorDebug_Release(ICorDebug *iface)
{
RuntimeHost *This = impl_from_ICorDebug( iface );
return ICorRuntimeHost_Release(&This->ICorRuntimeHost_iface);
}
/*** ICorDebug methods ***/
static HRESULT WINAPI CorDebug_Initialize(ICorDebug *iface)
{
RuntimeHost *This = impl_from_ICorDebug( iface );
FIXME("stub %p\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI CorDebug_Terminate(ICorDebug *iface)
{
RuntimeHost *This = impl_from_ICorDebug( iface );
FIXME("stub %p\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI CorDebug_SetManagedHandler(ICorDebug *iface, ICorDebugManagedCallback *pCallback)
{
RuntimeHost *This = impl_from_ICorDebug( iface );
FIXME("stub %p %p\n", This, pCallback);
return E_NOTIMPL;
}
static HRESULT WINAPI CorDebug_SetUnmanagedHandler(ICorDebug *iface, ICorDebugUnmanagedCallback *pCallback)
{
RuntimeHost *This = impl_from_ICorDebug( iface );
FIXME("stub %p %p\n", This, pCallback);
return E_NOTIMPL;
}
static HRESULT WINAPI CorDebug_CreateProcess(ICorDebug *iface, LPCWSTR lpApplicationName,
LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles,
DWORD dwCreationFlags, PVOID lpEnvironment,LPCWSTR lpCurrentDirectory,
LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation,
CorDebugCreateProcessFlags debuggingFlags, ICorDebugProcess **ppProcess)
{
RuntimeHost *This = impl_from_ICorDebug( iface );
FIXME("stub %p %s %s %p %p %d %d %p %s %p %p %d %p\n", This, debugstr_w(lpApplicationName),
debugstr_w(lpCommandLine), lpProcessAttributes, lpThreadAttributes,
bInheritHandles, dwCreationFlags, lpEnvironment, debugstr_w(lpCurrentDirectory),
lpStartupInfo, lpProcessInformation, debuggingFlags, ppProcess);
return E_NOTIMPL;
}
static HRESULT WINAPI CorDebug_DebugActiveProcess(ICorDebug *iface, DWORD id, BOOL win32Attach,
ICorDebugProcess **ppProcess)
{
RuntimeHost *This = impl_from_ICorDebug( iface );
FIXME("stub %p %d %d %p\n", This, id, win32Attach, ppProcess);
return E_NOTIMPL;
}
static HRESULT WINAPI CorDebug_EnumerateProcesses( ICorDebug *iface, ICorDebugProcessEnum **ppProcess)
{
RuntimeHost *This = impl_from_ICorDebug( iface );
FIXME("stub %p %p\n", This, ppProcess);
return E_NOTIMPL;
}
static HRESULT WINAPI CorDebug_GetProcess(ICorDebug *iface, DWORD dwProcessId, ICorDebugProcess **ppProcess)
{
RuntimeHost *This = impl_from_ICorDebug( iface );
FIXME("stub %p %d %p\n", This, dwProcessId, ppProcess);
return E_NOTIMPL;
}
static HRESULT WINAPI CorDebug_CanLaunchOrAttach(ICorDebug *iface, DWORD dwProcessId,
BOOL win32DebuggingEnabled)
{
RuntimeHost *This = impl_from_ICorDebug( iface );
FIXME("stub %p %d %d\n", This, dwProcessId, win32DebuggingEnabled);
return E_NOTIMPL;
}
static const struct ICorDebugVtbl cordebug_vtbl =
{
CorDebug_QueryInterface,
CorDebug_AddRef,
CorDebug_Release,
CorDebug_Initialize,
CorDebug_Terminate,
CorDebug_SetManagedHandler,
CorDebug_SetUnmanagedHandler,
CorDebug_CreateProcess,
CorDebug_DebugActiveProcess,
CorDebug_EnumerateProcesses,
CorDebug_GetProcess,
CorDebug_CanLaunchOrAttach
};
void cordebug_init(RuntimeHost *This)
{
This->ICorDebug_iface.lpVtbl = &cordebug_vtbl;
}

View File

@ -32,6 +32,8 @@
#include "cor.h"
#include "mscoree.h"
#include "metahost.h"
#include "corhdr.h"
#include "cordebug.h"
#include "wine/list.h"
#include "mscoree_private.h"
@ -43,18 +45,6 @@ WINE_DEFAULT_DEBUG_CHANNEL( mscoree );
DEFINE_GUID(IID__AppDomain, 0x05f696dc,0x2b29,0x3663,0xad,0x8b,0xc4,0x38,0x9c,0xf2,0xa7,0x13);
struct RuntimeHost
{
ICorRuntimeHost ICorRuntimeHost_iface;
ICLRRuntimeHost ICLRRuntimeHost_iface;
const CLRRuntimeInfo *version;
loaded_mono *mono;
struct list domains;
MonoDomain *default_domain;
CRITICAL_SECTION lock;
LONG ref;
};
struct DomainEntry
{
struct list entry;
@ -796,6 +786,9 @@ HRESULT RuntimeHost_Construct(const CLRRuntimeInfo *runtime_version,
This->ICorRuntimeHost_iface.lpVtbl = &corruntimehost_vtbl;
This->ICLRRuntimeHost_iface.lpVtbl = &CLRHostVtbl;
cordebug_init(This);
This->ref = 1;
This->version = runtime_version;
This->mono = loaded_mono;
@ -831,6 +824,11 @@ HRESULT RuntimeHost_GetInterface(RuntimeHost *This, REFCLSID clsid, REFIID riid,
if (FAILED(hr))
return hr;
}
else if (IsEqualGUID(clsid, &CLSID_CLRDebuggingLegacy))
{
unk = (IUnknown*)&This->ICorDebug_iface;
IUnknown_AddRef(unk);
}
else
unk = NULL;

View File

@ -29,8 +29,10 @@
#include "winbase.h"
#include "winreg.h"
#include "ole2.h"
#include "cor.h"
#include "mscoree.h"
#include "corhdr.h"
#include "cordebug.h"
#include "metahost.h"
#include "wine/list.h"
#include "mscoree_private.h"

View File

@ -32,9 +32,12 @@
#include "ole2.h"
#include "corerror.h"
#include "cor.h"
#include "mscoree.h"
#include "fusion.h"
#include "corhdr.h"
#include "cordebug.h"
#include "metahost.h"
#include "fusion.h"
#include "wine/list.h"
#include "mscoree_private.h"
@ -1002,7 +1005,7 @@ static BOOL parse_runtime_version(LPCWSTR version, DWORD *major, DWORD *minor, D
return FALSE;
}
static HRESULT WINAPI CLRMetaHost_GetRuntime(ICLRMetaHost* iface,
HRESULT WINAPI CLRMetaHost_GetRuntime(ICLRMetaHost* iface,
LPCWSTR pwzVersion, REFIID iid, LPVOID *ppRuntime)
{
int i;

View File

@ -35,11 +35,13 @@
#include "initguid.h"
#include "msxml2.h"
#include "cor.h"
#include "corerror.h"
#include "cor.h"
#include "mscoree.h"
#include "fusion.h"
#include "corhdr.h"
#include "cordebug.h"
#include "metahost.h"
#include "fusion.h"
#include "wine/list.h"
#include "mscoree_private.h"
@ -444,10 +446,43 @@ HRESULT WINAPI CreateConfigStream(LPCWSTR filename, IStream **stream)
return E_NOTIMPL;
}
HRESULT WINAPI CreateDebuggingInterfaceFromVersion(int nDebugVersion, LPCWSTR version, IUnknown **ppIUnk)
HRESULT WINAPI CreateDebuggingInterfaceFromVersion(int nDebugVersion, LPCWSTR version, IUnknown **ppv)
{
FIXME("(%d %s, %p): stub\n", nDebugVersion, debugstr_w(version), ppIUnk);
return E_NOTIMPL;
const WCHAR v2_0[] = {'v','2','.','0','.','5','0','7','2','7',0};
HRESULT hr = E_FAIL;
ICLRRuntimeInfo *runtimeinfo;
if(nDebugVersion < 1 || nDebugVersion > 4)
return E_INVALIDARG;
TRACE("(%d %s, %p): stub\n", nDebugVersion, debugstr_w(version), ppv);
if(!ppv)
return E_INVALIDARG;
*ppv = NULL;
if(strcmpW(version, v2_0) != 0)
{
FIXME("Currently .NET Version '%s' not support.\n", debugstr_w(version));
return E_INVALIDARG;
}
if(nDebugVersion != 3)
return E_INVALIDARG;
hr = CLRMetaHost_GetRuntime(0, version, &IID_ICLRRuntimeInfo, (void**)&runtimeinfo);
if(hr == S_OK)
{
hr = ICLRRuntimeInfo_GetInterface(runtimeinfo, &CLSID_CLRDebuggingLegacy, &IID_ICorDebug, (void**)ppv);
ICLRRuntimeInfo_Release(runtimeinfo);
}
if(!*ppv)
return E_FAIL;
return hr;
}
HRESULT WINAPI CLRCreateInstance(REFCLSID clsid, REFIID riid, LPVOID *ppInterface)

View File

@ -33,6 +33,18 @@ HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file) DECLSPEC_HIDDEN;
HRESULT assembly_release(ASSEMBLY *assembly) DECLSPEC_HIDDEN;
HRESULT assembly_get_runtime_version(ASSEMBLY *assembly, LPSTR *version) DECLSPEC_HIDDEN;
/* Mono embedding */
typedef struct _MonoDomain MonoDomain;
typedef struct _MonoAssembly MonoAssembly;
typedef struct _MonoAssemblyName MonoAssemblyName;
typedef struct _MonoType MonoType;
typedef struct _MonoImage MonoImage;
typedef struct _MonoClass MonoClass;
typedef struct _MonoObject MonoObject;
typedef struct _MonoMethod MonoMethod;
typedef struct _MonoProfiler MonoProfiler;
typedef struct loaded_mono loaded_mono;
typedef struct RuntimeHost RuntimeHost;
typedef struct CLRRuntimeInfo
@ -48,6 +60,19 @@ typedef struct CLRRuntimeInfo
struct RuntimeHost *loaded_runtime;
} CLRRuntimeInfo;
struct RuntimeHost
{
ICorRuntimeHost ICorRuntimeHost_iface;
ICLRRuntimeHost ICLRRuntimeHost_iface;
ICorDebug ICorDebug_iface;
const CLRRuntimeInfo *version;
loaded_mono *mono;
struct list domains;
MonoDomain *default_domain;
CRITICAL_SECTION lock;
LONG ref;
};
extern HRESULT get_runtime_info(LPCWSTR exefile, LPCWSTR version, LPCWSTR config_file,
DWORD startup_flags, DWORD runtimeinfo_flags, BOOL legacy, ICLRRuntimeInfo **result) DECLSPEC_HIDDEN;
@ -70,17 +95,6 @@ extern HRESULT parse_config_file(LPCWSTR filename, parsed_config_file *result) D
extern void free_parsed_config_file(parsed_config_file *file) DECLSPEC_HIDDEN;
/* Mono embedding */
typedef struct _MonoDomain MonoDomain;
typedef struct _MonoAssembly MonoAssembly;
typedef struct _MonoAssemblyName MonoAssemblyName;
typedef struct _MonoType MonoType;
typedef struct _MonoImage MonoImage;
typedef struct _MonoClass MonoClass;
typedef struct _MonoObject MonoObject;
typedef struct _MonoMethod MonoMethod;
typedef struct _MonoProfiler MonoProfiler;
typedef enum {
MONO_IMAGE_OK,
MONO_IMAGE_ERROR_ERRNO,
@ -92,7 +106,7 @@ typedef MonoAssembly* (*MonoAssemblyPreLoadFunc)(MonoAssemblyName *aname, char *
typedef void (*MonoProfileFunc)(MonoProfiler *prof);
typedef struct loaded_mono
struct loaded_mono
{
HMODULE mono_handle;
HMODULE glib_handle;
@ -126,7 +140,7 @@ typedef struct loaded_mono
void (CDECL *mono_thread_pool_cleanup)(void);
void (CDECL *mono_thread_suspend_all_other_threads)(void);
void (CDECL *mono_threads_set_shutting_down)(void);
} loaded_mono;
};
/* loaded runtime interfaces */
extern void unload_all_runtimes(void) DECLSPEC_HIDDEN;
@ -145,4 +159,8 @@ extern HRESULT RuntimeHost_CreateManagedInstance(RuntimeHost *This, LPCWSTR name
extern HRESULT RuntimeHost_Destroy(RuntimeHost *This) DECLSPEC_HIDDEN;
HRESULT WINAPI CLRMetaHost_GetRuntime(ICLRMetaHost* iface, LPCWSTR pwzVersion, REFIID iid, LPVOID *ppRuntime) DECLSPEC_HIDDEN;
extern void cordebug_init(RuntimeHost *This);
#endif /* __MSCOREE_PRIVATE__ */

View File

@ -2,6 +2,7 @@ TESTDLL = mscoree.dll
IMPORTS = shlwapi
C_SRCS = \
debugging.c \
metahost.c \
mscoree.c

View File

@ -0,0 +1,106 @@
/*
* Copyright 2011 Alistair Leslie-Hughes
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include "windows.h"
#include "ole2.h"
#include "corerror.h"
#include "mscoree.h"
#include "corhdr.h"
#include "wine/test.h"
#include "initguid.h"
#include "cordebug.h"
static HMODULE hmscoree;
static HRESULT (WINAPI *pCreateDebuggingInterfaceFromVersion)(int, LPCWSTR, IUnknown **);
const WCHAR v2_0[] = {'v','2','.','0','.','5','0','7','2','7',0};
static BOOL init_functionpointers(void)
{
hmscoree = LoadLibraryA("mscoree.dll");
if (!hmscoree)
{
win_skip("mscoree.dll not available\n");
return FALSE;
}
pCreateDebuggingInterfaceFromVersion = (void *)GetProcAddress(hmscoree, "CreateDebuggingInterfaceFromVersion");
if (!pCreateDebuggingInterfaceFromVersion)
{
win_skip("functions not available\n");
FreeLibrary(hmscoree);
return FALSE;
}
return TRUE;
}
static void test_createDebugger(void)
{
HRESULT hr;
IUnknown *pUnk;
ICorDebug *pCorDebug;
hr = pCreateDebuggingInterfaceFromVersion(0, v2_0, &pUnk);
ok(hr == E_INVALIDARG, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr);
hr = pCreateDebuggingInterfaceFromVersion(1, v2_0, &pUnk);
ok(hr == E_INVALIDARG, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr);
hr = pCreateDebuggingInterfaceFromVersion(2, v2_0, &pUnk);
ok(hr == E_INVALIDARG, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr);
hr = pCreateDebuggingInterfaceFromVersion(4, v2_0, &pUnk);
ok(hr == E_INVALIDARG, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr);
hr = pCreateDebuggingInterfaceFromVersion(3, v2_0, NULL);
ok(hr == E_INVALIDARG, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr);
hr = pCreateDebuggingInterfaceFromVersion(3, v2_0, &pUnk);
if(hr == S_OK)
{
hr = IUnknown_QueryInterface(pUnk, &IID_ICorDebug, (void**)&pCorDebug);
todo_wine ok(hr == S_OK, "expected S_OK got %08x\n", hr);
if(hr == S_OK)
{
ICorDebug_Release(pCorDebug);
}
IUnknown_Release(pUnk);
}
else
{
skip(".NET 2.0 or mono not installed.\n");
}
}
START_TEST(debugging)
{
if (!init_functionpointers())
return;
test_createDebugger();
FreeLibrary(hmscoree);
}

View File

@ -19,6 +19,10 @@
import "unknwn.idl";
import "objidl.idl";
cpp_quote("#ifdef WINE_NO_UNICODE_MACROS")
cpp_quote("#undef CreateProcess")
cpp_quote("#endif")
interface ICorDebugAppDomain;
interface ICorDebugAppDomainEnum;
interface ICorDebugAssembly;
@ -51,6 +55,7 @@ interface ICorDebugStepper;
interface ICorDebugStepperEnum;
interface ICorDebugThreadEnum;
interface ICorDebugUnmanagedCallback;
interface ICorDebugValue;
interface ICorDebugValueBreakpoint;

View File

@ -88,6 +88,7 @@ typedef void (__stdcall *RuntimeLoadedCallbackFnPtr)(
CallbackThreadSetFnPtr pfnCallbackThreadSet,
CallbackThreadUnsetFnPtr pfnCallbackThreadUnset);
cpp_quote("DEFINE_GUID(CLSID_CLRDebuggingLegacy, 0xDF8395B5,0xA4BA,0x450b,0xA7,0x7C,0xA9,0xA4,0x77,0x62,0xC5,0x20);")
cpp_quote("DEFINE_GUID(CLSID_CLRMetaHost, 0x9280188d,0x0e8e,0x4867,0xb3,0x0c,0x7f,0xa8,0x38,0x84,0xe8,0xde);")
[