Commit 530c4741 authored by Sebastien Granjoux's avatar Sebastien Granjoux

Add a GError* parameter to debugger-stopped signal

	* plugins/debug-manager/debugger.c,
	plugins/debug-manager/plugin.c,
	plugins/gdb/debugger.c,
	libanjuta/interfaces/libanjuta.idl:
	Add a GError* parameter to debugger-stopped signal

	* (added) libanjuta/anjuta-error.c,
	(added) libanjuta/anjuta-error.h,
	libanjuta/Makefile.am:
	Register GError as a boxed type

	* libanjuta/interfaces/anjuta-idl-compiler.pl:
	Support GError* in signal, GError must be registered as a boxed type
	Accept NULL as strings

svn path=/trunk/; revision=3030
parent ee69339b
2007-06-28 Sebastien Granjoux <seb.sfo@free.fr>
* plugins/debug-manager/debugger.c,
plugins/debug-manager/plugin.c,
plugins/gdb/debugger.c,
libanjuta/interfaces/libanjuta.idl:
Add a GError* parameter to debugger-stopped signal
* (added) libanjuta/anjuta-error.c,
(added) libanjuta/anjuta-error.h,
libanjuta/Makefile.am:
Register GError as a boxed type
* libanjuta/interfaces/anjuta-idl-compiler.pl:
Support GError* in signal, GError must be registered as a boxed type
Accept NULL as strings
=== anjuta 2.2.0 ===
2007-06-25 Naba Kumar <naba.kumar@gnome.org>
......
......@@ -59,7 +59,9 @@ libanjuta_la_SOURCES= \
cell-renderer-captioned-image.c \
cell-renderer-captioned-image.h \
e-splash.h \
e-splash.c
e-splash.c \
anjuta-error.c \
anjuta-error.h
libanjutaincludedir=$(includedir)/libanjuta-1.0/libanjuta
......@@ -86,6 +88,7 @@ libanjuta_include = \
anjuta-serializer.h \
anjuta-glue-plugin.h \
anjuta-glue-factory.h \
anjuta-error.h \
resources.h
libanjutainclude_HEADERS = \
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* anjuta-error.c
* Copyright (C) 2007 Sebastien Granjoux <seb.sfo@free.fr>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "anjuta-error.h"
#ifdef NEED_G_ERROR_GET_TYPE
GType
g_error_get_type (void)
{
static GType type = G_TYPE_INVALID;
if (type == G_TYPE_INVALID)
{
type = g_boxed_type_register_static ("GError",
(GBoxedCopyFunc) g_error_copy,
(GBoxedFreeFunc) g_error_free);
}
return type;
}
#endif
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* anjuta-error.h
* Copyright (C) 2007 Sebastien Granjoux <seb.sfo@free.fr>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __ANJUTA_ERROR_H__
#define __ANJUTA_ERROR_H__
#include <glib-object.h>
G_BEGIN_DECLS
/* Boxed type for GError will not be done in GLib see bug #300610 */
#ifndef G_TYPE_ERROR
#define G_TYPE_ERROR (g_error_get_type())
#define NEED_G_ERROR_GET_TYPE
GType g_error_get_type (void) G_GNUC_CONST;
#endif
G_END_DECLS
#endif /* __ANJUTA_ERROR_H__ */
......@@ -48,12 +48,10 @@ my $type_map = {
},
"gchar*" => {
"gtype" => "G_TYPE_STRING",
"assert" => "__arg__ != NULL",
"fail_return" => "NULL"
},
"constgchar*" => {
"gtype" => "G_TYPE_STRING",
"assert" => "__arg__ != NULL",
"fail_return" => "NULL"
},
"gchar" => {
......@@ -124,6 +122,11 @@ my $type_map = {
"assert" => "G_IS_VALUE(__arg__)",
"fail_return" => "NULL"
},
"GError*" => {
"gtype" => "G_TYPE_BOXED",
"type" => "G_TYPE_ERROR",
"fail_return" => "NULL"
},
## G_TYPE_PARAM
"GObject*" => {
"gtype" => "G_TYPE_OBJECT",
......
......@@ -2686,24 +2686,27 @@ interface IAnjutaWizard
interface IAnjutaDebugger
{
#include "ianjuta-message-view.h"
#include <libanjuta/anjuta-error.h>
#include <sys/types.h>
/* Types */
enum Error
{
OK = 0,
NOT_READY = -1,
NOT_RUNNING = -2,
NOT_STOPPED = -3,
NOT_LOADED = -4,
NOT_STARTED = -5,
NOT_CONNECTED = -6,
NOT_IMPLEMENTED = -7,
NOT_READY,
NOT_RUNNING,
NOT_STOPPED,
NOT_LOADED,
NOT_STARTED,
NOT_CONNECTED,
NOT_IMPLEMENTED,
CANCEL,
UNABLE_TO_CREATE_VARIABLE,
UNABLE_TO_ACCESS_MEMORY,
UNABLE_TO_OPEN_FILE,
UNKNOWN_ERROR
UNSUPPORTED_FILE_TYPE,
UNKNOWN_ERROR,
OTHER_ERROR
}
enum Data
......@@ -2827,7 +2830,6 @@ interface IAnjutaDebugger
/**
* IAnjutaDebugger::debugger_started:
* @obj: Self
* @err: Error propagation and reporting.
*
* fixme
*/
......@@ -2836,17 +2838,15 @@ interface IAnjutaDebugger
/**
* IAnjutaDebugger::debugger_stopped:
* @obj: Self
* @status: Status as returned by waitpid
* @err: Error propagation and reporting.
*
* fixme
*/
void ::debugger_stopped (gint status);
void ::debugger_stopped (GError *err);
/**
* IAnjutaDebugger::program_loaded:
* @obj: Self
* @err: Error propagation and reporting.
*
* fixme
*/
......@@ -2855,7 +2855,6 @@ interface IAnjutaDebugger
/**
* IAnjutaDebugger::program_running:
* @obj: Self
* @err: Error propagation and reporting.
*
* fixme
*/
......@@ -2865,10 +2864,6 @@ interface IAnjutaDebugger
* IAnjutaDebugger::program_stopped:
* @obj: Self
* @thread: fixme
* @file: fixme
* @line: fixme
* @address: fixme
* @err: Error propagation and reporting.
*
* fixme
*/
......@@ -2877,7 +2872,6 @@ interface IAnjutaDebugger
/**
* IAnjutaDebugger::program_exited:
* @obj: Self
* @err: Error propagation and reporting.
*
* fixme
*/
......@@ -2886,7 +2880,6 @@ interface IAnjutaDebugger
/**
* IAnjutaDebugger::sharedlib_event:
* @obj: Self
* @err: Error propagation and reporting.
*
* fixme
*/
......@@ -2895,11 +2888,9 @@ interface IAnjutaDebugger
/**
* IAnjutaDebugger::location_changed:
* @obj: Self
* @thread: fixme
* @file: fixme
* @line: fixme
* @address: fixme
* @err: Error propagation and reporting.
*
* fixme
*/
......@@ -2910,7 +2901,6 @@ interface IAnjutaDebugger
* @obj: Self
* @frame: fixme
* @thread: thread
* @err: Error propagation and reporting.
*
* fixme
*/
......@@ -2921,7 +2911,6 @@ interface IAnjutaDebugger
* @obj: Self
* @name: Signal name
* @description: Signal description
* @err: Error propagation and reporting.
*
* fixme
*/
......@@ -2931,7 +2920,6 @@ interface IAnjutaDebugger
* IAnjutaDebugger::debugger_ready:
* @obj: Self
* @status: fixme
* @err: Error propagation and reporting.
*
* fixme
*/
......
......@@ -409,7 +409,7 @@ gboolean
dma_queue_check_status (DmaDebuggerQueue *self, DmaDebuggerCommandType type, GError **err);
void
dma_queue_update_debugger_status (DmaDebuggerQueue *self, IAnjutaDebuggerStatus state, gint status);
dma_queue_update_debugger_status (DmaDebuggerQueue *self, IAnjutaDebuggerStatus state, guint thread, GError *err);
/* Call backs
*---------------------------------------------------------------------------*/
......@@ -832,9 +832,9 @@ dma_queue_emit_debugger_ready (DmaDebuggerQueue *queue)
}
void
dma_queue_update_debugger_status (DmaDebuggerQueue *self, IAnjutaDebuggerStatus state, gint status)
dma_queue_update_debugger_status (DmaDebuggerQueue *self, IAnjutaDebuggerStatus state, guint thread, GError *err)
{
const char* signal = NULL;
IAnjutaDebuggerStatus signal = IANJUTA_DEBUGGER_BUSY;
self->queue_command = FALSE;
switch (state)
......@@ -854,7 +854,7 @@ dma_queue_update_debugger_status (DmaDebuggerQueue *self, IAnjutaDebuggerStatus
}
}
self->debugger_status = IANJUTA_DEBUGGER_STOPPED;
signal = "debugger-stopped";
signal = IANJUTA_DEBUGGER_STOPPED;
}
break;
case IANJUTA_DEBUGGER_STARTED:
......@@ -868,7 +868,7 @@ dma_queue_update_debugger_status (DmaDebuggerQueue *self, IAnjutaDebuggerStatus
}
}
self->debugger_status = IANJUTA_DEBUGGER_STARTED;
signal = "debugger-started";
signal = IANJUTA_DEBUGGER_STARTED;
}
break;
case IANJUTA_DEBUGGER_PROGRAM_LOADED:
......@@ -889,7 +889,7 @@ dma_queue_update_debugger_status (DmaDebuggerQueue *self, IAnjutaDebuggerStatus
}
self->debugger_status = IANJUTA_DEBUGGER_PROGRAM_LOADED;
self->stop_on_sharedlib = FALSE;
signal = "program-loaded";
signal = IANJUTA_DEBUGGER_PROGRAM_LOADED;
}
break;
case IANJUTA_DEBUGGER_PROGRAM_STOPPED:
......@@ -905,7 +905,7 @@ dma_queue_update_debugger_status (DmaDebuggerQueue *self, IAnjutaDebuggerStatus
self->debugger_status = IANJUTA_DEBUGGER_PROGRAM_STOPPED;
if (!self->stop_on_sharedlib)
{
signal = "program-stopped";
signal = IANJUTA_DEBUGGER_PROGRAM_STOPPED;
}
}
break;
......@@ -921,7 +921,7 @@ dma_queue_update_debugger_status (DmaDebuggerQueue *self, IAnjutaDebuggerStatus
}
self->debugger_status = IANJUTA_DEBUGGER_PROGRAM_RUNNING;
self->stop_on_sharedlib = FALSE;
signal = "program-running";
signal = IANJUTA_DEBUGGER_PROGRAM_RUNNING;
}
break;
}
......@@ -930,10 +930,28 @@ dma_queue_update_debugger_status (DmaDebuggerQueue *self, IAnjutaDebuggerStatus
dma_debugger_end_command (self);
/* Emit signal */
if (signal != NULL)
switch (signal)
{
g_signal_emit_by_name (self, signal, status);
case IANJUTA_DEBUGGER_BUSY:
/* Do nothing */
break;
case IANJUTA_DEBUGGER_STOPPED:
g_signal_emit_by_name (self, "debugger-stopped", err);
break;
case IANJUTA_DEBUGGER_STARTED:
g_signal_emit_by_name (self, "debugger-started");
break;
case IANJUTA_DEBUGGER_PROGRAM_LOADED:
g_signal_emit_by_name (self, "program-loaded");
break;
case IANJUTA_DEBUGGER_PROGRAM_STOPPED:
g_signal_emit_by_name (self, "program-stopped", thread);
break;
case IANJUTA_DEBUGGER_PROGRAM_RUNNING:
g_signal_emit_by_name (self, "program-running");
break;
}
self->queue_command = TRUE;
}
......@@ -1049,7 +1067,7 @@ dma_debugger_queue_execute (DmaDebuggerQueue *self)
IAnjutaDebuggerStatus status;
/* Recheck status in case of desynchronization */
status = ianjuta_debugger_get_status (self->debugger, NULL);
dma_queue_update_debugger_status (self, status, 0);
dma_queue_update_debugger_status (self, status, 0, NULL);
}
/* Check if there is something to execute */
......@@ -1078,7 +1096,11 @@ dma_debugger_queue_execute (DmaDebuggerQueue *self)
ianjuta_debugger_initialize (self->debugger, on_debugger_output, self, &err);
break;
case LOAD_COMMAND:
ianjuta_debugger_load (self->debugger, cmd->data.load.file, cmd->data.load.type, cmd->data.load.dirs, cmd->data.load.terminal, &err);
ianjuta_debugger_load (self->debugger, cmd->data.load.file, cmd->data.load.type, cmd->data.load.dirs, cmd->data.load.terminal, &err);
if (err != NULL)
{
g_signal_emit_by_name (self, "debugger-stopped", err);
}
break;
case ATTACH_COMMAND:
ianjuta_debugger_attach (self->debugger, cmd->data.attach.pid, cmd->data.load.dirs, &err);
......@@ -1298,7 +1320,7 @@ static void
on_dma_debugger_ready (DmaDebuggerQueue *self, IAnjutaDebuggerStatus status)
{
DEBUG_PRINT ("From debugger: receive debugger ready");
dma_queue_update_debugger_status (self, status, 0);
dma_queue_update_debugger_status (self, status, 0, NULL);
if (self->ready) dma_debugger_queue_execute (self);
}
......@@ -1307,15 +1329,16 @@ on_dma_debugger_started (DmaDebuggerQueue *self)
{
/* Nothing do to */
DEBUG_PRINT ("From debugger: receive debugger started");
dma_queue_update_debugger_status (self, IANJUTA_DEBUGGER_STARTED, 0);
dma_queue_update_debugger_status (self, IANJUTA_DEBUGGER_STARTED, 0, NULL);
if (self->ready) dma_debugger_queue_execute (self);
}
static void
on_dma_debugger_stopped (DmaDebuggerQueue *self, gint status)
on_dma_debugger_stopped (DmaDebuggerQueue *self, GError *err)
{
DEBUG_PRINT ("From debugger: receive debugger stopped");
dma_queue_update_debugger_status (self, IANJUTA_DEBUGGER_STOPPED, status);
DEBUG_PRINT ("From debugger: receive debugger stopped with error %p", err);
self->debugger_status = IANJUTA_DEBUGGER_STARTED;
dma_queue_update_debugger_status (self, IANJUTA_DEBUGGER_STOPPED, 0, err);
if (self->ready) dma_debugger_queue_execute (self);
}
......@@ -1323,7 +1346,7 @@ static void
on_dma_program_loaded (DmaDebuggerQueue *self)
{
DEBUG_PRINT ("From debugger: receive program loaded");
dma_queue_update_debugger_status (self, IANJUTA_DEBUGGER_PROGRAM_LOADED, 0);
dma_queue_update_debugger_status (self, IANJUTA_DEBUGGER_PROGRAM_LOADED, 0, NULL);
if (self->ready) dma_debugger_queue_execute (self);
}
......@@ -1331,14 +1354,14 @@ static void
on_dma_program_running (DmaDebuggerQueue *self)
{
DEBUG_PRINT ("From debugger: debugger_program_running");
dma_queue_update_debugger_status (self, IANJUTA_DEBUGGER_PROGRAM_RUNNING, 0);
dma_queue_update_debugger_status (self, IANJUTA_DEBUGGER_PROGRAM_RUNNING, 0, NULL);
}
static void
on_dma_program_stopped (DmaDebuggerQueue *self, guint thread)
{
DEBUG_PRINT ("From debugger: receive program stopped");
dma_queue_update_debugger_status (self, IANJUTA_DEBUGGER_PROGRAM_STOPPED, thread);
dma_queue_update_debugger_status (self, IANJUTA_DEBUGGER_PROGRAM_STOPPED, thread, NULL);
if (self->ready) dma_debugger_queue_execute (self);
}
......@@ -1346,7 +1369,7 @@ static void
on_dma_program_exited (DmaDebuggerQueue *self)
{
DEBUG_PRINT ("From debugger: receive program exited");
dma_queue_update_debugger_status (self, IANJUTA_DEBUGGER_PROGRAM_LOADED, 0);
dma_queue_update_debugger_status (self, IANJUTA_DEBUGGER_PROGRAM_LOADED, 0, NULL);
if (self->ready) dma_debugger_queue_execute (self);
}
......@@ -1376,7 +1399,7 @@ on_dma_sharedlib_event (DmaDebuggerQueue *self)
{
DEBUG_PRINT ("From debugger: shared lib event");
self->stop_on_sharedlib = TRUE;
dma_queue_update_debugger_status (self, IANJUTA_DEBUGGER_PROGRAM_STOPPED, 0);
dma_queue_update_debugger_status (self, IANJUTA_DEBUGGER_PROGRAM_STOPPED, 0, NULL);
g_signal_emit_by_name (self, "sharedlib-event");
ianjuta_debugger_run (IANJUTA_DEBUGGER (self), NULL);
}
......@@ -1391,8 +1414,6 @@ dma_debugger_activate_plugin (DmaDebuggerQueue* self, const gchar *mime_type)
AnjutaPluginDescription *plugin;
GList *descs = NULL;
gchar *value;
gchar **interface_list;
gchar **interface;
/* Get list of debugger plugins */
plugin_manager = anjuta_shell_get_plugin_manager (ANJUTA_PLUGIN(self->plugin)->shell, NULL);
......
......@@ -564,7 +564,7 @@ dma_plugin_program_unload (DebugManagerPlugin *this)
/* Called when the debugger is stopped */
static void
dma_plugin_debugger_stopped (DebugManagerPlugin *self, gint status)
dma_plugin_debugger_stopped (DebugManagerPlugin *self, GError *err)
{
AnjutaUI *ui;
GtkAction *action;
......@@ -598,10 +598,10 @@ dma_plugin_debugger_stopped (DebugManagerPlugin *self, gint status)
dma_plugin_debugger_ready (self, IANJUTA_DEBUGGER_STOPPED);
/* Display a warning if debugger stop unexpectedly */
if (status != 0)
if (err != NULL)
{
GtkWindow *parent = GTK_WINDOW (ANJUTA_PLUGIN(self)->shell);
anjuta_util_dialog_error (parent, _("gdb terminated unexpectedly with status %d\n"), status);
anjuta_util_dialog_error (parent, _("Debugger terminated with error %d: %s\n"), err->code, err->message);
}
}
......
......@@ -1471,6 +1471,7 @@ on_gdb_terminated (AnjutaLauncher *launcher,
gpointer data)
{
Debugger *debugger = DEBUGGER (data);
GError *err = NULL;
g_signal_handlers_disconnect_by_func (G_OBJECT (launcher),
G_CALLBACK (on_gdb_terminated),
......@@ -1494,9 +1495,18 @@ on_gdb_terminated (AnjutaLauncher *launcher,
debugger->priv->term_pid = -1;
debugger->priv->debugger_is_busy = 0;
debugger->priv->skip_next_prompt = FALSE;
if (!debugger->priv->terminating)
{
err = g_error_new (IANJUTA_DEBUGGER_ERROR,
IANJUTA_DEBUGGER_OTHER_ERROR,
"gdb terminated with status %d", status);
}
debugger->priv->terminating = FALSE;
if (debugger->priv->instance)
g_signal_emit_by_name (debugger->priv->instance, "debugger-stopped", status);
{
g_signal_emit_by_name (debugger->priv->instance, "debugger-stopped", err);
}
if (err != NULL) g_error_free (err);
}
static void
......@@ -1576,7 +1586,7 @@ debugger_abort (Debugger *debugger)
if (debugger->priv->instance != NULL)
{
/* Signal end of debugger */
g_signal_emit_by_name (debugger->priv->instance, "debugger-stopped", 0);
g_signal_emit_by_name (debugger->priv->instance, "debugger-stopped", NULL);
g_object_remove_weak_pointer (debugger->priv->instance, (gpointer *)&debugger->priv->instance);
debugger->priv->instance = NULL;
......
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