summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-04-20 19:03:07 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-04-20 19:03:07 (GMT)
commita2979604ebaa3d564908f13e4f9ab345fca0ff28 (patch)
treeeacebeb7f7c27ff862a702573541fb108d60a323
parent8e5c8417e8ef79c1b475cb1b86a1754b24f9af78 (diff)
Fixed the Python bindings providing sources and destinations linked to an instruction.
-rw-r--r--ChangeLog6
-rw-r--r--plugins/pychrysa/arch/instruction.c36
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 <nocbos@gmail.com>
+ * plugins/pychrysa/arch/instruction.c:
+ Fix the Python bindings providing sources and destinations linked
+ to an instruction.
+
+17-04-20 Cyrille Bagard <nocbos@gmail.com>
+
* 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;