-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDebuggerEvents.cs
More file actions
68 lines (61 loc) · 2.08 KB
/
DebuggerEvents.cs
File metadata and controls
68 lines (61 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using CodingWithCalvin.Otel4Vsix;
using Microsoft;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Debugger.Interop;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
namespace CodingWithCalvin.BreakpointNotifier
{
public sealed class DebuggerEvents : IVsDebuggerEvents, IDebugEventCallback2
{
private DebuggerEvents()
{
ThreadHelper.ThrowIfNotOnUIThread();
var debugger = (IVsDebugger)
ServiceProvider.GlobalProvider.GetService(typeof(IVsDebugger));
Assumes.Present(debugger);
debugger.AdviseDebuggerEvents(this, out _);
debugger.AdviseDebugEventCallback(this);
}
public static DebuggerEvents Initialize()
{
return new DebuggerEvents();
}
public int OnModeChange(DBGMODE dbgmodeNew)
{
VsixTelemetry.LogInformation("Debugger mode changed to {Mode}", dbgmodeNew.ToString());
return VSConstants.S_OK;
}
public int Event(
IDebugEngine2 pEngine,
IDebugProcess2 pProcess,
IDebugProgram2 pProgram,
IDebugThread2 pThread,
IDebugEvent2 pEvent,
ref Guid riidEvent,
uint dwAttrib)
{
if (pEvent is IDebugBreakpointEvent2)
{
using var activity = VsixTelemetry.StartCommandActivity("BreakpointNotifier.BreakpointHit");
try
{
VsixTelemetry.LogInformation("Breakpoint hit detected");
MessageBox.Show("Breakpoint Hit!");
}
catch (Exception ex)
{
activity?.RecordError(ex);
VsixTelemetry.TrackException(ex, new Dictionary<string, object>
{
{ "operation.name", "BreakpointHit" }
});
}
}
return VSConstants.S_OK;
}
}
}