Esempio n. 1
0
static void
debug_tree_add_children (DebugTree *tree, GtkTreeIter* parent, const GList *children)
{
	GList *child;
	
	child = g_list_first ((GList *)children);
	
	if (child == NULL)
	{
		/* Clear all children if they exist */
		debug_tree_remove_children (tree, parent, NULL);
	}
	else
	{
		GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree->view));
		GtkTreeIter iter;
		gboolean valid_iter;
		
		valid_iter = gtk_tree_model_iter_children (model, &iter, parent); 
		
		for (; child != NULL; child = g_list_next (child))
		{
			IAnjutaDebuggerVariableObject *var = (IAnjutaDebuggerVariableObject *)child->data;
			DmaVariableData *data;
			
			if (!valid_iter)
			{
				/* Add new tree node */
				gtk_tree_store_append(GTK_TREE_STORE(model), &iter, parent);
				gtk_tree_store_set(GTK_TREE_STORE(model), &iter,
					   TYPE_COLUMN, var->type == NULL ? UNKNOWN_TYPE : var->type,
					   VALUE_COLUMN, var->value == NULL ? UNKNOWN_VALUE : var->value,
					   VARIABLE_COLUMN, var->expression,
					   ROOT_COLUMN, FALSE,
					   DTREE_ENTRY_COLUMN, NULL,-1);
				data = NULL;
			}
			else
			{
				/* Update tree node */
				if (var->type != NULL)
					gtk_tree_store_set(GTK_TREE_STORE(model), &iter, TYPE_COLUMN, var->type, -1);
				if (var->value != NULL)
					gtk_tree_store_set(GTK_TREE_STORE(model), &iter, VALUE_COLUMN, var->value, -1);
				if (var->expression != NULL)
					gtk_tree_store_set(GTK_TREE_STORE(model), &iter, VARIABLE_COLUMN, var->expression, -1);
				gtk_tree_model_get(model, &iter, DTREE_ENTRY_COLUMN, &data, -1);	
			}
				
			if (data == NULL)
			{
				/* Create new data */
				data = dma_variable_data_new(var->name, FALSE);
				gtk_tree_store_set(GTK_TREE_STORE(model), &iter, DTREE_ENTRY_COLUMN, data, -1);				
			}
			else
			{
				data->changed = TRUE;
			}
		
			if (var->children == 0)
			{
				/* Clear all children if they exist */
				debug_tree_remove_children (tree, &iter, NULL);
			}
			else
			{
				/* Add dummy children */
				debug_tree_add_dummy (tree, &iter);
			}
			
			valid_iter = gtk_tree_model_iter_next (model, &iter); 
		}
		if (valid_iter)
		{
			/* Remove trailing children */
			debug_tree_remove_children (tree, parent, &iter);
		}
	}	
}
Esempio n. 2
0
static void
gdb_var_create (IAnjutaDebuggerVariableObject *variable, gpointer user_data, GError *err)
{
	DmaVariablePacket *pack = (DmaVariablePacket *) user_data;
	GtkTreeIter iter;
	
	g_return_if_fail (pack != NULL);

	if (err != NULL)
	{
		/* Command failed */
		dma_variable_packet_free (pack);
		
		return;
	}
	if ((pack->data == NULL)
		|| !dma_variable_packet_get_iter (pack, &iter))
	{
		/* Item has been deleted, but not removed from debugger as it was not
		 * created at this time, so remove it now */
		if ((pack->tree->debugger) && (variable->name))
		{
			dma_queue_delete_variable (pack->tree->debugger, variable->name);
		}
		dma_variable_packet_free (pack);
		
		return;
	}

	DmaVariableData *data = pack->data;
	
	if ((variable->name != NULL) && (data->name == NULL))
	{
		data->name = strdup (variable->name);
	}
    data->changed = TRUE;
	
	gtk_tree_store_set(GTK_TREE_STORE(pack->model), &iter,
					   TYPE_COLUMN, variable->type,
					   VALUE_COLUMN, variable->value, -1);
	

	if (variable->children == -1)
	{
		/* Find the number of children */
		DmaVariablePacket *pack_child =
                  dma_variable_packet_new(pack->model, &iter, pack->tree, data);

		dma_queue_list_children (
				pack_child->tree->debugger,
				variable->name,
				(IAnjutaDebuggerCallback)gdb_var_list_children,
				pack_child);
	}
	else if (variable->children > 0)
	{
		debug_tree_add_dummy (pack->tree, &iter);
	}
	else
	{
		debug_tree_remove_children (pack->tree, &iter, NULL);
	}
	
	
	/* Request value and/or children if they are missing
	 * reusing same packet if possible */
	if (variable->value == NULL)
	{
		dma_queue_evaluate_variable (
				pack->tree->debugger,
				variable->name,
				(IAnjutaDebuggerCallback)gdb_var_evaluate_expression,
				pack);
	}
	else
	{
		dma_variable_packet_free (pack);
	}
}
Esempio n. 3
0
static void
debug_tree_add_children (GtkTreeModel *model, DmaDebuggerQueue *debugger, GtkTreeIter* parent, guint from, const GList *children)
{
	GList *child;
	GtkTreeIter iter;
	gboolean valid;

	valid = gtk_tree_model_iter_nth_child (model, &iter, parent, from);

	/* Add new children */
	for (child = g_list_first ((GList *)children); child != NULL; child = g_list_next (child))
	{
		IAnjutaDebuggerVariableObject *var = (IAnjutaDebuggerVariableObject *)child->data;
		DmaVariableData *data;
		
		if (!valid)
		{
			/* Add new tree node */
			gtk_tree_store_append(GTK_TREE_STORE(model), &iter, parent);

			gtk_tree_store_set(GTK_TREE_STORE(model), &iter,
				TYPE_COLUMN, var->type == NULL ? UNKNOWN_TYPE : var->type,
				VALUE_COLUMN, var->value == NULL ? UNKNOWN_VALUE : var->value,
				VARIABLE_COLUMN, var->expression,
				ROOT_COLUMN, FALSE,
				DTREE_ENTRY_COLUMN, NULL,-1);
			data = NULL;
		}
		else
		{
			/* Update tree node */
			if (var->type != NULL)
				gtk_tree_store_set(GTK_TREE_STORE(model), &iter, TYPE_COLUMN, var->type, -1);
			if (var->value != NULL)
				gtk_tree_store_set(GTK_TREE_STORE(model), &iter, VALUE_COLUMN, var->value, -1);
			if (var->expression != NULL)
				gtk_tree_store_set(GTK_TREE_STORE(model), &iter, VARIABLE_COLUMN, var->expression, -1);
			gtk_tree_model_get(model, &iter, DTREE_ENTRY_COLUMN, &data, -1);

			if (var->name == NULL)
			{
				/* Dummy node representing additional children */
				if (data != NULL)
				{
					dma_variable_data_free (data);
					gtk_tree_store_set(GTK_TREE_STORE (model), &iter, DTREE_ENTRY_COLUMN, NULL, -1);
					data = NULL;
				}
			}
		}

		if ((var->name != NULL) && (data == NULL))
		{
			/* Create new data */
			data = dma_variable_data_new(var->name, TRUE);
			gtk_tree_store_set(GTK_TREE_STORE(model), &iter, DTREE_ENTRY_COLUMN, data, -1);
		}

		/* Clear all children if they exist */
		debug_tree_remove_children (model, debugger, &iter, NULL);
		if ((var->children != 0) || var->has_more || (var->name == NULL))
		{
			/* Add dummy children */
			debug_tree_model_add_dummy_children (model, &iter);
		}

		valid = gtk_tree_model_iter_next (model, &iter); 
	}
	
	/* Clear remaining old children */
	if (valid) debug_tree_remove_children (model, debugger, parent, &iter);
}