[gnome-builder/wip/chergert/debugger: 94/100] debugger: add some debugger types we'll need going forward
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/debugger: 94/100] debugger: add some debugger types we'll need going forward
- Date: Fri, 14 Apr 2017 21:39:24 +0000 (UTC)
commit 667fa3831cc18e9fdf5f57c738f6a0b013845e16
Author: Christian Hergert <chergert redhat com>
Date: Thu Apr 13 21:35:08 2017 -0700
debugger: add some debugger types we'll need going forward
libide/Makefile.am | 8 ++
libide/debugger/ide-debugger-frame.c | 97 +++++++++++++++
libide/debugger/ide-debugger-frame.h | 60 +++++++++
libide/debugger/ide-debugger-stack.c | 107 ++++++++++++++++
libide/debugger/ide-debugger-stack.h | 52 ++++++++
libide/debugger/ide-debugger-thread.c | 200 +++++++++++++++++++++++++++++++
libide/debugger/ide-debugger-thread.h | 50 ++++++++
libide/debugger/ide-debugger-variable.c | 91 ++++++++++++++
libide/debugger/ide-debugger-variable.h | 52 ++++++++
9 files changed, 717 insertions(+), 0 deletions(-)
---
diff --git a/libide/Makefile.am b/libide/Makefile.am
index 8dc9ee0..adf2cf2 100644
--- a/libide/Makefile.am
+++ b/libide/Makefile.am
@@ -54,9 +54,13 @@ libide_1_0_la_public_headers = \
debugger/ide-debug-manager.h \
debugger/ide-debugger-breakpoints.h \
debugger/ide-debugger-editor-view-addin.h \
+ debugger/ide-debugger-frame.h \
debugger/ide-debugger-perspective.h \
debugger/ide-debugger-workbench-addin.h \
debugger/ide-debugger-gutter-renderer.h \
+ debugger/ide-debugger-stack.h \
+ debugger/ide-debugger-thread.h \
+ debugger/ide-debugger-variable.h \
debugger/ide-debugger-view.h \
devices/ide-device-manager.h \
devices/ide-device-provider.h \
@@ -244,9 +248,13 @@ libide_1_0_la_public_sources = \
debugger/ide-debug-manager.c \
debugger/ide-debugger-breakpoints.c \
debugger/ide-debugger-editor-view-addin.c \
+ debugger/ide-debugger-frame.c \
debugger/ide-debugger-perspective.c \
debugger/ide-debugger-workbench-addin.c \
debugger/ide-debugger-gutter-renderer.c \
+ debugger/ide-debugger-stack.c \
+ debugger/ide-debugger-thread.c \
+ debugger/ide-debugger-variable.c \
debugger/ide-debugger-view.c \
devices/ide-device-manager.c \
devices/ide-device-provider.c \
diff --git a/libide/debugger/ide-debugger-frame.c b/libide/debugger/ide-debugger-frame.c
new file mode 100644
index 0000000..22cfe64
--- /dev/null
+++ b/libide/debugger/ide-debugger-frame.c
@@ -0,0 +1,97 @@
+/* ide-debugger-frame.c
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * This program 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.
+ *
+ * This program 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#define G_LOG_DOMAIN "ide-debugger-frame"
+
+#include "ide-debugger-frame.h"
+
+G_DEFINE_ABSTRACT_TYPE (IdeDebuggerFrame, ide_debugger_frame, G_TYPE_OBJECT)
+
+static void
+ide_debugger_frame_class_init (IdeDebuggerFrameClass *klass)
+{
+}
+
+static void
+ide_debugger_frame_init (IdeDebuggerFrame *self)
+{
+}
+
+guint
+ide_debugger_frame_get_index (IdeDebuggerFrame *self)
+{
+ g_return_val_if_fail (IDE_IS_DEBUGGER_FRAME (self), 0);
+
+ if (IDE_DEBUGGER_FRAME_GET_CLASS (self)->get_index)
+ return IDE_DEBUGGER_FRAME_GET_CLASS (self)->get_index (self);
+
+ return 0;
+}
+
+gchar *
+ide_debugger_frame_get_address (IdeDebuggerFrame *self)
+{
+ g_return_val_if_fail (IDE_IS_DEBUGGER_FRAME (self), 0);
+
+ if (IDE_DEBUGGER_FRAME_GET_CLASS (self)->get_address)
+ return IDE_DEBUGGER_FRAME_GET_CLASS (self)->get_address (self);
+
+ return NULL;
+}
+
+gchar *
+ide_debugger_frame_get_location (IdeDebuggerFrame *self)
+{
+ g_return_val_if_fail (IDE_IS_DEBUGGER_FRAME (self), 0);
+
+ if (IDE_DEBUGGER_FRAME_GET_CLASS (self)->get_location)
+ return IDE_DEBUGGER_FRAME_GET_CLASS (self)->get_location (self);
+
+ return NULL;
+}
+
+gchar *
+ide_debugger_frame_get_function (IdeDebuggerFrame *self)
+{
+ g_return_val_if_fail (IDE_IS_DEBUGGER_FRAME (self), 0);
+
+ if (IDE_DEBUGGER_FRAME_GET_CLASS (self)->get_function)
+ return IDE_DEBUGGER_FRAME_GET_CLASS (self)->get_function (self);
+
+ return NULL;
+}
+
+/**
+ * ide_debugger_frame_get_arguments:
+ * @self: a #IdeDebuggerFrame
+ *
+ * Gets the arguments passed to the function as #IdeDebuggerVariable.
+ *
+ * Returns: (transfer container) (element-type Ide.DebuggerVariable): The
+ * arguments for the function call in this frame.
+ */
+GPtrArray *
+ide_debugger_frame_get_arguments (IdeDebuggerFrame *self)
+{
+ g_return_val_if_fail (IDE_IS_DEBUGGER_FRAME (self), 0);
+
+ if (IDE_DEBUGGER_FRAME_GET_CLASS (self)->get_arguments)
+ return IDE_DEBUGGER_FRAME_GET_CLASS (self)->get_arguments (self);
+
+ return NULL;
+}
diff --git a/libide/debugger/ide-debugger-frame.h b/libide/debugger/ide-debugger-frame.h
new file mode 100644
index 0000000..5bedeef
--- /dev/null
+++ b/libide/debugger/ide-debugger-frame.h
@@ -0,0 +1,60 @@
+/* ide-debugger-frame.h
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * This program 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.
+ *
+ * This program 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef IDE_DEBUGGER_FRAME_H
+#define IDE_DEBUGGER_FRAME_H
+
+#include <gio/gio.h>
+
+#include "debugger/ide-debugger-variable.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_DEBUGGER_FRAME (ide_debugger_frame_get_type())
+
+G_DECLARE_DERIVABLE_TYPE (IdeDebuggerFrame, ide_debugger_frame, IDE, DEBUGGER_FRAME, GObject)
+
+struct _IdeDebuggerFrameClass
+{
+ GObjectClass parent_class;
+
+ guint (*get_index) (IdeDebuggerFrame *self);
+ gchar *(*get_function) (IdeDebuggerFrame *self);
+ GPtrArray *(*get_arguments) (IdeDebuggerFrame *self);
+ gchar *(*get_location) (IdeDebuggerFrame *self);
+ gchar *(*get_address) (IdeDebuggerFrame *self);
+
+ gpointer _reserved1;
+ gpointer _reserved2;
+ gpointer _reserved3;
+ gpointer _reserved4;
+ gpointer _reserved5;
+ gpointer _reserved6;
+ gpointer _reserved7;
+ gpointer _reserved8;
+};
+
+guint ide_debugger_frame_get_index (IdeDebuggerFrame *self);
+gchar *ide_debugger_frame_get_address (IdeDebuggerFrame *self);
+gchar *ide_debugger_frame_get_location (IdeDebuggerFrame *self);
+gchar *ide_debugger_frame_get_function (IdeDebuggerFrame *self);
+GPtrArray *ide_debugger_frame_get_arguments (IdeDebuggerFrame *self);
+
+G_END_DECLS
+
+#endif /* IDE_DEBUGGER_FRAME_H */
diff --git a/libide/debugger/ide-debugger-stack.c b/libide/debugger/ide-debugger-stack.c
new file mode 100644
index 0000000..6c92144
--- /dev/null
+++ b/libide/debugger/ide-debugger-stack.c
@@ -0,0 +1,107 @@
+/* ide-debugger-stack.c
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * This program 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.
+ *
+ * This program 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#define G_LOG_DOMAIN "ide-debugger-stack"
+
+#include "ide-debugger-stack.h"
+
+static void list_model_iface_init (GListModelInterface *iface);
+
+G_DEFINE_ABSTRACT_TYPE_WITH_CODE (IdeDebuggerStack, ide_debugger_stack, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, list_model_iface_init))
+
+static void
+ide_debugger_stack_class_init (IdeDebuggerStackClass *klass)
+{
+}
+
+static void
+ide_debugger_stack_init (IdeDebuggerStack *self)
+{
+}
+
+/**
+ * ide_debugger_stack_get_frame:
+ * @self: An #IdeDebuggerStack
+ * @position: the position within the stack, starting from 0
+ *
+ * It is an error to call this function with a position that is outside the
+ * range of the available frames in this stack.
+ *
+ * The index starts from 0.
+ *
+ * See ide_debugger_stack_get_n_frames() for the number of frames within
+ * this stack.
+ *
+ * Returns: (transfer full): An #IdeDebuggerFrame.
+ */
+IdeDebuggerFrame *
+ide_debugger_stack_get_frame (IdeDebuggerStack *self,
+ guint position)
+{
+ g_return_val_if_fail (IDE_IS_DEBUGGER_STACK (self), NULL);
+
+#ifdef IDE_ENABLE_TRACE
+ g_assert_cmpint (position, <, ide_debugger_stack_get_n_frames (self));
+#endif
+
+ return IDE_DEBUGGER_STACK_GET_CLASS (self)->get_frame (self, position);
+}
+
+/**
+ * ide_debugger_stack_get_n_frames:
+ * @self: An #IdeDebuggerStack
+ *
+ * Gets the number of frames within this stack trace.
+ *
+ * Returns: The number of frames in the stack trace.
+ */
+guint
+ide_debugger_stack_get_n_frames (IdeDebuggerStack *self)
+{
+ g_return_val_if_fail (IDE_IS_DEBUGGER_STACK (self), 0);
+
+ return IDE_DEBUGGER_STACK_GET_CLASS (self)->get_n_frames (self);
+}
+
+static guint
+ide_debugger_stack_get_n_items (GListModel *model)
+{
+ return ide_debugger_stack_get_n_frames (IDE_DEBUGGER_STACK (model));
+}
+
+static GType
+ide_debugger_stack_get_item_type (GListModel *model)
+{
+ return IDE_TYPE_DEBUGGER_FRAME;
+}
+
+static gpointer
+ide_debugger_stack_get_item (GListModel *model,
+ guint position)
+{
+ return ide_debugger_stack_get_frame (IDE_DEBUGGER_STACK (model), position);
+}
+
+static void
+list_model_iface_init (GListModelInterface *iface)
+{
+ iface->get_n_items = ide_debugger_stack_get_n_items;
+ iface->get_item_type = ide_debugger_stack_get_item_type;
+ iface->get_item = ide_debugger_stack_get_item;
+}
diff --git a/libide/debugger/ide-debugger-stack.h b/libide/debugger/ide-debugger-stack.h
new file mode 100644
index 0000000..f360964
--- /dev/null
+++ b/libide/debugger/ide-debugger-stack.h
@@ -0,0 +1,52 @@
+/* ide-debugger-stack.h
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * This program 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.
+ *
+ * This program 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef IDE_DEBUGGER_STACK_H
+#define IDE_DEBUGGER_STACK_H
+
+#include <gio/gio.h>
+
+#include "debugger/ide-debugger-frame.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_DEBUGGER_STACK (ide_debugger_stack_get_type())
+
+G_DECLARE_DERIVABLE_TYPE (IdeDebuggerStack, ide_debugger_stack, IDE, DEBUGGER_STACK, GObject)
+
+struct _IdeDebuggerStackClass
+{
+ GObjectClass parent;
+
+ guint (*get_n_frames) (IdeDebuggerStack *self);
+ IdeDebuggerFrame *(*get_frame) (IdeDebuggerStack *self,
+ guint position);
+
+ gpointer _reserved1;
+ gpointer _reserved2;
+ gpointer _reserved3;
+ gpointer _reserved4;
+};
+
+guint ide_debugger_stack_get_n_frames (IdeDebuggerStack *self);
+IdeDebuggerFrame *ide_debugger_stack_get_frame (IdeDebuggerStack *self,
+ guint position);
+
+G_END_DECLS
+
+#endif /* IDE_DEBUGGER_STACK_H */
diff --git a/libide/debugger/ide-debugger-thread.c b/libide/debugger/ide-debugger-thread.c
new file mode 100644
index 0000000..7220818
--- /dev/null
+++ b/libide/debugger/ide-debugger-thread.c
@@ -0,0 +1,200 @@
+/* ide-debugger-thread.c
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * This program 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.
+ *
+ * This program 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "ide-debugger-thread.h"
+
+typedef struct
+{
+ gchar *id;
+ gchar *name;
+} IdeDebuggerThreadPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (IdeDebuggerThread, ide_debugger_thread, G_TYPE_OBJECT)
+
+enum {
+ PROP_0,
+ PROP_ID,
+ PROP_NAME,
+ N_PROPS
+};
+
+static GParamSpec *properties [N_PROPS];
+
+IdeDebuggerThread *
+ide_debugger_thread_new (void)
+{
+ return g_object_new (IDE_TYPE_DEBUGGER_THREAD, NULL);
+}
+
+static void
+ide_debugger_thread_finalize (GObject *object)
+{
+ IdeDebuggerThread *self = (IdeDebuggerThread *)object;
+ IdeDebuggerThreadPrivate *priv = ide_debugger_thread_get_instance_private (self);
+
+ g_clear_pointer (&priv->id, g_free);
+ g_clear_pointer (&priv->name, g_free);
+
+ G_OBJECT_CLASS (ide_debugger_thread_parent_class)->finalize (object);
+}
+
+static void
+ide_debugger_thread_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ IdeDebuggerThread *self = IDE_DEBUGGER_THREAD (object);
+
+ switch (prop_id)
+ {
+ case PROP_ID:
+ g_value_set_string (value, ide_debugger_thread_get_id (self));
+ break;
+
+ case PROP_NAME:
+ g_value_set_string (value, ide_debugger_thread_get_name (self));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+ide_debugger_thread_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ IdeDebuggerThread *self = IDE_DEBUGGER_THREAD (object);
+
+ switch (prop_id)
+ {
+ case PROP_ID:
+ ide_debugger_thread_set_id (self, g_value_get_string (value));
+ break;
+
+ case PROP_NAME:
+ ide_debugger_thread_set_name (self, g_value_get_string (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+ide_debugger_thread_class_init (IdeDebuggerThreadClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = ide_debugger_thread_finalize;
+ object_class->get_property = ide_debugger_thread_get_property;
+ object_class->set_property = ide_debugger_thread_set_property;
+
+ /**
+ * IdeDebuggerThread:id:
+ *
+ * The "id" property contains the identifier of the thread within the debugger.
+ * This may not match the id of the thread to the operating system, but simply
+ * for internal access within the debugger.
+ *
+ * It generally starts from 1 and is monotonically increasing.
+ */
+ properties [PROP_ID] =
+ g_param_spec_string ("id",
+ "Id",
+ "The id of the thread",
+ NULL,
+ (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * IdeDebuggerThread:name:
+ *
+ * If the process has specified a name for the thread and the debugger has access to it,
+ * this is where that thread name should be stored.
+ *
+ * This allows the UI to display more than just "Thread 2" when referring to the thread.
+ */
+ properties [PROP_NAME] =
+ g_param_spec_string ("name",
+ "Name",
+ "The name of the thread",
+ NULL,
+ (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
+}
+
+static void
+ide_debugger_thread_init (IdeDebuggerThread *self)
+{
+}
+
+const gchar *
+ide_debugger_thread_get_id (IdeDebuggerThread *self)
+{
+ IdeDebuggerThreadPrivate *priv = ide_debugger_thread_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_DEBUGGER_THREAD (self), NULL);
+
+ return priv->id;
+}
+
+void
+ide_debugger_thread_set_id (IdeDebuggerThread *self,
+ const gchar *id)
+{
+ IdeDebuggerThreadPrivate *priv = ide_debugger_thread_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_DEBUGGER_THREAD (self));
+
+ if (g_strcmp0 (priv->id, id) != 0)
+ {
+ g_free (priv->id);
+ priv->id = g_strdup (id);
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ID]);
+ }
+}
+
+const gchar *
+ide_debugger_thread_get_name (IdeDebuggerThread *self)
+{
+ IdeDebuggerThreadPrivate *priv = ide_debugger_thread_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_DEBUGGER_THREAD (self), NULL);
+
+ return priv->name;
+}
+
+void
+ide_debugger_thread_set_name (IdeDebuggerThread *self,
+ const gchar *name)
+{
+ IdeDebuggerThreadPrivate *priv = ide_debugger_thread_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_DEBUGGER_THREAD (self));
+
+ if (g_strcmp0 (priv->name, name) != 0)
+ {
+ g_free (priv->name);
+ priv->name = g_strdup (name);
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_NAME]);
+ }
+}
diff --git a/libide/debugger/ide-debugger-thread.h b/libide/debugger/ide-debugger-thread.h
new file mode 100644
index 0000000..953168d
--- /dev/null
+++ b/libide/debugger/ide-debugger-thread.h
@@ -0,0 +1,50 @@
+/* ide-debugger-thread.h
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * This program 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.
+ *
+ * This program 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef IDE_DEBUGGER_THREAD_H
+#define IDE_DEBUGGER_THREAD_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_DEBUGGER_THREAD (ide_debugger_thread_get_type())
+
+G_DECLARE_DERIVABLE_TYPE (IdeDebuggerThread, ide_debugger_thread, IDE, DEBUGGER_THREAD, GObject)
+
+struct _IdeDebuggerThreadClass
+{
+ GObjectClass parent;
+
+ gpointer _reserved1;
+ gpointer _reserved2;
+ gpointer _reserved3;
+ gpointer _reserved4;
+};
+
+IdeDebuggerThread *ide_debugger_thread_new (void);
+const gchar *ide_debugger_thread_get_id (IdeDebuggerThread *self);
+void ide_debugger_thread_set_id (IdeDebuggerThread *self,
+ const gchar *id);
+const gchar *ide_debugger_thread_get_name (IdeDebuggerThread *self);
+void ide_debugger_thread_set_name (IdeDebuggerThread *self,
+ const gchar *name);
+
+G_END_DECLS
+
+#endif /* IDE_DEBUGGER_THREAD_H */
diff --git a/libide/debugger/ide-debugger-variable.c b/libide/debugger/ide-debugger-variable.c
new file mode 100644
index 0000000..dcd71af
--- /dev/null
+++ b/libide/debugger/ide-debugger-variable.c
@@ -0,0 +1,91 @@
+/* ide-debugger-variable.c
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * This program 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.
+ *
+ * This program 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#define G_LOG_DOMAIN "ide-debugger-variable"
+
+#include "ide-debugger-variable.h"
+
+G_DEFINE_ABSTRACT_TYPE (IdeDebuggerVariable, ide_debugger_variable, G_TYPE_OBJECT)
+
+static void
+ide_debugger_variable_class_init (IdeDebuggerVariableClass *klass)
+{
+}
+
+static void
+ide_debugger_variable_init (IdeDebuggerVariable *self)
+{
+}
+
+/**
+ * ide_debugger_variable_get_name:
+ * @self: a #IdeDebuggerVariable
+ *
+ * Gets the name of the variable if available.
+ *
+ * Returns: (nullable) (transfer full): The variable name as a string.
+ */
+gchar *
+ide_debugger_variable_get_name (IdeDebuggerVariable *self)
+{
+ g_return_val_if_fail (IDE_IS_DEBUGGER_VARIABLE (self), NULL);
+
+ if (IDE_DEBUGGER_VARIABLE_GET_CLASS (self)->get_name)
+ return IDE_DEBUGGER_VARIABLE_GET_CLASS (self)->get_name (self);
+
+ return NULL;
+}
+
+/**
+ * ide_debugger_variable_get_type_name:
+ * @self: a #IdeDebuggerVariable
+ *
+ * Gets the type name of the variable as a string. This will be language
+ * specific.
+ *
+ * Returns: (nullable) (transfer full): The type name as a string.
+ */
+gchar *
+ide_debugger_variable_get_type_name (IdeDebuggerVariable *self)
+{
+ g_return_val_if_fail (IDE_IS_DEBUGGER_VARIABLE (self), NULL);
+
+ if (IDE_DEBUGGER_VARIABLE_GET_CLASS (self)->get_type_name)
+ return IDE_DEBUGGER_VARIABLE_GET_CLASS (self)->get_type_name (self);
+
+ return NULL;
+}
+
+/**
+ * ide_debugger_variable_get_value:
+ * @self: a #IdeDebuggerVariable
+ *
+ * Gets the contents of the variable as a #GBytes.
+ *
+ * Returns: (nullable) (transfer full): A #GBytes or %NULL
+ */
+GBytes *
+ide_debugger_variable_get_value (IdeDebuggerVariable *self)
+{
+ g_return_val_if_fail (IDE_IS_DEBUGGER_VARIABLE (self), NULL);
+
+ if (IDE_DEBUGGER_VARIABLE_GET_CLASS (self)->get_value)
+ return IDE_DEBUGGER_VARIABLE_GET_CLASS (self)->get_value (self);
+
+ return NULL;
+}
diff --git a/libide/debugger/ide-debugger-variable.h b/libide/debugger/ide-debugger-variable.h
new file mode 100644
index 0000000..a9eaa9a
--- /dev/null
+++ b/libide/debugger/ide-debugger-variable.h
@@ -0,0 +1,52 @@
+/* ide-debugger-variable.h
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * This program 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.
+ *
+ * This program 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef IDE_DEBUGGER_VARIABLE_H
+#define IDE_DEBUGGER_VARIABLE_H
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_DEBUGGER_VARIABLE (ide_debugger_variable_get_type())
+
+G_DECLARE_DERIVABLE_TYPE (IdeDebuggerVariable, ide_debugger_variable, IDE, DEBUGGER_VARIABLE, GObject)
+
+struct _IdeDebuggerVariableClass
+{
+ GObjectClass parent_class;
+
+ gchar *(*get_name) (IdeDebuggerVariable *self);
+ gchar *(*get_type_name) (IdeDebuggerVariable *self);
+ GBytes *(*get_value) (IdeDebuggerVariable *self);
+
+ /* TODO: How do we want to do complex field types? */
+
+ gpointer _reserved1;
+ gpointer _reserved2;
+ gpointer _reserved3;
+ gpointer _reserved4;
+};
+
+gchar *ide_debugger_variable_get_name (IdeDebuggerVariable *self);
+gchar *ide_debugger_variable_get_type_name (IdeDebuggerVariable *self);
+GBytes *ide_debugger_variable_get_value (IdeDebuggerVariable *self);
+
+G_END_DECLS
+
+#endif /* IDE_DEBUGGER_VARIABLE_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]