return E_FAIL;
}
-HRESULT HitBreakpoint(ICorDebugThread *pThread, ULONG32 &id, ULONG32 ×)
+HRESULT HitBreakpoint(ICorDebugThread *pThread, Breakpoint &breakpoint)
{
HRESULT Status;
b.linenum == sp.startLine &&
b.enabled)
{
- id = b.id;
- times = ++b.times;
+ ++b.times;
+ b.ToBreakpoint(breakpoint);
return S_OK;
}
}
HRESULT GetCurrentBreakpoint(ICorDebugThread *pThread, Breakpoint &breakpoint);
void DeleteAllBreakpoints();
-HRESULT HitBreakpoint(ICorDebugThread *pThread, ULONG32 &id, ULONG32 ×);
+HRESULT HitBreakpoint(ICorDebugThread *pThread, Breakpoint &breakpoint);
void TryResolveBreakpointsForModule(ICorDebugModule *pModule);
return Status;
}
-HRESULT Debugger::EmitBreakpointEvent(BreakpointEvent event)
+void Debugger::EmitBreakpointEvent(BreakpointEvent event)
{
switch(event.reason)
{
std::string output;
PrintBreakpoint(event.breakpoint, output);
Debugger::Printf("=breakpoint-modified,%s\n", output.c_str());
- return S_OK;
+ return;
}
default:
- return S_OK;
+ break;
}
}
return S_OK;
}
-HRESULT Debugger::EmitStoppedEvent(StoppedEvent event)
+void Debugger::EmitStoppedEvent(StoppedEvent event)
{
HRESULT Status;
- ToRelease<ICorDebugThread> pThread;
- IfFailRet(m_pProcess->GetThread(event.threadId, &pThread));
-
- StackFrame stackFrame;
- ToRelease<ICorDebugFrame> pFrame;
- if (SUCCEEDED(pThread->GetActiveFrame(&pFrame)) && pFrame != nullptr)
- GetFrameLocation(pFrame, stackFrame);
std::string frameLocation;
- PrintFrameLocation(stackFrame, frameLocation);
+ PrintFrameLocation(event.frame, frameLocation);
switch(event.reason)
{
case StopBreakpoint:
{
- Breakpoint b;
- IfFailRet(GetCurrentBreakpoint(pThread, b));
-
Debugger::Printf("*stopped,reason=\"breakpoint-hit\",thread-id=\"%i\",stopped-threads=\"all\",bkptno=\"%u\",times=\"%u\",frame={%s}\n",
- event.threadId, (unsigned int)b.id, (unsigned int)b.hitCount, frameLocation.c_str());
- return S_OK;
+ event.threadId, (unsigned int)event.breakpoint.id, (unsigned int)event.breakpoint.hitCount, frameLocation.c_str());
+ return;
}
case StopStep:
{
Debugger::Printf("*stopped,reason=\"end-stepping-range\",thread-id=\"%i\",stopped-threads=\"all\",frame={%s}\n",
event.threadId, frameLocation.c_str());
- return S_OK;
+ return;
}
case StopException:
{
frameLocation.c_str());
}
default:
- return S_OK;
+ break;
}
}
-HRESULT Debugger::EmitExitedEvent(ExitedEvent event)
+void Debugger::EmitExitedEvent(ExitedEvent event)
{
Debugger::Printf("*stopped,reason=\"exited\",exit-code=\"%i\"\n", event.exitCode);
- return S_OK;
}
-HRESULT Debugger::EmitThreadEvent(ThreadEvent event)
+void Debugger::EmitThreadEvent(ThreadEvent event)
{
const char *reasonText = "";
switch(event.reason)
break;
}
Debugger::Printf("=%s,id=\"%i\"\n", reasonText, event.threadId);
- return S_OK;
}
-HRESULT Debugger::EmitOutputEvent(OutputEvent event)
+void Debugger::EmitOutputEvent(OutputEvent event)
{
if (event.source.empty())
Debugger::Printf("=message,text=\"%s\",send-to=\"output-window\"\"\n",
Debugger::Printf("=message,text=\"%s\",send-to=\"output-window\",source=\"%s\"\n",
Debugger::EscapeMIValue(event.output).c_str(),
Debugger::EscapeMIValue(event.source).c_str());
-
- return S_OK;
}
HRESULT Debugger::HandleCommand(std::string command,
const std::vector<std::string> &args,
std::string &output, StepType stepType);
- HRESULT EmitStoppedEvent(StoppedEvent event);
- HRESULT EmitExitedEvent(ExitedEvent event);
- HRESULT EmitThreadEvent(ThreadEvent event);
- HRESULT EmitOutputEvent(OutputEvent event);
+ static void EmitStoppedEvent(StoppedEvent event);
+ static void EmitExitedEvent(ExitedEvent event);
+ static void EmitThreadEvent(ThreadEvent event);
+ static void EmitOutputEvent(OutputEvent event);
public:
- static HRESULT EmitBreakpointEvent(BreakpointEvent event);
+ static void EmitBreakpointEvent(BreakpointEvent event);
static bool IsJustMyCode() { return m_justMyCode; }
static void SetJustMyCode(bool enable) { m_justMyCode = enable; }
DWORD threadId = 0;
pThread->GetID(&threadId);
- ULONG32 id = 0;
- ULONG32 times = 0;
- HitBreakpoint(pThread, id, times);
+ StoppedEvent event(StopBreakpoint, threadId);
+ HitBreakpoint(pThread, event.breakpoint);
+
+ ToRelease<ICorDebugFrame> pFrame;
+ if (SUCCEEDED(pThread->GetActiveFrame(&pFrame)) && pFrame != nullptr)
+ GetFrameLocation(pFrame, event.frame);
SetLastStoppedThread(pThread);
- m_debugger->EmitStoppedEvent(StoppedEvent(StopBreakpoint, threadId));
+ m_debugger->EmitStoppedEvent(event);
return S_OK;
}
DWORD threadId = 0;
pThread->GetID(&threadId);
+ StoppedEvent event(StopStep, threadId);
+ event.frame = stackFrame;
+
SetLastStoppedThread(pThread);
- m_debugger->EmitStoppedEvent(StoppedEvent(StopStep, threadId));
+ m_debugger->EmitStoppedEvent(event);
}
return S_OK;
}
DWORD threadId = 0;
pThread->GetID(&threadId);
+ StackFrame stackFrame;
+ ToRelease<ICorDebugFrame> pFrame;
+ if (SUCCEEDED(pThread->GetActiveFrame(&pFrame)) && pFrame != nullptr)
+ GetFrameLocation(pFrame, stackFrame);
+
SetLastStoppedThread(pThread);
std::string details = "An unhandled exception of type '" + excType + "' occurred in " + excModule;
StoppedEvent event(StopException, threadId);
event.text = excType;
event.description = message.empty() ? details : message;
+ event.frame = stackFrame;
m_debugger->EmitStoppedEvent(event);
};
StackFrame(uint64_t id, std::string name) : id(id), name(name) {}
};
-enum StopReason
-{
- StopStep,
- StopBreakpoint,
- StopException,
- StopPause,
- StopEntry
-};
-
-struct StoppedEvent
-{
- StopReason reason;
- std::string description;
- int threadId;
- std::string text;
- bool allThreadsStopped;
-
- StoppedEvent(StopReason reason, int threadId = 0) : reason(reason), threadId(threadId), allThreadsStopped(true) {}
-};
-
struct Breakpoint
{
uint32_t id;
BreakpointRemoved
};
+enum StopReason
+{
+ StopStep,
+ StopBreakpoint,
+ StopException,
+ StopPause,
+ StopEntry
+};
+
+struct StoppedEvent
+{
+ StopReason reason;
+ std::string description;
+ int threadId;
+ std::string text;
+ bool allThreadsStopped;
+
+ StackFrame frame; // exposed for MI protocol
+ Breakpoint breakpoint; // exposed for MI protocol
+
+ StoppedEvent(StopReason reason, int threadId = 0) : reason(reason), threadId(threadId), allThreadsStopped(true) {}
+};
+
struct BreakpointEvent
{
BreakpointReason reason;