Beispiel #1
0
/*
 * starts or continues debug process
 */
void debug_run(void)
{
	if (DBS_IDLE == debug_state)
	{
		gchar *target, *commandline;
		GList *env, *watches, *breaks;

		target = g_strstrip(tpage_get_target());
		if (!strlen(target))
		{
			g_free(target);
			return;
		}
		commandline = tpage_get_commandline();
		env = tpage_get_environment();
		watches = get_root_items(GTK_TREE_VIEW(wtree));
		breaks = breaks_get_all();

		/* init selected debugger  module */
		active_module = modules[tpage_get_debug_module_index()].module;
		if(active_module->run(target, commandline, env, watches, breaks, ttyname(pty_slave), &callbacks))
		{
			/* set target page - readonly */
			tpage_set_readonly(TRUE);

			/* update debuf state */
			debug_state = DBS_RUN_REQUESTED;
		}

		/* free stuff */
		g_free(target);
		g_free(commandline);

		g_list_foreach(env, (GFunc)g_free, NULL);
		g_list_free(env);

		g_list_foreach(watches, (GFunc)g_free, NULL);
		g_list_free(watches);

		g_list_free(breaks);
	}
	else if (DBS_STOPPED == debug_state)
	{
		/* resume */
		active_module->resume();
		debug_state = DBS_RUN_REQUESTED;
	}

	/* set breaks readonly if current module doesn't support run-time breaks operation */
	if (!(active_module->features & MF_ASYNC_BREAKS))
		bptree_set_readonly(TRUE);
}
Beispiel #2
0
/* 
 * called when debugger exits 
 */
static void on_debugger_exited (int code)
{
	/* remove marker for current instruction if was set */
	if (stack)
	{
		remove_stack_markers();
		g_list_foreach(stack, (GFunc)frame_free, NULL);
		g_list_free(stack);
		stack = NULL;
	}
	
	/* clear watch page */
	clear_watch_values(GTK_TREE_VIEW(wtree));
	
	/* clear autos page */
	gtk_tree_store_clear(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(atree))));

	/* clear stack trace tree */
	stree_clear();

	/* clear debug terminal */
	vte_terminal_reset(VTE_TERMINAL(terminal), TRUE, TRUE);

	/* clear debug messages window */
	GtkTextIter start, end;
	GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(debugger_messages_textview));
	gtk_text_buffer_get_bounds(buffer, &start, &end);
	gtk_text_buffer_delete(buffer, &start, &end);

	/* enable target page */
	tpage_set_readonly(FALSE);

	/* remove breaks readonly if current module doesn't support run-time breaks operation */
	if (!(active_module->features & MF_ASYNC_BREAKS))
		bptree_set_readonly(FALSE);
	
	/* set files that was readonly during debug writable */
	GList *iter = read_only_pages;
	while (iter)
	{
		GeanyDocument *doc = document_find_by_real_path((const gchar*)iter->data);
		if (doc)
			scintilla_send_message(doc->editor->sci, SCI_SETREADONLY, 0, 0);

		/* free file name */
		g_free(iter->data);

		iter = iter->next;
	}
	g_list_free(read_only_pages);
	read_only_pages = NULL;

	/* clear and destroy calltips cache */
	g_hash_table_destroy(calltips);
	calltips = NULL;

	/* enable widgets */
	enable_sensitive_widgets(TRUE);

	/* update buttons panel state */
	btnpanel_set_debug_state(DBS_IDLE);
	
	/* update debug state */
	debug_state = DBS_IDLE;
}
Beispiel #3
0
/* 
 * called from debug module when debugger is being stopped 
 */
static void on_debugger_stopped (int thread_id)
{
	/* update debug state */
	debug_state = DBS_STOPPED;

	/* update buttons panel state */
	if (!interrupt_data)
	{
		btnpanel_set_debug_state(debug_state);
	}

	/* clear calltips cache */
	g_hash_table_remove_all(calltips);

	/* if a stop was requested for asyncronous exiting -
	 * stop debug module and exit */
	if (exit_pending)
	{
		active_module->stop();
		exit_pending = FALSE;
		return;
	}

	/* check for async activities pending */
	if (interrupt_data)
	{
		interrupt_cb(interrupt_data);
		interrupt_data = NULL;
		
		active_module->resume();
		
		return;
	}

	/* clear stack tree view */
	stree_set_active_thread_id(thread_id);

	/* get current stack trace and put in the tree view */
	stack = active_module->get_stack();
	
	GList *iter = stack;
	while (iter)
	{
		frame *f = (frame*)iter->data;
		stree_add(f);
		iter = g_list_next(iter);
	}
	stree_select_first_frame(TRUE);

	/* files */
	GList *files = active_module->get_files();
	/* remove from list and make writable those files,
	that are not in the current list */
	iter = read_only_pages;
	while (iter)
	{
		if (!g_list_find_custom(files, iter->data, (GCompareFunc)g_strcmp0))
		{
			/* set document writable */
			GeanyDocument *doc = document_find_by_real_path((const gchar*)iter->data);
			if (doc)
				scintilla_send_message(doc->editor->sci, SCI_SETREADONLY, 0, 0);

			/* free file name */
			g_free(iter->data);
			/* save next item pointer */
			GList *next = iter->next;
			/* remove current item */
			read_only_pages = g_list_delete_link(read_only_pages, iter);

			/* set next item and continue */
			iter = next;
			continue;
		}

		iter = iter->next;
	}
	/* add to the list and make readonly those files
	from the current list that are new */
	iter = files;
	while (iter)
	{
		if (!g_list_find_custom(read_only_pages, iter->data, (GCompareFunc)g_strcmp0))
		{
			/* set document readonly */
			GeanyDocument *doc = document_find_by_real_path((const gchar*)iter->data);
			if (doc)
				scintilla_send_message(doc->editor->sci, SCI_SETREADONLY, 1, 0);

			/* add new file to the list */
			read_only_pages = g_list_append(read_only_pages, g_strdup((gchar*)iter->data));
		}
		iter = iter->next;
	}
	g_list_free(files);

	/* autos */
	GList *autos = active_module->get_autos();
	update_variables(GTK_TREE_VIEW(atree), NULL, autos);
	
	/* watches */
	GList *watches = active_module->get_watches();
	update_variables(GTK_TREE_VIEW(wtree), NULL, watches);

	if (stack)
	{
		frame *current = (frame*)stack->data;

		if (current->have_source)
		{
			/* open current instruction position */
			editor_open_position(current->file, current->line);
		}

		/* add current instruction marker */
		add_stack_markers();
	}

	/* enable widgets */
	enable_sensitive_widgets(TRUE);

	/* remove breaks readonly if current module doesn't support run-time breaks operation */
	if (!(active_module->features & MF_ASYNC_BREAKS))
		bptree_set_readonly(FALSE);
}