|
33 | 33 |
|
34 | 34 | #include <algorithm>
|
35 | 35 |
|
| 36 | +//++ |
| 37 | +// Details: The check for the non-MI command "frame variable" validates that the |
| 38 | +// process is paused and the frame exists. |
| 39 | +// Type: Method. |
| 40 | +// Args: processState - the current process state. |
| 41 | +// threadInvalid - (R) Caller's m_bThreadInvalid member. |
| 42 | +// Return: MIstatus::success - Function succeeded. |
| 43 | +// MIstatus::failure - Function failed. |
| 44 | +// Throws: None. |
| 45 | +//-- |
| 46 | +bool EnsureProcessIsPaused(lldb::StateType processState, bool &threadInvalid) { |
| 47 | + switch (processState) { |
| 48 | + case lldb::eStateInvalid: |
| 49 | + case lldb::eStateCrashed: |
| 50 | + threadInvalid = true; |
| 51 | + return MIstatus::failure; |
| 52 | + case lldb::eStateSuspended: |
| 53 | + case lldb::eStateStopped: |
| 54 | + break; |
| 55 | + default: |
| 56 | + threadInvalid = true; |
| 57 | + } |
| 58 | + |
| 59 | + return MIstatus::success; |
| 60 | +} |
| 61 | + |
36 | 62 | //++
|
37 | 63 | // Details: CMICmdCmdStackInfoDepth constructor.
|
38 | 64 | // Type: Method.
|
@@ -519,20 +545,18 @@ bool CMICmdCmdStackListArguments::Execute() {
|
519 | 545 | CMICmnLLDBDebugSessionInfo &rSessionInfo(
|
520 | 546 | CMICmnLLDBDebugSessionInfo::Instance());
|
521 | 547 | lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
|
| 548 | + |
| 549 | + if (!EnsureProcessIsPaused(sbProcess.GetState(), m_bThreadInvalid)) { |
| 550 | + return MIstatus::failure; |
| 551 | + } |
| 552 | + |
522 | 553 | lldb::SBThread thread = (nThreadId != UINT64_MAX)
|
523 | 554 | ? sbProcess.GetThreadByIndexID(nThreadId)
|
524 | 555 | : sbProcess.GetSelectedThread();
|
525 |
| - m_bThreadInvalid = !thread.IsValid(); |
| 556 | + m_bThreadInvalid |= !thread.IsValid(); |
526 | 557 | if (m_bThreadInvalid)
|
527 | 558 | return MIstatus::success;
|
528 | 559 |
|
529 |
| - const lldb::StopReason eStopReason = thread.GetStopReason(); |
530 |
| - if ((eStopReason == lldb::eStopReasonNone) || |
531 |
| - (eStopReason == lldb::eStopReasonInvalid)) { |
532 |
| - m_bThreadInvalid = true; |
533 |
| - return MIstatus::success; |
534 |
| - } |
535 |
| - |
536 | 560 | const MIuint nFrames = thread.GetNumFrames();
|
537 | 561 | if (nFrameLow >= nFrames) {
|
538 | 562 | // The low-frame is larger than the actual number of frames
|
@@ -857,20 +881,18 @@ bool CMICmdCmdStackListVariables::Execute() {
|
857 | 881 | CMICmnLLDBDebugSessionInfo &rSessionInfo(
|
858 | 882 | CMICmnLLDBDebugSessionInfo::Instance());
|
859 | 883 | lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
|
| 884 | + |
| 885 | + if (!EnsureProcessIsPaused(sbProcess.GetState(), m_bThreadInvalid)) { |
| 886 | + return MIstatus::failure; |
| 887 | + } |
| 888 | + |
860 | 889 | lldb::SBThread thread = (nThreadId != UINT64_MAX)
|
861 | 890 | ? sbProcess.GetThreadByIndexID(nThreadId)
|
862 | 891 | : sbProcess.GetSelectedThread();
|
863 |
| - m_bThreadInvalid = !thread.IsValid(); |
| 892 | + m_bThreadInvalid |= !thread.IsValid(); |
864 | 893 | if (m_bThreadInvalid)
|
865 | 894 | return MIstatus::success;
|
866 | 895 |
|
867 |
| - const lldb::StopReason eStopReason = thread.GetStopReason(); |
868 |
| - if ((eStopReason == lldb::eStopReasonNone) || |
869 |
| - (eStopReason == lldb::eStopReasonInvalid)) { |
870 |
| - m_bThreadInvalid = true; |
871 |
| - return MIstatus::success; |
872 |
| - } |
873 |
| - |
874 | 896 | lldb::SBFrame frame = (nFrame != UINT64_MAX) ? thread.GetFrameAtIndex(nFrame)
|
875 | 897 | : thread.GetSelectedFrame();
|
876 | 898 |
|
|
0 commit comments