[Lldb-commits] [lldb] r275226 - Remove assert since it was crashing the mutli process driver tests. Made the code behave correctly when indexes are out of range or the collection is empty and is "log enable lldb unwind" is enabled, log an error message.

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 12 16:07:50 PDT 2016


Author: gclayton
Date: Tue Jul 12 18:07:50 2016
New Revision: 275226

URL: http://llvm.org/viewvc/llvm-project?rev=275226&view=rev
Log:
Remove assert since it was crashing the mutli process driver tests. Made the code behave correctly when indexes are out of range or the collection is empty and is "log enable lldb unwind" is enabled, log an error message.


Modified:
    lldb/trunk/source/Symbol/UnwindPlan.cpp

Modified: lldb/trunk/source/Symbol/UnwindPlan.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindPlan.cpp?rev=275226&r1=275225&r2=275226&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/UnwindPlan.cpp (original)
+++ lldb/trunk/source/Symbol/UnwindPlan.cpp Tue Jul 12 18:07:50 2016
@@ -385,16 +385,27 @@ UnwindPlan::IsValidRowIndex (uint32_t id
 const UnwindPlan::RowSP
 UnwindPlan::GetRowAtIndex (uint32_t idx) const
 {
-    // You must call IsValidRowIndex(idx) first before calling this!!!
-    assert (idx < m_row_list.size());
-    return m_row_list[idx];
+    if (idx < m_row_list.size())
+        return m_row_list[idx];
+    else
+    {
+        Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
+        if (log)
+            log->Printf ("error: UnwindPlan::GetRowAtIndex(idx = %u) invalid index (number rows is %u)", idx, (uint32_t)m_row_list.size());
+        return UnwindPlan::RowSP();
+    }
 }
 
 const UnwindPlan::RowSP
 UnwindPlan::GetLastRow () const
 {
-    // You must call GetRowCount() first to make sure there is at least one row
-    assert (!m_row_list.empty());
+    if (m_row_list.empty())
+    {
+        Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
+        if (log)
+            log->Printf ("UnwindPlan::GetLastRow() when rows are empty");
+        return UnwindPlan::RowSP();
+    }
     return m_row_list.back();
 }
 




More information about the lldb-commits mailing list