From 675f58c4d806f43fd2621e6cc761e95081081cb6 Mon Sep 17 00:00:00 2001 From: sgranjoux Date: Fri, 8 Feb 2008 21:35:16 +0000 Subject: [PATCH] * plugins/debug-manager/command.c, plugins/debug-manager/command.h, plugins/debug-manager/queue.c: Fix crashes when trying to stop the debugger while it is busy git-svn-id: http://svn.gnome.org/svn/anjuta/trunk@3609 1dbfb86a-d425-0410-a06b-cb591aac69f6 --- ChangeLog | 7 +++++++ plugins/debug-manager/command.c | 2 +- plugins/debug-manager/command.h | 3 ++- plugins/debug-manager/queue.c | 40 +++++++++++++++++++++++++++++----------- 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index e4d1dfa9..028ae78d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-02-08 Sébastien Granjoux + + * plugins/debug-manager/command.c, + plugins/debug-manager/command.h, + plugins/debug-manager/queue.c: + Fix crashes when trying to stop the debugger while it is busy + 2008-02-08 Johannes Schmid Patch from Rodrigo Moya diff --git a/plugins/debug-manager/command.c b/plugins/debug-manager/command.c index 2bd13552..ac5efe6a 100644 --- a/plugins/debug-manager/command.c +++ b/plugins/debug-manager/command.c @@ -118,7 +118,7 @@ typedef enum NEED_DEBUGGER_STOPPED | NEED_DEBUGGER_STARTED, DMA_QUIT_COMMAND = QUIT_COMMAND | CANCEL_ALL_COMMAND | STOP_DEBUGGER | - NEED_DEBUGGER_STARTED | NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED, + HIGH_PRIORITY | NEED_DEBUGGER_STARTED | NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED, DMA_ABORT_COMMAND = ABORT_COMMAND | CANCEL_ALL_COMMAND | STOP_DEBUGGER | ASYNCHRONOUS | NEED_DEBUGGER_STARTED | NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING, diff --git a/plugins/debug-manager/command.h b/plugins/debug-manager/command.h index 4ef39919..610f33c5 100644 --- a/plugins/debug-manager/command.h +++ b/plugins/debug-manager/command.h @@ -52,7 +52,8 @@ typedef enum NEED_PROGRAM_RUNNING = RUN_PROGRAM << (STATE_TO_NEED - STATE_TO_CHANGE), CANCEL_IF_PROGRAM_RUNNING = 1 << 21, CANCEL_ALL_COMMAND = 1 << 22, - ASYNCHRONOUS = 1 << 23 + ASYNCHRONOUS = 1 << 23, + HIGH_PRIORITY = 1 << 24 } DmaCommandFlag; /* Create a new command structure and append to command queue */ diff --git a/plugins/debug-manager/queue.c b/plugins/debug-manager/queue.c index 25d0c047..9b315f1f 100644 --- a/plugins/debug-manager/queue.c +++ b/plugins/debug-manager/queue.c @@ -470,9 +470,9 @@ dma_queue_check_state (DmaDebuggerQueue *self, DmaQueueCommand* cmd) { IAnjutaDebuggerState state; - if (self->prepend_command) + if (self->prepend_command || dma_command_has_flag (cmd, HIGH_PRIORITY)) { - /* Prepend command use debugger state or current command state */ + /* Prepend command and high priority command use debugger state or current command state */ if (self->last != NULL) { state = dma_command_is_going_to_state (self->last); @@ -708,8 +708,11 @@ dma_debugger_queue_command_callback (const gpointer data, gpointer user_data, GE g_return_if_fail (self->last != NULL); self->prepend_command++; - dma_command_callback (self->last, data, err); - self->prepend_command--; + if (self->queue_state != IANJUTA_DEBUGGER_STOPPED) + { + dma_command_callback (self->last, data, err); + } + self->prepend_command--; } gboolean @@ -736,9 +739,29 @@ dma_debugger_queue_append (DmaDebuggerQueue *self, DmaQueueCommand *cmd) /* Append command at the beginning */ g_queue_push_head (self->queue, cmd); - dma_debugger_queue_complete (self, self->debugger_state); + /* We must not interrupt command having callback, as the command + * will be removed, the callback when emitted will be redirected to + * the handler of the next command */ + if ((state == IANJUTA_DEBUGGER_STOPPED) || (state == IANJUTA_DEBUGGER_PROGRAM_RUNNING)) + { + dma_debugger_queue_complete (self, self->debugger_state); + } + } + else if ((self->prepend_command > 0) || dma_command_has_flag (cmd, HIGH_PRIORITY)) + { + IAnjutaDebuggerState state; + + state = dma_command_is_going_to_state (cmd); + if (state != IANJUTA_DEBUGGER_BUSY) + { + /* Command is changing debugger state */ + dma_queue_cancel_unexpected (self, state); + } + + /* Prepend command at the beginning */ + g_queue_push_head (self->queue, cmd); } - else if (self->prepend_command == 0) + else { /* Append command at the end (in the queue) */ IAnjutaDebuggerState state; @@ -751,11 +774,6 @@ dma_debugger_queue_append (DmaDebuggerQueue *self, DmaQueueCommand *cmd) self->queue_state = state; } } - else - { - /* Prepend command at the beginning */ - g_queue_push_head (self->queue, cmd); - } dma_debugger_queue_execute(self); -- 2.11.4.GIT