[anjuta] gdb: Support faster pending breakpoints, handled by gdb



commit 23115bf476c3ca10aae3aa8a94c88ce9d331c295
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Wed Jun 16 22:34:07 2010 +0200

    gdb: Support faster pending breakpoints, handled by gdb

 libanjuta/interfaces/libanjuta.idl  |    4 +-
 plugins/debug-manager/breakpoints.c |    8 +
 plugins/gdb/debugger.c              |  286 +++++++++++++++++++++++------------
 plugins/gdb/debugger.h              |   11 +-
 plugins/gdb/gdb.init                |    3 +-
 5 files changed, 213 insertions(+), 99 deletions(-)
---
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index f608c3e..16b80db 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -4361,7 +4361,8 @@ interface IAnjutaDebugger
 			WITH_IGNORE = 1 << 15,
 			WITH_TIME = 1 << 11,
 			WITH_CONDITION = 1 << 12,
-			WITH_TEMPORARY = 1 << 13
+			WITH_TEMPORARY = 1 << 13,
+			WITH_PENDING = 1 << 14,
 		}
 
 		struct Item
@@ -4377,6 +4378,7 @@ interface IAnjutaDebugger
 			guint times;
 			gchar *condition;
 			gboolean temporary;
+			gboolean pending;
 		}
 
 		enum Method
diff --git a/plugins/debug-manager/breakpoints.c b/plugins/debug-manager/breakpoints.c
index b27a6ef..8d36e27 100644
--- a/plugins/debug-manager/breakpoints.c
+++ b/plugins/debug-manager/breakpoints.c
@@ -180,6 +180,10 @@ breakpoint_item_update_from_debugger (BreakpointItem *bi, const IAnjutaDebuggerB
 	{
 		bi->bp.temporary = bp->temporary;
 	}
+	if (bp->type & IANJUTA_DEBUGGER_BREAKPOINT_WITH_PENDING)
+	{
+		bi->bp.pending = bp->pending;
+	}
 	if ((bp->type & IANJUTA_DEBUGGER_BREAKPOINT_WITH_ENABLE) &&
 		!(bi->changed & IANJUTA_DEBUGGER_BREAKPOINT_WITH_ENABLE))
 	{
@@ -448,6 +452,10 @@ breakpoints_dbase_update_in_treeview (BreakpointsDBase *bd, BreakpointItem *bi)
 	{
 		format = "temporary (%d)";
 	}
+	else if (bi->bp.pending)
+	{
+		format = "pending (%d)";
+	}
 	else 
 	{
 		format = "permanent (%d)";
diff --git a/plugins/gdb/debugger.c b/plugins/gdb/debugger.c
index 61cc3f4..94a9b9b 100644
--- a/plugins/gdb/debugger.c
+++ b/plugins/gdb/debugger.c
@@ -129,6 +129,12 @@ struct _DebuggerPriv
 
 	/* Environment */
 	IAnjutaEnvironment *environment;
+	
+	/* GDB Features */
+	gboolean has_pending_breakpoints;
+	gboolean has_python_support;
+	gboolean has_thread_info;
+	gboolean has_frozen_varobjs;
 };
 
 static gpointer parent_class;
@@ -548,7 +554,7 @@ debugger_clear_buffers (Debugger *debugger)
 
 	/* Clear the output line buffer */
 	g_string_assign (debugger->priv->stdo_line, "");
-	if (!debugger->priv->current_cmd.keep_result)
+	if (!(debugger->priv->current_cmd.flags & DEBUGGER_COMMAND_KEEP_RESULT))
 		g_string_assign (debugger->priv->stdo_acc, "");
 
 	/* Clear the error line buffer */
@@ -591,8 +597,7 @@ debugger_queue_set_next_command (Debugger *debugger)
 		debugger->priv->current_cmd.parser = NULL;
 		debugger->priv->current_cmd.callback = NULL;
 		debugger->priv->current_cmd.user_data = NULL;
-		debugger->priv->current_cmd.suppress_error = FALSE;
-		debugger->priv->current_cmd.keep_result = FALSE;
+		debugger->priv->current_cmd.flags = 0;
 
 		return FALSE;
 	}
@@ -601,8 +606,7 @@ debugger_queue_set_next_command (Debugger *debugger)
 	debugger->priv->current_cmd.parser = dc->parser;
 	debugger->priv->current_cmd.callback = dc->callback;
 	debugger->priv->current_cmd.user_data = dc->user_data;
-	debugger->priv->current_cmd.suppress_error = dc->suppress_error;
-	debugger->priv->current_cmd.keep_result = dc->keep_result;
+	debugger->priv->current_cmd.flags = dc->flags;
 	g_free (dc);
 
 	return TRUE;
@@ -610,7 +614,7 @@ debugger_queue_set_next_command (Debugger *debugger)
 
 static void
 debugger_queue_command (Debugger *debugger, const gchar *cmd,
-						gboolean suppress_error, gboolean keep_result,
+						gint flags,
 						DebuggerParserFunc parser,
 						IAnjutaDebuggerCallback callback, gpointer user_data)
 {
@@ -626,10 +630,16 @@ debugger_queue_command (Debugger *debugger, const gchar *cmd,
 		dc->parser = parser;
 		dc->callback = callback;
 		dc->user_data = user_data;
-		dc->suppress_error = suppress_error;
-		dc->keep_result = keep_result;
+		dc->flags = flags;
+	}
+	if (flags & DEBUGGER_COMMAND_PREPEND)
+	{
+		debugger->priv->cmd_queqe = g_list_prepend (debugger->priv->cmd_queqe, dc);
+	}
+	else
+	{
+		debugger->priv->cmd_queqe = g_list_append (debugger->priv->cmd_queqe, dc);
 	}
-	debugger->priv->cmd_queqe = g_list_append (debugger->priv->cmd_queqe, dc);
 	debugger_queue_execute_command (debugger);
 }
 
@@ -654,8 +664,7 @@ debugger_queue_clear (Debugger *debugger)
 	debugger->priv->current_cmd.parser = NULL;
 	debugger->priv->current_cmd.callback = NULL;
 	debugger->priv->current_cmd.user_data = NULL;
-	debugger->priv->current_cmd.suppress_error = FALSE;
-	debugger->priv->current_cmd.keep_result = FALSE;
+	debugger->priv->current_cmd.flags = 0;
 	debugger_clear_buffers (debugger);
 }
 
@@ -722,7 +731,7 @@ debugger_load_executable (Debugger *debugger, const gchar *prog)
 	anjuta_set_execution_dir(dir);
 */
 	g_free (dir);
-	debugger_queue_command (debugger, command, FALSE, FALSE, debugger_load_executable_finish, NULL, NULL);
+	debugger_queue_command (debugger, command, 0, debugger_load_executable_finish, NULL, NULL);
 	g_free (command);
 	debugger->priv->starting = TRUE;
 	debugger->priv->terminating = FALSE;
@@ -751,7 +760,7 @@ debugger_load_core (Debugger *debugger, const gchar *core)
 	dir = g_path_get_dirname (core);
 	debugger->priv->search_dirs = 
 		g_list_prepend (debugger->priv->search_dirs, dir);
-	debugger_queue_command (debugger, command, FALSE, FALSE, NULL, NULL, NULL);
+	debugger_queue_command (debugger, command, 0, NULL, NULL, NULL);
 	g_free (command);
 }
 
@@ -768,7 +777,7 @@ debugger_set_working_directory (Debugger *debugger, const gchar *directory)
 	g_return_val_if_fail (IS_DEBUGGER (debugger), FALSE);
 
 	buff = g_strdup_printf ("-environment-cd %s", directory);	
-	debugger_queue_command (debugger, buff, FALSE, FALSE, NULL, NULL, NULL);
+	debugger_queue_command (debugger, buff, 0, NULL, NULL, NULL);
 	g_free (buff);
 	
 	return TRUE;
@@ -788,7 +797,7 @@ debugger_set_environment (Debugger *debugger, gchar **variables)
 		for (; *variables != NULL; variables++)
 		{
 			buff = g_strdup_printf("set environment %s", *variables);
-			debugger_queue_command (debugger, buff, FALSE, FALSE, NULL, NULL, NULL); 
+			debugger_queue_command (debugger, buff, 0, NULL, NULL, NULL); 
 			g_free (buff);
 		}
 	}
@@ -800,6 +809,70 @@ debugger_set_environment (Debugger *debugger, gchar **variables)
 	return TRUE;
 }
 
+static void
+debugger_list_features_completed (Debugger *debugger,
+									const GDBMIValue *mi_result,
+									const GList *cli_result,
+									GError* error)
+{
+	const GDBMIValue *features;
+	gint i;
+	
+	debugger->priv->has_pending_breakpoints = FALSE;
+	debugger->priv->has_python_support = FALSE;
+	debugger->priv->has_frozen_varobjs = FALSE;
+	debugger->priv->has_thread_info = FALSE;
+	
+	features = gdbmi_value_hash_lookup (mi_result, "features");
+		
+	for (i = 0; i < gdbmi_value_get_size (features); i++)
+	{
+		const GDBMIValue *feature;
+		const gchar *value;
+
+		feature = gdbmi_value_list_get_nth (features, i);
+		value = gdbmi_value_literal_get (feature);
+		
+		if (g_strcmp0 (value, "frozen-varobjs") == 0)
+		{
+			debugger->priv->has_frozen_varobjs = TRUE;
+		}
+		else if (g_strcmp0 (value, "thread-info") == 0)
+		{
+			debugger->priv->has_thread_info = TRUE;
+		}
+		else if (g_strcmp0 (value, "pending-breakpoints") == 0)
+		{
+			debugger->priv->has_pending_breakpoints = TRUE;
+		}
+		else if (g_strcmp0 (value, "python") == 0)
+		{
+			debugger->priv->has_python_support = TRUE;
+		}
+	}
+
+	if (debugger->priv->has_pending_breakpoints)
+	{
+		debugger_queue_command (debugger, "set stop-on-solib-events 0", DEBUGGER_COMMAND_PREPEND, NULL, NULL, NULL);
+	}
+	else
+	{
+		debugger_queue_command (debugger, "set stop-on-solib-events 1", DEBUGGER_COMMAND_PREPEND, NULL, NULL, NULL);
+	}
+}
+
+static gboolean
+debugger_list_features (Debugger *debugger)
+{
+	DEBUG_PRINT ("%s", "In function: list_featues()");
+
+	g_return_val_if_fail (IS_DEBUGGER (debugger), FALSE);
+
+	debugger_queue_command (debugger, "-list-features", 0, debugger_list_features_completed, NULL, NULL); 
+	
+	return TRUE;
+}
+
 gboolean
 debugger_start (Debugger *debugger, const GList *search_dirs,
 				const gchar *prog, gboolean is_libtool_prog)
@@ -1008,6 +1081,11 @@ debugger_start (Debugger *debugger, const GList *search_dirs,
 		}
 	}
 
+	/* Check available features */
+	debugger_list_features (debugger);
+
+	debugger_queue_command (debugger, "handle SIGINT stop print nopass", 0, NULL, NULL, NULL);
+	
 	return TRUE;
 }
 
@@ -1483,8 +1561,17 @@ parse_breakpoint (IAnjutaDebuggerBreakpointItem* bp, const GDBMIValue *brkpnt)
 	if (literal)
 	{
 		value = gdbmi_value_literal_get (literal);
-		bp->address = strtoul (value, NULL, 16);
-		bp->type |= IANJUTA_DEBUGGER_BREAKPOINT_ON_ADDRESS;
+		if (strcmp (value, "<PENDING>") == 0)
+		{
+			bp->type |= IANJUTA_DEBUGGER_BREAKPOINT_WITH_PENDING;
+			bp->pending = TRUE;
+		}
+		else
+		{
+			bp->address = strtoul (value, NULL, 16);
+			bp->type |= IANJUTA_DEBUGGER_BREAKPOINT_ON_ADDRESS;
+			bp->pending = FALSE;
+		}
 	}
 
 	literal = gdbmi_value_hash_lookup (brkpnt, "func");
@@ -1543,7 +1630,7 @@ debugger_stdo_flush (Debugger *debugger)
 	if (strncasecmp (line, "^error", 6) == 0)
 	{
 		/* GDB reported error */
-		if ((debugger->priv->current_cmd.keep_result)  || (debugger->priv->stdo_acc->len != 0))
+		if ((debugger->priv->current_cmd.flags & DEBUGGER_COMMAND_KEEP_RESULT)  || (debugger->priv->stdo_acc->len != 0))
 		{
 			/* Keep result for next command */
 
@@ -1604,7 +1691,7 @@ debugger_stdo_flush (Debugger *debugger)
 	}
 	else if (strncasecmp (line, "^done", 5) == 0)
 	{
-		if ((debugger->priv->current_cmd.keep_result)  || (debugger->priv->stdo_acc->len != 0))
+		if ((debugger->priv->current_cmd.flags & DEBUGGER_COMMAND_KEEP_RESULT)  || (debugger->priv->stdo_acc->len != 0))
 		{
 			/* Keep result for next command */
 
@@ -1623,7 +1710,7 @@ debugger_stdo_flush (Debugger *debugger)
 			line = debugger->priv->stdo_acc->str;
 		}
 
-	  	if (!debugger->priv->current_cmd.keep_result)	
+	  	if (!(debugger->priv->current_cmd.flags & DEBUGGER_COMMAND_KEEP_RESULT))
 		{	
 			/* GDB command has reported output */
 			GDBMIValue *val = gdbmi_value_parse (line);
@@ -1650,7 +1737,7 @@ debugger_stdo_flush (Debugger *debugger)
 			}
 		}
 
-		if (!debugger->priv->current_cmd.keep_result)
+		if (!(debugger->priv->current_cmd.flags & DEBUGGER_COMMAND_KEEP_RESULT))
 		{
 			g_string_assign (debugger->priv->stdo_acc, "");
 		}
@@ -1738,7 +1825,7 @@ debugger_stop_real (Debugger *debugger)
 	}
 
 	debugger->priv->terminating = TRUE;
-	debugger_queue_command (debugger, "-gdb-exit", FALSE, FALSE, NULL, NULL, NULL);
+	debugger_queue_command (debugger, "-gdb-exit", 0, NULL, NULL, NULL);
 }
 
 gboolean
@@ -1923,7 +2010,7 @@ debugger_is_connected (Debugger *debugger, const GDBMIValue *mi_results,
 			gchar *cmd;
 			
 			cmd = g_strconcat ("-target-select remote ", debugger->priv->remote_server, NULL);
-			debugger_queue_command (debugger, cmd, FALSE, FALSE, debugger_is_connected, NULL, NULL);
+			debugger_queue_command (debugger, cmd, 0, debugger_is_connected, NULL, NULL);
 			g_free (cmd);
 		}
 	}
@@ -1961,19 +2048,19 @@ debugger_start_program (Debugger *debugger, const gchar *remote, const gchar* ar
 	if (tty)
 	{
 		cmd = g_strdup_printf ("-inferior-tty-set %s", tty);
-		debugger_queue_command (debugger, cmd, FALSE, FALSE, NULL, NULL, NULL);
+		debugger_queue_command (debugger, cmd, 0, NULL, NULL, NULL);
 		g_free (cmd);
 	}
 
 	debugger->priv->inferior_pid = 0;
 	if (stop)
 	{
-		debugger_queue_command (debugger, "-break-insert -t main", FALSE, FALSE, NULL, NULL, NULL);
+		debugger_queue_command (debugger, "-break-insert -t main", 0, NULL, NULL, NULL);
 	}
 	if (args && (*args))
 	{
 		cmd = g_strconcat ("-exec-arguments ", args, NULL);
-		debugger_queue_command (debugger, cmd, FALSE, FALSE, NULL, NULL, NULL);
+		debugger_queue_command (debugger, cmd, 0, NULL, NULL, NULL);
 		g_free (cmd);
 	}
 
@@ -1985,15 +2072,15 @@ debugger_start_program (Debugger *debugger, const gchar *remote, const gchar* ar
 	{
 		debugger->priv->remote_server = g_strdup (remote);
 		cmd = g_strconcat ("-target-select remote ", remote, NULL);
-		debugger_queue_command (debugger, cmd, FALSE, FALSE, debugger_is_connected, NULL, NULL);
+		debugger_queue_command (debugger, cmd, 0, debugger_is_connected, NULL, NULL);
 		g_free (cmd);
 	}
 	else
 	{
-		debugger_queue_command (debugger, "-exec-run", FALSE, FALSE, NULL, NULL, NULL);
+		debugger_queue_command (debugger, "-exec-run", 0, NULL, NULL, NULL);
 		
 		/* Get pid of program on next stop */
-		debugger_queue_command (debugger, "info program", FALSE, FALSE, debugger_info_program_finish, NULL, NULL);
+		debugger_queue_command (debugger, "info program", 0, debugger_info_program_finish, NULL, NULL);
 		debugger->priv->post_execution_flag = DEBUGGER_NONE;
 	}
 }
@@ -2035,7 +2122,7 @@ debugger_attach_process_real (Debugger *debugger, pid_t pid)
 
 	debugger->priv->inferior_pid = pid;	
 	buff = g_strdup_printf ("attach %d", pid);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, 
+	debugger_queue_command (debugger, buff, 0, 
 							debugger_attach_process_finish, NULL, NULL);
 	g_free (buff);
 }
@@ -2113,7 +2200,7 @@ debugger_stop_program (Debugger *debugger)
 	{
 		/* FIXME: Why doesn't -exec-abort work??? */
 		/* debugger_queue_command (debugger, "-exec-abort", NULL, NULL); */
-		debugger_queue_command (debugger, "kill", FALSE, FALSE, NULL, NULL, NULL);
+		debugger_queue_command (debugger, "kill", 0, NULL, NULL, NULL);
 		debugger->priv->prog_is_running = FALSE;
 		debugger->priv->prog_is_attached = FALSE;
 		g_signal_emit_by_name (debugger->priv->instance, "program-exited");
@@ -2161,7 +2248,7 @@ debugger_detach_process (Debugger *debugger)
 		g_free (buff);
 	}
 	
-	debugger_queue_command (debugger, "detach", FALSE, FALSE, 
+	debugger_queue_command (debugger, "detach", 0, 
 							debugger_detach_process_finish, NULL, NULL);
 }
 
@@ -2170,6 +2257,8 @@ debugger_interrupt (Debugger *debugger)
 {
 	DEBUG_PRINT ("%s", "In function: debugger_interrupt()");
 
+	g_message ("debugger_interrupt inferiod_pid %d", debugger->priv->inferior_pid);
+
 	g_return_if_fail (IS_DEBUGGER (debugger));
 	g_return_if_fail (debugger->priv->prog_is_running == TRUE);
 
@@ -2202,7 +2291,7 @@ debugger_run (Debugger *debugger)
 	g_return_if_fail (debugger->priv->prog_is_running == TRUE);
 
 	/* Program running - continue */
-	debugger_queue_command (debugger, "-exec-continue", FALSE, FALSE, NULL, NULL, NULL);
+	debugger_queue_command (debugger, "-exec-continue", 0, NULL, NULL, NULL);
 }
 
 void
@@ -2213,7 +2302,7 @@ debugger_step_in (Debugger *debugger)
 	g_return_if_fail (IS_DEBUGGER (debugger));
 	g_return_if_fail (debugger->priv->prog_is_running == TRUE);
 
-	debugger_queue_command (debugger, "-exec-step", FALSE, FALSE, NULL, NULL, NULL);
+	debugger_queue_command (debugger, "-exec-step", 0, NULL, NULL, NULL);
 }
 
 void
@@ -2224,7 +2313,7 @@ debugger_step_over (Debugger *debugger)
 	g_return_if_fail (IS_DEBUGGER (debugger));
 	g_return_if_fail (debugger->priv->prog_is_running == TRUE);
 	
-	debugger_queue_command (debugger, "-exec-next", FALSE, FALSE, NULL, NULL, NULL);
+	debugger_queue_command (debugger, "-exec-next", 0, NULL, NULL, NULL);
 }
 
 void
@@ -2235,7 +2324,7 @@ debugger_step_out (Debugger *debugger)
 	g_return_if_fail (IS_DEBUGGER (debugger));
 	g_return_if_fail (debugger->priv->prog_is_running == TRUE);
 	
-	debugger_queue_command (debugger, "-exec-finish", FALSE, FALSE, NULL, NULL, NULL);
+	debugger_queue_command (debugger, "-exec-finish", 0, NULL, NULL, NULL);
 }
 
 void
@@ -2246,7 +2335,7 @@ debugger_stepi_in (Debugger *debugger)
 	g_return_if_fail (IS_DEBUGGER (debugger));
 	g_return_if_fail (debugger->priv->prog_is_running == TRUE);
 
-	debugger_queue_command (debugger, "-exec-step-instruction", FALSE, FALSE, NULL, NULL, NULL);
+	debugger_queue_command (debugger, "-exec-step-instruction", 0, NULL, NULL, NULL);
 }
 
 void
@@ -2257,7 +2346,7 @@ debugger_stepi_over (Debugger *debugger)
 	g_return_if_fail (IS_DEBUGGER (debugger));
 	g_return_if_fail (debugger->priv->prog_is_running == TRUE);
 	
-	debugger_queue_command (debugger, "-exec-next-instruction", FALSE, FALSE, NULL, NULL, NULL);
+	debugger_queue_command (debugger, "-exec-next-instruction", 0, NULL, NULL, NULL);
 }
 
 void
@@ -2271,7 +2360,7 @@ debugger_run_to_location (Debugger *debugger, const gchar *loc)
 	g_return_if_fail (debugger->priv->prog_is_running == TRUE);
 	
 	buff = g_strdup_printf ("-exec-until %s", loc);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, NULL, NULL, NULL);
+	debugger_queue_command (debugger, buff, 0, NULL, NULL, NULL);
 	g_free (buff);
 }
 
@@ -2287,11 +2376,13 @@ debugger_run_to_position (Debugger *debugger, const gchar *file, guint line)
 	g_return_if_fail (debugger->priv->prog_is_running == TRUE);
 
 	quoted_file = gdb_quote (file);	
-	buff = g_strdup_printf ("-break-insert -t \"\\\"%s\\\":%u\"", quoted_file, line);
+	buff = g_strdup_printf ("-break-insert -t %s \"\\\"%s\\\":%u\"",
+							debugger->priv->has_pending_breakpoints ? "-f" : "",
+							quoted_file, line);
 	g_free (quoted_file);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, NULL, NULL, NULL);
+	debugger_queue_command (debugger, buff, 0, NULL, NULL, NULL);
 	g_free (buff);
-	debugger_queue_command (debugger, "-exec-continue", FALSE, FALSE, NULL, NULL, NULL);
+	debugger_queue_command (debugger, "-exec-continue", 0, NULL, NULL, NULL);
 }
 
 void
@@ -2304,10 +2395,12 @@ debugger_run_to_address (Debugger *debugger, gulong address)
 	g_return_if_fail (IS_DEBUGGER (debugger));
 	g_return_if_fail (debugger->priv->prog_is_running == TRUE);
 	
-	buff = g_strdup_printf ("-break-insert -t *0x%lx", address);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, NULL, NULL, NULL);
+	buff = g_strdup_printf ("-break-insert -t %s *0x%lx",
+							debugger->priv->has_pending_breakpoints ? "-f" : "",
+							address);
+	debugger_queue_command (debugger, buff, 0, NULL, NULL, NULL);
 	g_free (buff);
-	debugger_queue_command (debugger, "-exec-continue", FALSE, FALSE, NULL, NULL, NULL);
+	debugger_queue_command (debugger, "-exec-continue", 0, NULL, NULL, NULL);
 }
 
 void
@@ -2386,7 +2479,7 @@ debugger_command (Debugger *debugger, const gchar *command,
 	}
 	else
 	{
-		debugger_queue_command (debugger, command, suppress_error, FALSE,
+		debugger_queue_command (debugger, command, suppress_error ? DEBUGGER_COMMAND_NO_ERROR : 0,
 								parser, user_data, NULL);
 	}
 }
@@ -2430,9 +2523,11 @@ debugger_add_breakpoint_at_line (Debugger *debugger, const gchar *file, guint li
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
 	quoted_file = gdb_quote (file);
-	buff = g_strdup_printf ("-break-insert \"\\\"%s\\\":%u\"", quoted_file, line);
+	buff = g_strdup_printf ("-break-insert %s \"\\\"%s\\\":%u\"",
+							debugger->priv->has_pending_breakpoints ? "-f" : "",
+							quoted_file, line);
 	g_free (quoted_file);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, debugger_add_breakpoint_finish, callback, user_data);
+	debugger_queue_command (debugger, buff, 0, debugger_add_breakpoint_finish, callback, user_data);
 	g_free (buff);
 }
 
@@ -2447,14 +2542,15 @@ debugger_add_breakpoint_at_function (Debugger *debugger, const gchar *file, cons
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
 	quoted_file = file == NULL ? NULL : gdb_quote (file);
-	buff = g_strdup_printf ("-break-insert %s%s%s%s%s",
-		       file == NULL ? "" : "\"\\\"",
-	       	       file == NULL ? "" : quoted_file,
-		       file == NULL ? "" : "\\\":" ,
-		       function,
-		       file == NULL ? "" : "\"");
+	buff = g_strdup_printf ("-break-insert %s %s%s%s%s%s",
+							debugger->priv->has_pending_breakpoints ? "-f" : "",
+							file == NULL ? "" : "\"\\\"",
+							file == NULL ? "" : quoted_file,
+							file == NULL ? "" : "\\\":" ,
+							function,
+							file == NULL ? "" : "\"");
 	g_free (quoted_file);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, debugger_add_breakpoint_finish, callback, user_data);
+	debugger_queue_command (debugger, buff, 0, debugger_add_breakpoint_finish, callback, user_data);
 	g_free (buff);
 }
 
@@ -2467,8 +2563,10 @@ debugger_add_breakpoint_at_address (Debugger *debugger, gulong address, IAnjutaD
 
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
-	buff = g_strdup_printf ("-break-insert *0x%lx", address);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, debugger_add_breakpoint_finish, callback, user_data);
+	buff = g_strdup_printf ("-break-insert %s *0x%lx",
+							debugger->priv->has_pending_breakpoints ? "-f" : "",
+							address);
+	debugger_queue_command (debugger, buff, 0, debugger_add_breakpoint_finish, callback, user_data);
 	g_free (buff);
 }
 
@@ -2483,7 +2581,7 @@ debugger_enable_breakpoint (Debugger *debugger, guint id, gboolean enable, IAnju
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
 	buff = g_strdup_printf (enable ? "-break-enable %d" : "-break-disable %d",id);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, debugger_add_breakpoint_finish, callback, user_data);
+	debugger_queue_command (debugger, buff, 0, debugger_add_breakpoint_finish, callback, user_data);
 	g_free (buff);
 }
 
@@ -2497,7 +2595,7 @@ debugger_ignore_breakpoint (Debugger *debugger, guint id, guint ignore, IAnjutaD
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
 	buff = g_strdup_printf ("-break-after %d %d", id, ignore);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, debugger_add_breakpoint_finish, callback, user_data);
+	debugger_queue_command (debugger, buff, 0, debugger_add_breakpoint_finish, callback, user_data);
 	g_free (buff);
 }
 
@@ -2511,7 +2609,7 @@ debugger_condition_breakpoint (Debugger *debugger, guint id, const gchar *condit
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
 	buff = g_strdup_printf ("-break-condition %d %s", id, condition == NULL ? "" : condition);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, debugger_add_breakpoint_finish, callback, user_data);
+	debugger_queue_command (debugger, buff, 0, debugger_add_breakpoint_finish, callback, user_data);
 	g_free (buff);
 }
 
@@ -2538,7 +2636,7 @@ debugger_remove_breakpoint (Debugger *debugger, guint id, IAnjutaDebuggerCallbac
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
 	buff = g_strdup_printf ("-break-delete %d", id);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, debugger_remove_breakpoint_finish, callback, user_data);
+	debugger_queue_command (debugger, buff, 0, debugger_remove_breakpoint_finish, callback, user_data);
 	g_free (buff);
 }
 
@@ -2600,7 +2698,7 @@ debugger_list_breakpoint (Debugger *debugger, IAnjutaDebuggerCallback callback,
 
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
-	debugger_queue_command (debugger, "-break-list", FALSE, FALSE, debugger_list_breakpoint_finish, callback, user_data);
+	debugger_queue_command (debugger, "-break-list", 0, debugger_list_breakpoint_finish, callback, user_data);
 }
 
 static void
@@ -2647,7 +2745,7 @@ debugger_print (Debugger *debugger, const gchar* variable, IAnjutaDebuggerCallba
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
 	buff = g_strdup_printf ("print %s", variable);
-	debugger_queue_command (debugger, buff, TRUE, FALSE, debugger_print_finish, callback, user_data);
+	debugger_queue_command (debugger, buff, DEBUGGER_COMMAND_NO_ERROR, debugger_print_finish, callback, user_data);
 	g_free (buff);
 }
 
@@ -2676,7 +2774,7 @@ debugger_evaluate (Debugger *debugger, const gchar* name, IAnjutaDebuggerCallbac
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
 	buff = g_strdup_printf ("-data-evaluate-expression %s", name);
-	debugger_queue_command (debugger, buff, TRUE, FALSE, debugger_evaluate_finish, callback, user_data);
+	debugger_queue_command (debugger, buff, DEBUGGER_COMMAND_NO_ERROR, debugger_evaluate_finish, callback, user_data);
 	g_free (buff);
 }
 
@@ -2745,9 +2843,9 @@ debugger_list_local (Debugger *debugger, IAnjutaDebuggerCallback callback, gpoin
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
 	buff = g_strdup_printf("-stack-list-arguments 0 %d %d", debugger->priv->current_frame, debugger->priv->current_frame);
-	debugger_queue_command (debugger, buff, TRUE, TRUE, NULL, NULL, NULL);
+	debugger_queue_command (debugger, buff, DEBUGGER_COMMAND_NO_ERROR | DEBUGGER_COMMAND_KEEP_RESULT, NULL, NULL, NULL);
 	g_free (buff);
-	debugger_queue_command (debugger, "-stack-list-locals 0", TRUE, FALSE, debugger_list_local_finish, callback, user_data);
+	debugger_queue_command (debugger, "-stack-list-locals 0", DEBUGGER_COMMAND_NO_ERROR, debugger_list_local_finish, callback, user_data);
 }
 
 static void
@@ -2801,7 +2899,7 @@ debugger_list_argument (Debugger *debugger, IAnjutaDebuggerCallback callback, gp
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
 	buff = g_strdup_printf("-stack-list-arguments 0 %d %d", debugger->priv->current_frame, debugger->priv->current_frame);
-	debugger_queue_command (debugger, buff, TRUE, FALSE, debugger_list_argument_finish, callback, user_data);
+	debugger_queue_command (debugger, buff, DEBUGGER_COMMAND_NO_ERROR, debugger_list_argument_finish, callback, user_data);
 	g_free (buff);
 }
 
@@ -2833,7 +2931,7 @@ debugger_info_frame (Debugger *debugger, guint frame, IAnjutaDebuggerCallback ca
 	{
 		buff = g_strdup_printf ("info frame %d", frame);
 	}
-	debugger_queue_command (debugger, buff, TRUE, FALSE, (DebuggerParserFunc)debugger_info_finish, callback, user_data);
+	debugger_queue_command (debugger, buff, DEBUGGER_COMMAND_NO_ERROR, (DebuggerParserFunc)debugger_info_finish, callback, user_data);
 	g_free (buff);
 }
 
@@ -2844,7 +2942,7 @@ debugger_info_signal (Debugger *debugger, IAnjutaDebuggerCallback callback, gpoi
 
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
-	debugger_queue_command (debugger, "info signals", TRUE, FALSE, (DebuggerParserFunc)debugger_info_finish, callback, user_data);
+	debugger_queue_command (debugger, "info signals", DEBUGGER_COMMAND_NO_ERROR, (DebuggerParserFunc)debugger_info_finish, callback, user_data);
 }
 
 void
@@ -2857,7 +2955,7 @@ debugger_info_sharedlib (Debugger *debugger, IAnjutaDebuggerCallback callback, g
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
 	buff = g_strdup_printf ("info sharedlib");
-	debugger_queue_command (debugger, buff, TRUE, FALSE, (DebuggerParserFunc)debugger_info_finish, callback, user_data);	g_free (buff);
+	debugger_queue_command (debugger, buff, DEBUGGER_COMMAND_NO_ERROR, (DebuggerParserFunc)debugger_info_finish, callback, user_data);	g_free (buff);
 }
 
 void
@@ -2867,7 +2965,7 @@ debugger_info_args (Debugger *debugger, IAnjutaDebuggerCallback callback, gpoint
 
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
-	debugger_queue_command (debugger, "info args", TRUE, FALSE, (DebuggerParserFunc)debugger_info_finish, callback, user_data);
+	debugger_queue_command (debugger, "info args", DEBUGGER_COMMAND_NO_ERROR, (DebuggerParserFunc)debugger_info_finish, callback, user_data);
 }
 
 void
@@ -2877,7 +2975,7 @@ debugger_info_target (Debugger *debugger, IAnjutaDebuggerCallback callback, gpoi
 
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
-	debugger_queue_command (debugger, "info target", TRUE, FALSE, (DebuggerParserFunc)debugger_info_finish, callback, user_data);
+	debugger_queue_command (debugger, "info target", DEBUGGER_COMMAND_NO_ERROR, (DebuggerParserFunc)debugger_info_finish, callback, user_data);
 }
 
 void
@@ -2887,7 +2985,7 @@ debugger_info_program (Debugger *debugger, IAnjutaDebuggerCallback callback, gpo
 
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
-	debugger_queue_command (debugger, "info program", TRUE, FALSE, (DebuggerParserFunc)debugger_info_finish, callback, user_data);
+	debugger_queue_command (debugger, "info program", DEBUGGER_COMMAND_NO_ERROR, (DebuggerParserFunc)debugger_info_finish, callback, user_data);
 }
 
 void
@@ -2897,7 +2995,7 @@ debugger_info_udot (Debugger *debugger, IAnjutaDebuggerCallback callback, gpoint
 
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
-	debugger_queue_command (debugger, "info udot", TRUE, FALSE, (DebuggerParserFunc)debugger_info_finish, callback, user_data);
+	debugger_queue_command (debugger, "info udot", DEBUGGER_COMMAND_NO_ERROR, (DebuggerParserFunc)debugger_info_finish, callback, user_data);
 }
 
 void
@@ -2907,7 +3005,7 @@ debugger_info_variables (Debugger *debugger, IAnjutaDebuggerCallback callback, g
 
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
-	debugger_queue_command (debugger, "info variables", TRUE, FALSE, (DebuggerParserFunc)debugger_info_finish, callback, user_data);
+	debugger_queue_command (debugger, "info variables", DEBUGGER_COMMAND_NO_ERROR, (DebuggerParserFunc)debugger_info_finish, callback, user_data);
 }
 
 static void
@@ -2994,7 +3092,7 @@ debugger_inspect_memory (Debugger *debugger, gulong address, guint length, IAnju
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
 	buff = g_strdup_printf ("-data-read-memory 0x%lx x 1 1 %d", address, length);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, debugger_read_memory_finish, callback, user_data);
+	debugger_queue_command (debugger, buff, 0, debugger_read_memory_finish, callback, user_data);
 	g_free (buff);
 }
 
@@ -3095,7 +3193,7 @@ debugger_disassemble (Debugger *debugger, gulong address, guint length, IAnjutaD
 	/* Handle overflow */
 	end = (address + length < address) ? G_MAXULONG : address + length;
 	buff = g_strdup_printf ("-data-disassemble -s 0x%lx -e 0x%lx  -- 0", address, end);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, debugger_disassemble_finish, callback, user_data);
+	debugger_queue_command (debugger, buff, 0, debugger_disassemble_finish, callback, user_data);
 	g_free (buff);
 }
 
@@ -3265,8 +3363,8 @@ debugger_list_frame (Debugger *debugger, IAnjutaDebuggerCallback callback, gpoin
 
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
-	debugger_queue_command (debugger, "-stack-list-frames", TRUE, TRUE, NULL, NULL, NULL);
-	debugger_queue_command (debugger, "-stack-list-arguments 1", TRUE, FALSE, debugger_stack_finish, callback, user_data);
+	debugger_queue_command (debugger, "-stack-list-frames", DEBUGGER_COMMAND_NO_ERROR | DEBUGGER_COMMAND_KEEP_RESULT, NULL, NULL, NULL);
+	debugger_queue_command (debugger, "-stack-list-arguments 1", DEBUGGER_COMMAND_NO_ERROR, debugger_stack_finish, callback, user_data);
 }
 
 /* Thread functions
@@ -3303,7 +3401,7 @@ debugger_set_thread (Debugger *debugger, gint thread)
 
 	buff = g_strdup_printf ("-thread-select %d", thread);
 
-	debugger_queue_command (debugger, buff, FALSE, FALSE, (DebuggerParserFunc)debugger_set_thread_finish, NULL, NULL);
+	debugger_queue_command (debugger, buff, 0, (DebuggerParserFunc)debugger_set_thread_finish, NULL, NULL);
 	g_free (buff);
 }
 
@@ -3360,7 +3458,7 @@ debugger_list_thread (Debugger *debugger, IAnjutaDebuggerCallback callback, gpoi
 
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
-	debugger_queue_command (debugger, "-thread-list-ids", TRUE, FALSE, debugger_list_thread_finish, callback, user_data);
+	debugger_queue_command (debugger, "-thread-list-ids", DEBUGGER_COMMAND_NO_ERROR, debugger_list_thread_finish, callback, user_data);
 }
 
 static void
@@ -3439,12 +3537,12 @@ debugger_info_thread (Debugger *debugger, gint thread, IAnjutaDebuggerCallback c
 
 	orig_thread = debugger->priv->current_thread;
 	buff = g_strdup_printf ("-thread-select %d", thread);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, (DebuggerParserFunc)debugger_info_set_thread_finish, NULL, NULL);
+	debugger_queue_command (debugger, buff, 0, (DebuggerParserFunc)debugger_info_set_thread_finish, NULL, NULL);
 	g_free (buff);
-	debugger_queue_command (debugger, "-stack-list-frames 0 0", FALSE, FALSE, (DebuggerParserFunc)debugger_info_thread_finish, callback, user_data);
+	debugger_queue_command (debugger, "-stack-list-frames 0 0", 0, (DebuggerParserFunc)debugger_info_thread_finish, callback, user_data);
 
 	buff = g_strdup_printf ("-thread-select %d", orig_thread);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, (DebuggerParserFunc)debugger_info_set_thread_finish, NULL, NULL);
+	debugger_queue_command (debugger, buff, 0, (DebuggerParserFunc)debugger_info_set_thread_finish, NULL, NULL);
 	g_free (buff);
 }
 
@@ -3552,7 +3650,7 @@ debugger_list_register (Debugger *debugger, IAnjutaDebuggerCallback callback, gp
 
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
-	debugger_queue_command (debugger, "-data-list-register-names", TRUE, FALSE, debugger_register_name_finish, callback, user_data);
+	debugger_queue_command (debugger, "-data-list-register-names", DEBUGGER_COMMAND_NO_ERROR, debugger_register_name_finish, callback, user_data);
 }
 
 void
@@ -3562,7 +3660,7 @@ debugger_update_register (Debugger *debugger, IAnjutaDebuggerCallback callback,
 
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
-	debugger_queue_command (debugger, "-data-list-register-values r", TRUE, FALSE, (DebuggerParserFunc)debugger_register_value_finish, callback, user_data);
+	debugger_queue_command (debugger, "-data-list-register-values r", DEBUGGER_COMMAND_NO_ERROR, (DebuggerParserFunc)debugger_register_value_finish, callback, user_data);
 }
 
 void
@@ -3575,7 +3673,7 @@ debugger_write_register (Debugger *debugger, const gchar *name, const gchar *val
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
 	buf = g_strdup_printf ("-data-evaluate-expression \"$%s=%s\"", name, value);
-	debugger_queue_command (debugger, buf, TRUE, FALSE, NULL, NULL, NULL);
+	debugger_queue_command (debugger, buf, DEBUGGER_COMMAND_NO_ERROR, NULL, NULL, NULL);
 	g_free (buf);
 }
 
@@ -3600,7 +3698,7 @@ debugger_set_frame (Debugger *debugger, gsize frame)
 
 	buff = g_strdup_printf ("-stack-select-frame %" G_GSIZE_FORMAT, frame);
 
-	debugger_queue_command (debugger, buff, FALSE, FALSE, (DebuggerParserFunc)debugger_set_frame_finish, NULL, (gpointer)frame);
+	debugger_queue_command (debugger, buff, 0, (DebuggerParserFunc)debugger_set_frame_finish, NULL, (gpointer)frame);
 	g_free (buff);
 }
 
@@ -3623,7 +3721,7 @@ debugger_delete_variable (Debugger *debugger, const gchar* name)
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
 	buff = g_strdup_printf ("-var-delete %s", name);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, NULL, NULL, NULL);
+	debugger_queue_command (debugger, buff, 0, NULL, NULL, NULL);
 	g_free (buff);
 }
 
@@ -3657,7 +3755,7 @@ debugger_evaluate_variable (Debugger *debugger, const gchar* name, IAnjutaDebugg
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
 	buff = g_strdup_printf ("-var-evaluate-expression %s", name);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, gdb_var_evaluate_expression, callback, user_data);
+	debugger_queue_command (debugger, buff, 0, gdb_var_evaluate_expression, callback, user_data);
 	g_free (buff);
 }
 
@@ -3671,7 +3769,7 @@ debugger_assign_variable (Debugger *debugger, const gchar* name, const gchar *va
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
 	buff = g_strdup_printf ("-var-assign %s %s", name, value);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, NULL, NULL, NULL);
+	debugger_queue_command (debugger, buff, 0, NULL, NULL, NULL);
 	g_free (buff);
 }
 
@@ -3744,7 +3842,7 @@ void debugger_list_variable_children (Debugger *debugger, const gchar* name, IAn
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
 	buff = g_strdup_printf ("-var-list-children --all-values %s", name);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, gdb_var_list_children, callback, user_data);
+	debugger_queue_command (debugger, buff, 0, gdb_var_list_children, callback, user_data);
 	g_free (buff);
 }
 
@@ -3782,7 +3880,7 @@ void debugger_create_variable (Debugger *debugger, const gchar* name, IAnjutaDeb
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
 	buff = g_strdup_printf ("-var-create - * %s", name);
-	debugger_queue_command (debugger, buff, FALSE, FALSE, gdb_var_create, callback, user_data);
+	debugger_queue_command (debugger, buff, 0, gdb_var_create, callback, user_data);
 	g_free (buff);
 }
 
@@ -3854,7 +3952,7 @@ void debugger_update_variable (Debugger *debugger, IAnjutaDebuggerCallback callb
 
 	g_return_if_fail (IS_DEBUGGER (debugger));
 
-	debugger_queue_command (debugger, "-var-update *", FALSE, FALSE, gdb_var_update, callback, user_data);
+	debugger_queue_command (debugger, "-var-update *", 0, gdb_var_update, callback, user_data);
 }
 
 GType
diff --git a/plugins/gdb/debugger.h b/plugins/gdb/debugger.h
index e5ff23c..5c92567 100644
--- a/plugins/gdb/debugger.h
+++ b/plugins/gdb/debugger.h
@@ -51,11 +51,18 @@ typedef void (*DebuggerParserFunc) (Debugger *debugger,
 									const GList *cli_result,
 									GError* error);
 
+typedef enum
+{
+	DEBUGGER_COMMAND_NO_ERROR = 1 << 0,
+	DEBUGGER_COMMAND_KEEP_RESULT = 1 << 1,
+	DEBUGGER_COMMAND_PREPEND = 1 << 2,
+} DebuggerCommandFlags;
+
+
 struct _DebuggerCommand
 {
 	gchar *cmd;
-	gboolean suppress_error;
-	gboolean keep_result;
+	DebuggerCommandFlags flags;
 	DebuggerParserFunc parser;
 	IAnjutaDebuggerCallback callback;
 	gpointer user_data;
diff --git a/plugins/gdb/gdb.init b/plugins/gdb/gdb.init
index f18bbf3..1717d29 100644
--- a/plugins/gdb/gdb.init
+++ b/plugins/gdb/gdb.init
@@ -9,5 +9,4 @@ set height 0
 set width 0
 set breakpoint pending on
 set backtrace limit 0
-set stop-on-solib-events 1
-
+handle SIGINT stop print nopass



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