[gnome-builder/wip/chergert/bug1: 51/69] debugger: reset breakpoints when stopping
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/bug1: 51/69] debugger: reset breakpoints when stopping
- Date: Sat, 2 Sep 2017 02:06:03 +0000 (UTC)
commit 067b11bc265967b604d3f6c4b31b2d467df077f6
Author: Christian Hergert <chergert redhat com>
Date: Thu Aug 31 00:09:32 2017 -0700
debugger: reset breakpoints when stopping
libide/debugger/ide-debug-manager.c | 93 ++++++++++++++++++++++++++++------
1 files changed, 76 insertions(+), 17 deletions(-)
---
diff --git a/libide/debugger/ide-debug-manager.c b/libide/debugger/ide-debug-manager.c
index fba5e77..2f9d847 100644
--- a/libide/debugger/ide-debug-manager.c
+++ b/libide/debugger/ide-debug-manager.c
@@ -378,24 +378,36 @@ ide_debug_manager_find_debugger (IdeDebugManager *self,
}
static void
-ide_debug_manager_runner_exited (IdeDebugManager *self,
- IdeRunner *runner)
+ide_debug_manager_reset_breakpoints_cb (gpointer item,
+ gpointer user_data)
{
- g_autoptr(IdeDebugger) debugger = NULL;
- g_autoptr(IdeRunner) hold_runner = NULL;
+ IdeDebugManager *self = user_data;
+ IdeDebuggerBreakpoint *breakpoint = item;
+ g_assert (IDE_IS_DEBUGGER_BREAKPOINT (breakpoint));
g_assert (IDE_IS_DEBUG_MANAGER (self));
- g_assert (IDE_IS_RUNNER (runner));
- /*
- * Keep debugger alive so that listeners to :debugger property can
- * properly disconnect signals when we clear the debugger instance.
- */
- debugger = g_steal_pointer (&self->debugger);
- hold_runner = g_steal_pointer (&self->runner);
+ _ide_debugger_breakpoint_reset (breakpoint);
+}
- ide_debug_manager_set_active (self, FALSE);
- g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_DEBUGGER]);
+static void
+ide_debug_manager_reset_breakpoints (IdeDebugManager *self)
+{
+ IdeDebuggerBreakpoints *breakpoints;
+ GHashTableIter iter;
+
+ IDE_ENTRY;
+
+ g_assert (IDE_IS_DEBUG_MANAGER (self));
+
+ g_hash_table_iter_init (&iter, self->breakpoints);
+
+ while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&breakpoints))
+ ide_debugger_breakpoints_foreach (breakpoints,
+ ide_debug_manager_reset_breakpoints_cb,
+ self);
+
+ IDE_EXIT;
}
static void
@@ -409,7 +421,13 @@ ide_debug_manager_sync_breakpoints_cb (gpointer item,
g_assert (IDE_IS_DEBUG_MANAGER (self));
g_assert (self->debugger != NULL);
- /* TODO */
+ /*
+ * If the breakpoint does not yet have an id, then we need to register
+ * it with the debugger. We clear all id's when the debugger exits so
+ * that we can replay them when starting the next session.
+ */
+ if (!ide_debugger_breakpoint_get_id (breakpoint))
+ ide_debugger_insert_breakpoint_async (self->debugger, breakpoint, NULL, NULL, NULL);
}
static void
@@ -445,6 +463,41 @@ ide_debug_manager_sync_breakpoints (IdeDebugManager *self)
IDE_EXIT;
}
+static void
+ide_debug_manager_runner_spawned (IdeDebugManager *self,
+ const gchar *identifier,
+ IdeRunner *runner)
+{
+ g_assert (IDE_IS_DEBUG_MANAGER (self));
+ g_assert (identifier != NULL);
+ g_assert (IDE_IS_RUNNER (runner));
+
+ ide_debug_manager_sync_breakpoints (self);
+}
+
+static void
+ide_debug_manager_runner_exited (IdeDebugManager *self,
+ IdeRunner *runner)
+{
+ g_autoptr(IdeDebugger) debugger = NULL;
+ g_autoptr(IdeRunner) hold_runner = NULL;
+
+ g_assert (IDE_IS_DEBUG_MANAGER (self));
+ g_assert (IDE_IS_RUNNER (runner));
+
+ /*
+ * Keep debugger alive so that listeners to :debugger property can
+ * properly disconnect signals when we clear the debugger instance.
+ */
+ debugger = g_steal_pointer (&self->debugger);
+ hold_runner = g_steal_pointer (&self->runner);
+
+ ide_debug_manager_set_active (self, FALSE);
+ ide_debug_manager_reset_breakpoints (self);
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_DEBUGGER]);
+}
+
/**
* ide_debug_manager_start:
* @self: an #IdeDebugManager
@@ -483,10 +536,16 @@ ide_debug_manager_start (IdeDebugManager *self,
ide_debugger_prepare (debugger, runner);
g_signal_connect_object (runner,
+ "spawned",
+ G_CALLBACK (ide_debug_manager_runner_spawned),
+ self,
+ G_CONNECT_SWAPPED);
+
+ g_signal_connect_object (runner,
"exited",
G_CALLBACK (ide_debug_manager_runner_exited),
self,
- G_CONNECT_SWAPPED);
+ G_CONNECT_SWAPPED | G_CONNECT_AFTER);
self->runner = g_object_ref (runner);
self->debugger = g_steal_pointer (&debugger);
@@ -495,8 +554,6 @@ ide_debug_manager_start (IdeDebugManager *self,
ide_debug_manager_set_active (self, TRUE);
- ide_debug_manager_sync_breakpoints (self);
-
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_DEBUGGER]);
ret = TRUE;
@@ -519,6 +576,8 @@ ide_debug_manager_stop (IdeDebugManager *self)
}
g_clear_object (&self->debugger);
+ ide_debug_manager_reset_breakpoints (self);
+
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_DEBUGGER]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]