xref: /llvm-project/lldb/bindings/interface/SBDebuggerExtensions.i (revision 380c5da98efa62920e9fbf3aa9a4fa8add236fb9)
1*662548c8SAlex Langford STRING_EXTENSION_OUTSIDE(SBDebugger)
2*662548c8SAlex Langford 
3*662548c8SAlex Langford %extend lldb::SBDebugger {
4*662548c8SAlex Langford #ifdef SWIGPYTHON
5*662548c8SAlex Langford     %pythoncode %{
6*662548c8SAlex Langford         def SetOutputFileHandle(self, file, transfer_ownership):
7*662548c8SAlex Langford             "DEPRECATED, use SetOutputFile"
8*662548c8SAlex Langford             if file is None:
9*662548c8SAlex Langford                 import sys
10*662548c8SAlex Langford                 file = sys.stdout
11*662548c8SAlex Langford             self.SetOutputFile(SBFile.Create(file, borrow=True))
12*662548c8SAlex Langford 
13*662548c8SAlex Langford         def SetInputFileHandle(self, file, transfer_ownership):
14*662548c8SAlex Langford             "DEPRECATED, use SetInputFile"
15*662548c8SAlex Langford             if file is None:
16*662548c8SAlex Langford                 import sys
17*662548c8SAlex Langford                 file = sys.stdin
18*662548c8SAlex Langford             self.SetInputFile(SBFile.Create(file, borrow=True))
19*662548c8SAlex Langford 
20*662548c8SAlex Langford         def SetErrorFileHandle(self, file, transfer_ownership):
21*662548c8SAlex Langford             "DEPRECATED, use SetErrorFile"
22*662548c8SAlex Langford             if file is None:
23*662548c8SAlex Langford                 import sys
24*662548c8SAlex Langford                 file = sys.stderr
25*662548c8SAlex Langford             self.SetErrorFile(SBFile.Create(file, borrow=True))
26*662548c8SAlex Langford 
27*662548c8SAlex Langford         def __iter__(self):
28*662548c8SAlex Langford             '''Iterate over all targets in a lldb.SBDebugger object.'''
29*662548c8SAlex Langford             return lldb_iter(self, 'GetNumTargets', 'GetTargetAtIndex')
30*662548c8SAlex Langford 
31*662548c8SAlex Langford         def __len__(self):
32*662548c8SAlex Langford             '''Return the number of targets in a lldb.SBDebugger object.'''
33*662548c8SAlex Langford             return self.GetNumTargets()
34*662548c8SAlex Langford     %}
35*662548c8SAlex Langford #endif
36*662548c8SAlex Langford 
37*662548c8SAlex Langford     lldb::FileSP GetInputFileHandle() {
38*662548c8SAlex Langford         return self->GetInputFile().GetFile();
39*662548c8SAlex Langford     }
40*662548c8SAlex Langford 
41*662548c8SAlex Langford     lldb::FileSP GetOutputFileHandle() {
42*662548c8SAlex Langford         return self->GetOutputFile().GetFile();
43*662548c8SAlex Langford     }
44*662548c8SAlex Langford 
45*662548c8SAlex Langford     lldb::FileSP GetErrorFileHandle() {
46*662548c8SAlex Langford         return self->GetErrorFile().GetFile();
47*662548c8SAlex Langford     }
48*662548c8SAlex Langford }
49