summaryrefslogtreecommitdiffstats
path: root/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
diff options
context:
space:
mode:
authorIlia K <ki.stfu@gmail.com>2015-03-26 07:11:31 +0000
committerIlia K <ki.stfu@gmail.com>2015-03-26 07:11:31 +0000
commit490500a7e851e5dbf77587818daf9714c71a8a70 (patch)
treeec1bc14c2a30eda6a009dd38eda462da1b8117ad /lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
parentfcc89a079f8f52551b36713d8f6ce84c89701430 (diff)
downloadbcm5719-llvm-490500a7e851e5dbf77587818daf9714c71a8a70.tar.gz
bcm5719-llvm-490500a7e851e5dbf77587818daf9714c71a8a70.zip
Fix =thread-exited message (MI)
Summary: This patch includes: # Fix invalid thread id in =thread-exited message # Remove invalid threads from cache All tests pass on OS X. Test Plan: now ``` =thread-exited,id="3",group-id="i1" =thread-exited,id="4",group-id="i1" =thread-exited,id="5",group-id="i1" ``` was ``` =thread-exited,id="4294967295",group-id="i1" =thread-exited,id="4294967295",group-id="i1" ... =thread-exited,id="4294967295",group-id="i1" =thread-exited,id="4294967295",group-id="i1" ``` Reviewers: abidh Reviewed By: abidh Subscribers: lldb-commits, abidh Differential Revision: http://reviews.llvm.org/D8603 llvm-svn: 233256
Diffstat (limited to 'lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp')
-rw-r--r--lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp60
1 files changed, 23 insertions, 37 deletions
diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp b/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
index 8d0841f9c96..37d495f1b54 100644
--- a/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
+++ b/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
@@ -1612,14 +1612,10 @@ CMICmnLLDBDebuggerHandleEvents::GetProcessStderr(void)
bool
CMICmnLLDBDebuggerHandleEvents::ChkForStateChanges(void)
{
- lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess();
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
if (!sbProcess.IsValid())
return MIstatus::success;
- lldb::SBTarget sbTarget = CMICmnLLDBDebugSessionInfo::Instance().GetTarget();
- if (!sbTarget.IsValid())
- return MIstatus::success;
-
- bool bOk = MIstatus::success;
// Check for created threads
const MIuint nThread = sbProcess.GetNumThreads();
@@ -1631,33 +1627,20 @@ CMICmnLLDBDebuggerHandleEvents::ChkForStateChanges(void)
if (!thread.IsValid())
continue;
- CMICmnLLDBDebugSessionInfo::VecActiveThreadId_t::const_iterator it =
- CMICmnLLDBDebugSessionInfo::Instance().m_vecActiveThreadId.begin();
- bool bFound = false;
- while (it != CMICmnLLDBDebugSessionInfo::Instance().m_vecActiveThreadId.end())
- {
- const MIuint nThreadId = *it;
- if (nThreadId == i)
- {
- bFound = true;
- break;
- }
-
- // Next
- ++it;
- }
+ const MIuint threadIndexID = thread.GetIndexID();
+ const bool bFound = std::find(rSessionInfo.m_vecActiveThreadId.begin(), rSessionInfo.m_vecActiveThreadId.end(), threadIndexID) != rSessionInfo.m_vecActiveThreadId.end();
if (!bFound)
{
- CMICmnLLDBDebugSessionInfo::Instance().m_vecActiveThreadId.push_back(i);
+ rSessionInfo.m_vecActiveThreadId.push_back(threadIndexID);
// Form MI "=thread-created,id=\"%d\",group-id=\"i1\""
- const CMIUtilString strValue(CMIUtilString::Format("%d", thread.GetIndexID()));
+ const CMIUtilString strValue(CMIUtilString::Format("%d", threadIndexID));
const CMICmnMIValueConst miValueConst(strValue);
const CMICmnMIValueResult miValueResult("id", miValueConst);
CMICmnMIOutOfBandRecord miOutOfBand(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated, miValueResult);
const CMICmnMIValueConst miValueConst2("i1");
const CMICmnMIValueResult miValueResult2("group-id", miValueConst2);
- bOk = miOutOfBand.Add(miValueResult2);
+ bool bOk = miOutOfBand.Add(miValueResult2);
bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBand);
if (!bOk)
return MIstatus::failure;
@@ -1667,13 +1650,13 @@ CMICmnLLDBDebuggerHandleEvents::ChkForStateChanges(void)
lldb::SBThread currentThread = sbProcess.GetSelectedThread();
if (currentThread.IsValid())
{
- const MIuint threadId = currentThread.GetIndexID();
- if (CMICmnLLDBDebugSessionInfo::Instance().m_currentSelectedThread != threadId)
+ const MIuint currentThreadIndexID = currentThread.GetIndexID();
+ if (rSessionInfo.m_currentSelectedThread != currentThreadIndexID)
{
- CMICmnLLDBDebugSessionInfo::Instance().m_currentSelectedThread = threadId;
+ rSessionInfo.m_currentSelectedThread = currentThreadIndexID;
// Form MI "=thread-selected,id=\"%d\""
- const CMIUtilString strValue(CMIUtilString::Format("%d", currentThread.GetIndexID()));
+ const CMIUtilString strValue(CMIUtilString::Format("%d", currentThreadIndexID));
const CMICmnMIValueConst miValueConst(strValue);
const CMICmnMIValueResult miValueResult("id", miValueConst);
CMICmnMIOutOfBandRecord miOutOfBand(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected, miValueResult);
@@ -1683,28 +1666,31 @@ CMICmnLLDBDebuggerHandleEvents::ChkForStateChanges(void)
}
// Check for invalid (removed) threads
- CMICmnLLDBDebugSessionInfo::VecActiveThreadId_t::const_iterator it = CMICmnLLDBDebugSessionInfo::Instance().m_vecActiveThreadId.begin();
- while (it != CMICmnLLDBDebugSessionInfo::Instance().m_vecActiveThreadId.end())
+ CMICmnLLDBDebugSessionInfo::VecActiveThreadId_t::const_iterator it = rSessionInfo.m_vecActiveThreadId.begin();
+ while (it != rSessionInfo.m_vecActiveThreadId.end())
{
- const MIuint nThreadId = *it;
- lldb::SBThread thread = sbProcess.GetThreadAtIndex(nThreadId);
+ const MIuint threadIndexID = *it;
+ lldb::SBThread thread = sbProcess.GetThreadByIndexID(threadIndexID);
if (!thread.IsValid())
{
// Form MI "=thread-exited,id=\"%ld\",group-id=\"i1\""
- const CMIUtilString strValue(CMIUtilString::Format("%ld", thread.GetIndexID()));
+ const CMIUtilString strValue(CMIUtilString::Format("%ld", threadIndexID));
const CMICmnMIValueConst miValueConst(strValue);
const CMICmnMIValueResult miValueResult("id", miValueConst);
CMICmnMIOutOfBandRecord miOutOfBand(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, miValueResult);
const CMICmnMIValueConst miValueConst2("i1");
const CMICmnMIValueResult miValueResult2("group-id", miValueConst2);
- bOk = miOutOfBand.Add(miValueResult2);
+ bool bOk = miOutOfBand.Add(miValueResult2);
bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBand);
if (!bOk)
return MIstatus::failure;
- }
- // Next
- ++it;
+ // Remove current thread from cache and get next
+ it = rSessionInfo.m_vecActiveThreadId.erase(it);
+ }
+ else
+ // Next
+ ++it;
}
return TextToStdout("(gdb)");
OpenPOWER on IntegriCloud