diff options
Diffstat (limited to 'plugins/pychrysa')
-rw-r--r-- | plugins/pychrysa/arch/instruction.c | 99 |
1 files changed, 83 insertions, 16 deletions
diff --git a/plugins/pychrysa/arch/instruction.c b/plugins/pychrysa/arch/instruction.c index 8ebdef0..67e3a6b 100644 --- a/plugins/pychrysa/arch/instruction.c +++ b/plugins/pychrysa/arch/instruction.c @@ -61,6 +61,9 @@ static PyObject *py_arch_instruction_get_keyword(PyObject *, void *); +/* Fournit tous les opérandes d'une instruction. */ +static PyObject *py_arch_instruction_get_operands(PyObject *, void *); + @@ -78,18 +81,18 @@ static PyObject *py_arch_instruction_get_keyword(PyObject *, void *); /* Fournit les origines d'une instruction donnée. */ -static PyObject *py_arch_instruction_get_sources(PyObject *, PyObject *); +static PyObject *py_arch_instruction_get_sources(PyObject *, void *); /* Fournit les destinations d'une instruction donnée. */ -static PyObject *py_arch_instruction_get_destinations(PyObject *, PyObject *); +static PyObject *py_arch_instruction_get_destinations(PyObject *, void *); /****************************************************************************** * * -* Paramètres : self = instruction d'architecture à manipuler. * -* args = liste d'arguments non utilisée ici. * +* Paramètres : self = instruction d'architecture à manipuler. * +* unused = adresse non utilisée ici. * * * * Description : Fournit les origines d'une instruction donnée. * * * @@ -99,7 +102,7 @@ static PyObject *py_arch_instruction_get_destinations(PyObject *, PyObject *); * * ******************************************************************************/ -static PyObject *py_arch_instruction_get_sources(PyObject *self, PyObject *args) +static PyObject *py_arch_instruction_get_sources(PyObject *self, void *unused) { PyObject *result; /* Instance à retourner */ GArchInstruction *instr; /* Version native */ @@ -112,6 +115,8 @@ static PyObject *py_arch_instruction_get_sources(PyObject *self, PyObject *args) instr = G_ARCH_INSTRUCTION(pygobject_get(self)); + g_arch_instruction_rlock_src(instr); + count = g_arch_instruction_get_sources(instr, &sources); result = PyTuple_New(count); @@ -126,6 +131,8 @@ static PyObject *py_arch_instruction_get_sources(PyObject *self, PyObject *args) } + g_arch_instruction_runlock_src(instr); + return result; } @@ -133,8 +140,8 @@ static PyObject *py_arch_instruction_get_sources(PyObject *self, PyObject *args) /****************************************************************************** * * -* Paramètres : self = instruction d'architecture à manipuler. * -* args = liste d'arguments non utilisée ici. * +* Paramètres : self = instruction d'architecture à manipuler. * +* unused = adresse non utilisée ici. * * * * Description : Fournit les destinations d'une instruction donnée. * * * @@ -144,7 +151,7 @@ static PyObject *py_arch_instruction_get_sources(PyObject *self, PyObject *args) * * ******************************************************************************/ -static PyObject *py_arch_instruction_get_destinations(PyObject *self, PyObject *args) +static PyObject *py_arch_instruction_get_destinations(PyObject *self, void *unused) { PyObject *result; /* Instance à retourner */ GArchInstruction *instr; /* Version native */ @@ -157,6 +164,8 @@ static PyObject *py_arch_instruction_get_destinations(PyObject *self, PyObject * instr = G_ARCH_INSTRUCTION(pygobject_get(self)); + g_arch_instruction_rlock_dest(instr); + count = g_arch_instruction_get_destinations(instr, &dests); result = PyTuple_New(count); @@ -171,6 +180,8 @@ static PyObject *py_arch_instruction_get_destinations(PyObject *self, PyObject * } + g_arch_instruction_runlock_dest(instr); + return result; } @@ -284,6 +295,58 @@ static PyObject *py_arch_instruction_get_keyword(PyObject *self, void *unused) +/****************************************************************************** +* * +* Paramètres : self = objet représentant une instruction. * +* unused = adresse non utilisée ici. * +* * +* Description : Fournit tous les opérandes d'une instruction. * +* * +* Retour : Valeur associée à la propriété consultée. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_arch_instruction_get_operands(PyObject *self, void *unused) +{ + PyObject *result; /* Instance à retourner */ + GArchInstruction *instr; /* Version native */ + size_t count; /* Nombre d'opérandes présents */ + size_t i; /* Boucle de parcours */ + GArchOperand *operand; /* Opérande à manipuler */ + PyObject *opobj; /* Version Python */ + int ret; /* Bilan d'une écriture d'arg. */ + + instr = G_ARCH_INSTRUCTION(pygobject_get(self)); + + g_arch_instruction_lock_operands(instr); + + count = _g_arch_instruction_count_operands(instr); + + result = PyTuple_New(count); + + for (i = 0; i < count; i++) + { + operand = _g_arch_instruction_get_operand(instr, i); + + opobj = pygobject_new(G_OBJECT(operand)); + + ret = PyTuple_SetItem(result, i, Py_BuildValue("O", opobj)); + assert(ret == 0); + + } + + g_arch_instruction_unlock_operands(instr); + + return result; + +} + + + + + @@ -308,14 +371,6 @@ static PyObject *py_arch_instruction_get_keyword(PyObject *self, void *unused) PyTypeObject *get_python_arch_instruction_type(void) { static PyMethodDef py_arch_instruction_methods[] = { - { "get_sources", py_arch_instruction_get_sources, - METH_NOARGS, - "get_sources(, /)\n--\n\nProvide the instructions list driving to the current instruction." - }, - { "get_destinations", py_arch_instruction_get_destinations, - METH_NOARGS, - "get_destinations(, /)\n--\n\nProvide the instructions list following the current instruction." - }, { NULL } }; @@ -328,6 +383,18 @@ PyTypeObject *get_python_arch_instruction_type(void) "keyword", (getter)py_arch_instruction_get_keyword, (setter)NULL, "Give le name of the assembly instruction.", NULL }, + { + "operands", (getter)py_arch_instruction_get_operands, (setter)NULL, + "Provide the list of instruction attached operands.", NULL + }, + { + "sources", (getter)py_arch_instruction_get_sources, (setter)NULL, + "Provide the instructions list driving to the current instruction." + }, + { + "destinations", (getter)py_arch_instruction_get_destinations, (setter)NULL, + "Provide the instructions list following the current instruction." + }, { NULL } }; |