[Lldb-commits] [lldb] r157767 - /lldb/trunk/source/Commands/CommandObjectThread.cpp

Jim Ingham jingham at apple.com
Thu May 31 13:48:41 PDT 2012


Author: jingham
Date: Thu May 31 15:48:41 2012
New Revision: 157767

URL: http://llvm.org/viewvc/llvm-project?rev=157767&view=rev
Log:
Fix a bunch of thinko's in the command "thread continue".

rdar://problem/11562050

Modified:
    lldb/trunk/source/Commands/CommandObjectThread.cpp

Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=157767&r1=157766&r2=157767&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectThread.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectThread.cpp Thu May 31 15:48:41 2012
@@ -660,11 +660,26 @@
                 std::vector<uint32_t> resume_thread_indexes;
                 for (uint32_t i=0; i<argc; ++i)
                 {
-                    idx = Args::StringToUInt32 (command.GetArgumentAtIndex(0), LLDB_INVALID_INDEX32);
-                    if (idx < num_threads)
-                        resume_thread_indexes.push_back(idx);
+                    bool success;
+                    const int base = 0;
+                    idx = Args::StringToUInt32 (command.GetArgumentAtIndex(i), LLDB_INVALID_INDEX32, base, &success);
+                    if (!success)
+                    {
+                        result.AppendErrorWithFormat ("invalid value for thread index: %s.", command.GetArgumentAtIndex(i));
+                        result.SetStatus (eReturnStatusFailed);
+                        return false;
+                    }
+                    else if (process->GetThreadList().FindThreadByIndexID(idx))
+                    {
+                        if (find(resume_thread_indexes.begin(), resume_thread_indexes.end(), idx) == resume_thread_indexes.end())
+                            resume_thread_indexes.push_back(idx);
+                    }
                     else
-                        result.AppendWarningWithFormat("Thread index %u out of range.\n", idx);
+                    {
+                        result.AppendErrorWithFormat("thread index %u out of range.\n", idx);
+                        result.SetStatus (eReturnStatusFailed);
+                        return false;
+                    }
                 }
 
                 if (resume_thread_indexes.empty())
@@ -675,13 +690,24 @@
                 }
                 else
                 {
-                    result.AppendMessage ("Resuming thread ");
+                    if (resume_thread_indexes.size() == 1)
+                        result.AppendMessageWithFormat ("Resuming thread: ");
+                    else
+                        result.AppendMessageWithFormat ("Resuming threads: ");
+
                     for (idx=0; idx<num_threads; ++idx)
                     {
                         Thread *thread = process->GetThreadList().FindThreadByIndexID(idx).get();
-                        if (find(resume_thread_indexes.begin(), resume_thread_indexes.end(), idx) != resume_thread_indexes.end())
+                        std::vector<uint32_t>::iterator this_thread_pos = find(resume_thread_indexes.begin(), resume_thread_indexes.end(), thread->GetIndexID());
+                        
+                        if (this_thread_pos != resume_thread_indexes.end())
                         {
-                            result.AppendMessageWithFormat ("%u ", idx);
+                            resume_thread_indexes.erase(this_thread_pos);
+                            if (resume_thread_indexes.size() > 0)
+                                result.AppendMessageWithFormat ("%u, ", thread->GetIndexID());
+                            else
+                                result.AppendMessageWithFormat ("%u ", thread->GetIndexID());
+                            
                             thread->SetResumeState (eStateRunning);
                         }
                         else





More information about the lldb-commits mailing list