[gnome-builder/wip/chergert/bug1: 75/101] breakpoints: add pointer to individual breakpoint



commit 9afbafb6399bda12f3f6b9e2f7b1136818a5d5fa
Author: Christian Hergert <chergert redhat com>
Date:   Wed Aug 30 15:13:33 2017 -0700

    breakpoints: add pointer to individual breakpoint

 libide/debugger/ide-debugger-breakpoints.c |   51 +++++++++++++++++++++++++--
 1 files changed, 47 insertions(+), 4 deletions(-)
---
diff --git a/libide/debugger/ide-debugger-breakpoints.c b/libide/debugger/ide-debugger-breakpoints.c
index 9ee95cb..07a7e91 100644
--- a/libide/debugger/ide-debugger-breakpoints.c
+++ b/libide/debugger/ide-debugger-breakpoints.c
@@ -24,10 +24,30 @@
 
 #include "debugger/ide-debugger-breakpoints.h"
 
+/**
+ * SECTION:ide-debugger-breakpoints
+ * @title: IdeDebuggerBreakpoints
+ * @short_title: A collection of breakpoints for a file
+ *
+ * The #IdeDebuggerBreakpoints provides a convenient container for breakpoints
+ * about a single file. This is useful for situations like the document gutter
+ * where we need very fast access to whether or not a line has a breakpoint set
+ * during the rendering process.
+ *
+ * At it's core, this is a sparse array as rarely do we have more than one
+ * cacheline of information about breakpoints in a file.
+ *
+ * This object is controled by the IdeDebuggerManager and will modify the
+ * breakpoints as necessary by the current debugger. If no debugger is
+ * active, the breakpoints are queued until the debugger has started, and
+ * then synchronized to the debugger process.
+ */
+
 typedef struct
 {
-  guint line;
-  IdeDebuggerBreakMode mode;
+  guint                  line;
+  IdeDebuggerBreakMode   mode;
+  IdeDebuggerBreakpoint *breakpoint;
 } LineInfo;
 
 struct _IdeDebuggerBreakpoints
@@ -53,6 +73,16 @@ G_DEFINE_TYPE (IdeDebuggerBreakpoints, ide_debugger_breakpoints, G_TYPE_OBJECT)
 static GParamSpec *properties [N_PROPS];
 static guint signals [N_SIGNALS];
 
+static void
+line_info_clear (gpointer data)
+{
+  LineInfo *info = data;
+
+  info->line = 0;
+  info->mode = 0;
+  g_clear_object (&info->breakpoint);
+}
+
 static gint
 line_info_compare (gconstpointer a,
                    gconstpointer b)
@@ -64,12 +94,21 @@ line_info_compare (gconstpointer a,
 }
 
 static void
+ide_debugger_breakpoints_dispose (GObject *object)
+{
+  IdeDebuggerBreakpoints *self = (IdeDebuggerBreakpoints *)object;
+
+  g_clear_pointer (&self->lines, g_array_unref);
+
+  G_OBJECT_CLASS (ide_debugger_breakpoints_parent_class)->dispose (object);
+}
+
+static void
 ide_debugger_breakpoints_finalize (GObject *object)
 {
   IdeDebuggerBreakpoints *self = (IdeDebuggerBreakpoints *)object;
 
   g_clear_object (&self->file);
-  g_clear_pointer (&self->lines, g_array_unref);
 
   G_OBJECT_CLASS (ide_debugger_breakpoints_parent_class)->finalize (object);
 }
@@ -117,6 +156,7 @@ ide_debugger_breakpoints_class_init (IdeDebuggerBreakpointsClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
+  object_class->dispose = ide_debugger_breakpoints_dispose;
   object_class->finalize = ide_debugger_breakpoints_finalize;
   object_class->get_property = ide_debugger_breakpoints_get_property;
   object_class->set_property = ide_debugger_breakpoints_set_property;
@@ -196,7 +236,10 @@ ide_debugger_breakpoints_set_line (IdeDebuggerBreakpoints *self,
     return;
 
   if (self->lines == NULL)
-    self->lines = g_array_new (FALSE, FALSE, sizeof (LineInfo));
+    {
+      self->lines = g_array_new (FALSE, FALSE, sizeof (LineInfo));
+      g_array_set_clear_func (self->lines, line_info_clear);
+    }
 
   info.line = line;
   info.mode = mode;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]