1 //===-- SWIG Interface for SBStream -----------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
14 "Represents a destination for streaming data output to. By default, a string
17 For example (from test/source-manager/TestSourceManager.py),
19 # Create the filespec for 'main.c'.
20 filespec = lldb.SBFileSpec('main.c', False)
21 source_mgr = self.dbg.GetSourceManager()
22 # Use a string stream as the destination.
23 stream = lldb.SBStream()
24 source_mgr.DisplaySourceLinesWithLineNumbers(filespec,
28 '=>', # prefix for current line
32 # 3 int main(int argc, char const *argv[]) {
33 # => 4 printf('Hello world.\\n'); // Set break point at this line.
36 self.expect(stream.GetData(), 'Source code displayed correctly',
38 patterns = ['=> %d.*Hello world' % self.line])") SBStream;
50 explicit operator bool() const;
52 %feature("docstring", "
53 If this stream is not redirected to a file, it will maintain a local
54 cache for the stream data which can be accessed using this accessor.") GetData;
58 %feature("docstring", "
59 If this stream is not redirected to a file, it will maintain a local
60 cache for the stream output whose length can be accessed using this
65 // wrapping the variadic Printf() with a plain Print()
66 // because it is hard to support varargs in SWIG bridgings
68 void Print (const char* str)
70 self->Printf("%s", str);
75 RedirectToFile (const char *path, bool append);
78 RedirectToFile (lldb::SBFile file);
81 RedirectToFile (lldb::FileSP file);
84 %feature("autodoc", "DEPRECATED, use RedirectToFile");
86 RedirectToFileHandle (lldb::FileSP file, bool transfer_fh_ownership) {
87 self->RedirectToFile(file);
92 RedirectToFileDescriptor (int fd, bool transfer_fh_ownership);
94 %feature("docstring", "
95 If the stream is redirected to a file, forget about the file and if
96 ownership of the file was transferred to this object, close the file.
97 If the stream is backed by a local cache, clear this cache.") Clear;