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