Skip to content

Commit

Permalink
Refactor exception breakpoint code.
Browse files Browse the repository at this point in the history
Changes:
- Partially revert PR111 and PR167 changes.
- Remove source-wide `using` usage for STL containers (we don't use it in entire project, plus, we have implementation for same containers what have STL in newer C++ standard versions).
- Revise exception breakpoint logic, will properly act in case of `throw` and `user-unhandled` now.
- Revise exception breakpoint logic, will peoperly work with and without JMC enabled.
- Fix stack trace output in order to properly mark non-user code frames, will mark such frames as "[External Code]" (same behaviour as MS vsdbg).
- Add error message in case evaluation failed due to variable with requested name does not exist in the current context.
- Fix MI/GDB protocol add and delete exception breakpoint commands.
- Fix MI/GDB and CLI protocols exception message related code, will provide proper info now.
- Add VSCode protocol 'terminate' command.
- Remove unused code.
  • Loading branch information
viewizard authored and Alexander Soldatov/Platform Lab /SRR/Staff Engineer/Samsung Electronics committed Jun 20, 2021
1 parent 14b8b12 commit 0eb4607
Show file tree
Hide file tree
Showing 22 changed files with 1,044 additions and 1,015 deletions.
46 changes: 23 additions & 23 deletions src/debugger/breakpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@

#include <palclr.h>

using std::string;

namespace netcoredbg
{

void Breakpoints::SetJustMyCode(bool enable)
{
m_uniqueFuncBreakpoints->SetJustMyCode(enable);
m_uniqueLineBreakpoints->SetJustMyCode(enable);
m_uniqueExceptionBreakpoints->SetJustMyCode(enable);
}

void Breakpoints::SetLastStoppedIlOffset(ICorDebugProcess *pProcess, const ThreadId &lastStoppedThreadId)
Expand All @@ -51,30 +50,12 @@ HRESULT Breakpoints::ManagedCallbackBreak(ICorDebugThread *pThread, const Thread
return m_uniqueBreakBreakpoint->ManagedCallbackBreak(pThread, lastStoppedThreadId);
}

HRESULT Breakpoints::InsertExceptionBreakpoint(const ExceptionBreakMode &mode, const std::string &name, uint32_t &id)
{
m_nextBreakpointIdMutex.lock();
id = m_nextBreakpointId++;
m_nextBreakpointIdMutex.unlock();

return m_uniqueExceptionBreakpoints->InsertExceptionBreakpoint(mode, name, id);
}

HRESULT Breakpoints::DeleteExceptionBreakpoint(const uint32_t id)
{
return m_uniqueExceptionBreakpoints->DeleteExceptionBreakpoint(id);
}

HRESULT Breakpoints::GetExceptionInfoResponse(ICorDebugProcess *pProcess, ThreadId threadId, ExceptionInfoResponse &exceptionInfoResponse)
{
return m_uniqueExceptionBreakpoints->GetExceptionInfoResponse(pProcess, threadId, exceptionInfoResponse);
}

void Breakpoints::DeleteAll()
{
m_uniqueEntryBreakpoint->Delete();
m_uniqueFuncBreakpoints->DeleteAll();
m_uniqueLineBreakpoints->DeleteAll();
m_uniqueExceptionBreakpoints->DeleteAll();
}

HRESULT Breakpoints::DisableAll(ICorDebugProcess *pProcess)
Expand Down Expand Up @@ -123,6 +104,20 @@ HRESULT Breakpoints::SetLineBreakpoints(ICorDebugProcess *pProcess, const std::s
});
}

HRESULT Breakpoints::SetExceptionBreakpoints(const std::vector<ExceptionBreakpoint> &exceptionBreakpoints, std::vector<Breakpoint> &breakpoints)
{
return m_uniqueExceptionBreakpoints->SetExceptionBreakpoints(exceptionBreakpoints, breakpoints, [&]() -> uint32_t
{
std::lock_guard<std::mutex> lock(m_nextBreakpointIdMutex);
return m_nextBreakpointId++;
});
}

HRESULT Breakpoints::GetExceptionInfo(ICorDebugThread *pThread, ExceptionInfo &exceptionInfo)
{
return m_uniqueExceptionBreakpoints->GetExceptionInfo(pThread, exceptionInfo);
}

HRESULT Breakpoints::ManagedCallbackBreakpoint(IDebugger *debugger, ICorDebugThread *pThread, ICorDebugBreakpoint *pBreakpoint, Breakpoint &breakpoint, bool &atEntry)
{
// CheckBreakpointHit return:
Expand Down Expand Up @@ -164,9 +159,9 @@ HRESULT Breakpoints::ManagedCallbackLoadModule(ICorDebugModule *pModule, std::ve
return S_OK;
}

HRESULT Breakpoints::ManagedCallbackException(ICorDebugThread *pThread, CorDebugExceptionCallbackType dwEventType, StoppedEvent &event, std::string &textOutput)
HRESULT Breakpoints::ManagedCallbackException(ICorDebugThread *pThread, ExceptionCallbackType eventType, const std::string &excModule, StoppedEvent &event)
{
return m_uniqueExceptionBreakpoints->ManagedCallbackException(pThread, dwEventType, event, textOutput);
return m_uniqueExceptionBreakpoints->ManagedCallbackException(pThread, eventType, excModule, event);
}

HRESULT Breakpoints::AllBreakpointsActivate(bool act)
Expand Down Expand Up @@ -203,4 +198,9 @@ void Breakpoints::EnumerateBreakpoints(std::function<bool (const IDebugger::Brea

}

HRESULT Breakpoints::ManagedCallbackExitThread(ICorDebugThread *pThread)
{
return m_uniqueExceptionBreakpoints->ManagedCallbackExitThread(pThread);
}

} // namespace netcoredbg
12 changes: 6 additions & 6 deletions src/debugger/breakpoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ class Breakpoints
{
public:

Breakpoints(std::shared_ptr<Modules> &sharedModules, std::shared_ptr<Variables> &sharedVariables, std::shared_ptr<Evaluator> &sharedEvaluator) :
Breakpoints(std::shared_ptr<Modules> &sharedModules, std::shared_ptr<Evaluator> &sharedEvaluator) :
m_uniqueBreakBreakpoint(new BreakBreakpoint(sharedModules)),
m_uniqueEntryBreakpoint(new EntryBreakpoint(sharedModules)),
m_uniqueExceptionBreakpoints(new ExceptionBreakpoints(sharedVariables, sharedEvaluator)),
m_uniqueExceptionBreakpoints(new ExceptionBreakpoints(sharedEvaluator)),
m_uniqueFuncBreakpoints(new FuncBreakpoints(sharedModules)),
m_uniqueLineBreakpoints(new LineBreakpoints(sharedModules)),
m_nextBreakpointId(1)
Expand All @@ -44,10 +44,9 @@ class Breakpoints
HRESULT SetFuncBreakpoints(ICorDebugProcess *pProcess, const std::vector<FuncBreakpoint> &funcBreakpoints, std::vector<Breakpoint> &breakpoints);
HRESULT SetLineBreakpoints(ICorDebugProcess *pProcess, const std::string &filename,
const std::vector<LineBreakpoint> &lineBreakpoints, std::vector<Breakpoint> &breakpoints);
HRESULT SetExceptionBreakpoints(const std::vector<ExceptionBreakpoint> &exceptionBreakpoints, std::vector<Breakpoint> &breakpoints);

HRESULT InsertExceptionBreakpoint(const ExceptionBreakMode &mode, const std::string &name, uint32_t &id);
HRESULT DeleteExceptionBreakpoint(const uint32_t id);
HRESULT GetExceptionInfoResponse(ICorDebugProcess *pProcess, ThreadId threadId, ExceptionInfoResponse &exceptionInfoResponse);
HRESULT GetExceptionInfo(ICorDebugThread *pThread, ExceptionInfo &exceptionInfo);

void EnumerateBreakpoints(std::function<bool (const IDebugger::BreakpointInfo&)>&& callback);
HRESULT BreakpointActivate(uint32_t id, bool act);
Expand All @@ -62,8 +61,9 @@ class Breakpoints
// return S_OK;
HRESULT ManagedCallbackBreak(ICorDebugThread *pThread, const ThreadId &lastStoppedThreadId);
HRESULT ManagedCallbackBreakpoint(IDebugger *debugger, ICorDebugThread *pThread, ICorDebugBreakpoint *pBreakpoint, Breakpoint &breakpoint, bool &atEntry);
HRESULT ManagedCallbackException(ICorDebugThread *pThread, CorDebugExceptionCallbackType dwEventType, StoppedEvent &event, std::string &textOutput);
HRESULT ManagedCallbackException(ICorDebugThread *pThread, ExceptionCallbackType eventType, const std::string &excModule, StoppedEvent &event);
HRESULT ManagedCallbackLoadModule(ICorDebugModule *pModule, std::vector<BreakpointEvent> &events);
HRESULT ManagedCallbackExitThread(ICorDebugThread *pThread);

private:

Expand Down
Loading

0 comments on commit 0eb4607

Please sign in to comment.