Add SetCurrentInlinedDepth API.
In GetFramesUpTo, don't adjust the number of frames for the inlined depth if the number of frames in UINT32_MAX.

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@163432 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/StackFrameList.cpp b/source/Target/StackFrameList.cpp
index ce48c97..a215025 100644
--- a/source/Target/StackFrameList.cpp
+++ b/source/Target/StackFrameList.cpp
@@ -13,6 +13,7 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
+#include "lldb/Core/Log.h"
 #include "lldb/Core/StreamFile.h"
 #include "lldb/Core/SourceManager.h"
 #include "lldb/Symbol/Block.h"
@@ -77,13 +78,16 @@
 uint32_t
 StackFrameList::GetCurrentInlinedDepth ()
 {
-    if (m_show_inlined_frames)
+    if (m_show_inlined_frames && m_current_inlined_pc != LLDB_INVALID_ADDRESS)
     {
         lldb::addr_t cur_pc = m_thread.GetRegisterContext()->GetPC();
         if (cur_pc != m_current_inlined_pc)
         {
             m_current_inlined_pc = LLDB_INVALID_ADDRESS;
             m_current_inlined_depth = UINT32_MAX;
+            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
+            if (log && log->GetVerbose())
+                log->Printf ("GetCurrentInlinedDepth: invalidating current inlined depth.\n");
         }
         return m_current_inlined_depth;
     }
@@ -103,6 +107,9 @@
         {
             m_current_inlined_depth = UINT32_MAX;
             m_current_inlined_pc = LLDB_INVALID_ADDRESS;
+            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
+            if (log && log->GetVerbose())
+                log->Printf ("ResetCurrentInlinedDepth: Invalidating current inlined depth.\n");
         }
         else
         {
@@ -169,6 +176,9 @@
                                     }
                                     m_current_inlined_pc = curr_pc;
                                     m_current_inlined_depth = num_inlined_functions + 1;
+                                    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
+                                    if (log && log->GetVerbose())
+                                        log->Printf ("ResetCurrentInlinedDepth: setting inlined depth: %d 0x%llx.\n", m_current_inlined_depth, curr_pc);
                                     
                                 }
                                 break;
@@ -200,6 +210,16 @@
 }
 
 void
+StackFrameList::SetCurrentInlinedDepth (uint32_t new_depth)
+{
+    m_current_inlined_depth = new_depth;
+    if (new_depth == UINT32_MAX)
+        m_current_inlined_pc = LLDB_INVALID_ADDRESS;
+    else
+        m_current_inlined_pc = m_thread.GetRegisterContext()->GetPC();
+}
+
+void
 StackFrameList::GetFramesUpTo(uint32_t end_idx)
 {
     // We've already gotten more frames than asked for, or we've already finished unwinding, return.
@@ -215,10 +235,11 @@
 #endif
         // If we are hiding some frames from the outside world, we need to add those onto the total count of
         // frames to fetch.  However, we don't need ot do that if end_idx is 0 since in that case we always
-        // get the first concrete frame and all the inlined frames below it...
+        // get the first concrete frame and all the inlined frames below it...  And of course, if end_idx is
+        // UINT32_MAX that means get all, so just do that...
         
         uint32_t inlined_depth = 0;
-        if (end_idx > 0)
+        if (end_idx > 0 && end_idx != UINT32_MAX)
         {
             inlined_depth = GetCurrentInlinedDepth();
             if (inlined_depth != UINT32_MAX)
@@ -322,8 +343,9 @@
             StackFrameList *prev_frames = m_prev_frames_sp.get();
             StackFrameList *curr_frames = this;
             
-            curr_frames->m_current_inlined_depth = prev_frames->m_current_inlined_depth;
-            curr_frames->m_current_inlined_pc = prev_frames->m_current_inlined_pc;
+            //curr_frames->m_current_inlined_depth = prev_frames->m_current_inlined_depth;
+            //curr_frames->m_current_inlined_pc = prev_frames->m_current_inlined_pc;
+            //printf ("GetFramesUpTo: Copying current inlined depth: %d 0x%llx.\n", curr_frames->m_current_inlined_depth, curr_frames->m_current_inlined_pc);
 
 #if defined (DEBUG_STACK_FRAMES)
             s.PutCString("\nprev_frames:\n");