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