microsoft / microsoft/MIEngine

set pending breakpoint from within the extension

Open
#530 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
859
Forks
233
Avg merge
1d 6h
Merged PRs (30d)
3

Description

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 auto 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. My research so far yields no good way.

Could any one help me here ?

Thanks !

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in MIDebugEngine/Engine.Impl/DebuggedProcess.cs, especially GetInitializeCommands() and HandleBreakModeEvent(), then trace BreakpointManager.FindHitBreakpoints() and the pending-breakpoint creation APIs in BreakpointManager and AD7Engine. Done means the startup breakpoint at main is registered through the breakpoint system and is not skipped when hit.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.