Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions src/CodingWithCalvin.BreakpointNotifier/DebuggerEvents.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System.Windows.Forms;
using System;
using System.Windows.Forms;
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
public sealed class DebuggerEvents : IVsDebuggerEvents, IDebugEventCallback2
{
private DebuggerEvents()
{
Expand All @@ -16,6 +18,7 @@ private DebuggerEvents()
ServiceProvider.GlobalProvider.GetService(typeof(IVsDebugger));
Assumes.Present(debugger);
debugger.AdviseDebuggerEvents(this, out _);
debugger.AdviseDebugEventCallback(this);
}

public static DebuggerEvents Initialize()
Expand All @@ -25,11 +28,23 @@ public static DebuggerEvents Initialize()

public int OnModeChange(DBGMODE dbgmodeNew)
{
switch (dbgmodeNew)
// No longer showing message here - we use IDebugEventCallback2 instead
// to specifically detect breakpoint hits vs. step operations
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)
{
case DBGMODE.DBGMODE_Break:
MessageBox.Show("Breakpoint Hit!");
break;
MessageBox.Show("Breakpoint Hit!");
}

return VSConstants.S_OK;
Expand Down