[anjuta] gdb: bgo #617323 - Save debugger stack trace
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] gdb: bgo #617323 - Save debugger stack trace
- Date: Sat, 10 Jul 2010 10:25:55 +0000 (UTC)
commit 2998d6152551c4609de4f4aeaef64133b0b138dd
Author: Sébastien Granjoux <seb sfo free fr>
Date: Fri Jul 9 21:33:40 2010 +0200
gdb: bgo #617323 - Save debugger stack trace
libanjuta/interfaces/libanjuta.idl | 14 ++++++++
plugins/debug-manager/anjuta-debug-manager.xml | 1 +
plugins/debug-manager/command.c | 21 ++++++++++++-
plugins/debug-manager/command.h | 1 +
plugins/debug-manager/stack_trace.c | 33 ++++++++++++++++++++
plugins/gdb/debugger.c | 39 ++++++++++++++++++++++++
plugins/gdb/debugger.h | 1 +
plugins/gdb/plugin.c | 11 +++++++
plugins/js-debugger/plugin.c | 9 +++++
9 files changed, 129 insertions(+), 1 deletions(-)
---
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index af4179f..df8df88 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -4337,6 +4337,20 @@ interface IAnjutaDebugger
void disable_log ();
/**
+ * ianjuta_debugger_dump_stack_trace:
+ * @obj: Self
+ * @callback: Callback to call getting a list of frame
+ * @user_data: User data that is passed back to the callback
+ * @err: Error propagation and reporting.
+ *
+ * Return a stack trace valid for a bug reports.
+ * This function is optional.
+ *
+ * Returns: TRUE if sucessful, otherwise FALSE.
+ */
+ gboolean dump_stack_trace (Callback callback, gpointer user_data);
+
+ /**
* SECTION:ianjuta-debugger-breakpoint
* @title: IAnjutaDebuggerBreakpoint
* @short_description: Breakpoint Debugger interface
diff --git a/plugins/debug-manager/anjuta-debug-manager.xml b/plugins/debug-manager/anjuta-debug-manager.xml
index 28a24f6..76de833 100644
--- a/plugins/debug-manager/anjuta-debug-manager.xml
+++ b/plugins/debug-manager/anjuta-debug-manager.xml
@@ -81,6 +81,7 @@
<popup name="PopupStack">
<menuitem name="SetCurrentFrame" action="ActionDmaSetCurrentFrame" />
<menuitem name="JumpToFrame" action="ActionDmaJumpToFrame" />
+ <menuitem name="DumpStackTrace" action="ActionDmaDumpStackTrace" />
</popup>
<popup name="PopupWatch">
<menuitem name="AddWatch" action="ActionDmaAddWatch" />
diff --git a/plugins/debug-manager/command.c b/plugins/debug-manager/command.c
index 92c9a78..52b0c9c 100644
--- a/plugins/debug-manager/command.c
+++ b/plugins/debug-manager/command.c
@@ -96,7 +96,8 @@ typedef enum
INFO_VARIABLES_COMMAND,
SET_FRAME_COMMAND,
LIST_FRAME_COMMAND,
- UPDATE_REGISTER_COMMAND, /* 0x30 */
+ DUMP_STACK_TRACE_COMMAND, /* 0x30 */
+ UPDATE_REGISTER_COMMAND,
WRITE_REGISTER_COMMAND,
EVALUATE_COMMAND,
INSPECT_COMMAND,
@@ -253,6 +254,9 @@ typedef enum
DMA_LIST_FRAME_COMMAND =
LIST_FRAME_COMMAND |
NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
+ DMA_DUMP_STACK_TRACE_COMMAND =
+ DUMP_STACK_TRACE_COMMAND |
+ NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
DMA_UPDATE_REGISTER_COMMAND =
UPDATE_REGISTER_COMMAND |
NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
@@ -571,6 +575,10 @@ dma_command_new (DmaDebuggerCommand cmd_type,...)
cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
cmd->user_data = va_arg (args, gpointer);
break;
+ case DUMP_STACK_TRACE_COMMAND:
+ cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
+ cmd->user_data = va_arg (args, gpointer);
+ break;
case LIST_REGISTER_COMMAND:
cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
cmd->user_data = va_arg (args, gpointer);
@@ -885,6 +893,12 @@ dma_queue_list_frame (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback ,
}
gboolean
+dma_queue_dump_stack_trace (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data)
+{
+ return dma_debugger_queue_append (self, dma_command_new (DMA_DUMP_STACK_TRACE_COMMAND, callback, user_data));
+}
+
+gboolean
dma_queue_callback (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data)
{
return dma_debugger_queue_append (self, dma_command_new (DMA_CALLBACK_COMMAND, callback, user_data));
@@ -1048,6 +1062,7 @@ dma_command_free (DmaQueueCommand *cmd)
break;
case SET_FRAME_COMMAND:
case LIST_FRAME_COMMAND:
+ case DUMP_STACK_TRACE_COMMAND:
case INSPECT_MEMORY_COMMAND:
case DISASSEMBLE_COMMAND:
break;
@@ -1319,6 +1334,9 @@ dma_command_run (DmaQueueCommand *cmd, IAnjutaDebugger *debugger,
case LIST_FRAME_COMMAND:
ret = ianjuta_debugger_list_frame (debugger, callback, queue, err);
break;
+ case DUMP_STACK_TRACE_COMMAND:
+ ret = ianjuta_debugger_dump_stack_trace (debugger, callback, queue, err);
+ break;
case LIST_REGISTER_COMMAND:
ret = ianjuta_debugger_register_list_register (IANJUTA_DEBUGGER_REGISTER (debugger), callback, queue, err);
break;
@@ -1429,6 +1447,7 @@ dma_command_callback (DmaQueueCommand *cmd, const gpointer data, GError *err)
case INFO_UDOT_COMMAND:
case INFO_VARIABLES_COMMAND:
case LIST_FRAME_COMMAND:
+ case DUMP_STACK_TRACE_COMMAND:
case LIST_REGISTER_COMMAND:
case UPDATE_REGISTER_COMMAND:
case INSPECT_MEMORY_COMMAND:
diff --git a/plugins/debug-manager/command.h b/plugins/debug-manager/command.h
index d2fa9b0..cfc9d4c 100644
--- a/plugins/debug-manager/command.h
+++ b/plugins/debug-manager/command.h
@@ -97,6 +97,7 @@ gboolean dma_queue_info_udot (DmaDebuggerQueue *self, IAnjutaDebuggerCallback ca
gboolean dma_queue_info_variables (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data);
gboolean dma_queue_set_frame (DmaDebuggerQueue *self, guint frame);
gboolean dma_queue_list_frame (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data);
+gboolean dma_queue_dump_stack_trace (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data);
gboolean dma_queue_list_register (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data);
gboolean dma_queue_callback (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data);
void dma_queue_enable_log (DmaDebuggerQueue *self, IAnjutaMessageView *log);
diff --git a/plugins/debug-manager/stack_trace.c b/plugins/debug-manager/stack_trace.c
index 6e31dc5..6cef131 100644
--- a/plugins/debug-manager/stack_trace.c
+++ b/plugins/debug-manager/stack_trace.c
@@ -515,6 +515,31 @@ on_stack_view_source_activate (GtkAction *action, gpointer user_data)
}
static void
+on_got_stack_trace (const gchar *trace, gpointer user_data, GError *error)
+{
+ StackTrace* st = (StackTrace*) user_data;
+ IAnjutaDocumentManager *docman;
+
+ docman = anjuta_shell_get_interface (ANJUTA_PLUGIN (st->plugin)->shell, IAnjutaDocumentManager, NULL);
+ if (docman != NULL)
+ {
+ ianjuta_document_manager_add_buffer (docman, "Stack Trace", trace, NULL);
+ }
+}
+
+static void
+on_stack_get_trace (GtkAction *action, gpointer user_data)
+{
+ StackTrace* st = (StackTrace*) user_data;
+
+ /* Ask debugger to get all frame data */
+ dma_queue_dump_stack_trace (
+ st->debugger,
+ (IAnjutaDebuggerCallback)on_got_stack_trace,
+ st);
+}
+
+static void
on_stack_trace_row_activated (GtkTreeView *treeview,
GtkTreePath *arg1,
GtkTreeViewColumn *arg2,
@@ -563,6 +588,14 @@ static GtkActionEntry actions_stack_trace[] = {
NULL,
NULL,
G_CALLBACK (on_stack_view_source_activate)
+ },
+ {
+ "ActionDmaDumpStackTrace",
+ NULL,
+ N_("Get Stack trace"),
+ NULL,
+ NULL,
+ G_CALLBACK (on_stack_get_trace)
}
};
diff --git a/plugins/gdb/debugger.c b/plugins/gdb/debugger.c
index 140d70b..ce1bba0 100644
--- a/plugins/gdb/debugger.c
+++ b/plugins/gdb/debugger.c
@@ -3448,6 +3448,45 @@ debugger_list_frame (Debugger *debugger, IAnjutaDebuggerCallback callback, gpoin
debugger_queue_command (debugger, "-stack-list-arguments 1", DEBUGGER_COMMAND_NO_ERROR, debugger_stack_finish, callback, user_data);
}
+static void
+debugger_dump_stack_finish (Debugger *debugger, const GDBMIValue *mi_results, const GList *cli_results, GError *error)
+{
+ IAnjutaDebuggerCallback callback = debugger->priv->current_cmd.callback;
+ gpointer user_data = debugger->priv->current_cmd.user_data;
+
+ if (callback != NULL)
+ {
+ GString *result;
+ GList *item;
+
+ result = g_string_new (NULL);
+
+ for (item = g_list_first ((GList *)cli_results); item != NULL; item = g_list_next (item))
+ {
+ const gchar *line = (const gchar *)item->data;
+
+ /* Keep only data outputed by CLI command */
+ if (*line == '~')
+ {
+ g_string_append (result, line + 1);
+ }
+ }
+
+ callback (result->str, user_data, NULL);
+
+ g_string_free (result, TRUE);
+ }
+}
+
+void debugger_dump_stack_trace (Debugger *debugger, IAnjutaDebuggerCallback func, gpointer user_data)
+{
+ DEBUG_PRINT ("%s", "In function: debugger_dump_stack_frame()");
+
+ g_return_if_fail (IS_DEBUGGER (debugger));
+
+ debugger_queue_command (debugger, "thread apply all backtrace", DEBUGGER_COMMAND_NO_ERROR, debugger_dump_stack_finish, func, user_data);
+}
+
/* Thread functions
*---------------------------------------------------------------------------*/
diff --git a/plugins/gdb/debugger.h b/plugins/gdb/debugger.h
index 1640733..1f0b2eb 100644
--- a/plugins/gdb/debugger.h
+++ b/plugins/gdb/debugger.h
@@ -178,6 +178,7 @@ void debugger_write_register (Debugger *debugger, const gchar *name, const gchar
void debugger_list_argument (Debugger *debugger, IAnjutaDebuggerCallback func, gpointer user_data);
void debugger_list_frame (Debugger *debugger, IAnjutaDebuggerCallback func, gpointer user_data);
void debugger_set_frame (Debugger *debugger, gsize frame);
+void debugger_dump_stack_trace (Debugger *debugger, IAnjutaDebuggerCallback func, gpointer user_data);
/* Thread */
void debugger_list_thread (Debugger *debugger, IAnjutaDebuggerCallback func, gpointer user_data);
diff --git a/plugins/gdb/plugin.c b/plugins/gdb/plugin.c
index 20e0637..87dec74 100644
--- a/plugins/gdb/plugin.c
+++ b/plugins/gdb/plugin.c
@@ -820,6 +820,16 @@ idebugger_list_register (IAnjutaDebugger *plugin, IAnjutaDebuggerCallback callba
}
static gboolean
+idebugger_dump_stack_trace (IAnjutaDebugger *plugin, IAnjutaDebuggerCallback callback , gpointer user_data, GError **err)
+{
+ GdbPlugin *this = ANJUTA_PLUGIN_GDB (plugin);
+
+ debugger_dump_stack_trace (this->debugger, callback, user_data);
+
+ return TRUE;
+}
+
+static gboolean
idebugger_callback (IAnjutaDebugger *plugin, IAnjutaDebuggerCallback callback , gpointer user_data, GError **err)
{
@@ -890,6 +900,7 @@ idebugger_iface_init (IAnjutaDebuggerIface *iface)
iface->set_thread = idebugger_set_thread;
iface->info_thread = idebugger_info_thread;
iface->list_register = idebugger_list_register;
+ iface->dump_stack_trace = idebugger_dump_stack_trace;
iface->send_command = idebugger_send_command;
diff --git a/plugins/js-debugger/plugin.c b/plugins/js-debugger/plugin.c
index d30797a..4be1129 100644
--- a/plugins/js-debugger/plugin.c
+++ b/plugins/js-debugger/plugin.c
@@ -473,6 +473,14 @@ idebugger_list_register (IAnjutaDebugger *plugin, IAnjutaDebuggerCallback callba
}
static gboolean
+idebugger_dump_stack_trace (IAnjutaDebugger *plugin, IAnjutaDebuggerCallback callback , gpointer user_data, GError **err)
+{
+ DEBUG_PRINT ("%s", "dump_stack_trace: Not Implemented");
+
+ return FALSE;
+}
+
+static gboolean
idebugger_callback (IAnjutaDebugger *plugin, IAnjutaDebuggerCallback callback , gpointer user_data, GError **err)
{
DEBUG_PRINT ("%s", "callback: Implemented");
@@ -535,6 +543,7 @@ idebugger_iface_init (IAnjutaDebuggerIface *iface)
iface->set_thread = idebugger_set_thread;
iface->info_thread = idebugger_info_thread;
iface->list_register = idebugger_list_register;
+ iface->dump_stack_trace = idebugger_dump_stack_trace;
iface->send_command = idebugger_send_command;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]