1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4//*****************************************************************************
5// File: ShimCallback.cpp
6//
7
8//
9// The V3 ICD debugging APIs have a lower abstraction level than V2.
10// This provides V2 ICD debugging functionality on top of the V3 debugger object.
11//*****************************************************************************
12
13#include "stdafx.h"
14
15#include "safewrap.h"
16#include "check.h"
17
18#include <limits.h>
19#include "shimpriv.h"
20
21
22//
23// Callback that shim provides, which then queues up the events.
24//
25ShimProxyCallback::ShimProxyCallback(ShimProcess * pShim)
26 : m_cRef(0)
27{
28 m_pShim = pShim;
29}
30
31// Implement IUnknown
32ULONG ShimProxyCallback::AddRef()
33{
34 return InterlockedIncrement(&m_cRef);
35}
36ULONG ShimProxyCallback::Release()
37{
38 LONG ref = InterlockedDecrement(&m_cRef);
39 if (ref == 0)
40 {
41 delete this;
42 return 0;
43 }
44 return ref;
45
46}
47HRESULT ShimProxyCallback::QueryInterface(REFIID riid, void **ppInterface)
48{
49 if (riid == IID_ICorDebugManagedCallback)
50 {
51 *ppInterface = static_cast<ICorDebugManagedCallback*>(this);
52 }
53 else if (riid == IID_ICorDebugManagedCallback2)
54 {
55 *ppInterface = static_cast<ICorDebugManagedCallback2*>(this);
56 }
57 else if (riid == IID_ICorDebugManagedCallback3)
58 {
59 *ppInterface = static_cast<ICorDebugManagedCallback3*>(this);
60 }
61 else if (riid == IID_ICorDebugManagedCallback4)
62 {
63 *ppInterface = static_cast<ICorDebugManagedCallback4*>(this);
64 }
65 else if (riid == IID_IUnknown)
66 {
67 *ppInterface = static_cast<IUnknown*>(static_cast<ICorDebugManagedCallback*>(this));
68 }
69 else
70 {
71 *ppInterface = NULL;
72 return E_NOINTERFACE;
73 }
74
75 this->AddRef();
76 return S_OK;
77}
78
79//
80// Map from an old frame to a new one.
81//
82// Arguments:
83// pThread - thread that frame is on
84// pOldFrame - old frame before the continue, may have gotten neutered.
85//
86// Returns:
87// a new, non-neutered frame that matches the old frame.
88//
89// Notes:
90// Called by event handlers below (which are considered Outside the RS).
91// No adjust of reference, Thread already has reference.
92// @dbgtodo shim-stackwalks: this is used for exception callbacks, which may change for V3.
93ICorDebugFrame * UpdateFrame(ICorDebugThread * pThread, ICorDebugFrame * pOldFrame)
94{
95 PUBLIC_API_ENTRY_FOR_SHIM(NULL);
96
97 RSExtSmartPtr<ICorDebugFrame> pNewFrame;
98
99 EX_TRY
100 {
101 CordbFrame * pFrame = static_cast<CordbFrame *> (pOldFrame);
102 if (pFrame != NULL)
103 {
104 FramePointer fp = pFrame->GetFramePointer();
105
106 CordbThread * pThread2 = static_cast<CordbThread *> (pThread);
107 pThread2->FindFrame(&pNewFrame, fp);
108
109 //
110 }
111 }
112 EX_CATCH
113 {
114 // Do not throw out of this function. Doing so means that the debugger never gets a chance to
115 // continue the debuggee process. This will lead to a hang. Instead, try to make a best effort to
116 // continue with a NULL ICDFrame. VS is able to handle this gracefully.
117 pNewFrame.Assign(NULL);
118 }
119 EX_END_CATCH(SwallowAllExceptions);
120
121 return pNewFrame;
122}
123
124
125
126//
127// Below this was autogenerated
128//
129
130// Implementation of ICorDebugManagedCallback::Breakpoint
131HRESULT ShimProxyCallback::Breakpoint(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, ICorDebugBreakpoint * pBreakpoint)
132{
133 m_pShim->PreDispatchEvent();
134 class BreakpointEvent : public ManagedEvent
135 {
136 // callbacks parameters. These are strong references
137 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
138 RSExtSmartPtr<ICorDebugThread > m_pThread;
139 RSExtSmartPtr<ICorDebugBreakpoint > m_pBreakpoint;
140
141 public:
142 // Ctor
143 BreakpointEvent(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, ICorDebugBreakpoint * pBreakpoint) :
144 ManagedEvent(pThread)
145 {
146 this->m_pAppDomain.Assign(pAppDomain);
147 this->m_pThread.Assign(pThread);
148 this->m_pBreakpoint.Assign(pBreakpoint);
149 }
150
151 HRESULT Dispatch(DispatchArgs args)
152 {
153 return args.GetCallback1()->Breakpoint(m_pAppDomain, m_pThread, m_pBreakpoint);
154 }
155 }; // end class BreakpointEvent
156
157 m_pShim->GetManagedEventQueue()->QueueEvent(new BreakpointEvent(pAppDomain, pThread, pBreakpoint));
158 return S_OK;
159} // end of methodICorDebugManagedCallback::Breakpoint
160
161
162// Implementation of ICorDebugManagedCallback::StepComplete
163HRESULT ShimProxyCallback::StepComplete(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, ICorDebugStepper * pStepper, CorDebugStepReason reason)
164{
165 m_pShim->PreDispatchEvent();
166 class StepCompleteEvent : public ManagedEvent
167 {
168 // callbacks parameters. These are strong references
169 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
170 RSExtSmartPtr<ICorDebugThread > m_pThread;
171 RSExtSmartPtr<ICorDebugStepper > m_pStepper;
172 CorDebugStepReason m_reason;
173
174 public:
175 // Ctor
176 StepCompleteEvent(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, ICorDebugStepper * pStepper, CorDebugStepReason reason) :
177 ManagedEvent(pThread)
178 {
179 this->m_pAppDomain.Assign(pAppDomain);
180 this->m_pThread.Assign(pThread);
181 this->m_pStepper.Assign(pStepper);
182 this->m_reason = reason;
183 }
184
185 HRESULT Dispatch(DispatchArgs args)
186 {
187 return args.GetCallback1()->StepComplete(m_pAppDomain, m_pThread, m_pStepper, m_reason);
188 }
189 }; // end class StepCompleteEvent
190
191 m_pShim->GetManagedEventQueue()->QueueEvent(new StepCompleteEvent(pAppDomain, pThread, pStepper, reason));
192 return S_OK;
193} // end of methodICorDebugManagedCallback::StepComplete
194
195
196// Implementation of ICorDebugManagedCallback::Break
197HRESULT ShimProxyCallback::Break(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread)
198{
199 m_pShim->PreDispatchEvent();
200 class BreakEvent : public ManagedEvent
201 {
202 // callbacks parameters. These are strong references
203 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
204 RSExtSmartPtr<ICorDebugThread > m_pThread;
205
206 public:
207 // Ctor
208 BreakEvent(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread) :
209 ManagedEvent(pThread)
210 {
211 this->m_pAppDomain.Assign(pAppDomain);
212 this->m_pThread.Assign(pThread);
213 }
214
215 HRESULT Dispatch(DispatchArgs args)
216 {
217 return args.GetCallback1()->Break(m_pAppDomain, m_pThread);
218 }
219 }; // end class BreakEvent
220
221 m_pShim->GetManagedEventQueue()->QueueEvent(new BreakEvent(pAppDomain, pThread));
222 return S_OK;
223} // end of methodICorDebugManagedCallback::Break
224
225
226// Implementation of ICorDebugManagedCallback::Exception
227HRESULT ShimProxyCallback::Exception(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, BOOL fUnhandled)
228{
229 m_pShim->PreDispatchEvent();
230 class ExceptionEvent : public ManagedEvent
231 {
232 // callbacks parameters. These are strong references
233 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
234 RSExtSmartPtr<ICorDebugThread > m_pThread;
235 BOOL m_fUnhandled;
236
237 public:
238 // Ctor
239 ExceptionEvent(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, BOOL fUnhandled) :
240 ManagedEvent(pThread)
241 {
242 this->m_pAppDomain.Assign(pAppDomain);
243 this->m_pThread.Assign(pThread);
244 this->m_fUnhandled = fUnhandled;
245 }
246
247 HRESULT Dispatch(DispatchArgs args)
248 {
249 return args.GetCallback1()->Exception(m_pAppDomain, m_pThread, m_fUnhandled);
250 }
251 }; // end class ExceptionEvent
252
253 m_pShim->GetManagedEventQueue()->QueueEvent(new ExceptionEvent(pAppDomain, pThread, fUnhandled));
254 return S_OK;
255} // end of methodICorDebugManagedCallback::Exception
256
257
258// Implementation of ICorDebugManagedCallback::EvalComplete
259HRESULT ShimProxyCallback::EvalComplete(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, ICorDebugEval * pEval)
260{
261 m_pShim->PreDispatchEvent();
262 class EvalCompleteEvent : public ManagedEvent
263 {
264 // callbacks parameters. These are strong references
265 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
266 RSExtSmartPtr<ICorDebugThread > m_pThread;
267 RSExtSmartPtr<ICorDebugEval > m_pEval;
268
269 public:
270 // Ctor
271 EvalCompleteEvent(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, ICorDebugEval * pEval) :
272 ManagedEvent(pThread)
273 {
274 this->m_pAppDomain.Assign(pAppDomain);
275 this->m_pThread.Assign(pThread);
276 this->m_pEval.Assign(pEval);
277 }
278
279 HRESULT Dispatch(DispatchArgs args)
280 {
281 return args.GetCallback1()->EvalComplete(m_pAppDomain, m_pThread, m_pEval);
282 }
283 }; // end class EvalCompleteEvent
284
285 m_pShim->GetManagedEventQueue()->QueueEvent(new EvalCompleteEvent(pAppDomain, pThread, pEval));
286 return S_OK;
287} // end of methodICorDebugManagedCallback::EvalComplete
288
289
290// Implementation of ICorDebugManagedCallback::EvalException
291HRESULT ShimProxyCallback::EvalException(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, ICorDebugEval * pEval)
292{
293 m_pShim->PreDispatchEvent();
294 class EvalExceptionEvent : public ManagedEvent
295 {
296 // callbacks parameters. These are strong references
297 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
298 RSExtSmartPtr<ICorDebugThread > m_pThread;
299 RSExtSmartPtr<ICorDebugEval > m_pEval;
300
301 public:
302 // Ctor
303 EvalExceptionEvent(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, ICorDebugEval * pEval) :
304 ManagedEvent(pThread)
305 {
306 this->m_pAppDomain.Assign(pAppDomain);
307 this->m_pThread.Assign(pThread);
308 this->m_pEval.Assign(pEval);
309 }
310
311 HRESULT Dispatch(DispatchArgs args)
312 {
313 return args.GetCallback1()->EvalException(m_pAppDomain, m_pThread, m_pEval);
314 }
315 }; // end class EvalExceptionEvent
316
317 m_pShim->GetManagedEventQueue()->QueueEvent(new EvalExceptionEvent(pAppDomain, pThread, pEval));
318 return S_OK;
319} // end of methodICorDebugManagedCallback::EvalException
320
321
322// Implementation of ICorDebugManagedCallback::CreateProcess
323// This will only be called for a Real create-process event.
324HRESULT ShimProxyCallback::CreateProcess(ICorDebugProcess * pProcess)
325{
326 m_pShim->PreDispatchEvent(true);
327 QueueCreateProcess(pProcess);
328 return S_OK;
329}
330
331void ShimProxyCallback::QueueCreateProcess(ICorDebugProcess * pProcess)
332{
333 class CreateProcessEvent : public ManagedEvent
334 {
335 // callbacks parameters. These are strong references
336 RSExtSmartPtr<ICorDebugProcess > m_pProcess;
337
338 public:
339 // Ctor
340 CreateProcessEvent(ICorDebugProcess * pProcess, ShimProcess * pShim) :
341 ManagedEvent(),
342 m_pShim(pShim)
343 {
344 this->m_pProcess.Assign(pProcess);
345 }
346
347 HRESULT Dispatch(DispatchArgs args)
348 {
349 // signal that we are in the callback--this will be cleared in code:CordbProcess::ContinueInternal
350 m_pShim->SetInCreateProcess(true);
351 return args.GetCallback1()->CreateProcess(m_pProcess);
352 }
353
354 // we need access to the shim in Dispatch so we can set the InCreateProcess flag to keep track of
355 // when we are actually in the callback. We need this information to be able to emulate
356 // the hresult logic in v2.0.
357 ShimProcess * m_pShim;
358 }; // end class CreateProcessEvent
359
360 if (!m_pShim->RemoveDuplicateCreationEventIfPresent(pProcess))
361 {
362 m_pShim->GetManagedEventQueue()->QueueEvent(new CreateProcessEvent(pProcess, m_pShim));
363 }
364} // end of methodICorDebugManagedCallback::CreateProcess
365
366
367// Implementation of ICorDebugManagedCallback::ExitProcess
368HRESULT ShimProxyCallback::ExitProcess(ICorDebugProcess * pProcess)
369{
370 m_pShim->PreDispatchEvent();
371 class ExitProcessEvent : public ManagedEvent
372 {
373 // callbacks parameters. These are strong references
374 RSExtSmartPtr<ICorDebugProcess > m_pProcess;
375
376 public:
377 // Ctor
378 ExitProcessEvent(ICorDebugProcess * pProcess) :
379 ManagedEvent()
380 {
381 this->m_pProcess.Assign(pProcess);
382 }
383
384 HRESULT Dispatch(DispatchArgs args)
385 {
386 return args.GetCallback1()->ExitProcess(m_pProcess);
387 }
388 }; // end class ExitProcessEvent
389
390 m_pShim->RemoveDuplicateCreationEventIfPresent(pProcess);
391 m_pShim->GetManagedEventQueue()->QueueEvent(new ExitProcessEvent(pProcess));
392 return S_OK;
393} // end of methodICorDebugManagedCallback::ExitProcess
394
395
396// Implementation of ICorDebugManagedCallback::CreateThread
397HRESULT ShimProxyCallback::CreateThread(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread)
398{
399 m_pShim->PreDispatchEvent();
400 class CreateThreadEvent : public ManagedEvent
401 {
402 // callbacks parameters. These are strong references
403 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
404 RSExtSmartPtr<ICorDebugThread > m_pThread;
405
406 public:
407 // Ctor
408 CreateThreadEvent(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread) :
409 ManagedEvent(pThread)
410 {
411 this->m_pAppDomain.Assign(pAppDomain);
412 this->m_pThread.Assign(pThread);
413 }
414
415 HRESULT Dispatch(DispatchArgs args)
416 {
417 return args.GetCallback1()->CreateThread(m_pAppDomain, m_pThread);
418 }
419 }; // end class CreateThreadEvent
420
421 if (!m_pShim->RemoveDuplicateCreationEventIfPresent(pThread))
422 {
423 m_pShim->GetManagedEventQueue()->QueueEvent(new CreateThreadEvent(pAppDomain, pThread));
424 }
425 return S_OK;
426} // end of methodICorDebugManagedCallback::CreateThread
427
428
429// Implementation of ICorDebugManagedCallback::ExitThread
430HRESULT ShimProxyCallback::ExitThread(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread)
431{
432 m_pShim->PreDispatchEvent();
433 class ExitThreadEvent : public ManagedEvent
434 {
435 // callbacks parameters. These are strong references
436 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
437 RSExtSmartPtr<ICorDebugThread > m_pThread;
438
439 public:
440 // Ctor
441 ExitThreadEvent(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread) :
442 ManagedEvent(pThread)
443 {
444 this->m_pAppDomain.Assign(pAppDomain);
445 this->m_pThread.Assign(pThread);
446 }
447
448 HRESULT Dispatch(DispatchArgs args)
449 {
450 return args.GetCallback1()->ExitThread(m_pAppDomain, m_pThread);
451 }
452 }; // end class ExitThreadEvent
453
454 m_pShim->RemoveDuplicateCreationEventIfPresent(pThread);
455 m_pShim->GetManagedEventQueue()->QueueEvent(new ExitThreadEvent(pAppDomain, pThread));
456 return S_OK;
457} // end of methodICorDebugManagedCallback::ExitThread
458
459
460// Called from fake attach events.
461//
462// Arguments:
463// pAppDomain - appdomain for the LoadModule debug event
464// pModule - module being loaded.
465//
466// Notes:
467// See code:ShimProcess::QueueFakeAttachEvents
468// This is the fake version of code:ShimProxyCallback::LoadModule.
469// It sends an IPC event to go in process to collect information that we can't yet get via
470// DAC from out-of-proc.
471void ShimProxyCallback::FakeLoadModule(ICorDebugAppDomain *pAppDomain, ICorDebugModule *pModule)
472{
473 class FakeLoadModuleEvent : public ManagedEvent
474 {
475 // callbacks parameters. These are strong references
476 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
477 RSExtSmartPtr<ICorDebugModule > m_pModule;
478
479 public:
480 // Ctor
481 FakeLoadModuleEvent(ICorDebugAppDomain * pAppDomain, ICorDebugModule * pModule, ShimProcess * pShim) :
482 ManagedEvent(),
483 m_pShim(pShim)
484 {
485 this->m_pAppDomain.Assign(pAppDomain);
486 this->m_pModule.Assign(pModule);
487 }
488
489 HRESULT Dispatch(DispatchArgs args)
490 {
491 // signal that we are in the callback--this will be cleared in code:CordbProcess::ContinueInternal
492 m_pShim->SetInLoadModule(true);
493 return args.GetCallback1()->LoadModule(m_pAppDomain, m_pModule);
494 }
495
496 // we need access to the shim in Dispatch so we can set the InLoadModule flag to keep track
497 // when we are actually in the callback. We need this information to be able to emulate
498 // the hresult logic in v2.0.
499 ShimProcess * m_pShim;
500 }; // end class LoadModuleEvent
501
502 m_pShim->GetManagedEventQueue()->QueueEvent(new FakeLoadModuleEvent(pAppDomain, pModule, m_pShim));
503} // end of methodICorDebugManagedCallback::LoadModule
504
505
506// Implementation of ICorDebugManagedCallback::LoadModule
507HRESULT ShimProxyCallback::LoadModule(ICorDebugAppDomain * pAppDomain, ICorDebugModule * pModule)
508{
509 m_pShim->PreDispatchEvent();
510 class LoadModuleEvent : public ManagedEvent
511 {
512 // callbacks parameters. These are strong references
513 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
514 RSExtSmartPtr<ICorDebugModule > m_pModule;
515
516 public:
517 // Ctor
518 LoadModuleEvent(ICorDebugAppDomain * pAppDomain, ICorDebugModule * pModule) :
519 ManagedEvent()
520 {
521 this->m_pAppDomain.Assign(pAppDomain);
522 this->m_pModule.Assign(pModule);
523 }
524
525 HRESULT Dispatch(DispatchArgs args)
526 {
527 return args.GetCallback1()->LoadModule(m_pAppDomain, m_pModule);
528 }
529 }; // end class LoadModuleEvent
530
531 if (!m_pShim->RemoveDuplicateCreationEventIfPresent(pModule))
532 {
533 m_pShim->GetManagedEventQueue()->QueueEvent(new LoadModuleEvent(pAppDomain, pModule));
534 }
535 return S_OK;
536} // end of methodICorDebugManagedCallback::LoadModule
537
538
539// Implementation of ICorDebugManagedCallback::UnloadModule
540HRESULT ShimProxyCallback::UnloadModule(ICorDebugAppDomain * pAppDomain, ICorDebugModule * pModule)
541{
542 m_pShim->PreDispatchEvent();
543 class UnloadModuleEvent : public ManagedEvent
544 {
545 // callbacks parameters. These are strong references
546 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
547 RSExtSmartPtr<ICorDebugModule > m_pModule;
548
549 public:
550 // Ctor
551 UnloadModuleEvent(ICorDebugAppDomain * pAppDomain, ICorDebugModule * pModule) :
552 ManagedEvent()
553 {
554 this->m_pAppDomain.Assign(pAppDomain);
555 this->m_pModule.Assign(pModule);
556 }
557
558 HRESULT Dispatch(DispatchArgs args)
559 {
560 return args.GetCallback1()->UnloadModule(m_pAppDomain, m_pModule);
561 }
562 }; // end class UnloadModuleEvent
563
564 m_pShim->RemoveDuplicateCreationEventIfPresent(pModule);
565 m_pShim->GetManagedEventQueue()->QueueEvent(new UnloadModuleEvent(pAppDomain, pModule));
566 return S_OK;
567} // end of methodICorDebugManagedCallback::UnloadModule
568
569
570// Implementation of ICorDebugManagedCallback::LoadClass
571HRESULT ShimProxyCallback::LoadClass(ICorDebugAppDomain * pAppDomain, ICorDebugClass * pClass)
572{
573 m_pShim->PreDispatchEvent();
574 class LoadClassEvent : public ManagedEvent
575 {
576 // callbacks parameters. These are strong references
577 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
578 RSExtSmartPtr<ICorDebugClass > m_pClass;
579
580 public:
581 // Ctor
582 LoadClassEvent(ICorDebugAppDomain * pAppDomain, ICorDebugClass * pClass) :
583 ManagedEvent()
584 {
585 this->m_pAppDomain.Assign(pAppDomain);
586 this->m_pClass.Assign(pClass);
587 }
588
589 HRESULT Dispatch(DispatchArgs args)
590 {
591 return args.GetCallback1()->LoadClass(m_pAppDomain, m_pClass);
592 }
593 }; // end class LoadClassEvent
594
595 m_pShim->GetManagedEventQueue()->QueueEvent(new LoadClassEvent(pAppDomain, pClass));
596 return S_OK;
597} // end of methodICorDebugManagedCallback::LoadClass
598
599
600// Implementation of ICorDebugManagedCallback::UnloadClass
601HRESULT ShimProxyCallback::UnloadClass(ICorDebugAppDomain * pAppDomain, ICorDebugClass * pClass)
602{
603 m_pShim->PreDispatchEvent();
604 class UnloadClassEvent : public ManagedEvent
605 {
606 // callbacks parameters. These are strong references
607 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
608 RSExtSmartPtr<ICorDebugClass > m_pClass;
609
610 public:
611 // Ctor
612 UnloadClassEvent(ICorDebugAppDomain * pAppDomain, ICorDebugClass * pClass) :
613 ManagedEvent()
614 {
615 this->m_pAppDomain.Assign(pAppDomain);
616 this->m_pClass.Assign(pClass);
617 }
618
619 HRESULT Dispatch(DispatchArgs args)
620 {
621 return args.GetCallback1()->UnloadClass(m_pAppDomain, m_pClass);
622 }
623 }; // end class UnloadClassEvent
624
625 m_pShim->GetManagedEventQueue()->QueueEvent(new UnloadClassEvent(pAppDomain, pClass));
626 return S_OK;
627} // end of methodICorDebugManagedCallback::UnloadClass
628
629
630// Implementation of ICorDebugManagedCallback::DebuggerError
631HRESULT ShimProxyCallback::DebuggerError(ICorDebugProcess * pProcess, HRESULT errorHR, DWORD errorCode)
632{
633 m_pShim->PreDispatchEvent();
634 class DebuggerErrorEvent : public ManagedEvent
635 {
636 // callbacks parameters. These are strong references
637 RSExtSmartPtr<ICorDebugProcess > m_pProcess;
638 HRESULT m_errorHR;
639 DWORD m_errorCode;
640
641 public:
642 // Ctor
643 DebuggerErrorEvent(ICorDebugProcess * pProcess, HRESULT errorHR, DWORD errorCode) :
644 ManagedEvent()
645 {
646 this->m_pProcess.Assign(pProcess);
647 this->m_errorHR = errorHR;
648 this->m_errorCode = errorCode;
649 }
650
651 HRESULT Dispatch(DispatchArgs args)
652 {
653 return args.GetCallback1()->DebuggerError(m_pProcess, m_errorHR, m_errorCode);
654 }
655 }; // end class DebuggerErrorEvent
656
657 m_pShim->GetManagedEventQueue()->QueueEvent(new DebuggerErrorEvent(pProcess, errorHR, errorCode));
658 return S_OK;
659} // end of methodICorDebugManagedCallback::DebuggerError
660
661
662// Implementation of ICorDebugManagedCallback::LogMessage
663HRESULT ShimProxyCallback::LogMessage(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, LONG lLevel, __in LPWSTR pLogSwitchName, __in LPWSTR pMessage)
664{
665 m_pShim->PreDispatchEvent();
666 class LogMessageEvent : public ManagedEvent
667 {
668 // callbacks parameters. These are strong references
669 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
670 RSExtSmartPtr<ICorDebugThread > m_pThread;
671 LONG m_lLevel;
672 StringCopyHolder m_pLogSwitchName;
673 StringCopyHolder m_pMessage;
674
675 public:
676 // Ctor
677 LogMessageEvent(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, LONG lLevel, LPCWSTR pLogSwitchName, LPCWSTR pMessage) :
678 ManagedEvent(pThread)
679 {
680 this->m_pAppDomain.Assign(pAppDomain);
681 this->m_pThread.Assign(pThread);
682 this->m_lLevel = lLevel;
683 this->m_pLogSwitchName.AssignCopy(pLogSwitchName);
684 this->m_pMessage.AssignCopy(pMessage);
685 }
686
687 HRESULT Dispatch(DispatchArgs args)
688 {
689 return args.GetCallback1()->LogMessage(m_pAppDomain, m_pThread, m_lLevel, const_cast<WCHAR*>((const WCHAR*)m_pLogSwitchName), const_cast<WCHAR*>((const WCHAR*)m_pMessage));
690 }
691 }; // end class LogMessageEvent
692
693 m_pShim->GetManagedEventQueue()->QueueEvent(new LogMessageEvent(pAppDomain, pThread, lLevel, pLogSwitchName, pMessage));
694 return S_OK;
695} // end of methodICorDebugManagedCallback::LogMessage
696
697
698// Implementation of ICorDebugManagedCallback::LogSwitch
699HRESULT ShimProxyCallback::LogSwitch(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, LONG lLevel, ULONG ulReason, __in LPWSTR pLogSwitchName, __in LPWSTR pParentName)
700{
701 m_pShim->PreDispatchEvent();
702 class LogSwitchEvent : public ManagedEvent
703 {
704 // callbacks parameters. These are strong references
705 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
706 RSExtSmartPtr<ICorDebugThread > m_pThread;
707 LONG m_lLevel;
708 ULONG m_ulReason;
709 StringCopyHolder m_pLogSwitchName;
710 StringCopyHolder m_pParentName;
711
712 public:
713 // Ctor
714 LogSwitchEvent(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, LONG lLevel, ULONG ulReason, LPCWSTR pLogSwitchName, LPCWSTR pParentName) :
715 ManagedEvent(pThread)
716 {
717 this->m_pAppDomain.Assign(pAppDomain);
718 this->m_pThread.Assign(pThread);
719 this->m_lLevel = lLevel;
720 this->m_ulReason = ulReason;
721 this->m_pLogSwitchName.AssignCopy(pLogSwitchName);
722 this->m_pParentName.AssignCopy(pParentName);
723 }
724
725 HRESULT Dispatch(DispatchArgs args)
726 {
727 return args.GetCallback1()->LogSwitch(m_pAppDomain, m_pThread, m_lLevel, m_ulReason, const_cast<WCHAR*>((const WCHAR*)m_pLogSwitchName), const_cast<WCHAR*>((const WCHAR*)m_pParentName));
728 }
729 }; // end class LogSwitchEvent
730
731 m_pShim->GetManagedEventQueue()->QueueEvent(new LogSwitchEvent(pAppDomain, pThread, lLevel, ulReason, pLogSwitchName, pParentName));
732 return S_OK;
733} // end of methodICorDebugManagedCallback::LogSwitch
734
735
736// Implementation of ICorDebugManagedCallback::CreateAppDomain
737HRESULT ShimProxyCallback::CreateAppDomain(ICorDebugProcess * pProcess, ICorDebugAppDomain * pAppDomain)
738{
739 m_pShim->PreDispatchEvent();
740 class CreateAppDomainEvent : public ManagedEvent
741 {
742 // callbacks parameters. These are strong references
743 RSExtSmartPtr<ICorDebugProcess > m_pProcess;
744 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
745
746 public:
747 // Ctor
748 CreateAppDomainEvent(ICorDebugProcess * pProcess, ICorDebugAppDomain * pAppDomain) :
749 ManagedEvent()
750 {
751 this->m_pProcess.Assign(pProcess);
752 this->m_pAppDomain.Assign(pAppDomain);
753 }
754
755 HRESULT Dispatch(DispatchArgs args)
756 {
757 return args.GetCallback1()->CreateAppDomain(m_pProcess, m_pAppDomain);
758 }
759 }; // end class CreateAppDomainEvent
760
761 if (!m_pShim->RemoveDuplicateCreationEventIfPresent(pAppDomain))
762 {
763 m_pShim->GetManagedEventQueue()->QueueEvent(new CreateAppDomainEvent(pProcess, pAppDomain));
764 }
765 return S_OK;
766} // end of methodICorDebugManagedCallback::CreateAppDomain
767
768
769// Implementation of ICorDebugManagedCallback::ExitAppDomain
770HRESULT ShimProxyCallback::ExitAppDomain(ICorDebugProcess * pProcess, ICorDebugAppDomain * pAppDomain)
771{
772 m_pShim->PreDispatchEvent();
773 class ExitAppDomainEvent : public ManagedEvent
774 {
775 // callbacks parameters. These are strong references
776 RSExtSmartPtr<ICorDebugProcess > m_pProcess;
777 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
778
779 public:
780 // Ctor
781 ExitAppDomainEvent(ICorDebugProcess * pProcess, ICorDebugAppDomain * pAppDomain) :
782 ManagedEvent()
783 {
784 this->m_pProcess.Assign(pProcess);
785 this->m_pAppDomain.Assign(pAppDomain);
786 }
787
788 HRESULT Dispatch(DispatchArgs args)
789 {
790 return args.GetCallback1()->ExitAppDomain(m_pProcess, m_pAppDomain);
791 }
792 }; // end class ExitAppDomainEvent
793
794 m_pShim->RemoveDuplicateCreationEventIfPresent(pAppDomain);
795 m_pShim->GetManagedEventQueue()->QueueEvent(new ExitAppDomainEvent(pProcess, pAppDomain));
796 return S_OK;
797} // end of methodICorDebugManagedCallback::ExitAppDomain
798
799
800// Implementation of ICorDebugManagedCallback::LoadAssembly
801HRESULT ShimProxyCallback::LoadAssembly(ICorDebugAppDomain * pAppDomain, ICorDebugAssembly * pAssembly)
802{
803 m_pShim->PreDispatchEvent();
804 class LoadAssemblyEvent : public ManagedEvent
805 {
806 // callbacks parameters. These are strong references
807 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
808 RSExtSmartPtr<ICorDebugAssembly > m_pAssembly;
809
810 public:
811 // Ctor
812 LoadAssemblyEvent(ICorDebugAppDomain * pAppDomain, ICorDebugAssembly * pAssembly) :
813 ManagedEvent()
814 {
815 this->m_pAppDomain.Assign(pAppDomain);
816 this->m_pAssembly.Assign(pAssembly);
817 }
818
819 HRESULT Dispatch(DispatchArgs args)
820 {
821 return args.GetCallback1()->LoadAssembly(m_pAppDomain, m_pAssembly);
822 }
823 }; // end class LoadAssemblyEvent
824
825 if (!m_pShim->RemoveDuplicateCreationEventIfPresent(pAssembly))
826 {
827 m_pShim->GetManagedEventQueue()->QueueEvent(new LoadAssemblyEvent(pAppDomain, pAssembly));
828 }
829 return S_OK;
830} // end of methodICorDebugManagedCallback::LoadAssembly
831
832
833// Implementation of ICorDebugManagedCallback::UnloadAssembly
834HRESULT ShimProxyCallback::UnloadAssembly(ICorDebugAppDomain * pAppDomain, ICorDebugAssembly * pAssembly)
835{
836 m_pShim->PreDispatchEvent();
837 class UnloadAssemblyEvent : public ManagedEvent
838 {
839 // callbacks parameters. These are strong references
840 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
841 RSExtSmartPtr<ICorDebugAssembly > m_pAssembly;
842
843 public:
844 // Ctor
845 UnloadAssemblyEvent(ICorDebugAppDomain * pAppDomain, ICorDebugAssembly * pAssembly) :
846 ManagedEvent()
847 {
848 this->m_pAppDomain.Assign(pAppDomain);
849 this->m_pAssembly.Assign(pAssembly);
850 }
851
852 HRESULT Dispatch(DispatchArgs args)
853 {
854 return args.GetCallback1()->UnloadAssembly(m_pAppDomain, m_pAssembly);
855 }
856 }; // end class UnloadAssemblyEvent
857
858 m_pShim->RemoveDuplicateCreationEventIfPresent(pAssembly);
859 m_pShim->GetManagedEventQueue()->QueueEvent(new UnloadAssemblyEvent(pAppDomain, pAssembly));
860 return S_OK;
861} // end of methodICorDebugManagedCallback::UnloadAssembly
862
863
864// Implementation of ICorDebugManagedCallback::ControlCTrap
865HRESULT ShimProxyCallback::ControlCTrap(ICorDebugProcess * pProcess)
866{
867 m_pShim->PreDispatchEvent();
868 class ControlCTrapEvent : public ManagedEvent
869 {
870 // callbacks parameters. These are strong references
871 RSExtSmartPtr<ICorDebugProcess > m_pProcess;
872
873 public:
874 // Ctor
875 ControlCTrapEvent(ICorDebugProcess * pProcess) :
876 ManagedEvent()
877 {
878 this->m_pProcess.Assign(pProcess);
879 }
880
881 HRESULT Dispatch(DispatchArgs args)
882 {
883 return args.GetCallback1()->ControlCTrap(m_pProcess);
884 }
885 }; // end class ControlCTrapEvent
886
887 m_pShim->GetManagedEventQueue()->QueueEvent(new ControlCTrapEvent(pProcess));
888 return S_OK;
889} // end of methodICorDebugManagedCallback::ControlCTrap
890
891
892// Implementation of ICorDebugManagedCallback::NameChange
893HRESULT ShimProxyCallback::NameChange(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread)
894{
895 m_pShim->PreDispatchEvent();
896 class NameChangeEvent : public ManagedEvent
897 {
898 // callbacks parameters. These are strong references
899 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
900 RSExtSmartPtr<ICorDebugThread > m_pThread;
901
902 public:
903 // Ctor
904 NameChangeEvent(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread) :
905 ManagedEvent(pThread)
906 {
907 this->m_pAppDomain.Assign(pAppDomain);
908 this->m_pThread.Assign(pThread);
909 }
910
911 HRESULT Dispatch(DispatchArgs args)
912 {
913 return args.GetCallback1()->NameChange(m_pAppDomain, m_pThread);
914 }
915 }; // end class NameChangeEvent
916
917 m_pShim->GetManagedEventQueue()->QueueEvent(new NameChangeEvent(pAppDomain, pThread));
918 return S_OK;
919} // end of methodICorDebugManagedCallback::NameChange
920
921
922// Implementation of ICorDebugManagedCallback::UpdateModuleSymbols
923HRESULT ShimProxyCallback::UpdateModuleSymbols(ICorDebugAppDomain * pAppDomain, ICorDebugModule * pModule, IStream * pSymbolStream)
924{
925 m_pShim->PreDispatchEvent();
926 class UpdateModuleSymbolsEvent : public ManagedEvent
927 {
928 // callbacks parameters. These are strong references
929 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
930 RSExtSmartPtr<ICorDebugModule > m_pModule;
931 RSExtSmartPtr<IStream > m_pSymbolStream;
932
933 public:
934 // Ctor
935 UpdateModuleSymbolsEvent(ICorDebugAppDomain * pAppDomain, ICorDebugModule * pModule, IStream * pSymbolStream) :
936 ManagedEvent()
937 {
938 this->m_pAppDomain.Assign(pAppDomain);
939 this->m_pModule.Assign(pModule);
940 this->m_pSymbolStream.Assign(pSymbolStream);
941 }
942
943 HRESULT Dispatch(DispatchArgs args)
944 {
945 return args.GetCallback1()->UpdateModuleSymbols(m_pAppDomain, m_pModule, m_pSymbolStream);
946 }
947 }; // end class UpdateModuleSymbolsEvent
948
949 m_pShim->GetManagedEventQueue()->QueueEvent(new UpdateModuleSymbolsEvent(pAppDomain, pModule, pSymbolStream));
950 return S_OK;
951} // end of methodICorDebugManagedCallback::UpdateModuleSymbols
952
953
954// Implementation of ICorDebugManagedCallback::EditAndContinueRemap
955HRESULT ShimProxyCallback::EditAndContinueRemap(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, ICorDebugFunction * pFunction, BOOL fAccurate)
956{
957 m_pShim->PreDispatchEvent();
958 class EditAndContinueRemapEvent : public ManagedEvent
959 {
960 // callbacks parameters. These are strong references
961 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
962 RSExtSmartPtr<ICorDebugThread > m_pThread;
963 RSExtSmartPtr<ICorDebugFunction > m_pFunction;
964 BOOL m_fAccurate;
965
966 public:
967 // Ctor
968 EditAndContinueRemapEvent(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, ICorDebugFunction * pFunction, BOOL fAccurate) :
969 ManagedEvent(pThread)
970 {
971 this->m_pAppDomain.Assign(pAppDomain);
972 this->m_pThread.Assign(pThread);
973 this->m_pFunction.Assign(pFunction);
974 this->m_fAccurate = fAccurate;
975 }
976
977 HRESULT Dispatch(DispatchArgs args)
978 {
979 return args.GetCallback1()->EditAndContinueRemap(m_pAppDomain, m_pThread, m_pFunction, m_fAccurate);
980 }
981 }; // end class EditAndContinueRemapEvent
982
983 m_pShim->GetManagedEventQueue()->QueueEvent(new EditAndContinueRemapEvent(pAppDomain, pThread, pFunction, fAccurate));
984 return S_OK;
985} // end of methodICorDebugManagedCallback::EditAndContinueRemap
986
987
988// Implementation of ICorDebugManagedCallback::BreakpointSetError
989HRESULT ShimProxyCallback::BreakpointSetError(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, ICorDebugBreakpoint * pBreakpoint, DWORD dwError)
990{
991 m_pShim->PreDispatchEvent();
992 class BreakpointSetErrorEvent : public ManagedEvent
993 {
994 // callbacks parameters. These are strong references
995 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
996 RSExtSmartPtr<ICorDebugThread > m_pThread;
997 RSExtSmartPtr<ICorDebugBreakpoint > m_pBreakpoint;
998 DWORD m_dwError;
999
1000 public:
1001 // Ctor
1002 BreakpointSetErrorEvent(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, ICorDebugBreakpoint * pBreakpoint, DWORD dwError) :
1003 ManagedEvent(pThread)
1004 {
1005 this->m_pAppDomain.Assign(pAppDomain);
1006 this->m_pThread.Assign(pThread);
1007 this->m_pBreakpoint.Assign(pBreakpoint);
1008 this->m_dwError = dwError;
1009 }
1010
1011 HRESULT Dispatch(DispatchArgs args)
1012 {
1013 return args.GetCallback1()->BreakpointSetError(m_pAppDomain, m_pThread, m_pBreakpoint, m_dwError);
1014 }
1015 }; // end class BreakpointSetErrorEvent
1016
1017 m_pShim->GetManagedEventQueue()->QueueEvent(new BreakpointSetErrorEvent(pAppDomain, pThread, pBreakpoint, dwError));
1018 return S_OK;
1019} // end of methodICorDebugManagedCallback::BreakpointSetError
1020
1021
1022// Implementation of ICorDebugManagedCallback2::FunctionRemapOpportunity
1023HRESULT ShimProxyCallback::FunctionRemapOpportunity(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, ICorDebugFunction * pOldFunction, ICorDebugFunction * pNewFunction, ULONG32 oldILOffset)
1024{
1025 m_pShim->PreDispatchEvent();
1026 class FunctionRemapOpportunityEvent : public ManagedEvent
1027 {
1028 // callbacks parameters. These are strong references
1029 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
1030 RSExtSmartPtr<ICorDebugThread > m_pThread;
1031 RSExtSmartPtr<ICorDebugFunction > m_pOldFunction;
1032 RSExtSmartPtr<ICorDebugFunction > m_pNewFunction;
1033 ULONG32 m_oldILOffset;
1034
1035 public:
1036 // Ctor
1037 FunctionRemapOpportunityEvent(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, ICorDebugFunction * pOldFunction, ICorDebugFunction * pNewFunction, ULONG32 oldILOffset) :
1038 ManagedEvent(pThread)
1039 {
1040 this->m_pAppDomain.Assign(pAppDomain);
1041 this->m_pThread.Assign(pThread);
1042 this->m_pOldFunction.Assign(pOldFunction);
1043 this->m_pNewFunction.Assign(pNewFunction);
1044 this->m_oldILOffset = oldILOffset;
1045 }
1046
1047 HRESULT Dispatch(DispatchArgs args)
1048 {
1049 return args.GetCallback2()->FunctionRemapOpportunity(m_pAppDomain, m_pThread, m_pOldFunction, m_pNewFunction, m_oldILOffset);
1050 }
1051 }; // end class FunctionRemapOpportunityEvent
1052
1053 m_pShim->GetManagedEventQueue()->QueueEvent(new FunctionRemapOpportunityEvent(pAppDomain, pThread, pOldFunction, pNewFunction, oldILOffset));
1054 return S_OK;
1055} // end of methodICorDebugManagedCallback2::FunctionRemapOpportunity
1056
1057
1058// Implementation of ICorDebugManagedCallback2::CreateConnection
1059HRESULT ShimProxyCallback::CreateConnection(ICorDebugProcess * pProcess, CONNID dwConnectionId, __in LPWSTR pConnectionName)
1060{
1061 m_pShim->PreDispatchEvent();
1062 class CreateConnectionEvent : public ManagedEvent
1063 {
1064 // callbacks parameters. These are strong references
1065 RSExtSmartPtr<ICorDebugProcess > m_pProcess;
1066 CONNID m_dwConnectionId;
1067 StringCopyHolder m_pConnectionName;
1068
1069 public:
1070 // Ctor
1071 CreateConnectionEvent(ICorDebugProcess * pProcess, CONNID dwConnectionId, LPCWSTR pConnectionName) :
1072 ManagedEvent()
1073 {
1074 this->m_pProcess.Assign(pProcess);
1075 this->m_dwConnectionId = dwConnectionId;
1076 this->m_pConnectionName.AssignCopy(pConnectionName);
1077 }
1078
1079 HRESULT Dispatch(DispatchArgs args)
1080 {
1081 return args.GetCallback2()->CreateConnection(m_pProcess, m_dwConnectionId, const_cast<WCHAR*>((const WCHAR*)m_pConnectionName));
1082 }
1083 }; // end class CreateConnectionEvent
1084
1085 m_pShim->GetManagedEventQueue()->QueueEvent(new CreateConnectionEvent(pProcess, dwConnectionId, pConnectionName));
1086 return S_OK;
1087} // end of methodICorDebugManagedCallback2::CreateConnection
1088
1089
1090// Implementation of ICorDebugManagedCallback2::ChangeConnection
1091HRESULT ShimProxyCallback::ChangeConnection(ICorDebugProcess * pProcess, CONNID dwConnectionId)
1092{
1093 m_pShim->PreDispatchEvent();
1094 class ChangeConnectionEvent : public ManagedEvent
1095 {
1096 // callbacks parameters. These are strong references
1097 RSExtSmartPtr<ICorDebugProcess > m_pProcess;
1098 CONNID m_dwConnectionId;
1099
1100 public:
1101 // Ctor
1102 ChangeConnectionEvent(ICorDebugProcess * pProcess, CONNID dwConnectionId) :
1103 ManagedEvent()
1104 {
1105 this->m_pProcess.Assign(pProcess);
1106 this->m_dwConnectionId = dwConnectionId;
1107 }
1108
1109 HRESULT Dispatch(DispatchArgs args)
1110 {
1111 return args.GetCallback2()->ChangeConnection(m_pProcess, m_dwConnectionId);
1112 }
1113 }; // end class ChangeConnectionEvent
1114
1115 m_pShim->GetManagedEventQueue()->QueueEvent(new ChangeConnectionEvent(pProcess, dwConnectionId));
1116 return S_OK;
1117} // end of methodICorDebugManagedCallback2::ChangeConnection
1118
1119
1120// Implementation of ICorDebugManagedCallback2::DestroyConnection
1121HRESULT ShimProxyCallback::DestroyConnection(ICorDebugProcess * pProcess, CONNID dwConnectionId)
1122{
1123 m_pShim->PreDispatchEvent();
1124 class DestroyConnectionEvent : public ManagedEvent
1125 {
1126 // callbacks parameters. These are strong references
1127 RSExtSmartPtr<ICorDebugProcess > m_pProcess;
1128 CONNID m_dwConnectionId;
1129
1130 public:
1131 // Ctor
1132 DestroyConnectionEvent(ICorDebugProcess * pProcess, CONNID dwConnectionId) :
1133 ManagedEvent()
1134 {
1135 this->m_pProcess.Assign(pProcess);
1136 this->m_dwConnectionId = dwConnectionId;
1137 }
1138
1139 HRESULT Dispatch(DispatchArgs args)
1140 {
1141 return args.GetCallback2()->DestroyConnection(m_pProcess, m_dwConnectionId);
1142 }
1143 }; // end class DestroyConnectionEvent
1144
1145 m_pShim->GetManagedEventQueue()->QueueEvent(new DestroyConnectionEvent(pProcess, dwConnectionId));
1146 return S_OK;
1147} // end of methodICorDebugManagedCallback2::DestroyConnection
1148
1149
1150
1151// Implementation of ICorDebugManagedCallback2::Exception
1152HRESULT ShimProxyCallback::Exception(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, ICorDebugFrame * pFrame, ULONG32 nOffset, CorDebugExceptionCallbackType dwEventType, DWORD dwFlags)
1153{
1154 m_pShim->PreDispatchEvent();
1155 class ExceptionEvent : public ManagedEvent
1156 {
1157 // callbacks parameters. These are strong references
1158 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
1159 RSExtSmartPtr<ICorDebugThread > m_pThread;
1160 RSExtSmartPtr<ICorDebugFrame > m_pFrame;
1161 ULONG32 m_nOffset;
1162 CorDebugExceptionCallbackType m_dwEventType;
1163 DWORD m_dwFlags;
1164
1165 public:
1166 // Ctor
1167 ExceptionEvent(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, ICorDebugFrame * pFrame, ULONG32 nOffset, CorDebugExceptionCallbackType dwEventType, DWORD dwFlags) :
1168 ManagedEvent(pThread)
1169 {
1170 this->m_pAppDomain.Assign(pAppDomain);
1171 this->m_pThread.Assign(pThread);
1172 this->m_pFrame.Assign(pFrame);
1173 this->m_nOffset = nOffset;
1174 this->m_dwEventType = dwEventType;
1175 this->m_dwFlags = dwFlags;
1176 }
1177
1178 HRESULT Dispatch(DispatchArgs args)
1179 {
1180 return args.GetCallback2()->Exception(m_pAppDomain, m_pThread, UpdateFrame(m_pThread, m_pFrame), m_nOffset, m_dwEventType, m_dwFlags);
1181 }
1182 }; // end class ExceptionEvent
1183
1184 m_pShim->GetManagedEventQueue()->QueueEvent(new ExceptionEvent(pAppDomain, pThread, pFrame, nOffset, dwEventType, dwFlags));
1185 return S_OK;
1186} // end of methodICorDebugManagedCallback2::Exception
1187
1188
1189// Implementation of ICorDebugManagedCallback2::ExceptionUnwind
1190HRESULT ShimProxyCallback::ExceptionUnwind(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, CorDebugExceptionUnwindCallbackType dwEventType, DWORD dwFlags)
1191{
1192 m_pShim->PreDispatchEvent();
1193 class ExceptionUnwindEvent : public ManagedEvent
1194 {
1195 // callbacks parameters. These are strong references
1196 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
1197 RSExtSmartPtr<ICorDebugThread > m_pThread;
1198 CorDebugExceptionUnwindCallbackType m_dwEventType;
1199 DWORD m_dwFlags;
1200
1201 public:
1202 // Ctor
1203 ExceptionUnwindEvent(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, CorDebugExceptionUnwindCallbackType dwEventType, DWORD dwFlags) :
1204 ManagedEvent(pThread)
1205 {
1206 this->m_pAppDomain.Assign(pAppDomain);
1207 this->m_pThread.Assign(pThread);
1208 this->m_dwEventType = dwEventType;
1209 this->m_dwFlags = dwFlags;
1210 }
1211
1212 HRESULT Dispatch(DispatchArgs args)
1213 {
1214 return args.GetCallback2()->ExceptionUnwind(m_pAppDomain, m_pThread, m_dwEventType, m_dwFlags);
1215 }
1216 }; // end class ExceptionUnwindEvent
1217
1218 m_pShim->GetManagedEventQueue()->QueueEvent(new ExceptionUnwindEvent(pAppDomain, pThread, dwEventType, dwFlags));
1219 return S_OK;
1220} // end of methodICorDebugManagedCallback2::ExceptionUnwind
1221
1222
1223// Implementation of ICorDebugManagedCallback2::FunctionRemapComplete
1224HRESULT ShimProxyCallback::FunctionRemapComplete(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, ICorDebugFunction * pFunction)
1225{
1226 m_pShim->PreDispatchEvent();
1227 class FunctionRemapCompleteEvent : public ManagedEvent
1228 {
1229 // callbacks parameters. These are strong references
1230 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
1231 RSExtSmartPtr<ICorDebugThread > m_pThread;
1232 RSExtSmartPtr<ICorDebugFunction > m_pFunction;
1233
1234 public:
1235 // Ctor
1236 FunctionRemapCompleteEvent(ICorDebugAppDomain * pAppDomain, ICorDebugThread * pThread, ICorDebugFunction * pFunction) :
1237 ManagedEvent(pThread)
1238 {
1239 this->m_pAppDomain.Assign(pAppDomain);
1240 this->m_pThread.Assign(pThread);
1241 this->m_pFunction.Assign(pFunction);
1242 }
1243
1244 HRESULT Dispatch(DispatchArgs args)
1245 {
1246 return args.GetCallback2()->FunctionRemapComplete(m_pAppDomain, m_pThread, m_pFunction);
1247 }
1248 }; // end class FunctionRemapCompleteEvent
1249
1250 m_pShim->GetManagedEventQueue()->QueueEvent(new FunctionRemapCompleteEvent(pAppDomain, pThread, pFunction));
1251 return S_OK;
1252} // end of methodICorDebugManagedCallback2::FunctionRemapComplete
1253
1254
1255// Implementation of ICorDebugManagedCallback2::MDANotification
1256HRESULT ShimProxyCallback::MDANotification(ICorDebugController * pController, ICorDebugThread * pThread, ICorDebugMDA * pMDA)
1257{
1258 m_pShim->PreDispatchEvent();
1259 class MDANotificationEvent : public ManagedEvent
1260 {
1261 // callbacks parameters. These are strong references
1262 RSExtSmartPtr<ICorDebugController > m_pController;
1263 RSExtSmartPtr<ICorDebugThread > m_pThread;
1264 RSExtSmartPtr<ICorDebugMDA > m_pMDA;
1265
1266 public:
1267 // Ctor
1268 MDANotificationEvent(ICorDebugController * pController, ICorDebugThread * pThread, ICorDebugMDA * pMDA) :
1269 ManagedEvent(pThread)
1270 {
1271 this->m_pController.Assign(pController);
1272 this->m_pThread.Assign(pThread);
1273 this->m_pMDA.Assign(pMDA);
1274 }
1275
1276 HRESULT Dispatch(DispatchArgs args)
1277 {
1278 return args.GetCallback2()->MDANotification(m_pController, m_pThread, m_pMDA);
1279 }
1280 }; // end class MDANotificationEvent
1281
1282 m_pShim->GetManagedEventQueue()->QueueEvent(new MDANotificationEvent(pController, pThread, pMDA));
1283 return S_OK;
1284} // end of methodICorDebugManagedCallback2::MDANotification
1285
1286// Implementation of ICorDebugManagedCallback3::CustomNotification
1287// Arguments:
1288// input:
1289// pThread - thread on which the notification occurred
1290// pAppDomain - appDomain in which the notification occurred
1291// Return value: S_OK
1292HRESULT ShimProxyCallback::CustomNotification(ICorDebugThread * pThread, ICorDebugAppDomain * pAppDomain)
1293{
1294 m_pShim->PreDispatchEvent();
1295 class CustomNotificationEvent : public ManagedEvent
1296 {
1297 // callbacks parameters. These are strong references
1298 RSExtSmartPtr<ICorDebugAppDomain > m_pAppDomain;
1299 RSExtSmartPtr<ICorDebugThread > m_pThread;
1300
1301 public:
1302 // Ctor
1303 CustomNotificationEvent(ICorDebugThread * pThread, ICorDebugAppDomain * pAppDomain) :
1304 ManagedEvent(pThread)
1305 {
1306 this->m_pAppDomain.Assign(pAppDomain);
1307 this->m_pThread.Assign(pThread);
1308 }
1309
1310 HRESULT Dispatch(DispatchArgs args)
1311 {
1312 return args.GetCallback3()->CustomNotification(m_pThread, m_pAppDomain);
1313 }
1314 }; // end class CustomNotificationEvent
1315
1316 m_pShim->GetManagedEventQueue()->QueueEvent(new CustomNotificationEvent(pThread, pAppDomain));
1317 return S_OK;
1318}
1319
1320// Implementation of ICorDebugManagedCallback4::BeforeGarbageCollection
1321// Arguments:
1322// input:
1323// pController - controller in which the notification occurred
1324// Return value: S_OK
1325HRESULT ShimProxyCallback::BeforeGarbageCollection(ICorDebugProcess* pProcess)
1326{
1327 m_pShim->PreDispatchEvent();
1328 class BeforeGarbageCollectionEvent : public ManagedEvent
1329 {
1330 // callbacks parameters. These are strong references
1331 RSExtSmartPtr<ICorDebugProcess> m_pProcess;
1332
1333 public:
1334 // Ctor
1335 BeforeGarbageCollectionEvent(ICorDebugProcess* pProcess) :
1336 ManagedEvent()
1337 {
1338 this->m_pProcess.Assign(pProcess);
1339 }
1340
1341 HRESULT Dispatch(DispatchArgs args)
1342 {
1343 return args.GetCallback4()->BeforeGarbageCollection(m_pProcess);
1344 }
1345 }; // end class BeforeGarbageCollectionEvent
1346
1347 m_pShim->GetManagedEventQueue()->QueueEvent(new BeforeGarbageCollectionEvent(pProcess));
1348 return S_OK;
1349}
1350
1351// Implementation of ICorDebugManagedCallback4::AfterGarbageCollection
1352// Arguments:
1353// input:
1354// pController - controller in which the notification occurred
1355// Return value: S_OK
1356HRESULT ShimProxyCallback::AfterGarbageCollection(ICorDebugProcess* pProcess)
1357{
1358 m_pShim->PreDispatchEvent();
1359 class AfterGarbageCollectionEvent : public ManagedEvent
1360 {
1361 // callbacks parameters. These are strong references
1362 RSExtSmartPtr<ICorDebugProcess > m_pProcess;
1363
1364 public:
1365 // Ctor
1366 AfterGarbageCollectionEvent(ICorDebugProcess* pProcess) :
1367 ManagedEvent()
1368 {
1369 this->m_pProcess.Assign(pProcess);
1370 }
1371
1372 HRESULT Dispatch(DispatchArgs args)
1373 {
1374 return args.GetCallback4()->AfterGarbageCollection(m_pProcess);
1375 }
1376 }; // end class AfterGarbageCollectionEvent
1377
1378 m_pShim->GetManagedEventQueue()->QueueEvent(new AfterGarbageCollectionEvent(pProcess));
1379 return S_OK;
1380}
1381
1382// Implementation of ICorDebugManagedCallback4::DataBreakpoint
1383// Arguments:
1384// input:
1385// pProcess - process in which the notification occurred
1386// Return value: S_OK
1387HRESULT ShimProxyCallback::DataBreakpoint(ICorDebugProcess* pProcess, ICorDebugThread* pThread, BYTE* pContext, ULONG32 contextSize)
1388{
1389 m_pShim->PreDispatchEvent();
1390 class DataBreakpointEvent : public ManagedEvent
1391 {
1392 // callbacks parameters. These are strong references
1393 RSExtSmartPtr<ICorDebugProcess> m_pProcess;
1394 RSExtSmartPtr<ICorDebugThread> m_pThread;
1395 CONTEXT m_context;
1396 ULONG32 m_contextSize;
1397
1398 public:
1399 // Ctor
1400 DataBreakpointEvent(ICorDebugProcess* pProcess, ICorDebugThread* pThread, BYTE* pContext, ULONG32 contextSize) :
1401 ManagedEvent()
1402 {
1403 this->m_pProcess.Assign(pProcess);
1404 this->m_pThread.Assign(pThread);
1405
1406 _ASSERTE(contextSize == sizeof(CONTEXT));
1407 this->m_contextSize = min(contextSize, sizeof(CONTEXT));
1408 memcpy(&(this->m_context), pContext, this->m_contextSize);
1409 }
1410
1411 HRESULT Dispatch(DispatchArgs args)
1412 {
1413 return args.GetCallback4()->DataBreakpoint(m_pProcess, m_pThread, reinterpret_cast<BYTE*>(&m_context), m_contextSize);
1414 }
1415 }; // end class AfterGarbageCollectionEvent
1416
1417 m_pShim->GetManagedEventQueue()->QueueEvent(new DataBreakpointEvent(pProcess, pThread, pContext, contextSize));
1418 return S_OK;
1419}
1420
1421
1422
1423