Commit b3089d7d authored by Christian Hergert's avatar Christian Hergert Committed by Günther Wagner

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).
parent 70f85f19
......@@ -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);
}
......@@ -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,
......
......@@ -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);
}
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment