1 //===-- SBSourceManager.cpp -------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/lldb-python.h"
12 #include "lldb/API/SBDebugger.h"
13 #include "lldb/API/SBSourceManager.h"
14 #include "lldb/API/SBTarget.h"
15 #include "lldb/API/SBStream.h"
17 #include "lldb/API/SBFileSpec.h"
18 #include "lldb/Core/Debugger.h"
19 #include "lldb/Core/Stream.h"
20 #include "lldb/Core/StreamFile.h"
21 #include "lldb/Core/SourceManager.h"
23 #include "lldb/Target/Target.h"
25 namespace lldb_private
27 class SourceManagerImpl
30 SourceManagerImpl (const lldb::DebuggerSP &debugger_sp) :
31 m_debugger_wp (debugger_sp),
36 SourceManagerImpl (const lldb::TargetSP &target_sp) :
38 m_target_wp (target_sp)
42 SourceManagerImpl (const SourceManagerImpl &rhs)
46 m_debugger_wp = rhs.m_debugger_wp;
47 m_target_wp = rhs.m_target_wp;
51 DisplaySourceLinesWithLineNumbers (const lldb_private::FileSpec &file,
53 uint32_t context_before,
54 uint32_t context_after,
55 const char *current_line_cstr,
56 lldb_private::Stream *s)
61 lldb::TargetSP target_sp (m_target_wp.lock());
64 return target_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers (file,
73 lldb::DebuggerSP debugger_sp (m_debugger_wp.lock());
76 return debugger_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers (file,
88 lldb::DebuggerWP m_debugger_wp;
89 lldb::TargetWP m_target_wp;
95 using namespace lldb_private;
97 SBSourceManager::SBSourceManager (const SBDebugger &debugger)
99 m_opaque_ap.reset(new SourceManagerImpl (debugger.get_sp()));
102 SBSourceManager::SBSourceManager (const SBTarget &target)
104 m_opaque_ap.reset(new SourceManagerImpl (target.GetSP()));
107 SBSourceManager::SBSourceManager (const SBSourceManager &rhs)
112 m_opaque_ap.reset(new SourceManagerImpl (*(rhs.m_opaque_ap.get())));
115 const lldb::SBSourceManager &
116 SBSourceManager::operator = (const lldb::SBSourceManager &rhs)
118 m_opaque_ap.reset (new SourceManagerImpl (*(rhs.m_opaque_ap.get())));
122 SBSourceManager::~SBSourceManager()
127 SBSourceManager::DisplaySourceLinesWithLineNumbers
129 const SBFileSpec &file,
131 uint32_t context_before,
132 uint32_t context_after,
133 const char *current_line_cstr,
137 if (m_opaque_ap.get() == NULL)
140 return m_opaque_ap->DisplaySourceLinesWithLineNumbers (file.ref(),