diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-02-18 16:41:31 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-02-18 16:41:31 (GMT) |
commit | deb012d919ea6c5e79702a39a03a85be2ffcf406 (patch) | |
tree | ae9cee108d05e0a6674d8617a08d0ea09165443c /plugins/pyoida | |
parent | 73605bffb935fc51a52be1936426211e31dd898a (diff) |
Retrieved the frames stack from the running process.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@235 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/pyoida')
-rw-r--r-- | plugins/pyoida/debug/debugger.c | 40 |
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 } |