summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/debug/gdbrsp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysa/debug/gdbrsp')
-rw-r--r--plugins/pychrysa/debug/gdbrsp/Makefile.am15
-rw-r--r--plugins/pychrysa/debug/gdbrsp/gdb.c165
-rw-r--r--plugins/pychrysa/debug/gdbrsp/gdb.h42
-rw-r--r--plugins/pychrysa/debug/gdbrsp/module.c86
-rw-r--r--plugins/pychrysa/debug/gdbrsp/module.h39
5 files changed, 347 insertions, 0 deletions
diff --git a/plugins/pychrysa/debug/gdbrsp/Makefile.am b/plugins/pychrysa/debug/gdbrsp/Makefile.am
new file mode 100644
index 0000000..cf7b78a
--- /dev/null
+++ b/plugins/pychrysa/debug/gdbrsp/Makefile.am
@@ -0,0 +1,15 @@
+
+noinst_LTLIBRARIES = libpychrysadebuggdbrsp.la
+
+libpychrysadebuggdbrsp_la_SOURCES = \
+ gdb.h gdb.c \
+ module.h module.c
+
+
+libpychrysadebuggdbrsp_la_LDFLAGS =
+
+
+AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \
+ -I../../../../src
+
+AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
diff --git a/plugins/pychrysa/debug/gdbrsp/gdb.c b/plugins/pychrysa/debug/gdbrsp/gdb.c
new file mode 100644
index 0000000..cbbf66b
--- /dev/null
+++ b/plugins/pychrysa/debug/gdbrsp/gdb.c
@@ -0,0 +1,165 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * gdb.c - équivalent Python du fichier "debug/gdbrsp/gdb.c"
+ *
+ * Copyright (C) 2016 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "gdb.h"
+
+
+#include <pygobject.h>
+
+
+#include <i18n.h>
+
+
+#include <debug/gdbrsp/gdb.h>
+
+
+#include "../debugger.h"
+#include "../../helpers.h"
+#include "../../analysis/binary.h"
+
+
+/* Crée un nouvel objet Python de type 'GdbDebugger'. */
+static PyObject *py_gdb_debugger_new(PyTypeObject *, PyObject *, PyObject *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : type = type de l'objet à instancier. *
+* args = arguments fournis à l'appel. *
+* kwds = arguments de type key=val fournis. *
+* *
+* Description : Crée un nouvel objet Python de type 'GdbDebugger'. *
+* *
+* Retour : Instance Python mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_gdb_debugger_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ PyObject *result; /* Instance à retourner */
+ PyObject *binary_obj; /* Objet pour le binaire lié */
+ const char *server; /* Nom du serveur à contacter */
+ unsigned short port; /* Port de connexion */
+ int ret; /* Bilan de lecture des args. */
+ GLoadedBinary *binary; /* Binaire chargé en mémoire */
+ GBinaryDebugger *debugger; /* Création GLib à transmettre */
+
+ ret = PyArg_ParseTuple(args, "OsH", &binary_obj, &server, &port);
+ if (!ret) return NULL;
+
+ ret = PyObject_IsInstance(binary_obj, (PyObject *)get_python_loaded_binary_type());
+ if (!ret)
+ {
+ PyErr_SetString(PyExc_TypeError, _("The first argument must be an instance of LoadedBinary."));
+ return NULL;
+ }
+
+ binary = G_LOADED_BINARY(pygobject_get(binary_obj));
+
+ debugger = g_gdb_debugger_new(binary, server, port);
+
+ result = pygobject_new(G_OBJECT(debugger));
+
+ g_object_unref(debugger);
+
+ return (PyObject *)result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit un accès à une définition de type à diffuser. *
+* *
+* Retour : Définition d'objet pour Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyTypeObject *get_python_gdb_debugger_type(void)
+{
+ static PyMethodDef py_gdb_debugger_methods[] = {
+ { NULL }
+ };
+
+ static PyGetSetDef py_gdb_debugger_getseters[] = {
+ { NULL }
+ };
+
+ static PyTypeObject py_gdb_debugger_type = {
+
+ PyVarObject_HEAD_INIT(NULL, 0)
+
+ .tp_name = "pychrysalide.debug.gdbrsp.GdbDebugger",
+ .tp_basicsize = sizeof(PyGObject),
+
+ .tp_flags = Py_TPFLAGS_DEFAULT,
+
+ .tp_doc = "PyChrysalide GDB debugger",
+
+ .tp_methods = py_gdb_debugger_methods,
+ .tp_getset = py_gdb_debugger_getseters,
+ .tp_new = (newfunc)py_gdb_debugger_new
+
+ };
+
+ return &py_gdb_debugger_type;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Prend en charge l'objet 'pychrysalide....gdbrsp.GdbDebugger'.*
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool register_python_gdb_debugger(PyObject *module)
+{
+ PyTypeObject *py_gdb_debugger_type; /* Type Python 'GdbDebugger' */
+ PyObject *dict; /* Dictionnaire du module */
+
+ py_gdb_debugger_type = get_python_gdb_debugger_type();
+
+ dict = PyModule_GetDict(module);
+
+ if (!register_class_for_pygobject(dict, G_TYPE_GDB_DEBUGGER,
+ py_gdb_debugger_type, get_python_binary_debugger_type()))
+ return false;
+
+ return true;
+
+}
diff --git a/plugins/pychrysa/debug/gdbrsp/gdb.h b/plugins/pychrysa/debug/gdbrsp/gdb.h
new file mode 100644
index 0000000..c3d1330
--- /dev/null
+++ b/plugins/pychrysa/debug/gdbrsp/gdb.h
@@ -0,0 +1,42 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * gdb.h - prototypes pour l'équivalent Python du fichier "debug/gdbrsp/gdb.h"
+ *
+ * Copyright (C) 2016 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_PYCHRYSA_DEBUG_GDBRSP_DEBUGGER_H
+#define _PLUGINS_PYCHRYSA_DEBUG_GDBRSP_DEBUGGER_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Fournit un accès à une définition de type à diffuser. */
+PyTypeObject *get_python_gdb_debugger_type(void);
+
+/* Prend en charge l'objet 'pychrysalide.debug.gdbrsp.GdbDebugger'. */
+bool register_python_gdb_debugger(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYCHRYSA_DEBUG_GDBRSP_DEBUGGER_H */
diff --git a/plugins/pychrysa/debug/gdbrsp/module.c b/plugins/pychrysa/debug/gdbrsp/module.c
new file mode 100644
index 0000000..6e7896c
--- /dev/null
+++ b/plugins/pychrysa/debug/gdbrsp/module.c
@@ -0,0 +1,86 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * module.c - intégration du répertoire gdbrsp en tant que module
+ *
+ * Copyright (C) 2012 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "module.h"
+
+
+#include "gdb.h"
+
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Ajoute le module 'debug.gdbrsp' au module Python. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool add_debug_gdbrsp_module_to_python_module(PyObject *super)
+{
+ bool result; /* Bilan à retourner */
+ PyObject *module; /* Sous-module mis en place */
+ int ret; /* Bilan d'un appel */
+
+ static PyModuleDef py_chrysalide_gdbrsp_module = {
+
+ .m_base = PyModuleDef_HEAD_INIT,
+
+ .m_name = "pychrysalide.debug.gdbrsp",
+ .m_doc = "Python module for Chrysalide.debug.gdbrsp",
+
+ .m_size = -1,
+
+ };
+
+ result = false;
+
+ module = PyModule_Create(&py_chrysalide_gdbrsp_module);
+ if (module == NULL) return false;
+
+ ret = PyState_AddModule(super, &py_chrysalide_gdbrsp_module);
+ if (ret != 0) goto loading_failed;
+
+ ret = _PyImport_FixupBuiltin(module, "pychrysalide.debug.gdbrsp");
+ if (ret != 0) goto loading_failed;
+
+ Py_INCREF(module);
+ ret = PyModule_AddObject(super, "gdbrsp", module);
+ if (ret != 0) goto loading_failed;
+
+ result = true;
+
+ result &= register_python_gdb_debugger(module);
+
+ loading_failed:
+
+ assert(result);
+
+ return result;
+
+}
diff --git a/plugins/pychrysa/debug/gdbrsp/module.h b/plugins/pychrysa/debug/gdbrsp/module.h
new file mode 100644
index 0000000..78e62b0
--- /dev/null
+++ b/plugins/pychrysa/debug/gdbrsp/module.h
@@ -0,0 +1,39 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * module.h - prototypes pour l'intégration du répertoire gdbrsp en tant que module
+ *
+ * Copyright (C) 2012-2016 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_PYCHRYSA_DEBUG_GDBRSP_MODULE_H
+#define _PLUGINS_PYCHRYSA_DEBUG_GDBRSP_MODULE_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Ajoute le module 'debug.gdbrsp' au module Python. */
+bool add_debug_gdbrsp_module_to_python_module(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYCHRYSA_DEBUG_GDBRSP_MODULE_H */