From a2979604ebaa3d564908f13e4f9ab345fca0ff28 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Thu, 20 Apr 2017 21:03:07 +0200 Subject: Fixed the Python bindings providing sources and destinations linked to an instruction. --- ChangeLog | 6 ++++++ plugins/pychrysa/arch/instruction.c | 36 ++++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index f163828..9e34a2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 17-04-20 Cyrille Bagard + * plugins/pychrysa/arch/instruction.c: + Fix the Python bindings providing sources and destinations linked + to an instruction. + +17-04-20 Cyrille Bagard + * plugins/pychrysa/arch/immediate.c: Update code. diff --git a/plugins/pychrysa/arch/instruction.c b/plugins/pychrysa/arch/instruction.c index 67e3a6b..0e10728 100644 --- a/plugins/pychrysa/arch/instruction.c +++ b/plugins/pychrysa/arch/instruction.c @@ -106,32 +106,34 @@ static PyObject *py_arch_instruction_get_sources(PyObject *self, void *unused) { PyObject *result; /* Instance à retourner */ GArchInstruction *instr; /* Version native */ - instr_link_t *sources; /* Origine des liens */ + instr_link_t *source; /* Origine des liens */ size_t count; /* Nombre de liens présents */ size_t i; /* Boucle de parcours */ - PyObject *dest; /* Destination de lien Python */ + PyObject *linked; /* Source de lien Python */ PyObject *type; /* Nature du lien en Python */ int ret; /* Bilan d'une écriture d'arg. */ instr = G_ARCH_INSTRUCTION(pygobject_get(self)); - g_arch_instruction_rlock_src(instr); + g_arch_instruction_lock_src(instr); - count = g_arch_instruction_get_sources(instr, &sources); + count = g_arch_instruction_count_sources(instr); result = PyTuple_New(count); for (i = 0; i < count; i++) { - dest = pygobject_new(G_OBJECT(sources[i].linked)); - type = PyLong_FromLong(sources[i].type); + source = g_arch_instruction_get_source(instr, i); - ret = PyTuple_SetItem(result, i, Py_BuildValue("(OO)", dest, type)); + linked = pygobject_new(G_OBJECT(source->linked)); + type = PyLong_FromLong(source->type); + + ret = PyTuple_SetItem(result, i, Py_BuildValue("(OO)", linked, type)); assert(ret == 0); } - g_arch_instruction_runlock_src(instr); + g_arch_instruction_unlock_src(instr); return result; @@ -155,32 +157,34 @@ static PyObject *py_arch_instruction_get_destinations(PyObject *self, void *unus { PyObject *result; /* Instance à retourner */ GArchInstruction *instr; /* Version native */ - instr_link_t *dests; /* Destination des liens */ + instr_link_t *dest; /* Destination des liens */ size_t count; /* Nombre de liens présents */ size_t i; /* Boucle de parcours */ - PyObject *dest; /* Destination de lien Python */ + PyObject *linked; /* Destination de lien Python */ PyObject *type; /* Nature du lien en Python */ int ret; /* Bilan d'une écriture d'arg. */ instr = G_ARCH_INSTRUCTION(pygobject_get(self)); - g_arch_instruction_rlock_dest(instr); + g_arch_instruction_lock_dest(instr); - count = g_arch_instruction_get_destinations(instr, &dests); + count = g_arch_instruction_count_destinations(instr); result = PyTuple_New(count); for (i = 0; i < count; i++) { - dest = pygobject_new(G_OBJECT(dests[i].linked)); - type = PyLong_FromLong(dests[i].type); + dest = g_arch_instruction_get_destination(instr, i); + + linked = pygobject_new(G_OBJECT(dest->linked)); + type = PyLong_FromLong(dest->type); - ret = PyTuple_SetItem(result, i, Py_BuildValue("(OO)", dest, type)); + ret = PyTuple_SetItem(result, i, Py_BuildValue("(OO)", linked, type)); assert(ret == 0); } - g_arch_instruction_runlock_dest(instr); + g_arch_instruction_unlock_dest(instr); return result; -- cgit v0.11.2-87-g4458