Visual Studio'da, herhangi bir işlem için hata ayıklayıcısını eklemek isterseniz, kullanmak istediğiniz belirli bir motoru (kod türü) veya bir dizi motor kümesi seçmenize olanak tanır:Hata ayıklayıcı tarafından kullanılan hata ayıklama motorları hakkında bilgi
sonra Ekle düğmesini tıklarsanız, (da motor ve süreçleri seçilmiş sonra), ayıklayıcı işlemi başlatılır ekleyin. Daha sonra hata ayıklama ile ilgili olaylar da tetiklenir. IDebugEventCallback2::Event
grab tür olaylara kullanılan (ve örneğin ayıklayıcı aslında çalışmasına verdiği süreçlerin adlarını ayıklamak) edilebilir: olmuştur motorları hakkında bazı bilgiler almak için herhangi bir benzer bir yolu var mı
public int Event(IDebugEngine2 engine, IDebugProcess2 process, IDebugProgram2 program,
IDebugThread2 thread, IDebugEvent2 debugEvent, ref Guid riidEvent,
uint attributes)
{
if (debugEvent is IDebugProcessCreateEvent2)
{
string processname;
if(process != null)
process.GetName((uint) enum_GETNAME_TYPE.GN_FILENAME, out processname);
//...
}
}
seçilen?
GÜNCELLEME: biraz daha detaylı kodu:
public class DebugEventsHunter : IVsDebuggerEvents, IDebugEventCallback2
{
private readonly IVsDebugger _debugger;
private uint _cookie;
public DebugEventsHunter(IVsDebugger debugger) { _debugger = debugger; }
public void Start()
{
_debugger.AdviseDebuggerEvents(this, out _cookie);
_debugger.AdviseDebugEventCallback(this);
}
public int Event(IDebugEngine2 engine, IDebugProcess2 process, IDebugProgram2 program,
IDebugThread2 thread, IDebugEvent2 debugEvent, ref Guid riidEvent, uint attributes)
{
if (debugEvent is IDebugProcessCreateEvent2)
{
// get process name (shown before)
}
if (debugEvent is IDebugEngineCreateEvent2)
{
// why execution flow never enters this scope?
IDebugEngine2 e;
((IDebugEngineCreateEvent2)debugEvent).GetEngine(out e);
}
// engine parameter is also always null within this scope
return VSConstants.S_OK;
}
public int OnModeChange(DBGMODE mode) { /*...*/ }
}
ve kullanımı:
bir hata ayıklama motoru bir süreç başlattı veya varolan sürecine verdiğivar debugger = GetService(typeof(SVsShellDebugger)) as IVsDebugger;
var hunter = new DebugEventsHunter(debugger);
hunter.Start();
Sonraki adımı nasıl atladığınızı görmek zor, IDebugProcessCreateEvent2.GetEngine() öğesini çağırın. Ne yanlış gitti? –
@Hans Passant: "IDebugEngineCreateEvent2 :: GetEngine()" demek istiyorsan, onu kullanmayı denedim, ancak hiç bir başarı gösteremedim. Ne yanlış yaptığımı doğrulamak için güncellenmiş soru kontrol edin (btw: VS2013 kullanıyorum, bu herhangi bir fark yaratıyor). – jwaliszko