summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/Python
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2011-11-28 21:39:07 +0000
committerJohnny Chen <johnny.chen@apple.com>2011-11-28 21:39:07 +0000
commit49cb85db64046f0030134cf4eac27b1dbe02cc2c (patch)
treebbc3506195df1c8be5a7154df3adc2a7c23ebb70 /lldb/scripts/Python
parentc086f0f91b775b7342ccea87a849474987c39b27 (diff)
downloadbcm5719-llvm-49cb85db64046f0030134cf4eac27b1dbe02cc2c.tar.gz
bcm5719-llvm-49cb85db64046f0030134cf4eac27b1dbe02cc2c.zip
SBProcess.PutSTDIN() needs to be properly typemapped when swigging,
so that we can do Python scripting like this: target = self.dbg.CreateTarget(self.exe) self.dbg.SetAsync(True) process = target.LaunchSimple(None, None, os.getcwd()) process.PutSTDIN("Line 1 Entered.\n") process.PutSTDIN("Line 2 Entered.\n") process.PutSTDIN("Line 3 Entered.\n") Add TestProcessIO.py to exercise the process IO API: PutSTDIN()/GetSTDOUT()/GetSTDERR(). llvm-svn: 145282
Diffstat (limited to 'lldb/scripts/Python')
-rw-r--r--lldb/scripts/Python/interface/SBCommandInterpreter.i2
-rw-r--r--lldb/scripts/Python/interface/SBProcess.i4
-rw-r--r--lldb/scripts/Python/python-typemaps.swig9
3 files changed, 15 insertions, 0 deletions
diff --git a/lldb/scripts/Python/interface/SBCommandInterpreter.i b/lldb/scripts/Python/interface/SBCommandInterpreter.i
index 6a5ee2466b0..ec9e51c561a 100644
--- a/lldb/scripts/Python/interface/SBCommandInterpreter.i
+++ b/lldb/scripts/Python/interface/SBCommandInterpreter.i
@@ -99,8 +99,10 @@ public:
lldb::SBProcess
GetProcess ();
+#if 0
ssize_t
WriteToScriptInterpreter (const char *src);
+#endif
ssize_t
WriteToScriptInterpreter (const char *src, size_t src_len);
diff --git a/lldb/scripts/Python/interface/SBProcess.i b/lldb/scripts/Python/interface/SBProcess.i
index 531cd5903cf..b2ab9231a26 100644
--- a/lldb/scripts/Python/interface/SBProcess.i
+++ b/lldb/scripts/Python/interface/SBProcess.i
@@ -64,6 +64,10 @@ public:
lldb::ByteOrder
GetByteOrder() const;
+ %feature("autodoc", "
+ Writes data into the current process's stdin. API client specifies a Python
+ string as the only argument.
+ ") PutSTDIN;
size_t
PutSTDIN (const char *src, size_t src_len);
diff --git a/lldb/scripts/Python/python-typemaps.swig b/lldb/scripts/Python/python-typemaps.swig
index 5fbe161aa4c..55f2819ce0c 100644
--- a/lldb/scripts/Python/python-typemaps.swig
+++ b/lldb/scripts/Python/python-typemaps.swig
@@ -76,6 +76,15 @@
$1 = (char *) PyString_AsString($input);
$2 = PyString_Size($input);
}
+// Ditto for SBProcess::PutSTDIN(const char *src, size_t src_len).
+%typemap(in) (const char *src, size_t src_len) {
+ if (!PyString_Check($input)) {
+ PyErr_SetString(PyExc_ValueError, "Expecting a string");
+ return NULL;
+ }
+ $1 = (char *) PyString_AsString($input);
+ $2 = PyString_Size($input);
+}
// And SBProcess::WriteMemory.
%typemap(in) (const void *buf, size_t size) {
if (!PyString_Check($input)) {
OpenPOWER on IntegriCloud