Author: lawrence_danna Date: Thu Oct 10 12:10:59 2019 New Revision: 374422 URL: http://llvm.org/viewvc/llvm-project?rev=374422&view=rev Log: update SBDebugger::SetInputFile() etc to work on native Files
Summary: This patch adds FileSP versions of SetInputFile(), SetOutputFile, and SetErrorFile(). SWIG will convert native python file objects into FileSP. Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: clayborg, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68734 Modified: lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py lldb/trunk/scripts/interface/SBDebugger.i lldb/trunk/source/API/SBDebugger.cpp Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=374422&r1=374421&r2=374422&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Thu Oct 10 12:10:59 2019 @@ -94,6 +94,12 @@ public: SBError SetErrorFile(SBFile file); + SBError SetInputFile(FileSP file); + + SBError SetOutputFile(FileSP file); + + SBError SetErrorFile(FileSP file); + SBFile GetInputFile(); SBFile GetOutputFile(); Modified: lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py?rev=374422&r1=374421&r2=374422&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py Thu Oct 10 12:10:59 2019 @@ -549,7 +549,6 @@ class FileHandleTestCase(lldbtest.TestBa @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 @@ class FileHandleTestCase(lldbtest.TestBa @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 @@ class FileHandleTestCase(lldbtest.TestBa @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 @@ class FileHandleTestCase(lldbtest.TestBa @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 @@ class FileHandleTestCase(lldbtest.TestBa @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 @@ class FileHandleTestCase(lldbtest.TestBa @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) Modified: lldb/trunk/scripts/interface/SBDebugger.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBDebugger.i?rev=374422&r1=374421&r2=374422&view=diff ============================================================================== --- lldb/trunk/scripts/interface/SBDebugger.i (original) +++ lldb/trunk/scripts/interface/SBDebugger.i Thu Oct 10 12:10:59 2019 @@ -165,21 +165,27 @@ public: 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 @@ public: SBError SetErrorFile (SBFile file); + SBError + SetInputFile (FileSP file); + + SBError + SetOutputFile (FileSP file); + + SBError + SetErrorFile (FileSP file); + SBFile GetInputFile (); Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=374422&r1=374421&r2=374422&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Thu Oct 10 12:10:59 2019 @@ -292,6 +292,11 @@ void SBDebugger::SetInputFileHandle(FILE SetInputFile((FileSP)std::make_shared<NativeFile>(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 @@ SBError SBDebugger::SetInputFile(SBFile 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 @@ void SBDebugger::SetErrorFileHandle(FILE SetErrorFile((FileSP)std::make_shared<NativeFile>(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 void SetFileHandleRedirect(SBDebu 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 @@ template <> void RegisterMethods<SBDebug SBFile)>::method<&SBDebugger::SetErrorFile>::doit, &SetFileRedirect); + R.Register(&invoke<SBError (SBDebugger::*)( + FileSP)>::method<&SBDebugger::SetInputFile>::doit, + &SetFileRedirect); + R.Register(&invoke<SBError (SBDebugger::*)( + FileSP)>::method<&SBDebugger::SetOutputFile>::doit, + &SetFileRedirect); + R.Register(&invoke<SBError (SBDebugger::*)( + FileSP)>::method<&SBDebugger::SetErrorFile>::doit, + &SetFileRedirect); + LLDB_REGISTER_CONSTRUCTOR(SBDebugger, ()); LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &)); LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &)); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits