From 70749edb0850567e5cd6b0369f30e0dda255fa99 Mon Sep 17 00:00:00 2001 From: sgranjoux Date: Mon, 17 Mar 2008 21:49:09 +0000 Subject: [PATCH] * plugins/debug-manager/registers.c: Avoid a crash when debugger stop on an error * plugins/debug-manager/start.c, plugins/gdb/debugger.c, libanjuta/interfaces/libanjuta.idl: Display an error message when debugger target is not found git-svn-id: http://svn.gnome.org/svn/anjuta/trunk@3784 1dbfb86a-d425-0410-a06b-cb591aac69f6 --- ChangeLog | 10 +++++++ libanjuta/interfaces/libanjuta.idl | 1 + plugins/debug-manager/registers.c | 13 +++++++-- plugins/debug-manager/start.c | 56 ++++++++++++++++++++++---------------- plugins/gdb/debugger.c | 16 +++++++---- 5 files changed, 64 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index ddfaa659..6105aef7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-03-17 Sébastien Granjoux + + * plugins/debug-manager/registers.c: + Avoid a crash when debugger stop on an error + + * plugins/debug-manager/start.c, + plugins/gdb/debugger.c, + libanjuta/interfaces/libanjuta.idl: + Display an error message when debugger target is not found + 2008-03-15 Naba Kumar * configure.in: diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl index a7f4463f..d57ff9e6 100644 --- a/libanjuta/interfaces/libanjuta.idl +++ b/libanjuta/interfaces/libanjuta.idl @@ -2912,6 +2912,7 @@ interface IAnjutaDebugger UNSUPPORTED_VERSION, UNABLE_TO_FIND_DEBUGGER, ALREADY_DONE, + PROGRAM_NOT_FOUND, UNKNOWN_ERROR, OTHER_ERROR } diff --git a/plugins/debug-manager/registers.c b/plugins/debug-manager/registers.c index 7ada3a34..74771f24 100644 --- a/plugins/debug-manager/registers.c +++ b/plugins/debug-manager/registers.c @@ -128,7 +128,13 @@ on_cpu_registers_updated (const GList *registers, gpointer user_data, GError *er return; } - + + if (self->current == NULL) + { + /* Program has exited */ + return; + } + /* Get first item in list view */ valid = gtk_tree_model_get_iter_first (self->current->model, &iter); list = GTK_LIST_STORE (self->current->model); @@ -246,7 +252,7 @@ dma_thread_create_new_register_list (CpuRegisters *self, gint thread) GError *err = NULL; self->current = regs; - + /* List is empty, ask debugger to get all register name */ dma_queue_list_register ( self->debugger, @@ -291,11 +297,12 @@ on_clear_register_list (gpointer data, gpointer user_data) static void dma_thread_clear_all_register_list (CpuRegisters *self) { + self->current = NULL; + /* Clear all GtkListStore */ g_list_foreach (self->list, (GFunc)on_clear_register_list, NULL); g_list_free (self->list); - self->current = NULL; self->list = NULL; } diff --git a/plugins/debug-manager/start.c b/plugins/debug-manager/start.c index 3e862938..73b1285d 100644 --- a/plugins/debug-manager/start.c +++ b/plugins/debug-manager/start.c @@ -847,7 +847,7 @@ on_select_target (GtkButton *button, gpointer user_data) gtk_dialog_response (GTK_DIALOG (user_data), ANJUTA_RESPONSE_SELECT_TARGET); } -static void +static gboolean dma_start_load_uri (DmaStart *this) { GList *search_dirs; @@ -855,29 +855,38 @@ dma_start_load_uri (DmaStart *this) gchar *mime_type; gchar *filename; - if (!dma_quit_debugger (this)) return; + if (!dma_quit_debugger (this)) return FALSE; - if ((this->target_uri != NULL) && (*(this->target_uri) != '\0')) + if ((this->target_uri == NULL) || (*(this->target_uri) == '\0')) { - vfs_uri = gnome_vfs_uri_new (this->target_uri); - - g_return_if_fail (vfs_uri != NULL); + /* Missing URI */ + return FALSE; + } + vfs_uri = gnome_vfs_uri_new (this->target_uri); - if (!gnome_vfs_uri_is_local (vfs_uri)) return; + g_return_if_fail (vfs_uri != NULL); + + if (!gnome_vfs_uri_is_local (vfs_uri)) return FALSE; - search_dirs = get_source_directories (this->plugin); + search_dirs = get_source_directories (this->plugin); - mime_type = gnome_vfs_get_mime_type (this->target_uri); - filename = gnome_vfs_get_local_path_from_uri (this->target_uri); + mime_type = gnome_vfs_get_mime_type (this->target_uri); + if (mime_type == NULL) + { + anjuta_util_dialog_error(GTK_WINDOW (this->plugin->shell), + _("Unable to open %s. Debugger cannot start."), this->target_uri); + return FALSE; + } + filename = gnome_vfs_get_local_path_from_uri (this->target_uri); - dma_queue_load (this->debugger, filename, mime_type, this->source_dirs); + dma_queue_load (this->debugger, filename, mime_type, this->source_dirs); - g_free (filename); - g_free (mime_type); - gnome_vfs_uri_unref (vfs_uri); - free_source_directories (search_dirs); + g_free (filename); + g_free (mime_type); + gnome_vfs_uri_unref (vfs_uri); + free_source_directories (search_dirs); - } + return TRUE; } static gboolean @@ -1304,13 +1313,13 @@ dma_attach_to_process (DmaStart* this) gboolean dma_run_target (DmaStart *this) { - if (dma_set_parameters (this) == TRUE) - { - dma_start_load_uri (this); - dma_queue_start (this->debugger, this->program_args == NULL ? "" : this->program_args, this->run_in_terminal, this->stop_at_beginning); - } + if (!dma_set_parameters (this)) return FALSE; + + if (!dma_start_load_uri (this)) return FALSE; + + dma_queue_start (this->debugger, this->program_args == NULL ? "" : this->program_args, this->run_in_terminal, this->stop_at_beginning); - return this->target_uri != NULL; + return TRUE; } gboolean @@ -1318,7 +1327,8 @@ dma_rerun_target (DmaStart *this) { if (this->target_uri == NULL) return FALSE; - dma_start_load_uri (this); + if (!dma_start_load_uri (this)) return FALSE; + dma_queue_start (this->debugger, this->program_args == NULL ? "" : this->program_args, this->run_in_terminal, this->stop_at_beginning); return TRUE; diff --git a/plugins/gdb/debugger.c b/plugins/gdb/debugger.c index 47930c12..7161831a 100644 --- a/plugins/gdb/debugger.c +++ b/plugins/gdb/debugger.c @@ -202,6 +202,8 @@ const static GdbMessageCode GdbErrorMessage[] = IANJUTA_DEBUGGER_UNABLE_TO_ACCESS_MEMORY}, {"No source file named ", IANJUTA_DEBUGGER_UNABLE_TO_OPEN_FILE}, + {"No executable file specified.", + IANJUTA_DEBUGGER_PROGRAM_NOT_FOUND}, {NULL, 0}}; static guint @@ -213,12 +215,6 @@ gdb_match_error(const gchar *message) { gsize len = strlen (msg->msg); - if (!isspace (msg->msg[len - 1])) - { - /* Match the whole string */ - len++; - } - if (memcmp (msg->msg, message, len) == 0) { return msg->code; @@ -1459,6 +1455,14 @@ debugger_stdo_flush (Debugger *debugger) error = gdb_parse_error (debugger, val); + /* Trap state error */ + if ((error != NULL) && (error->code == IANJUTA_DEBUGGER_PROGRAM_NOT_FOUND)) + { + debugger->priv->prog_is_running = FALSE; + debugger->priv->prog_is_attached = FALSE; + debugger->priv->prog_is_loaded = FALSE; + } + if (debugger->priv->current_cmd.parser != NULL) { debugger->priv->current_cmd.parser (debugger, val, debugger->priv->cli_lines, error); -- 2.11.4.GIT