diff options
| author | Sean Callanan <scallanan@apple.com> | 2011-12-14 23:49:37 +0000 |
|---|---|---|
| committer | Sean Callanan <scallanan@apple.com> | 2011-12-14 23:49:37 +0000 |
| commit | 50952e9571ee97d10888a7f2cfe0106a921e5b57 (patch) | |
| tree | b835defe94f1da8c6055a1eeadf29dbeb1d64f9c /lldb/scripts/Python | |
| parent | 75d7d5e988539819d596f345d99c26a7aa3bd09b (diff) | |
| download | bcm5719-llvm-50952e9571ee97d10888a7f2cfe0106a921e5b57.tar.gz bcm5719-llvm-50952e9571ee97d10888a7f2cfe0106a921e5b57.zip | |
I have added a function to SBTarget that allows
clients to disassemble a series of raw bytes as
demonstrated by a new testcase.
In the future, this API will also allow clients
to provide a callback that adds comments for
addresses in the disassembly.
I also modified the SWIG harness to ensure that
Python ByteArrays work as well as strings as
sources of raw data.
llvm-svn: 146611
Diffstat (limited to 'lldb/scripts/Python')
| -rw-r--r-- | lldb/scripts/Python/interface/SBTarget.i | 5 | ||||
| -rw-r--r-- | lldb/scripts/Python/python-typemaps.swig | 48 |
2 files changed, 37 insertions, 16 deletions
diff --git a/lldb/scripts/Python/interface/SBTarget.i b/lldb/scripts/Python/interface/SBTarget.i index 04dcfbf9d21..676a6c0bab4 100644 --- a/lldb/scripts/Python/interface/SBTarget.i +++ b/lldb/scripts/Python/interface/SBTarget.i @@ -470,7 +470,10 @@ public: lldb::SBBroadcaster GetBroadcaster () const; - + + lldb::SBInstructionList + GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size); + bool GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); }; diff --git a/lldb/scripts/Python/python-typemaps.swig b/lldb/scripts/Python/python-typemaps.swig index 55f2819ce0c..86ce7af6980 100644 --- a/lldb/scripts/Python/python-typemaps.swig +++ b/lldb/scripts/Python/python-typemaps.swig @@ -69,30 +69,48 @@ // typemap for an outgoing buffer // See also SBEvent::SBEvent(uint32_t event, const char *cstr, uint32_t cstr_len). %typemap(in) (const char *cstr, uint32_t cstr_len) { - if (!PyString_Check($input)) { - PyErr_SetString(PyExc_ValueError, "Expecting a string"); - return NULL; + if (PyString_Check($input)) { + $1 = (char *) PyString_AsString($input); + $2 = PyString_Size($input); + } + else if(PyByteArray_Check($input)) { + $1 = (char *) PyByteArray_AsString($input); + $2 = PyByteArray_Size($input); + } + else { + PyErr_SetString(PyExc_ValueError, "Expecting a string"); + return NULL; } - $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; + if (PyString_Check($input)) { + $1 = (char *) PyString_AsString($input); + $2 = PyString_Size($input); + } + else if(PyByteArray_Check($input)) { + $1 = (char *) PyByteArray_AsString($input); + $2 = PyByteArray_Size($input); + } + else { + 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)) { - PyErr_SetString(PyExc_ValueError, "Expecting a string"); - return NULL; + if (PyString_Check($input)) { + $1 = (void *) PyString_AsString($input); + $2 = PyString_Size($input); + } + else if(PyByteArray_Check($input)) { + $1 = (void *) PyByteArray_AsString($input); + $2 = PyByteArray_Size($input); + } + else { + PyErr_SetString(PyExc_ValueError, "Expecting a string"); + return NULL; } - $1 = (void *) PyString_AsString($input); - $2 = PyString_Size($input); } // typemap for an incoming buffer |

