[gnome-builder/wip/chergert/bug1: 31/43] debugger: use IdeDebuggerAddress for breakpoints
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/bug1: 31/43] debugger: use IdeDebuggerAddress for breakpoints
- Date: Tue, 29 Aug 2017 21:13:42 +0000 (UTC)
commit a79e958ededc27127d3e9284f6c784cbf9976b88
Author: Christian Hergert <chergert redhat com>
Date: Mon Aug 28 14:42:58 2017 -0700
debugger: use IdeDebuggerAddress for breakpoints
This was the last place we were still using strings for addresses in the
inferior process.
libide/debugger/ide-debugger-breakpoint.c | 32 ++++++++++-----------
libide/debugger/ide-debugger-breakpoint.h | 4 +-
libide/debugger/ide-debugger-breakpoints-view.c | 35 ++++++++++++++++++++++-
plugins/gdb/gbp-gdb-debugger.c | 7 ++--
4 files changed, 55 insertions(+), 23 deletions(-)
---
diff --git a/libide/debugger/ide-debugger-breakpoint.c b/libide/debugger/ide-debugger-breakpoint.c
index b1b9b95..bbe57ea 100644
--- a/libide/debugger/ide-debugger-breakpoint.c
+++ b/libide/debugger/ide-debugger-breakpoint.c
@@ -23,7 +23,6 @@
typedef struct
{
- gchar *address;
gchar *function;
gchar *id;
gchar *file;
@@ -36,6 +35,7 @@ typedef struct
IdeDebuggerBreakMode mode : 8;
guint enabled : 1;
+ IdeDebuggerAddress address;
gint64 count;
} IdeDebuggerBreakpointPrivate;
@@ -65,7 +65,6 @@ ide_debugger_breakpoint_finalize (GObject *object)
IdeDebuggerBreakpoint *self = (IdeDebuggerBreakpoint *)object;
IdeDebuggerBreakpointPrivate *priv = ide_debugger_breakpoint_get_instance_private (self);
- g_clear_pointer (&priv->address, g_free);
g_clear_pointer (&priv->function, g_free);
g_clear_pointer (&priv->id, g_free);
g_clear_pointer (&priv->file, g_free);
@@ -86,7 +85,7 @@ ide_debugger_breakpoint_get_property (GObject *object,
switch (prop_id)
{
case PROP_ADDRESS:
- g_value_set_string (value, ide_debugger_breakpoint_get_address (self));
+ g_value_set_uint64 (value, ide_debugger_breakpoint_get_address (self));
break;
case PROP_ID:
@@ -146,7 +145,7 @@ ide_debugger_breakpoint_set_property (GObject *object,
switch (prop_id)
{
case PROP_ADDRESS:
- ide_debugger_breakpoint_set_address (self, g_value_get_string (value));
+ ide_debugger_breakpoint_set_address (self, g_value_get_uint64 (value));
break;
case PROP_ID:
@@ -206,16 +205,17 @@ ide_debugger_breakpoint_class_init (IdeDebuggerBreakpointClass *klass)
/**
* IdeDebuggerBreakpoint:address:
*
- * The address of the breakpoint, if available. This is a string so that
- * architectures other than that of the user can be supported.
+ * The address of the breakpoint, if available.
+ *
+ * Builder only supports up to 64-bit addresses at this time.
*
* Since: 3.26
*/
properties [PROP_ADDRESS] =
- g_param_spec_string ("address",
+ g_param_spec_uint64 ("address",
"Address",
"The address of the breakpoint",
- NULL,
+ 0, G_MAXUINT64, IDE_DEBUGGER_ADDRESS_INVALID,
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
/**
@@ -423,19 +423,18 @@ ide_debugger_breakpoint_get_id (IdeDebuggerBreakpoint *self)
* Gets the "address" property, which defines where the breakpoint is
* located in memory.
*
- * This value is a string to allow for communicating with architectures
- * different than the host of the debugging UI.
+ * Builder only supports up to 64-bit addresses at this time.
*
* Returns: The address of the breakpoint, if any.
*
* Since: 3.26
*/
-const gchar *
+IdeDebuggerAddress
ide_debugger_breakpoint_get_address (IdeDebuggerBreakpoint *self)
{
IdeDebuggerBreakpointPrivate *priv = ide_debugger_breakpoint_get_instance_private (self);
- g_return_val_if_fail (IDE_IS_DEBUGGER_BREAKPOINT (self), NULL);
+ g_return_val_if_fail (IDE_IS_DEBUGGER_BREAKPOINT (self), IDE_DEBUGGER_ADDRESS_INVALID);
return priv->address;
}
@@ -443,7 +442,7 @@ ide_debugger_breakpoint_get_address (IdeDebuggerBreakpoint *self)
/**
* ide_debugger_breakpoint_set_address:
* @self: An #IdeDebuggerBreakpoint
- * @address: (nullable): The address of the breakpoint
+ * @address: The address of the breakpoint
*
* Sets the address of the breakpoint, if any.
*
@@ -451,16 +450,15 @@ ide_debugger_breakpoint_get_address (IdeDebuggerBreakpoint *self)
*/
void
ide_debugger_breakpoint_set_address (IdeDebuggerBreakpoint *self,
- const gchar *address)
+ IdeDebuggerAddress address)
{
IdeDebuggerBreakpointPrivate *priv = ide_debugger_breakpoint_get_instance_private (self);
g_return_if_fail (IDE_IS_DEBUGGER_BREAKPOINT (self));
- if (g_strcmp0 (address, priv->address) != 0)
+ if (priv->address != address)
{
- g_free (priv->address);
- priv->address = g_strdup (address);
+ priv->address = address;
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ADDRESS]);
}
}
diff --git a/libide/debugger/ide-debugger-breakpoint.h b/libide/debugger/ide-debugger-breakpoint.h
index 2c0d3ae..a79cb3a 100644
--- a/libide/debugger/ide-debugger-breakpoint.h
+++ b/libide/debugger/ide-debugger-breakpoint.h
@@ -56,9 +56,9 @@ void ide_debugger_breakpoint_set_mode (IdeDebuggerBre
IdeDebuggerDisposition ide_debugger_breakpoint_get_disposition (IdeDebuggerBreakpoint *self);
void ide_debugger_breakpoint_set_disposition (IdeDebuggerBreakpoint *self,
IdeDebuggerDisposition disposition);
-const gchar *ide_debugger_breakpoint_get_address (IdeDebuggerBreakpoint *self);
+IdeDebuggerAddress ide_debugger_breakpoint_get_address (IdeDebuggerBreakpoint *self);
void ide_debugger_breakpoint_set_address (IdeDebuggerBreakpoint *self,
- const gchar *address);
+ IdeDebuggerAddress address);
const gchar *ide_debugger_breakpoint_get_spec (IdeDebuggerBreakpoint *self);
void ide_debugger_breakpoint_set_spec (IdeDebuggerBreakpoint *self,
const gchar *spec);
diff --git a/libide/debugger/ide-debugger-breakpoints-view.c b/libide/debugger/ide-debugger-breakpoints-view.c
index 3959a52..f56f4ce 100644
--- a/libide/debugger/ide-debugger-breakpoints-view.c
+++ b/libide/debugger/ide-debugger-breakpoints-view.c
@@ -189,6 +189,39 @@ ide_debugger_breakpoints_view_enabled_toggled (IdeDebuggerBreakpointsView *self,
}
static void
+address_cell_data_func (GtkCellLayout *cell_layout,
+ GtkCellRenderer *cell,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ g_autoptr(IdeDebuggerBreakpoint) breakpoint = NULL;
+ IdeDebuggerAddress addr = IDE_DEBUGGER_ADDRESS_INVALID;
+
+ g_assert (GTK_IS_TREE_VIEW_COLUMN (cell_layout));
+ g_assert (GTK_IS_CELL_RENDERER_TEXT (cell));
+ g_assert (GTK_IS_TREE_MODEL (model));
+ g_assert (iter != NULL);
+
+ gtk_tree_model_get (model, iter, 0, &breakpoint, -1);
+
+ if (breakpoint != NULL)
+ addr = ide_debugger_breakpoint_get_address (breakpoint);
+
+ if (addr == IDE_DEBUGGER_ADDRESS_INVALID)
+ {
+ g_object_set (cell, "text", NULL, NULL);
+ }
+ else
+ {
+ g_autofree gchar *str = NULL;
+
+ str = g_strdup_printf ("0x%"G_GINT64_MODIFIER"x", addr);
+ g_object_set (cell, "text", str, NULL);
+ }
+}
+
+static void
string_property_cell_data_func (GtkCellLayout *cell_layout,
GtkCellRenderer *cell,
GtkTreeModel *model,
@@ -468,7 +501,7 @@ ide_debugger_breakpoints_view_init (IdeDebuggerBreakpointsView *self)
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (self->address_column),
GTK_CELL_RENDERER (self->address_cell),
- string_property_cell_data_func, "address", NULL);
+ address_cell_data_func, NULL, NULL);
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (self->hits_column),
GTK_CELL_RENDERER (self->hits_cell),
diff --git a/plugins/gdb/gbp-gdb-debugger.c b/plugins/gdb/gbp-gdb-debugger.c
index 1ab9424..75431e6 100644
--- a/plugins/gdb/gbp-gdb-debugger.c
+++ b/plugins/gdb/gbp-gdb-debugger.c
@@ -407,7 +407,7 @@ gbp_gdb_debugger_handle_breakpoint (GbpGdbDebugger *self,
ide_debugger_breakpoint_set_mode (breakpoint, parse_mode_from_string (type));
ide_debugger_breakpoint_set_disposition (breakpoint, parse_disposition_from_string (disp));
- ide_debugger_breakpoint_set_address (breakpoint, addr);
+ ide_debugger_breakpoint_set_address (breakpoint, ide_debugger_address_parse (addr));
ide_debugger_breakpoint_set_function (breakpoint, func);
ide_debugger_breakpoint_set_file (breakpoint, file);
ide_debugger_breakpoint_set_enabled (breakpoint, enabled);
@@ -535,7 +535,7 @@ gbp_gdb_debugger_handle_stopped (GbpGdbDebugger *self,
breakpoint = ide_debugger_breakpoint_new (id);
ide_debugger_breakpoint_set_thread (breakpoint, thread_id);
- ide_debugger_breakpoint_set_address (breakpoint, address);
+ ide_debugger_breakpoint_set_address (breakpoint, ide_debugger_address_parse (address));
ide_debugger_breakpoint_set_function (breakpoint, func);
ide_debugger_breakpoint_set_disposition (breakpoint, parse_disposition_from_string (disp));
@@ -884,7 +884,8 @@ gbp_gdb_debugger_list_breakpoints_cb (GObject *object,
breakpoint = ide_debugger_breakpoint_new (iter->number);
- ide_debugger_breakpoint_set_address (breakpoint, iter->address);
+ ide_debugger_breakpoint_set_address (breakpoint,
+ ide_debugger_address_parse (iter->address));
ide_debugger_breakpoint_set_function (breakpoint, iter->func_name);
ide_debugger_breakpoint_set_file (breakpoint, iter->file);
ide_debugger_breakpoint_set_line (breakpoint, iter->line);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]