Hi there,
I'm writing a debugger extension based on MIEngine. One thing I want to do is allow stop-at-main on debugger start, namely the debugger instead of user needs to set a breakpoint at main().
In MIDebugEngine/Engine.Impl/DebuggedProcess.cs->GetInitializeCommands(), there is this line:
commands.Add(new LaunchCommand("-break-insert main", ignoreFailures: true));
It does set a break at main. But when the breakpoint gets hit, this code handles it:
DebuggedProcess.HandleBreakModeEvent()
As this line
AD7BoundBreakpoint[] bkpt = _breakpointManager.FindHitBreakpoints(bkptno, addr, frame, out fContinue);
fails to find the breakpoint in BreakpointManager, a continue command is issued later by this line
//we hit a bp pending deletion
//post the CmdContinueAsync operation so it does not happen until we have deleted all the pending deletes
CmdContinueAsyncConditional(breakRequest);
That means the breakpoint is practically skipped.
To solve the problem, the best solution I can think of is to set the breakpoint at main by calling this
Microsoft.MIDebugEngine.BreakpointManager.CreatePendingBreakpoint((IDebugBreakpointRequest2 pBPRequest, out IDebugPendingBreakpoint2 ppPendingBP)
or
Microsoft.MIDebugEngine.AD7Engine.CreatePendingBreakpoint(IDebugBreakpointRequest2 pBPRequest, out IDebugPendingBreakpoint2 ppPendingBP)
But the road block I run into is how to create the "pBRRequest" object for the API. The interfaceIDebugBreakpointRequest2 is a complex one with interfaces in it. My research so far yields no good way.
Could any one help by giving me an example ?
Thanks !