Author: kuba.brecka
Date: Wed Mar 30 05:50:24 2016
New Revision: 264854

URL: http://llvm.org/viewvc/llvm-project?rev=264854&view=rev
Log:
Fix the ThreadSanitizer support to avoid creating empty SBThreads and to not 
crash when thread_id is unavailable.  Plus a whitespace fix.


Modified:
    lldb/trunk/source/API/SBThread.cpp
    
lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp

Modified: lldb/trunk/source/API/SBThread.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=264854&r1=264853&r2=264854&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThread.cpp (original)
+++ lldb/trunk/source/API/SBThread.cpp Wed Mar 30 05:50:24 2016
@@ -338,8 +338,12 @@ AddThreadsForPath(std::string path, Thre
             pcs.push_back(pc->GetAsInteger()->GetValue());
             return true;
         });
+
+        if (pcs.size() == 0)
+            return true;
         
-        tid_t tid = 
o->GetObjectForDotSeparatedPath("thread_id")->GetIntegerValue();
+        StructuredData::ObjectSP thread_id_obj = 
o->GetObjectForDotSeparatedPath("thread_id");
+        tid_t tid = thread_id_obj ? thread_id_obj->GetIntegerValue() : 0;
         uint32_t stop_id = 0;
         bool stop_id_is_valid = false;
         HistoryThread *history_thread = new HistoryThread(*process_sp, tid, 
pcs, stop_id, stop_id_is_valid);

Modified: 
lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp?rev=264854&r1=264853&r2=264854&view=diff
==============================================================================
--- 
lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
 Wed Mar 30 05:50:24 2016
@@ -259,7 +259,7 @@ for (int i = 0; i < t.thread_count; i++)
     __tsan_get_report_thread(t.report, i, &t.threads[i].tid, 
&t.threads[i].pid, &t.threads[i].running, &t.threads[i].name, 
&t.threads[i].parent_tid, t.threads[i].trace, REPORT_TRACE_SIZE);
 }
 
-if (t.unique_tid_count > REPORT_ARRAY_SIZE) t.unique_tid_count = 
REPORT_ARRAY_SIZE;
+if (t.unique_tid_count > REPORT_ARRAY_SIZE) t.unique_tid_count = 
REPORT_ARRAY_SIZE;
 for (int i = 0; i < t.unique_tid_count; i++) {
     t.unique_tids[i].idx = i;
     __tsan_get_report_unique_tid(t.report, i, &t.unique_tids[i].tid);


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to