anjuta r3620 - in trunk: . libanjuta/interfaces plugins/debug-manager plugins/gdb



Author: sgranjoux
Date: Sun Feb 10 11:47:07 2008
New Revision: 3620
URL: http://svn.gnome.org/viewvc/anjuta?rev=3620&view=rev

Log:
	* plugins/debug-manager/command.c,
	plugins/debug-manager/command.h,
	plugins/debug-manager/breakpoints.c,
	libanjuta/interfaces/libanjuta.idl:
	Avoid adding the same breakpoint several times

	* plugins/gdb/debugger.c:
	Fix bug #515463: Deattaching process kill it


Modified:
   trunk/ChangeLog
   trunk/libanjuta/interfaces/libanjuta.idl
   trunk/plugins/debug-manager/breakpoints.c
   trunk/plugins/debug-manager/command.c
   trunk/plugins/debug-manager/command.h
   trunk/plugins/gdb/debugger.c

Modified: trunk/libanjuta/interfaces/libanjuta.idl
==============================================================================
--- trunk/libanjuta/interfaces/libanjuta.idl	(original)
+++ trunk/libanjuta/interfaces/libanjuta.idl	Sun Feb 10 11:47:07 2008
@@ -2911,6 +2911,7 @@
 		UNSUPPORTED_FILE_TYPE,
 		UNSUPPORTED_VERSION,
 		UNABLE_TO_FIND_DEBUGGER,
+		ALREADY_DONE,
 		UNKNOWN_ERROR,
 		OTHER_ERROR
 	}

Modified: trunk/plugins/debug-manager/breakpoints.c
==============================================================================
--- trunk/plugins/debug-manager/breakpoints.c	(original)
+++ trunk/plugins/debug-manager/breakpoints.c	Sun Feb 10 11:47:07 2008
@@ -746,6 +746,7 @@
 		breakpoint_item_ref (bi);
 		ok = dma_queue_add_breakpoint_at_line (
 					bd->debugger,
+					&(bi->bp.id),											   
 					bi->bp.file,
 					bi->bp.line,
 					on_breakpoint_callback,
@@ -756,6 +757,7 @@
 		breakpoint_item_ref (bi);
 		ok = dma_queue_add_breakpoint_at_function (
 					bd->debugger,
+					&(bi->bp.id),											   
 					bi->bp.file == NULL ? "" : bi->bp.file,
 					bi->bp.function,
 					on_breakpoint_callback,
@@ -767,6 +769,7 @@
 		breakpoint_item_ref (bi);
 		ok = dma_queue_add_breakpoint_at_address (
 					bd->debugger,
+					&(bi->bp.id),											   
 					bi->bp.address,
 					on_breakpoint_callback,
 					bi);

Modified: trunk/plugins/debug-manager/command.c
==============================================================================
--- trunk/plugins/debug-manager/command.c	(original)
+++ trunk/plugins/debug-manager/command.c	Sun Feb 10 11:47:07 2008
@@ -298,6 +298,7 @@
 			GList *dirs;
 		} attach;
 		struct {
+			guint *id;
 			gchar *file;
 			guint line;
 			gulong address;
@@ -439,18 +440,21 @@
 		cmd->user_data = va_arg (args, gpointer);
 		break;
 	case BREAK_LINE_COMMAND:
+		cmd->data.pos.id = va_arg (args, guint *);
 		cmd->data.pos.file = g_strdup (va_arg (args, gchar *));
 		cmd->data.pos.line = va_arg (args, guint);
 		cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
 		cmd->user_data = va_arg (args, gpointer);
 		break;
 	case BREAK_FUNCTION_COMMAND:
+		cmd->data.pos.id = va_arg (args, guint *);
 		cmd->data.pos.file = g_strdup (va_arg (args, gchar *));
 		cmd->data.pos.function = g_strdup (va_arg (args, gchar *));
 		cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
 		cmd->user_data = va_arg (args, gpointer);
 		break;
 	case BREAK_ADDRESS_COMMAND:
+		cmd->data.pos.id = va_arg (args, guint *);
 		cmd->data.pos.address = va_arg (args, gulong);
 		cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
 		cmd->user_data = va_arg (args, gpointer);
@@ -836,21 +840,21 @@
 }
 
 gboolean
-dma_queue_add_breakpoint_at_line (DmaDebuggerQueue *self, const gchar* file, guint line, IAnjutaDebuggerCallback callback, gpointer user_data)
+dma_queue_add_breakpoint_at_line (DmaDebuggerQueue *self, guint *id, const gchar* file, guint line, IAnjutaDebuggerCallback callback, gpointer user_data)
 {
-	return dma_debugger_queue_append (self, dma_command_new (DMA_BREAK_LINE_COMMAND, file, line, callback, user_data));
+	return dma_debugger_queue_append (self, dma_command_new (DMA_BREAK_LINE_COMMAND, id, file, line, callback, user_data));
 }
 
 gboolean
-dma_queue_add_breakpoint_at_function (DmaDebuggerQueue *self, const gchar* file, const gchar* function, IAnjutaDebuggerCallback callback, gpointer user_data)
+dma_queue_add_breakpoint_at_function (DmaDebuggerQueue *self, guint *id, const gchar* file, const gchar* function, IAnjutaDebuggerCallback callback, gpointer user_data)
 {
-	return dma_debugger_queue_append (self, dma_command_new (DMA_BREAK_FUNCTION_COMMAND, file, function, callback, user_data));
+	return dma_debugger_queue_append (self, dma_command_new (DMA_BREAK_FUNCTION_COMMAND, id, file, function, callback, user_data));
 }
 
 gboolean
-dma_queue_add_breakpoint_at_address (DmaDebuggerQueue *self, gulong address, IAnjutaDebuggerCallback callback, gpointer user_data)
+dma_queue_add_breakpoint_at_address (DmaDebuggerQueue *self, guint *id, gulong address, IAnjutaDebuggerCallback callback, gpointer user_data)
 {
-	return dma_debugger_queue_append (self, dma_command_new (DMA_BREAK_ADDRESS_COMMAND, address, callback, user_data));
+	return dma_debugger_queue_append (self, dma_command_new (DMA_BREAK_ADDRESS_COMMAND, id, address, callback, user_data));
 }
 
 gboolean
@@ -1065,6 +1069,28 @@
 	dma_command_free (cmd);
 }
 
+/* It is possible that the queue contains several add breakpoint command
+ * for the same one. Just before sending the command to the debugger check
+ * that the breakpoint is still not set */
+
+static gboolean
+dma_command_is_breakpoint_pending (DmaQueueCommand *cmd)
+{
+	GError *err;
+	
+	if (*cmd->data.pos.id == 0) return TRUE;		/* Breakpoint is not set, can add it */
+	
+	err	= g_error_new (IANJUTA_DEBUGGER_ERROR , IANJUTA_DEBUGGER_ALREADY_DONE, "Breakpoint is already set with id %d", *cmd->data.pos.id);
+
+	if (cmd->callback != NULL)
+	{
+		cmd->callback (NULL, cmd->user_data, err);
+	}
+	g_error_free (err);
+	
+	return FALSE;
+}
+
 gboolean
 dma_command_run (DmaQueueCommand *cmd, IAnjutaDebugger *debugger,
 				 DmaDebuggerQueue *queue, GError **err)
@@ -1140,13 +1166,34 @@
 		ret = ianjuta_debugger_breakpoint_clear (IANJUTA_DEBUGGER_BREAKPOINT (debugger), cmd->data.brk.id, callback, queue, err);	
 		break;
 	case BREAK_LINE_COMMAND:
-		ret = ianjuta_debugger_breakpoint_set_at_line (IANJUTA_DEBUGGER_BREAKPOINT (debugger), cmd->data.pos.file, cmd->data.pos.line, callback, queue, err);	
+		if (dma_command_is_breakpoint_pending (cmd))
+		{	
+			ret = ianjuta_debugger_breakpoint_set_at_line (IANJUTA_DEBUGGER_BREAKPOINT (debugger), cmd->data.pos.file, cmd->data.pos.line, callback, queue, err);	
+		}
+		else
+		{
+			ret = FALSE;
+		}
 		break;
 	case BREAK_FUNCTION_COMMAND:
-		ret = ianjuta_debugger_breakpoint_set_at_function (IANJUTA_DEBUGGER_BREAKPOINT (debugger), cmd->data.pos.file, cmd->data.pos.function, callback, queue, err);	
+		if (dma_command_is_breakpoint_pending (cmd))
+		{	
+			ret = ianjuta_debugger_breakpoint_set_at_function (IANJUTA_DEBUGGER_BREAKPOINT (debugger), cmd->data.pos.file, cmd->data.pos.function, callback, queue, err);	
+		}
+		else
+		{
+			ret = FALSE;
+		}
 		break;
 	case BREAK_ADDRESS_COMMAND:
-		ret = ianjuta_debugger_breakpoint_set_at_address (IANJUTA_DEBUGGER_BREAKPOINT (debugger), cmd->data.pos.address, callback, queue, err);	
+		if (dma_command_is_breakpoint_pending (cmd))
+		{	
+			ret = ianjuta_debugger_breakpoint_set_at_address (IANJUTA_DEBUGGER_BREAKPOINT (debugger), cmd->data.pos.address, callback, queue, err);	
+		}
+		else
+		{
+			ret = FALSE;
+		}
 		break;
 	case CONDITION_BREAK_COMMAND:
 		ret = ianjuta_debugger_breakpoint_condition (IANJUTA_DEBUGGER_BREAKPOINT (debugger), cmd->data.brk.id, cmd->data.brk.condition, callback, queue, err);	

Modified: trunk/plugins/debug-manager/command.h
==============================================================================
--- trunk/plugins/debug-manager/command.h	(original)
+++ trunk/plugins/debug-manager/command.h	Sun Feb 10 11:47:07 2008
@@ -98,9 +98,9 @@
 gboolean dma_queue_callback (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data);
 void dma_queue_enable_log (DmaDebuggerQueue *self, IAnjutaMessageView *log);
 void dma_queue_disable_log (DmaDebuggerQueue *self);
-gboolean dma_queue_add_breakpoint_at_line (DmaDebuggerQueue *self, const gchar* file, guint line, IAnjutaDebuggerCallback callback, gpointer user_data);
-gboolean dma_queue_add_breakpoint_at_function (DmaDebuggerQueue *self, const gchar* file, const gchar* function, IAnjutaDebuggerCallback callback, gpointer user_data);
-gboolean dma_queue_add_breakpoint_at_address (DmaDebuggerQueue *self, gulong address, IAnjutaDebuggerCallback callback, gpointer user_data);
+gboolean dma_queue_add_breakpoint_at_line (DmaDebuggerQueue *self, guint *id, const gchar* file, guint line, IAnjutaDebuggerCallback callback, gpointer user_data);
+gboolean dma_queue_add_breakpoint_at_function (DmaDebuggerQueue *self, guint *id, const gchar* file, const gchar* function, IAnjutaDebuggerCallback callback, gpointer user_data);
+gboolean dma_queue_add_breakpoint_at_address (DmaDebuggerQueue *self, guint *id, gulong address, IAnjutaDebuggerCallback callback, gpointer user_data);
 gboolean dma_queue_enable_breakpoint (DmaDebuggerQueue *self, guint id, gboolean enable, IAnjutaDebuggerCallback callback, gpointer user_data);
 gboolean dma_queue_ignore_breakpoint (DmaDebuggerQueue *self, guint id, guint ignore, IAnjutaDebuggerCallback callback, gpointer user_data);
 gboolean dma_queue_condition_breakpoint (DmaDebuggerQueue *self, guint id, const gchar *condition, IAnjutaDebuggerCallback callback, gpointer user_data);

Modified: trunk/plugins/gdb/debugger.c
==============================================================================
--- trunk/plugins/gdb/debugger.c	(original)
+++ trunk/plugins/gdb/debugger.c	Sun Feb 10 11:47:07 2008
@@ -1573,7 +1573,9 @@
 	
 	/* if program is attached - detach from it before quiting */
 	if (debugger->priv->prog_is_attached == TRUE)
-		debugger_queue_command (debugger, "detach", FALSE, FALSE, NULL, NULL, NULL);
+	{
+		debugger_detach_process(debugger);
+	}
 
 	debugger->priv->terminating = TRUE;
 	debugger_queue_command (debugger, "-gdb-exit", FALSE, FALSE, NULL, NULL, NULL);
@@ -1645,6 +1647,7 @@
 	/* Emit signal, state of the debugger must be DEBUGGER_STOPPED */
 	debugger->priv->prog_is_running = FALSE;
 	debugger->priv->prog_is_attached = FALSE;
+	debugger->priv->inferior_pid = 0;
 	debugger->priv->prog_is_loaded = FALSE;
 	debugger->priv->debugger_is_busy = 0;
 	debugger->priv->debugger_is_started = FALSE;
@@ -1785,7 +1788,11 @@
 	}
 	debugger->priv->prog_is_attached = TRUE;
 	debugger->priv->prog_is_running = TRUE;
-	//debugger_emit_status (debugger);
+	/* It is not really a shared lib event, but it allows to restart
+	 * the program after setting breakpoints. It is better to restart
+	 * it because we don't have the normal stop frame that tell where
+	 * the program is stopped */
+	debugger->priv->solib_event = TRUE;
 }
 
 static void
@@ -1876,7 +1883,9 @@
 	g_return_if_fail (debugger->priv->prog_is_running == TRUE);
 	
 	if (debugger->priv->prog_is_attached == TRUE)
-		debugger_queue_command (debugger, "detach", FALSE, FALSE, NULL, NULL, NULL);
+	{
+		debugger_detach_process (debugger);
+	}
 	else
 	{
 		/* FIXME: Why doesn't -exec-abort work??? */
@@ -1906,6 +1915,7 @@
 									 _("Program detached\n"),
 									 debugger->priv->output_user_data);
 	}
+	debugger->priv->inferior_pid = 0;
 	debugger->priv->prog_is_attached = FALSE;
 	debugger->priv->prog_is_running = FALSE;
 	g_signal_emit_by_name (debugger->priv->instance, "program-exited");
@@ -1917,7 +1927,7 @@
 	gchar *buff;
 
 	DEBUG_PRINT ("In function: debugger_detach_process()");
-	
+
 	g_return_if_fail (debugger->priv->prog_is_attached == TRUE);
 
 	if (debugger->priv->output_callback)
@@ -1930,7 +1940,6 @@
 	
 	debugger_queue_command (debugger, "detach", FALSE, FALSE, 
 							debugger_detach_process_finish, NULL, NULL);
-	debugger->priv->prog_is_attached = FALSE;
 }
 
 void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]