| 1760 | |
| 1761 | |
| 1762 | DebugStopReason DebuggerController::ExecuteAdapterAndWait(const DebugAdapterOperation operation) |
| 1763 | { |
| 1764 | // Due to the nature of the wait, this mutex should NOT be allowed to be locked recursively. |
| 1765 | // If this is a pause operation, do not try to lock the mutex -- it is mostly likely held by another thread |
| 1766 | if ((operation != DebugAdapterPause) && (operation != DebugAdapterQuit) && (operation != DebugAdapterDetach) |
| 1767 | && !m_adapterMutex.try_lock()) |
| 1768 | throw std::runtime_error("Cannot obtain mutex for debug adapter"); |
| 1769 | |
| 1770 | Semaphore sem; |
| 1771 | DebugStopReason reason = UnknownReason; |
| 1772 | size_t callback = RegisterEventCallback( |
| 1773 | [&](const DebuggerEvent& event) { |
| 1774 | switch (event.type) |
| 1775 | { |
| 1776 | case AdapterStoppedEventType: |
| 1777 | reason = event.data.targetStoppedData.reason; |
| 1778 | sem.Release(); |
| 1779 | break; |
| 1780 | // It is a little awkward to add two cases for these events, but we must take them into account, |
| 1781 | // since after we resume the target, the target can either or exit. |
| 1782 | case TargetExitedEventType: |
| 1783 | case DetachedEventType: |
| 1784 | // There is no DebugStopReason for "detach", so we use ProcessExited for now |
| 1785 | reason = ProcessExited; |
| 1786 | sem.Release(); |
| 1787 | break; |
| 1788 | default: |
| 1789 | break; |
| 1790 | } |
| 1791 | m_lastAdapterStopEventConsumed = true; |
| 1792 | }, |
| 1793 | "WaitForAdapterStop"); |
| 1794 | |
| 1795 | bool resumeOK = false; |
| 1796 | bool operationRequested = false; |
| 1797 | switch (operation) |
| 1798 | { |
| 1799 | case DebugAdapterGo: |
| 1800 | resumeOK = m_adapter->Go(); |
| 1801 | break; |
| 1802 | case DebugAdapterStepInto: |
| 1803 | resumeOK = m_adapter->StepInto(); |
| 1804 | break; |
| 1805 | case DebugAdapterStepOver: |
| 1806 | resumeOK = m_adapter->StepOver(); |
| 1807 | break; |
| 1808 | case DebugAdapterStepReturn: |
| 1809 | resumeOK = m_adapter->StepReturn(); |
| 1810 | break; |
| 1811 | case DebugAdapterPause: |
| 1812 | operationRequested = m_adapter->BreakInto(); |
| 1813 | break; |
| 1814 | case DebugAdapterQuit: |
| 1815 | m_liveView->AbortAnalysis(); |
| 1816 | m_adapter->Quit(); |
| 1817 | break; |
| 1818 | case DebugAdapterDetach: |
| 1819 | m_liveView->AbortAnalysis(); |
nothing calls this directly
no test coverage detected