2 * Copyright 2011 Alistair Leslie-Hughes
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "wine/test.h"
33 static HMODULE hmscoree
;
35 static HRESULT (WINAPI
*pCreateDebuggingInterfaceFromVersion
)(int, LPCWSTR
, IUnknown
**);
37 const WCHAR v2_0
[] = {'v','2','.','0','.','5','0','7','2','7',0};
39 static HRESULT WINAPI
ManagedCallback2_QueryInterface(ICorDebugManagedCallback2
*iface
, REFIID riid
, void **ppv
)
41 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_ICorDebugManagedCallback2
, riid
))
47 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
53 static ULONG WINAPI
ManagedCallback2_AddRef(ICorDebugManagedCallback2
*iface
)
58 static ULONG WINAPI
ManagedCallback2_Release(ICorDebugManagedCallback2
*iface
)
63 static HRESULT WINAPI
ManagedCallback2_FunctionRemapOpportunity(ICorDebugManagedCallback2
*iface
,
64 ICorDebugAppDomain
*pAppDomain
, ICorDebugThread
*pThread
,
65 ICorDebugFunction
*pOldFunction
, ICorDebugFunction
*pNewFunction
,
68 ok(0, "unexpected call\n");
72 static HRESULT WINAPI
ManagedCallback2_CreateConnection(ICorDebugManagedCallback2
*iface
,
73 ICorDebugProcess
*pProcess
, CONNID dwConnectionId
, WCHAR
*pConnName
)
75 ok(0, "unexpected call\n");
79 static HRESULT WINAPI
ManagedCallback2_ChangeConnection(ICorDebugManagedCallback2
*iface
,
80 ICorDebugProcess
*pProcess
, CONNID dwConnectionId
)
82 ok(0, "unexpected call\n");
86 static HRESULT WINAPI
ManagedCallback2_DestroyConnection(ICorDebugManagedCallback2
*iface
,
87 ICorDebugProcess
*pProcess
, CONNID dwConnectionId
)
89 ok(0, "unexpected call\n");
93 static HRESULT WINAPI
ManagedCallback2_Exception(ICorDebugManagedCallback2
*iface
,
94 ICorDebugAppDomain
*pAppDomain
, ICorDebugThread
*pThread
,
95 ICorDebugFrame
*pFrame
, ULONG32 nOffset
,
96 CorDebugExceptionCallbackType dwEventType
, DWORD dwFlags
)
98 ok(0, "unexpected call\n");
102 static HRESULT WINAPI
ManagedCallback2_ExceptionUnwind(ICorDebugManagedCallback2
*iface
,
103 ICorDebugAppDomain
*pAppDomain
, ICorDebugThread
*pThread
,
104 CorDebugExceptionUnwindCallbackType dwEventType
, DWORD dwFlags
)
106 ok(0, "unexpected call\n");
110 static HRESULT WINAPI
ManagedCallback2_FunctionRemapComplete(ICorDebugManagedCallback2
*iface
,
111 ICorDebugAppDomain
*pAppDomain
, ICorDebugThread
*pThread
,
112 ICorDebugFunction
*pFunction
)
114 ok(0, "unexpected call\n");
118 static HRESULT WINAPI
ManagedCallback2_MDANotification(ICorDebugManagedCallback2
*iface
,
119 ICorDebugController
*pController
, ICorDebugThread
*pThread
,
122 ok(0, "unexpected call\n");
126 static struct ICorDebugManagedCallback2Vtbl managedCallback2Vtbl
= {
127 ManagedCallback2_QueryInterface
,
128 ManagedCallback2_AddRef
,
129 ManagedCallback2_Release
,
130 ManagedCallback2_FunctionRemapOpportunity
,
131 ManagedCallback2_CreateConnection
,
132 ManagedCallback2_ChangeConnection
,
133 ManagedCallback2_DestroyConnection
,
134 ManagedCallback2_Exception
,
135 ManagedCallback2_ExceptionUnwind
,
136 ManagedCallback2_FunctionRemapComplete
,
137 ManagedCallback2_MDANotification
140 static ICorDebugManagedCallback2 ManagedCallback2
= { &managedCallback2Vtbl
};
142 static HRESULT WINAPI
ManagedCallback_QueryInterface(ICorDebugManagedCallback
*iface
, REFIID riid
, void **ppv
)
144 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_ICorDebugManagedCallback
, riid
))
149 else if(IsEqualGUID(&IID_ICorDebugManagedCallback2
, riid
))
151 *ppv
= (void**)&ManagedCallback2
;
155 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
157 return E_NOINTERFACE
;
160 static ULONG WINAPI
ManagedCallback_AddRef(ICorDebugManagedCallback
*iface
)
165 static ULONG WINAPI
ManagedCallback_Release(ICorDebugManagedCallback
*iface
)
170 static HRESULT WINAPI
ManagedCallback_Breakpoint(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
171 ICorDebugThread
*pThread
, ICorDebugBreakpoint
*pBreakpoint
)
173 ok(0, "unexpected call\n");
177 static HRESULT WINAPI
ManagedCallback_StepComplete(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
178 ICorDebugThread
*pThread
, ICorDebugStepper
*pStepper
, CorDebugStepReason reason
)
180 ok(0, "unexpected call\n");
184 static HRESULT WINAPI
ManagedCallback_Break(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
185 ICorDebugThread
*thread
)
187 ok(0, "unexpected call\n");
191 static HRESULT WINAPI
ManagedCallback_Exception(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
192 ICorDebugThread
*pThread
, BOOL unhandled
)
194 ok(0, "unexpected call\n");
198 static HRESULT WINAPI
ManagedCallback_EvalComplete(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
199 ICorDebugThread
*pThread
, ICorDebugEval
*pEval
)
201 ok(0, "unexpected call\n");
205 static HRESULT WINAPI
ManagedCallback_EvalException(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
206 ICorDebugThread
*pThread
, ICorDebugEval
*pEval
)
208 ok(0, "unexpected call\n");
212 static HRESULT WINAPI
ManagedCallback_CreateProcess(ICorDebugManagedCallback
*iface
, ICorDebugProcess
*pProcess
)
214 ok(0, "unexpected call\n");
218 static HRESULT WINAPI
ManagedCallback_ExitProcess(ICorDebugManagedCallback
*iface
, ICorDebugProcess
*pProcess
)
220 ok(0, "unexpected call\n");
224 static HRESULT WINAPI
ManagedCallback_CreateThread(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
225 ICorDebugThread
*thread
)
227 ok(0, "unexpected call\n");
231 static HRESULT WINAPI
ManagedCallback_ExitThread(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
232 ICorDebugThread
*thread
)
234 ok(0, "unexpected call\n");
238 static HRESULT WINAPI
ManagedCallback_LoadModule(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
239 ICorDebugModule
*pModule
)
241 ok(0, "unexpected call\n");
245 static HRESULT WINAPI
ManagedCallback_UnloadModule(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
246 ICorDebugModule
*pModule
)
248 ok(0, "unexpected call\n");
252 static HRESULT WINAPI
ManagedCallback_LoadClass(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
255 ok(0, "unexpected call\n");
259 static HRESULT WINAPI
ManagedCallback_UnloadClass(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
262 ok(0, "unexpected call\n");
266 static HRESULT WINAPI
ManagedCallback_DebuggerError(ICorDebugManagedCallback
*iface
, ICorDebugProcess
*pProcess
,
267 HRESULT errorHR
, DWORD errorCode
)
269 ok(0, "unexpected call\n");
273 static HRESULT WINAPI
ManagedCallback_LogMessage(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
274 ICorDebugThread
*pThread
, LONG lLevel
, WCHAR
*pLogSwitchName
, WCHAR
*pMessage
)
276 ok(0, "unexpected call\n");
280 static HRESULT WINAPI
ManagedCallback_LogSwitch(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
281 ICorDebugThread
*pThread
, LONG lLevel
, ULONG ulReason
,
282 WCHAR
*pLogSwitchName
, WCHAR
*pParentName
)
284 ok(0, "unexpected call\n");
288 static HRESULT WINAPI
ManagedCallback_CreateAppDomain(ICorDebugManagedCallback
*iface
, ICorDebugProcess
*pProcess
,
289 ICorDebugAppDomain
*pAppDomain
)
291 ok(0, "unexpected call\n");
295 static HRESULT WINAPI
ManagedCallback_ExitAppDomain(ICorDebugManagedCallback
*iface
, ICorDebugProcess
*pProcess
,
296 ICorDebugAppDomain
*pAppDomain
)
298 ok(0, "unexpected call\n");
302 static HRESULT WINAPI
ManagedCallback_LoadAssembly(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
303 ICorDebugAssembly
*pAssembly
)
305 ok(0, "unexpected call\n");
309 static HRESULT WINAPI
ManagedCallback_UnloadAssembly(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
310 ICorDebugAssembly
*pAssembly
)
312 ok(0, "unexpected call\n");
316 static HRESULT WINAPI
ManagedCallback_ControlCTrap(ICorDebugManagedCallback
*iface
, ICorDebugProcess
*pProcess
)
318 ok(0, "unexpected call\n");
322 static HRESULT WINAPI
ManagedCallback_NameChange(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
323 ICorDebugThread
*pThread
)
325 ok(0, "unexpected call\n");
329 static HRESULT WINAPI
ManagedCallback_UpdateModuleSymbols(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
330 ICorDebugModule
*pModule
, IStream
*pSymbolStream
)
332 ok(0, "unexpected call\n");
336 static HRESULT WINAPI
ManagedCallback_EditAndContinueRemap(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
337 ICorDebugThread
*pThread
, ICorDebugFunction
*pFunction
, BOOL fAccurate
)
339 ok(0, "unexpected call\n");
343 static HRESULT WINAPI
ManagedCallback_BreakpointSetError(ICorDebugManagedCallback
*iface
, ICorDebugAppDomain
*pAppDomain
,
344 ICorDebugThread
*pThread
, ICorDebugBreakpoint
*pBreakpoint
, DWORD dwError
)
346 ok(0, "unexpected call\n");
350 static ICorDebugManagedCallbackVtbl managedCallbackVtbl
= {
351 ManagedCallback_QueryInterface
,
352 ManagedCallback_AddRef
,
353 ManagedCallback_Release
,
354 ManagedCallback_Breakpoint
,
355 ManagedCallback_StepComplete
,
356 ManagedCallback_Break
,
357 ManagedCallback_Exception
,
358 ManagedCallback_EvalComplete
,
359 ManagedCallback_EvalException
,
360 ManagedCallback_CreateProcess
,
361 ManagedCallback_ExitProcess
,
362 ManagedCallback_CreateThread
,
363 ManagedCallback_ExitThread
,
364 ManagedCallback_LoadModule
,
365 ManagedCallback_UnloadModule
,
366 ManagedCallback_LoadClass
,
367 ManagedCallback_UnloadClass
,
368 ManagedCallback_DebuggerError
,
369 ManagedCallback_LogMessage
,
370 ManagedCallback_LogSwitch
,
371 ManagedCallback_CreateAppDomain
,
372 ManagedCallback_ExitAppDomain
,
373 ManagedCallback_LoadAssembly
,
374 ManagedCallback_UnloadAssembly
,
375 ManagedCallback_ControlCTrap
,
376 ManagedCallback_NameChange
,
377 ManagedCallback_UpdateModuleSymbols
,
378 ManagedCallback_EditAndContinueRemap
,
379 ManagedCallback_BreakpointSetError
382 static ICorDebugManagedCallback ManagedCallback
= { &managedCallbackVtbl
};
384 static BOOL
init_functionpointers(void)
386 hmscoree
= LoadLibraryA("mscoree.dll");
390 win_skip("mscoree.dll not available\n");
394 pCreateDebuggingInterfaceFromVersion
= (void *)GetProcAddress(hmscoree
, "CreateDebuggingInterfaceFromVersion");
396 if (!pCreateDebuggingInterfaceFromVersion
)
398 win_skip("functions not available\n");
399 FreeLibrary(hmscoree
);
406 #define check_process_enum(core, e) _check_process_enum(__LINE__, core, e)
407 static void _check_process_enum(unsigned line
, ICorDebug
*pCorDebug
, ULONG nExpected
)
410 ICorDebugProcessEnum
*pProcessEnum
= NULL
;
412 hr
= ICorDebug_EnumerateProcesses(pCorDebug
, NULL
);
413 ok_(__FILE__
,line
) (hr
== E_INVALIDARG
, "expected E_INVALIDARG got %08x\n", hr
);
415 hr
= ICorDebug_EnumerateProcesses(pCorDebug
, &pProcessEnum
);
416 ok_(__FILE__
,line
) (hr
== S_OK
, "expected S_OK got %08x\n", hr
);
421 hr
= ICorDebugProcessEnum_GetCount(pProcessEnum
, &cnt
);
422 ok_(__FILE__
,line
) (hr
== S_OK
, "expected S_OK got %08x\n", hr
);
423 ok_(__FILE__
,line
) (cnt
== nExpected
, "expected %d got %d\n", nExpected
, cnt
);
425 ICorDebugProcessEnum_Release(pProcessEnum
);
429 static void test_createDebugger(void)
433 ICorDebug
*pCorDebug
;
435 hr
= pCreateDebuggingInterfaceFromVersion(0, v2_0
, &pUnk
);
436 ok(hr
== E_INVALIDARG
, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr
);
438 hr
= pCreateDebuggingInterfaceFromVersion(1, v2_0
, &pUnk
);
439 ok(hr
== E_INVALIDARG
, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr
);
441 hr
= pCreateDebuggingInterfaceFromVersion(2, v2_0
, &pUnk
);
442 ok(hr
== E_INVALIDARG
, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr
);
444 hr
= pCreateDebuggingInterfaceFromVersion(4, v2_0
, &pUnk
);
445 ok(hr
== E_INVALIDARG
, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr
);
447 hr
= pCreateDebuggingInterfaceFromVersion(3, v2_0
, NULL
);
448 ok(hr
== E_INVALIDARG
, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr
);
450 hr
= pCreateDebuggingInterfaceFromVersion(3, v2_0
, &pUnk
);
453 hr
= IUnknown_QueryInterface(pUnk
, &IID_ICorDebug
, (void**)&pCorDebug
);
454 ok(hr
== S_OK
, "expected S_OK got %08x\n", hr
);
457 hr
= ICorDebug_Initialize(pCorDebug
);
458 ok(hr
== S_OK
, "expected S_OK got %08x\n", hr
);
461 hr
= ICorDebug_SetManagedHandler(pCorDebug
, NULL
);
462 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG got %08x\n", hr
);
464 hr
= ICorDebug_SetManagedHandler(pCorDebug
, &ManagedCallback
);
465 ok(hr
== S_OK
, "expected S_OK got %08x\n", hr
);
467 /* We should have no processes */
468 check_process_enum(pCorDebug
, 0);
471 ICorDebug_Release(pCorDebug
);
473 IUnknown_Release(pUnk
);
477 skip(".NET 2.0 or mono not installed.\n");
481 START_TEST(debugging
)
485 if (!init_functionpointers())
488 test_createDebugger();
490 FreeLibrary(hmscoree
);