mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-05 00:49:43 +00:00
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 llvm-svn: 374422
This commit is contained in:
parent
d496003205
commit
c040b30ffc
@ -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();
|
||||
|
@ -549,7 +549,6 @@ class FileHandleTestCase(lldbtest.TestBase):
|
||||
|
||||
@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.TestBase):
|
||||
|
||||
|
||||
@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.TestBase):
|
||||
|
||||
|
||||
@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.TestBase):
|
||||
|
||||
|
||||
@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.TestBase):
|
||||
|
||||
|
||||
@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.TestBase):
|
||||
|
||||
@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)
|
||||
|
@ -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 ();
|
||||
|
||||
|
@ -292,6 +292,11 @@ void SBDebugger::SetInputFileHandle(FILE *fh, bool transfer_ownership) {
|
||||
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 file) {
|
||||
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 *fh, bool transfer_ownership) {
|
||||
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(SBDebugger *, FILE *, bool) {
|
||||
|
||||
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<SBDebugger>(Registry &R) {
|
||||
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 &));
|
||||
|
Loading…
x
Reference in New Issue
Block a user