[gnome-builder: 1/11] debugger: add API to interpret a command
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder: 1/11] debugger: add API to interpret a command
- Date: Sat, 4 Jul 2020 17:28:31 +0000 (UTC)
commit b3089d7d0b6dc849fa35c9c542c2829bcf135cf9
Author: Christian Hergert <chergert redhat com>
Date: Fri Sep 28 23:44:43 2018 -0700
debugger: add API to interpret a command
This gives us the plumbing necessary to be able to send a command to
execute to the debugger backend. In particular, this could be used to
create an interactive console to gdb or other debuggers that the user
can type into (and maybe even someday get autocompletion on).
src/libide/debugger/ide-debugger-fallbacks.c | 29 +++++++++++++
src/libide/debugger/ide-debugger-private.h | 8 ++++
src/libide/debugger/ide-debugger.c | 61 ++++++++++++++++++++++++++++
src/libide/debugger/ide-debugger.h | 18 ++++++++
4 files changed, 116 insertions(+)
---
diff --git a/src/libide/debugger/ide-debugger-fallbacks.c b/src/libide/debugger/ide-debugger-fallbacks.c
index a12cc1d6a..3ce9e66c4 100644
--- a/src/libide/debugger/ide-debugger-fallbacks.c
+++ b/src/libide/debugger/ide-debugger-fallbacks.c
@@ -259,3 +259,32 @@ _ide_debugger_real_disassemble_finish (IdeDebugger *self,
return g_task_propagate_pointer (G_TASK (result), error);
}
+
+void
+_ide_debugger_real_interpret_async (IdeDebugger *self,
+ const gchar *command,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_assert (IDE_IS_DEBUGGER (self));
+ g_assert (command != NULL);
+ g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+ g_task_report_new_error (self, callback, user_data,
+ _ide_debugger_real_interpret_async,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ "Interpret command is not supported");
+}
+
+gboolean
+_ide_debugger_real_interpret_finish (IdeDebugger *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ g_assert (IDE_IS_DEBUGGER (self));
+ g_assert (G_IS_TASK (result));
+
+ return g_task_propagate_boolean (G_TASK (result), error);
+}
diff --git a/src/libide/debugger/ide-debugger-private.h b/src/libide/debugger/ide-debugger-private.h
index df1c1ee08..19ce4750b 100644
--- a/src/libide/debugger/ide-debugger-private.h
+++ b/src/libide/debugger/ide-debugger-private.h
@@ -46,6 +46,14 @@ void _ide_debugger_real_list_frames_async (IdeDebugger
GPtrArray *_ide_debugger_real_list_frames_finish (IdeDebugger *self,
GAsyncResult *result,
GError **error);
+void _ide_debugger_real_interpret_async (IdeDebugger *self,
+ const gchar *command,
+ GCancellable
*cancellable,
+ GAsyncReadyCallback
callback,
+ gpointer
user_data);
+gboolean _ide_debugger_real_interpret_finish (IdeDebugger *self,
+ GAsyncResult *result,
+ GError **error);
void _ide_debugger_real_interrupt_async (IdeDebugger *self,
IdeDebuggerThreadGroup
*thread_group,
GCancellable
*cancellable,
diff --git a/src/libide/debugger/ide-debugger.c b/src/libide/debugger/ide-debugger.c
index 712e354b0..61c2d6233 100644
--- a/src/libide/debugger/ide-debugger.c
+++ b/src/libide/debugger/ide-debugger.c
@@ -490,6 +490,8 @@ ide_debugger_class_init (IdeDebuggerClass *klass)
klass->thread_group_removed = ide_debugger_real_thread_group_removed;
klass->thread_removed = ide_debugger_real_thread_removed;
klass->thread_selected = ide_debugger_real_thread_selected;
+ klass->interpret_async = _ide_debugger_real_interpret_async;
+ klass->interpret_finish = _ide_debugger_real_interpret_finish;
/**
* IdeDebugger:display-name:
@@ -2012,3 +2014,62 @@ ide_debugger_prepare (IdeDebugger *self,
if (IDE_DEBUGGER_GET_CLASS (self)->prepare)
IDE_DEBUGGER_GET_CLASS (self)->prepare (self, runner);
}
+
+/**
+ * ide_debugger_interpret_async:
+ * @self: an #IdeDebugger
+ * @command: a command to execute
+ * @cancellable: (nullable): a #GCancellable or %NULL
+ * @callback: a callback to execute, or %NULL
+ * @user_data: user data for @callback
+ *
+ * Asynchronously requests that the debugger interpret the command.
+ *
+ * This is used by the interactive-console to submit commands to the debugger
+ * that are in the native syntax of that debugger.
+ *
+ * The debugger is expected to return any textual output via the
+ * IdeDebugger::log signal.
+ *
+ * Call ide_debugger_interpret_finish() from @callback to determine if the
+ * command was interpreted.
+ *
+ * Since: 3.32
+ */
+void
+ide_debugger_interpret_async (IdeDebugger *self,
+ const gchar *command,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_return_if_fail (IDE_IS_DEBUGGER (self));
+ g_return_if_fail (command != NULL);
+
+ return IDE_DEBUGGER_GET_CLASS (self)->interpret_async (self, command, cancellable, callback, user_data);
+}
+
+/**
+ * ide_debugger_interpret_finish:
+ * @self: an #IdeDebugger
+ * @result: a #GAsyncResult provided to callback
+ * @error: a location for a #GError, or %NULL
+ *
+ * Retrieves the result of the asynchronous operation to interpret a debugger
+ * command.
+ *
+ * Returns: %TRUE if the command was interpreted, otherwise %FALSE and
+ * @error is set.
+ *
+ * Since: 3.32
+ */
+gboolean
+ide_debugger_interpret_finish (IdeDebugger *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ g_return_val_if_fail (IDE_IS_DEBUGGER (self), FALSE);
+ g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
+
+ return IDE_DEBUGGER_GET_CLASS (self)->interpret_finish (self, result, error);
+}
diff --git a/src/libide/debugger/ide-debugger.h b/src/libide/debugger/ide-debugger.h
index ba301c1e6..ec6c1a600 100644
--- a/src/libide/debugger/ide-debugger.h
+++ b/src/libide/debugger/ide-debugger.h
@@ -185,6 +185,14 @@ struct _IdeDebuggerClass
GPtrArray *(*disassemble_finish) (IdeDebugger *self,
GAsyncResult *result,
GError **error);
+ void (*interpret_async) (IdeDebugger *self,
+ const gchar *command,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ gboolean (*interpret_finish) (IdeDebugger *self,
+ GAsyncResult *result,
+ GError **error);
/*< private >*/
gpointer _reserved[32];
@@ -385,5 +393,15 @@ void ide_debugger_emit_library_loaded (IdeDebugger
IDE_AVAILABLE_IN_3_32
void ide_debugger_emit_library_unloaded (IdeDebugger *self,
IdeDebuggerLibrary *library);
+IDE_AVAILABLE_IN_3_32
+void ide_debugger_interpret_async (IdeDebugger *self,
+ const gchar *command,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+IDE_AVAILABLE_IN_3_32
+gboolean ide_debugger_interpret_finish (IdeDebugger *self,
+ GAsyncResult *result,
+ GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]