From 50952e9571ee97d10888a7f2cfe0106a921e5b57 Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Wed, 14 Dec 2011 23:49:37 +0000 Subject: 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 --- lldb/scripts/Python/interface/SBTarget.i | 5 +++- lldb/scripts/Python/python-typemaps.swig | 48 ++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 16 deletions(-) (limited to 'lldb/scripts/Python') 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 -- cgit v1.2.3