diff options
Diffstat (limited to 'plugins/pychrysalide/debug/gdbrsp')
-rw-r--r-- | plugins/pychrysalide/debug/gdbrsp/gdb.c | 21 | ||||
-rw-r--r-- | plugins/pychrysalide/debug/gdbrsp/gdb.h | 2 | ||||
-rw-r--r-- | plugins/pychrysalide/debug/gdbrsp/module.c | 46 | ||||
-rw-r--r-- | plugins/pychrysalide/debug/gdbrsp/module.h | 7 |
4 files changed, 47 insertions, 29 deletions
diff --git a/plugins/pychrysalide/debug/gdbrsp/gdb.c b/plugins/pychrysalide/debug/gdbrsp/gdb.c index a4cde20..df56ca4 100644 --- a/plugins/pychrysalide/debug/gdbrsp/gdb.c +++ b/plugins/pychrysalide/debug/gdbrsp/gdb.c @@ -35,6 +35,7 @@ #include "../debugger.h" +#include "../../access.h" #include "../../helpers.h" #include "../../analysis/binary.h" @@ -148,18 +149,24 @@ PyTypeObject *get_python_gdb_debugger_type(void) * * ******************************************************************************/ -bool register_python_gdb_debugger(PyObject *module) +bool ensure_python_gdb_debugger_is_registered(void) { - PyTypeObject *py_gdb_debugger_type; /* Type Python 'GdbDebugger' */ + PyTypeObject *type; /* Type Python 'GdbDebugger' */ + PyObject *module; /* Module à recompléter */ PyObject *dict; /* Dictionnaire du module */ - py_gdb_debugger_type = get_python_gdb_debugger_type(); + type = get_python_gdb_debugger_type(); - dict = PyModule_GetDict(module); + if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) + { + module = get_access_to_python_module("pychrysalide.debug.gdbrsp"); + + 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; + if (!register_class_for_pygobject(dict, G_TYPE_GDB_DEBUGGER, type, get_python_binary_debugger_type())) + return false; + + } return true; diff --git a/plugins/pychrysalide/debug/gdbrsp/gdb.h b/plugins/pychrysalide/debug/gdbrsp/gdb.h index 00afab5..057a38d 100644 --- a/plugins/pychrysalide/debug/gdbrsp/gdb.h +++ b/plugins/pychrysalide/debug/gdbrsp/gdb.h @@ -35,7 +35,7 @@ PyTypeObject *get_python_gdb_debugger_type(void); /* Prend en charge l'objet 'pychrysalide.debug.gdbrsp.GdbDebugger'. */ -bool register_python_gdb_debugger(PyObject *); +bool ensure_python_gdb_debugger_is_registered(void); diff --git a/plugins/pychrysalide/debug/gdbrsp/module.c b/plugins/pychrysalide/debug/gdbrsp/module.c index 6e7896c..c077aa7 100644 --- a/plugins/pychrysalide/debug/gdbrsp/module.c +++ b/plugins/pychrysalide/debug/gdbrsp/module.c @@ -26,28 +26,28 @@ #include "gdb.h" +#include "../../helpers.h" /****************************************************************************** * * -* Paramètres : module = module dont la définition est à compléter. * +* Paramètres : super = module dont la définition est à compléter. * * * -* Description : Ajoute le module 'debug.gdbrsp' au module Python. * +* Description : Ajoute le module 'debug.gdbresp' à un module Python. * * * -* Retour : - * +* Retour : Bilan de l'opération. * * * * Remarques : - * * * ******************************************************************************/ -bool add_debug_gdbrsp_module_to_python_module(PyObject *super) +bool add_debug_gdbresp_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 = { + static PyModuleDef py_chrysalide_debug_gdbresp_module = { .m_base = PyModuleDef_HEAD_INIT, @@ -58,26 +58,34 @@ bool add_debug_gdbrsp_module_to_python_module(PyObject *super) }; - result = false; + module = build_python_module(super, &py_chrysalide_debug_gdbresp_module); - module = PyModule_Create(&py_chrysalide_gdbrsp_module); - if (module == NULL) return false; + result = (module != NULL); - ret = PyState_AddModule(super, &py_chrysalide_gdbrsp_module); - if (ret != 0) goto loading_failed; + return result; - 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; +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Intègre les objets du module 'debug.gdbresp'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ - result &= register_python_gdb_debugger(module); +bool populate_debug_gdbresp_module(void) +{ + bool result; /* Bilan à retourner */ + + result = true; - loading_failed: + if (result) result = ensure_python_gdb_debugger_is_registered(); assert(result); diff --git a/plugins/pychrysalide/debug/gdbrsp/module.h b/plugins/pychrysalide/debug/gdbrsp/module.h index edc2b11..0ed3719 100644 --- a/plugins/pychrysalide/debug/gdbrsp/module.h +++ b/plugins/pychrysalide/debug/gdbrsp/module.h @@ -31,8 +31,11 @@ -/* Ajoute le module 'debug.gdbrsp' au module Python. */ -bool add_debug_gdbrsp_module_to_python_module(PyObject *); +/* Ajoute le module 'debug.gdbresp' à un module Python. */ +bool add_debug_gdbresp_module(PyObject *); + +/* Intègre les objets du module 'debug.gdbresp'. */ +bool populate_debug_gdbresp_module(void); |