[gnome-builder/wip/chergert/debugger] debugger: implement step in/over
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/debugger] debugger: implement step in/over
- Date: Tue, 9 May 2017 21:42:52 +0000 (UTC)
commit d023764fac7dee0e832d903f3335f3c2a008f9ff
Author: albfan <albertofanjul gmail com>
Date: Tue May 9 01:25:28 2017 +0200
debugger: implement step in/over
This implements step in/over by adding step and next operations to the
Mi2Client and plumbing them in to IdeDebugger and GbpGdbDebugger.
https://bugzilla.gnome.org/show_bug.cgi?id=782357
contrib/mi2/mi2-client.c | 109 ++++++++++++++++++++++++++++++++++++++++
contrib/mi2/mi2-client.h | 17 ++++++
libide/debugger/ide-debugger.c | 2 +-
plugins/gdb/gbp-gdb-debugger.c | 3 +
4 files changed, 130 insertions(+), 1 deletions(-)
---
diff --git a/contrib/mi2/mi2-client.c b/contrib/mi2/mi2-client.c
index 4210984..9f676bc 100644
--- a/contrib/mi2/mi2-client.c
+++ b/contrib/mi2/mi2-client.c
@@ -957,6 +957,114 @@ mi2_client_run_finish (Mi2Client *self,
}
/**
+ * mi2_client_step_async:
+ * @self: a #Mi2Client
+ * @cancellable: (nullable): an optional #GCancellable, or %NULL
+ * @callback: (scope async) (closure user_data): a callback to execute
+ * @user_data: user data for @callback
+ *
+ * Asynchronously executes the continue command.
+ *
+ * Call mi2_client_step_finish() from @callback to get the result.
+ */
+void
+mi2_client_step_async (Mi2Client *self,
+ gboolean reverse,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_autoptr(GTask) task = NULL;
+
+ g_return_if_fail (MI2_IS_CLIENT (self));
+ g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+ task = g_task_new (self, cancellable, callback, user_data);
+ g_task_set_source_tag (task, mi2_client_step_async);
+
+ mi2_client_exec_async (self,
+ reverse ? "-exec-step --reverse" : "-exec-step",
+ cancellable,
+ mi2_client_exec_cb,
+ g_steal_pointer (&task));
+}
+
+/**
+ * mi2_client_step_finish:
+ * @self: a #Mi2Client
+ * @result: the #GAsyncResult provided to the callback function
+ * @error: a location for a #GError, or %NULL
+ *
+ * Completes an asynchronous request to mi2_client_step_async().
+ *
+ * Returns: %TRUE if successful, otherwise %FALSE and @error is est.
+ */
+gboolean
+mi2_client_step_finish (Mi2Client *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ g_return_val_if_fail (MI2_IS_CLIENT (self), FALSE);
+ g_return_val_if_fail (G_IS_TASK (result), FALSE);
+
+ return g_task_propagate_boolean (G_TASK (result), error);
+}
+
+/**
+ * mi2_client_next_async:
+ * @self: a #Mi2Client
+ * @cancellable: (nullable): an optional #GCancellable, or %NULL
+ * @callback: (scope async) (closure user_data): a callback to execute
+ * @user_data: user data for @callback
+ *
+ * Asynchronously executes the continue command.
+ *
+ * Call mi2_client_next_finish() from @callback to get the result.
+ */
+void
+mi2_client_next_async (Mi2Client *self,
+ gboolean reverse,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_autoptr(GTask) task = NULL;
+
+ g_return_if_fail (MI2_IS_CLIENT (self));
+ g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+ task = g_task_new (self, cancellable, callback, user_data);
+ g_task_set_source_tag (task, mi2_client_next_async);
+
+ mi2_client_exec_async (self,
+ reverse ? "-exec-next --reverse" : "-exec-next",
+ cancellable,
+ mi2_client_exec_cb,
+ g_steal_pointer (&task));
+}
+
+/**
+ * mi2_client_next_finish:
+ * @self: a #Mi2Client
+ * @result: the #GAsyncResult provided to the callback function
+ * @error: a location for a #GError, or %NULL
+ *
+ * Completes an asynchronous request to mi2_client_next_async().
+ *
+ * Returns: %TRUE if successful, otherwise %FALSE and @error is est.
+ */
+gboolean
+mi2_client_next_finish (Mi2Client *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ g_return_val_if_fail (MI2_IS_CLIENT (self), FALSE);
+ g_return_val_if_fail (G_IS_TASK (result), FALSE);
+
+ return g_task_propagate_boolean (G_TASK (result), error);
+}
+
+/**
* mi2_client_continue_async:
* @self: a #Mi2Client
* @cancellable: (nullable): an optional #GCancellable, or %NULL
@@ -1047,6 +1155,7 @@ mi2_stop_reason_get_type (void)
GType _type_id;
static const GEnumValue values[] = {
{ MI2_STOP_UNKNOWN, "MI2_STOP_UNKNOWN", "unknown" },
+ { MI2_STOP_END_STEPPING_RANGE, "MI2_STOP_END_STEPPING_RANGE", "end-stepping-range" },
{ MI2_STOP_EXITED_NORMALLY, "MI2_STOP_EXITED_NORMALLY", "exited-normally" },
{ MI2_STOP_BREAKPOINT_HIT, "MI2_STOP_BREAKPOINT_HIT", "breakpoint-hit" },
{ 0 }
diff --git a/contrib/mi2/mi2-client.h b/contrib/mi2/mi2-client.h
index af4b3be..0654fa8 100644
--- a/contrib/mi2/mi2-client.h
+++ b/contrib/mi2/mi2-client.h
@@ -36,6 +36,7 @@ G_DECLARE_DERIVABLE_TYPE (Mi2Client, mi2_client, MI2, CLIENT, GObject)
typedef enum
{
MI2_STOP_UNKNOWN,
+ MI2_STOP_END_STEPPING_RANGE,
MI2_STOP_EXITED_NORMALLY,
MI2_STOP_BREAKPOINT_HIT,
} Mi2StopReason;
@@ -100,6 +101,22 @@ void mi2_client_shutdown_async (Mi2Client
gboolean mi2_client_shutdown_finish (Mi2Client *self,
GAsyncResult *result,
GError **error);
+void mi2_client_step_async (Mi2Client *self,
+ gboolean reverse,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean mi2_client_step_finish (Mi2Client *self,
+ GAsyncResult *result,
+ GError **error);
+void mi2_client_next_async (Mi2Client *self,
+ gboolean reverse,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean mi2_client_next_finish (Mi2Client *self,
+ GAsyncResult *result,
+ GError **error);
void mi2_client_continue_async (Mi2Client *self,
gboolean reverse,
GCancellable *cancellable,
diff --git a/libide/debugger/ide-debugger.c b/libide/debugger/ide-debugger.c
index bbab4de..000fa8f 100644
--- a/libide/debugger/ide-debugger.c
+++ b/libide/debugger/ide-debugger.c
@@ -91,7 +91,7 @@ ide_debugger_real_load_source_cb (GObject *object,
gtk_text_buffer_get_iter_at_line_offset (GTK_TEXT_BUFFER (buffer),
&iter,
- line,
+ line - 1,
line_offset);
gtk_text_buffer_select_range (GTK_TEXT_BUFFER (buffer), &iter, &iter);
diff --git a/plugins/gdb/gbp-gdb-debugger.c b/plugins/gdb/gbp-gdb-debugger.c
index d4e592c..11ca79e 100644
--- a/plugins/gdb/gbp-gdb-debugger.c
+++ b/plugins/gdb/gbp-gdb-debugger.c
@@ -183,9 +183,11 @@ gbp_gdb_debugger_run (IdeDebugger *debugger,
switch (run_type)
{
case IDE_DEBUGGER_RUN_STEP_IN:
+ mi2_client_next_async (self->client, FALSE, NULL, NULL, NULL);
break;
case IDE_DEBUGGER_RUN_STEP_OVER:
+ mi2_client_step_async (self->client, FALSE, NULL, NULL, NULL);
break;
case IDE_DEBUGGER_RUN_CONTINUE:
@@ -340,6 +342,7 @@ gbp_gdb_debugger_on_client_stopped (GbpGdbDebugger *self,
switch (reason)
{
case MI2_STOP_BREAKPOINT_HIT:
+ case MI2_STOP_END_STEPPING_RANGE:
self->can_continue = TRUE;
self->can_step_in = TRUE;
self->can_step_over = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]