summaryrefslogtreecommitdiff
path: root/plugins/pyoida
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pyoida')
-rw-r--r--plugins/pyoida/debug/debugger.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/plugins/pyoida/debug/debugger.c b/plugins/pyoida/debug/debugger.c
index 75de6d8..3e42ab7 100644
--- a/plugins/pyoida/debug/debugger.c
+++ b/plugins/pyoida/debug/debugger.c
@@ -25,6 +25,7 @@
#include "debugger.h"
+#include <malloc.h>
#include <pygobject.h>
@@ -36,7 +37,7 @@
static PyObject *py_binary_debugger_list_all_threads(PyObject *, PyObject *);
/* Fournit la pile d'exécution courante via un débogueur. */
-static PyObject *py_binary_debugger_get_current_stack(PyObject *, PyObject *);
+static PyObject *py_binary_debugger_get_frames_stack(PyObject *, PyObject *);
@@ -171,9 +172,38 @@ static PyObject *py_binary_debugger_list_all_threads(PyObject *self, PyObject *a
* *
******************************************************************************/
-static PyObject *py_binary_debugger_get_current_stack(PyObject *self, PyObject *args)
+static PyObject *py_binary_debugger_get_frames_stack(PyObject *self, PyObject *args)
{
- return PyLong_FromLong(23);
+ PyObject *result; /* Trouvailles à retourner */
+ GBinaryDebugger *debugger; /* Version native */
+ unsigned long thread; /* Identifiant du thread visé */
+ size_t count; /* Taille de cette liste */
+ dbg_frame_t *frames; /* Frames courantes trouvées */
+ size_t i; /* Boucle de parcours */
+ PyObject *frame; /* Détails sur une frame */
+
+ debugger = G_BINARY_DEBUGGER(pygobject_get(self));
+
+ if (!PyArg_ParseTuple(args, "k", &thread))
+ return Py_None;
+
+ frames = g_binary_debugger_get_frames_stack(debugger, thread, &count);
+
+ result = PyTuple_New(count);
+
+ for (i = 0; i < count; i++)
+ {
+ frame = PyTuple_New(1);
+ PyTuple_SetItem(result, i, frame);
+
+ PyTuple_SetItem(frame, 0, PyLong_FromUnsignedLongLong(frames[i].addr));
+
+ }
+
+ if (frames != NULL)
+ free(frames);
+
+ return result;
}
@@ -205,8 +235,8 @@ bool register_python_binary_debugger(PyObject *module)
"List all current active threads."
},
{
- "get_current_stack", (PyCFunction)py_binary_debugger_get_current_stack,
- METH_NOARGS,
+ "get_frames_stack", (PyCFunction)py_binary_debugger_get_frames_stack,
+ METH_VARARGS,
"Provide the current callstack using a debugger."
},
{ NULL }