diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -94,6 +94,12 @@ SBError SetErrorFile(SBFile file); + SBError SetInputFile(FileSP file); + + SBError SetOutputFile(FileSP file); + + SBError SetErrorFile(FileSP file); + SBFile GetInputFile(); SBFile GetOutputFile(); diff --git a/lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py b/lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py --- a/lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py @@ -549,7 +549,6 @@ @add_test_categories(['pyapi']) @skipIf(py_version=['<', (3,)]) - @expectedFailureAll() # fixme multiple problems with this def test_string_out(self): f = io.StringIO() status = self.debugger.SetOutputFile(f) @@ -559,7 +558,6 @@ @add_test_categories(['pyapi']) - @expectedFailureAll() # FIXME need FileSP version of SBDebugger::SetErrorFile @skipIf(py_version=['<', (3,)]) def test_string_error(self): f = io.StringIO() @@ -630,7 +628,6 @@ @add_test_categories(['pyapi']) - @expectedFailureAll() # FIXME need FileSP version of SBDebugger::SetErrorFile @skipIf(py_version=['<', (3,)]) def test_file_out(self): with open(self.out_filename, 'w') as f: @@ -654,7 +651,6 @@ @add_test_categories(['pyapi']) - @expectedFailureAll() # FIXME need FileSP version of SBDebugger::SetErrorFile def test_file_error(self): with open(self.out_filename, 'w') as f: status = self.debugger.SetErrorFile(f) @@ -746,7 +742,6 @@ @add_test_categories(['pyapi']) - @expectedFailureAll() # FIXME need FileSP version of SBDebugger::SetOutputFile def test_close(self): debugger = self.debugger with open(self.out_filename, 'w') as f: @@ -767,7 +762,6 @@ @add_test_categories(['pyapi']) @skipIf(py_version=['<', (3,)]) - @expectedFailureAll() # FIXME need FileSP version of SBDebugger::SetOutputFile def test_stdout(self): f = io.StringIO() status = self.debugger.SetOutputFile(f) diff --git a/lldb/scripts/interface/SBDebugger.i b/lldb/scripts/interface/SBDebugger.i --- a/lldb/scripts/interface/SBDebugger.i +++ b/lldb/scripts/interface/SBDebugger.i @@ -165,21 +165,27 @@ void SkipLLDBInitFiles (bool b); + %feature("autodoc", "DEPRECATED, use SetInputFile"); void SetInputFileHandle (FILE *f, bool transfer_ownership); + %feature("autodoc", "DEPRECATED, use SetOutputFile"); void SetOutputFileHandle (FILE *f, bool transfer_ownership); + %feature("autodoc", "DEPRECATED, use SetErrorFile"); void SetErrorFileHandle (FILE *f, bool transfer_ownership); + %feature("autodoc", "DEPRECATED, use GetInputFile"); FILE * GetInputFileHandle (); + %feature("autodoc", "DEPRECATED, use GetOutputFile"); FILE * GetOutputFileHandle (); + %feature("autodoc", "DEPRECATED, use GetErrorFile"); FILE * GetErrorFileHandle (); @@ -192,6 +198,15 @@ SBError SetErrorFile (SBFile file); + SBError + SetInputFile (FileSP file); + + SBError + SetOutputFile (FileSP file); + + SBError + SetErrorFile (FileSP file); + SBFile GetInputFile (); diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -292,6 +292,11 @@ SetInputFile((FileSP)std::make_shared(fh, transfer_ownership)); } +SBError SBDebugger::SetInputFile(FileSP file_sp) { + LLDB_RECORD_METHOD(SBError, SBDebugger, SetInputFile, (FileSP), file_sp); + return SetInputFile(SBFile(file_sp)); +} + // Shouldn't really be settable after initialization as this could cause lots // of problems; don't want users trying to switch modes in the middle of a // debugging session. @@ -332,6 +337,11 @@ return error; } +SBError SBDebugger::SetOutputFile(FileSP file_sp) { + LLDB_RECORD_METHOD(SBError, SBDebugger, SetOutputFile, (FileSP), file_sp); + return SetOutputFile(SBFile(file_sp)); +} + void SBDebugger::SetOutputFileHandle(FILE *fh, bool transfer_ownership) { LLDB_RECORD_METHOD(void, SBDebugger, SetOutputFileHandle, (FILE *, bool), fh, transfer_ownership); @@ -359,6 +369,11 @@ SetErrorFile((FileSP)std::make_shared(fh, transfer_ownership)); } +SBError SBDebugger::SetErrorFile(FileSP file_sp) { + LLDB_RECORD_METHOD(SBError, SBDebugger, SetErrorFile, (FileSP), file_sp); + return SetErrorFile(SBFile(file_sp)); +} + SBError SBDebugger::SetErrorFile(SBFile file) { LLDB_RECORD_METHOD(SBError, SBDebugger, SetErrorFile, (SBFile file), file); SBError error; @@ -1576,6 +1591,8 @@ static SBError SetFileRedirect(SBDebugger *, SBFile file) { return SBError(); } +static SBError SetFileRedirect(SBDebugger *, FileSP file) { return SBError(); } + static bool GetDefaultArchitectureRedirect(char *arch_name, size_t arch_name_len) { // The function is writing to its argument. Without the redirect it would @@ -1606,6 +1623,16 @@ SBFile)>::method<&SBDebugger::SetErrorFile>::doit, &SetFileRedirect); + R.Register(&invoke::method<&SBDebugger::SetInputFile>::doit, + &SetFileRedirect); + R.Register(&invoke::method<&SBDebugger::SetOutputFile>::doit, + &SetFileRedirect); + R.Register(&invoke::method<&SBDebugger::SetErrorFile>::doit, + &SetFileRedirect); + LLDB_REGISTER_CONSTRUCTOR(SBDebugger, ()); LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &)); LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &));