summaryrefslogtreecommitdiff
path: root/src/debug/debugger.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2010-07-29 00:02:49 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2010-07-29 00:02:49 (GMT)
commit73af1bd66e5d1a2e30d56151532710f2b28d12df (patch)
tree88f98194359accd8349193f4cbe3c4cabee24d23 /src/debug/debugger.c
parentf150f36ee0297b4499a41bbbfc06699cd2f72db5 (diff)
Improved the GDB client.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@175 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/debug/debugger.c')
-rw-r--r--src/debug/debugger.c212
1 files changed, 212 insertions, 0 deletions
diff --git a/src/debug/debugger.c b/src/debug/debugger.c
new file mode 100644
index 0000000..a7d7470
--- /dev/null
+++ b/src/debug/debugger.c
@@ -0,0 +1,212 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * debugger.c - gestion des différents débogueurs
+ *
+ * Copyright (C) 2008 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA 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.
+ *
+ * OpenIDA 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "debugger.h"
+
+#include "debugger-int.h"
+#include "remgdb/gdb.h"
+#include "ptrace/ptrace.h"
+#include "../gtkext/iodamarshal.h"
+
+
+
+/* Initialise la classe de base des débogueurs. */
+static void g_binary_debugger_class_init(GBinaryDebuggerClass *);
+
+/* Initialise une instance de base d'un débogueur. */
+static void g_binary_debugger_init(GBinaryDebugger *);
+
+
+
+/* Indique le type définit pour une ligne de représentation. */
+G_DEFINE_TYPE(GBinaryDebugger, g_binary_debugger, G_TYPE_OBJECT);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe de base des débogueurs. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_binary_debugger_class_init(GBinaryDebuggerClass *klass)
+{
+ g_signal_new("debugger-stopped",
+ G_TYPE_BINARY_DEBUGGER,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(GBinaryDebuggerClass, debugger_stopped),
+ NULL, NULL,
+ g_cclosure_user_marshal_VOID__UINT64_UINT64,
+ G_TYPE_NONE, 2, G_TYPE_UINT64, G_TYPE_UINT64);
+
+ g_signal_new("halted",
+ G_TYPE_BINARY_DEBUGGER,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(GBinaryDebuggerClass, debugger_halted),
+ NULL, NULL,
+ g_cclosure_user_marshal_VOID__INT_UINT64_INT,
+ G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_UINT64, G_TYPE_INT);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : debugger = instance à initialiser. *
+* *
+* Description : Initialise une instance de base d'un débogueur. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_binary_debugger_init(GBinaryDebugger *debugger)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : type = type de débigueur choisi pour l'opération. *
+* binary = binaire devant être débogué. *
+* *
+* Description : Crée un nouveau débogueur. *
+* *
+* Retour : Composant GObject mis en place ou NULL. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GBinaryDebugger *g_new_binary_debugger(DebuggerType type, GOpenidaBinary *binary)
+{
+ GBinaryDebugger *result;
+
+ switch (type)
+ {
+ case DGT_REMOTE_GDB:
+ result = g_gdb_debugger_new(binary, NULL);
+ break;
+
+ case DGT_PTRACE:
+ result = g_object_new(G_TYPE_PTRACE_DEBUGGER, NULL);
+ break;
+
+ default:
+ result = NULL;
+ break;
+
+ }
+
+ if (result != NULL)
+ result->binary = binary;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : debugger = débogueur à manipuler ici. *
+* *
+* Description : Démarre une procédure de débogage. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_binary_debugger_run(GBinaryDebugger *debugger)
+{
+ debugger->run(debugger);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : debugger = débogueur à manipuler ici. *
+* *
+* Description : Reprend une procédure de débogage. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_binary_debugger_resume(GBinaryDebugger *debugger)
+{
+ debugger->resume(debugger);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : debugger = débogueur à manipuler ici. *
+* *
+* Description : Tue une procédure de débogage. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_binary_debugger_kill(GBinaryDebugger *debugger)
+{
+ debugger->kill(debugger);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : debugger = débogueur à manipuler ici. *
+* count = nombre de transmissions effetuées. *
+* *
+* Description : Fournit la valeur des registres de l'architecture. *
+* *
+* Retour : Tableau de valeurs transmises à libérer de la mémoire / NULL.*
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+register_value *g_binary_debugger_get_registers(GBinaryDebugger *debugger, size_t *count)
+{
+ return debugger->get_reg_values(debugger, count);
+
+}