Move the SourceManager from the Debugger to the Target.  That way it can store the per-Target default Source File & Line.
Set the default Source File & line to main (if it can be found.) at startup.  Selecting the current thread & or frame resets 
the current source file & line, and "source list" as well as the breakpoint command "break set -l <NUM>" will use the 
current source file.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@139323 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/StackFrameList.cpp b/source/Target/StackFrameList.cpp
index 660bdcc..a19106e 100644
--- a/source/Target/StackFrameList.cpp
+++ b/source/Target/StackFrameList.cpp
@@ -14,11 +14,14 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Core/StreamFile.h"
+#include "lldb/Core/SourceManager.h"
 #include "lldb/Symbol/Block.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/Symbol.h"
+#include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/StackFrame.h"
+#include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Target/Unwind.h"
 
@@ -401,15 +404,16 @@
     const_iterator pos;
     const_iterator begin = m_frames.begin();
     const_iterator end = m_frames.end();
+    m_selected_frame_idx = 0;
     for (pos = begin; pos != end; ++pos)
     {
         if (pos->get() == frame)
         {
             m_selected_frame_idx = std::distance (begin, pos);
-            return m_selected_frame_idx;
+            break;
         }
     }
-    m_selected_frame_idx = 0;
+    SetDefaultFileAndLineToSelectedFrame();
     return m_selected_frame_idx;
 }
 
@@ -419,6 +423,22 @@
 {
     Mutex::Locker locker (m_mutex);
     m_selected_frame_idx = idx;
+    SetDefaultFileAndLineToSelectedFrame();
+}
+
+void
+StackFrameList::SetDefaultFileAndLineToSelectedFrame()
+{
+    if (m_thread.GetID() == m_thread.GetProcess().GetThreadList().GetSelectedThread()->GetID())
+    {
+        StackFrameSP frame_sp = m_frames[m_selected_frame_idx];
+        if (frame_sp)
+        {
+            SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
+            if (sc.line_entry.file)
+            m_thread.GetProcess().GetTarget().GetSourceManager().SetDefaultFileAndLine (sc.line_entry.file, sc.line_entry.line);
+        }
+    }
 }
 
 // The thread has been run, reset the number stack frames to zero so we can