问题描述
您好,
Hi there,
我正在编写基于MIEngine的调试器扩展.我想做的一件事是允许在调试器启动时在main处停止,即调试器而不是用户需要在main()处设置断点.
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().
在MIDebugEngine/Engine.Impl/DebuggedProcess.cs-> GetInitializeCommands()中,有以下一行:
commands.Add(new LaunchCommand(-break-insert main",ignoreFailures:true));
In MIDebugEngine/Engine.Impl/DebuggedProcess.cs->GetInitializeCommands(), there is this line:
commands.Add(new LaunchCommand("-break-insert main", ignoreFailures: true));
它确实在main处设置了一个中断.但是当遇到断点时,此代码将对其进行处理:
DebuggedProcess.HandleBreakModeEvent()
由于这行
AD7BoundBreakpoint [] bkpt = _breakpointManager.FindHitBreakpoints(bkptno,addr,frame,out fContinue);
在BreakpointManager中找不到断点,此行稍后会发出继续命令
//我们碰到了一个点,等待删除
//发布CmdContinueAsync操作,以便在我们删除所有待处理的删除操作之前不会发生
CmdContinueAsyncConditional(breakRequest);
这意味着该断点实际上已被跳过.
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.
要解决该问题,我能想到的最佳解决方案是通过调用此断点来设置main
Microsoft.MIDebugEngine.BreakpointManager.CreatePendingBreakpoint(((IDebugBreakpointRequest2 pBPRequest,出IDebugPendingBreakpoint2 ppPendingBP)
或
Microsoft.MIDebugEngine.AD7Engine.CreatePendingBreakpoint(IDebugBreakpointRequest2 pBPRequest,出IDebugPendingBreakpoint2 ppPendingBP)
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)
但是我遇到的障碍是如何创建"pBRRequest" API的对象. 界面 IDebugBreakpointRequest2是一个包含接口的复杂程序.到目前为止,我的研究没有好的方法.
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 ?
谢谢!
推荐答案
以下链接提供了有关如何创建IDebugBreakpointRequest2实例的示例,供您参考.
The following link provide a sample about how to create IDebugBreakpointRequest2 instance for your reference.
最诚挚的问候,
吴可乐
这篇关于从调试器扩展中设置挂起的断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!