Branch: refs/heads/master Author: Alexander Petukhov devel@apetukhov.ru Committer: Alexander Petukhov devel@apetukhov.ru Date: Thu, 14 Jun 2012 06:05:29 Commit: 26eba1446a1475e238e84fb2c9f614b8c9efdf39 https://github.com/geany/geany-plugins/commit/26eba1446a1475e238e84fb2c9f614...
Log Message: ----------- Merge branch 'debugger_bugfixing' of github.com:cesspit/geany-plugins into debugger
Modified Paths: -------------- debugger/src/atree.c debugger/src/atree.h debugger/src/bptree.c debugger/src/bptree.h debugger/src/breakpoint.c debugger/src/breakpoint.h debugger/src/breakpoints.c debugger/src/breakpoints.h debugger/src/btnpanel.c debugger/src/btnpanel.h debugger/src/callbacks.c debugger/src/callbacks.h debugger/src/calltip.h debugger/src/cell_renderers/cellrendererbreakicon.c debugger/src/cell_renderers/cellrendererframeicon.c debugger/src/cell_renderers/cellrenderertoggle.c debugger/src/dbm_gdb.c debugger/src/dconfig.c debugger/src/dconfig.h debugger/src/debug.c debugger/src/debug.h debugger/src/debug_module.c debugger/src/debug_module.h debugger/src/dpaned.c debugger/src/dpaned.h debugger/src/envtree.c debugger/src/envtree.h debugger/src/gui.c debugger/src/gui.h debugger/src/keys.c debugger/src/keys.h debugger/src/markers.c debugger/src/markers.h debugger/src/pixbuf.c debugger/src/pixbuf.h debugger/src/plugin.c debugger/src/stree.c debugger/src/stree.h debugger/src/tabs.h debugger/src/tpage.c debugger/src/tpage.h debugger/src/utils.c debugger/src/utils.h debugger/src/vtree.c debugger/src/vtree.h debugger/src/watch_model.c debugger/src/watch_model.h debugger/src/wtree.c debugger/src/wtree.h
Modified: debugger/src/atree.c 1 files changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -25,6 +25,7 @@
#include <gtk/gtk.h>
+#include "atree.h" #include "watch_model.h" #include "vtree.h"
Modified: debugger/src/atree.h 10 files changed, 9 insertions(+), 1 deletions(-) =================================================================== @@ -18,6 +18,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ - + +#ifndef ATREE_H +#define ATREE_H + +#include <gtk/gtk.h> + +#include "watch_model.h" + GtkWidget* atree_init(watch_expanded_callback expanded, watch_button_pressed buttonpressed);
+#endif /* guard */
Modified: debugger/src/bptree.c 187 files changed, 101 insertions(+), 86 deletions(-) =================================================================== @@ -81,10 +81,9 @@ enum /* * gets tree row reference for an unsected row at the same depth */ -GtkTreeRowReference* get_unselected_sibling(GtkTreePath *path) +static GtkTreeRowReference* get_unselected_sibling(GtkTreePath *path) { GtkTreeRowReference *sibling = NULL; - GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
/* move down find first unselected sibling */ @@ -156,18 +155,18 @@ static gboolean on_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean key { gboolean show = FALSE; int bx, by; - gtk_tree_view_convert_widget_to_bin_window_coords(GTK_TREE_VIEW(widget), x, y, &bx, &by); - GtkTreePath *tpath = NULL; GtkTreeViewColumn *column = NULL; + + gtk_tree_view_convert_widget_to_bin_window_coords(GTK_TREE_VIEW(widget), x, y, &bx, &by); if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bx, by, &tpath, &column, NULL, NULL)) { if (1 == gtk_tree_path_get_depth(tpath) && column == gtk_tree_view_get_column(GTK_TREE_VIEW(widget), FILEPATH)) { GtkTreeIter iter; - gtk_tree_model_get_iter(model, &iter, tpath); - gchar *path = NULL; + + gtk_tree_model_get_iter(model, &iter, tpath); gtk_tree_model_get(model, &iter, FILEPATH, &path, -1);
gtk_tooltip_set_text(tooltip, path); @@ -189,17 +188,20 @@ static void on_render_filename(GtkTreeViewColumn *tree_column, GtkCellRenderer * GtkTreeIter *iter, gpointer data) { gchar *path = NULL; + GtkTreePath *tpath; + gtk_tree_model_get(model, iter, FILEPATH, &path, -1);
- GtkTreePath *tpath = gtk_tree_model_get_path(model, iter); + tpath = gtk_tree_model_get_path(model, iter); if (1 != gtk_tree_path_get_depth(tpath)) { g_object_set(cell, "text", path, NULL); } else { - const gchar *name = g_basename(path); + gchar *name = g_path_get_basename(path); g_object_set(cell, "text", name ? name : path, NULL); + g_free(name); } if (path) @@ -211,7 +213,7 @@ static void on_render_filename(GtkTreeViewColumn *tree_column, GtkCellRenderer * /* * hides file checkbox for breaks rows */ -void on_render_enable_for_file(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, +static void on_render_enable_for_file(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) { GtkTreePath *path = gtk_tree_model_get_path(model, iter); @@ -222,7 +224,7 @@ void on_render_enable_for_file(GtkTreeViewColumn *tree_column, GtkCellRenderer * /* * hides break pixbuf for file rows */ -void on_render_enable_break(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, +static void on_render_enable_break(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) { GtkTreePath *path = gtk_tree_model_get_path(model, iter); @@ -233,7 +235,7 @@ void on_render_enable_break(GtkTreeViewColumn *tree_column, GtkCellRenderer *cel /* * makes condition and hitscount uneditable and empty for file rows */ -void on_render(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, +static void on_render(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) { GtkTreePath *path = gtk_tree_model_get_path(model, iter); @@ -258,21 +260,20 @@ void on_render(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeMod */ static void on_row_double_click(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data) { + GtkTreeIter iter, parent_iter; + gchar *file; + int line; + if (1 == gtk_tree_path_get_depth(path)) { return; } - GtkTreeIter iter; gtk_tree_model_get_iter ( model, &iter, path); - - gchar *file; - int line; - GtkTreeIter parent_iter; gtk_tree_model_iter_parent(model, &parent_iter, &iter); gtk_tree_model_get ( @@ -296,28 +297,27 @@ static void on_row_double_click(GtkTreeView *tree_view, GtkTreePath *path, GtkTr /* * editing "condition" column value finished */ -void on_condition_changed(GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer user_data) +static void on_condition_changed(GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer user_data) { - GtkTreeIter iter; - GtkTreePath *tree_path = gtk_tree_path_new_from_string (path); + gchar *file; + int line; + gchar* oldcondition; + GtkTreeIter iter, parent_iter; + GtkTreePath *tree_path = gtk_tree_path_new_from_string (path);
gtk_tree_model_get_iter ( model, &iter, tree_path); - GtkTreeIter parent_iter; gtk_tree_model_iter_parent(model, &parent_iter, &iter);
- gchar *file; gtk_tree_model_get ( model, &parent_iter, FILEPATH, &file, -1); - int line; - gchar* oldcondition; gtk_tree_model_get ( model, &iter, @@ -336,32 +336,33 @@ void on_condition_changed(GtkCellRendererText *renderer, gchar *path, gchar *new /* * editing "hitscount" column value finished */ -void on_hitscount_changed(GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer user_data) +static void on_hitscount_changed(GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer user_data) { + GtkTreeIter iter, parent_iter; + GtkTreePath *tree_path; + gchar *file; + int line; + gint oldcount; int count = atoi(new_text); + if (!count && strcmp(new_text, "0")) return;
- GtkTreeIter iter; - GtkTreePath *tree_path = gtk_tree_path_new_from_string (path); + tree_path = gtk_tree_path_new_from_string (path);
gtk_tree_model_get_iter ( model, &iter, tree_path);
- GtkTreeIter parent_iter; gtk_tree_model_iter_parent(model, &parent_iter, &iter);
- gchar *file; gtk_tree_model_get ( model, &parent_iter, FILEPATH, &file, -1);
- int line; - gint oldcount; gtk_tree_model_get ( model, &iter, @@ -379,21 +380,24 @@ void on_hitscount_changed(GtkCellRendererText *renderer, gchar *path, gchar *new /* * enable / disable all breaks for a file when it's checkbox icon has been clicked */ -void on_enable_for_file(GtkCellRendererToggle *cell_renderer, gchar *path, gpointer user_data) +static void on_enable_for_file(GtkCellRendererToggle *cell_renderer, gchar *path, gpointer user_data) { + GtkTreeIter iter; + GtkTreePath *tree_path; + gboolean current_state; + /* do not process event is page is readonly (debug is running) */ if (readonly) return; - GtkTreeIter iter; - GtkTreePath *tree_path = gtk_tree_path_new_from_string (path); + tree_path = gtk_tree_path_new_from_string (path); gtk_tree_model_get_iter ( model, &iter, tree_path);
- gboolean current_state = gtk_cell_renderer_toggle_get_active(cell_renderer); + current_state = gtk_cell_renderer_toggle_get_active(cell_renderer);
/* check if this is a file row */ if(1 == gtk_tree_path_get_depth(tree_path)) @@ -416,14 +420,16 @@ void on_enable_for_file(GtkCellRendererToggle *cell_renderer, gchar *path, gpoin /* * enable / disable particulary break when it's icon has been clicked */ -void on_enable_break(CellRendererBreakIcon *cell_renderer, gchar *path, gpointer user_data) +static void on_enable_break(CellRendererBreakIcon *cell_renderer, gchar *path, gpointer user_data) { + GtkTreeIter iter; + GtkTreePath *tree_path; + /* do not process event is page is readonly (debug is running) */ if (readonly) return; - GtkTreeIter iter; - GtkTreePath *tree_path = gtk_tree_path_new_from_string (path); + tree_path = gtk_tree_path_new_from_string (path); gtk_tree_model_get_iter ( model, @@ -433,11 +439,11 @@ void on_enable_break(CellRendererBreakIcon *cell_renderer, gchar *path, gpointer /* check if this is not a file row */ if(1 != gtk_tree_path_get_depth(tree_path)) { - GtkTreeIter parent_iter; - gtk_tree_model_iter_parent(model, &parent_iter, &iter); - gchar *file; int line; + GtkTreeIter parent_iter; + + gtk_tree_model_iter_parent(model, &parent_iter, &iter);
gtk_tree_model_get ( model, @@ -463,24 +469,28 @@ void on_enable_break(CellRendererBreakIcon *cell_renderer, gchar *path, gpointer */ static gboolean on_key_pressed(GtkWidget *widget, GdkEvent *event, gpointer user_data) { + guint keyval = ((GdkEventKey*)event)->keyval; + GtkTreeSelection *selection; + GList *rows; + /* do not process event is page is readonly (debug is running) */ if (readonly) return FALSE;
- guint keyval = ((GdkEventKey*)event)->keyval; - /* get selected rows */ - GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); - GList *rows = gtk_tree_selection_get_selected_rows(selection, &model); + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); + rows = gtk_tree_selection_get_selected_rows(selection, &model); rows = g_list_sort(rows, (GCompareFunc)gtk_tree_path_compare);
if (keyval == GDK_Delete && rows && g_list_length(rows)) { + GList *breaks, *iter; + GtkTreeRowReference *new_selection = NULL; + GtkTreePath *first_path = (GtkTreePath*)rows->data; + /* "delete selected rows" */
/* get new selection */ - GtkTreeRowReference *new_selection = NULL; - GtkTreePath *first_path = (GtkTreePath*)rows->data; if (gtk_tree_path_get_depth(first_path) > 1) { new_selection = get_unselected_sibling(first_path); @@ -498,13 +508,12 @@ static gboolean on_key_pressed(GtkWidget *widget, GdkEvent *event, gpointer user /* collect GList of breakpoints to remove if file row is met - add all unselected breaks to the list as well */ - GList *iter = rows; - GList *breaks = NULL; - while (iter) + breaks = NULL; + for (iter = rows; iter; iter = iter->next) { GtkTreePath *path = (GtkTreePath*)iter->data; - GtkTreeIter titer; + gtk_tree_model_get_iter(model, &titer, path); if (1 == gtk_tree_path_get_depth(path)) @@ -518,11 +527,12 @@ static gboolean on_key_pressed(GtkWidget *widget, GdkEvent *event, gpointer user { gchar *file = NULL; gint line; + breakpoint *bp;
gtk_tree_model_get(model, &titer, FILEPATH, &file, -1); gtk_tree_model_get(model, &citer, LINE, &line, -1);
- breakpoint *bp = breaks_lookup_breakpoint(file, line); + bp = breaks_lookup_breakpoint(file, line); breaks = g_list_append(breaks, bp); @@ -534,21 +544,22 @@ static gboolean on_key_pressed(GtkWidget *widget, GdkEvent *event, gpointer user else { GtkTreeIter piter; + gchar *file = NULL; + gint line; + breakpoint *bp; + gtk_tree_model_iter_parent(model, &piter, &titer); - gchar *file = NULL; gtk_tree_model_get(model, &piter, FILEPATH, &file, -1);
- gint line; gtk_tree_model_get(model, &titer, LINE, &line, -1);
- breakpoint *bp = breaks_lookup_breakpoint(file, line); + bp = breaks_lookup_breakpoint(file, line); breaks = g_list_append(breaks, bp); g_free(file); } - iter = iter->next; } if (1 == g_list_length(breaks)) @@ -594,6 +605,10 @@ static gboolean on_key_pressed(GtkWidget *widget, GdkEvent *event, gpointer user */ gboolean bptree_init(move_to_line_cb cb) { + GtkTreeSelection *selection; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + /* save double click callback */ on_break_clicked = cb; @@ -622,7 +637,7 @@ gboolean bptree_init(move_to_line_cb cb) gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), 1); gtk_widget_set_has_tooltip(GTK_WIDGET(tree), TRUE); /* multiple selection */ - GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); /* connect signals */ @@ -631,33 +646,32 @@ gboolean bptree_init(move_to_line_cb cb) g_signal_connect(G_OBJECT(tree), "query-tooltip", G_CALLBACK (on_query_tooltip), NULL);
/* creating columns */ - GtkTreeViewColumn *column;
/* icon, file */ - GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); + renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new(); gtk_tree_view_column_pack_end(column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func(column, renderer, on_render_filename, NULL, NULL); - + /* enable for file */ - GtkCellRenderer *file_enable_renderer = cell_renderer_toggle_new (); - g_signal_connect (G_OBJECT(file_enable_renderer), "toggled", G_CALLBACK(on_enable_for_file), NULL); - gtk_tree_view_column_pack_end(column, file_enable_renderer, FALSE); - gtk_tree_view_column_set_attributes(column, file_enable_renderer, "active", ENABLED, NULL); - gtk_tree_view_column_set_cell_data_func(column, file_enable_renderer, on_render_enable_for_file, NULL, NULL); + renderer = cell_renderer_toggle_new (); + g_signal_connect (G_OBJECT(renderer), "toggled", G_CALLBACK(on_enable_for_file), NULL); + gtk_tree_view_column_pack_end(column, renderer, FALSE); + gtk_tree_view_column_set_attributes(column, renderer, "active", ENABLED, NULL); + gtk_tree_view_column_set_cell_data_func(column, renderer, on_render_enable_for_file, NULL, NULL);
/* enable breakpoint */ - GtkCellRenderer *break_enable_renderer = cell_renderer_break_icon_new (); - g_signal_connect (G_OBJECT(break_enable_renderer), "clicked", G_CALLBACK(on_enable_break), NULL); + renderer = cell_renderer_break_icon_new (); + g_signal_connect (G_OBJECT(renderer), "clicked", G_CALLBACK(on_enable_break), NULL);
- g_object_set(break_enable_renderer, "pixbuf_enabled", (gpointer)break_pixbuf, NULL); - g_object_set(break_enable_renderer, "pixbuf_disabled", (gpointer)break_disabled_pixbuf, NULL); - g_object_set(break_enable_renderer, "pixbuf_conditional", (gpointer)break_condition_pixbuf, NULL); - g_object_set(break_enable_renderer, "pixbuf_file", (gpointer)break_pixbuf, NULL); + g_object_set(renderer, "pixbuf_enabled", (gpointer)break_pixbuf, NULL); + g_object_set(renderer, "pixbuf_disabled", (gpointer)break_disabled_pixbuf, NULL); + g_object_set(renderer, "pixbuf_conditional", (gpointer)break_condition_pixbuf, NULL); + g_object_set(renderer, "pixbuf_file", (gpointer)break_pixbuf, NULL); - gtk_tree_view_column_pack_end(column, break_enable_renderer, FALSE); - gtk_tree_view_column_set_attributes(column, break_enable_renderer, "enabled", ENABLED, "condition", CONDITION, "hitscount", HITSCOUNT, NULL); - gtk_tree_view_column_set_cell_data_func(column, break_enable_renderer, on_render_enable_break, NULL, NULL); + gtk_tree_view_column_pack_end(column, renderer, FALSE); + gtk_tree_view_column_set_attributes(column, renderer, "enabled", ENABLED, "condition", CONDITION, "hitscount", HITSCOUNT, NULL); + gtk_tree_view_column_set_cell_data_func(column, renderer, on_render_enable_break, NULL, NULL);
gtk_tree_view_column_set_title(column, _("Location")); gtk_tree_view_column_set_resizable (column, TRUE); @@ -675,9 +689,8 @@ gboolean bptree_init(move_to_line_cb cb) /* hits count */ hcount_renderer = gtk_cell_renderer_spin_new (); - GtkAdjustment* adj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 100000.0, 1.0, 2.0, 2.0)); g_object_set (hcount_renderer, - "adjustment", adj, + "adjustment", gtk_adjustment_new (0.0, 0.0, 100000.0, 1.0, 2.0, 2.0), "digits", 0, NULL); g_signal_connect (G_OBJECT (hcount_renderer), "edited", G_CALLBACK (on_hitscount_changed), NULL); column = gtk_tree_view_column_new_with_attributes (_("Hit count"), hcount_renderer, "text", HITSCOUNT, NULL); @@ -709,7 +722,7 @@ gboolean bptree_init(move_to_line_cb cb) * destroy breaks tree and associated data * arguments: */ -void bptree_destroy() +void bptree_destroy(void) { g_hash_table_destroy(files); } @@ -721,9 +734,10 @@ void bptree_destroy() */ void bptree_set_enabled(breakpoint *bp) { + GtkTreeIter parent; + gtk_tree_store_set(store, &(bp->iter), ENABLED, bp->enabled, -1);
- GtkTreeIter parent; gtk_tree_model_iter_parent(model, &parent, &(bp->iter)); update_file_node(&parent); } @@ -756,7 +770,7 @@ void bptree_set_condition(breakpoint* bp) */ gchar* bptree_get_condition(breakpoint *bp) { - gchar *condition; + gchar *condition; gtk_tree_model_get ( model, &(bp->iter), @@ -785,17 +799,20 @@ void bptree_set_readonly(gboolean value) */ void bptree_add_breakpoint(breakpoint* bp) { - GtkTreeIter file_iter; + GtkTreeIter file_iter, iter, child, *sibling = NULL; GtkTreeRowReference *file_reference = (GtkTreeRowReference*)g_hash_table_lookup(files, bp->file); + if (!file_reference) { + GtkTreePath *file_path; + gtk_tree_store_prepend (store, &file_iter, NULL); gtk_tree_store_set (store, &file_iter, FILEPATH, bp->file, ENABLED, TRUE, -1);
- GtkTreePath *file_path = gtk_tree_model_get_path(model, &file_iter); + file_path = gtk_tree_model_get_path(model, &file_iter); file_reference = gtk_tree_row_reference_new(model, file_path); gtk_tree_path_free(file_path);
@@ -809,7 +826,6 @@ void bptree_add_breakpoint(breakpoint* bp) } /* lookup where to insert new row */ - GtkTreeIter child, *sibling = NULL; if(gtk_tree_model_iter_children(model, &child, &file_iter)) { do @@ -829,11 +845,10 @@ void bptree_add_breakpoint(breakpoint* bp) while(gtk_tree_model_iter_next(model, &child)); } - GtkTreeIter iter; gtk_tree_store_insert_before(store, &iter, &file_iter, sibling); - bp->iter = iter; - - bptree_update_breakpoint(bp); + bp->iter = iter; + + bptree_update_breakpoint(bp); }
/* @@ -883,7 +898,7 @@ void bptree_remove_breakpoint(breakpoint* bp) * updates all file ENABLED checkboxes base on theit children states * arguments: */ -void bptree_update_file_nodes() +void bptree_update_file_nodes(void) { GtkTreeIter file; if(gtk_tree_model_iter_children(model, &file, NULL))
Modified: debugger/src/bptree.h 14 files changed, 12 insertions(+), 2 deletions(-) =================================================================== @@ -19,8 +19,16 @@ * MA 02110-1301, USA. */
+#ifndef BPTREE_H +#define BPTREE_H + +#include <glib.h> + +#include "breakpoint.h" +#include "breakpoints.h" + gboolean bptree_init(move_to_line_cb callback); -void bptree_destroy(); +void bptree_destroy(void); void bptree_add_breakpoint(breakpoint* bp); void bptree_update_breakpoint(breakpoint* bp); void bptree_remove_breakpoint(breakpoint* bp); @@ -29,4 +37,6 @@ void bptree_set_enabled(breakpoint* bp); gchar* bptree_get_condition(breakpoint* bp); void bptree_set_readonly(gboolean readonly); -void bptree_update_file_nodes(); +void bptree_update_file_nodes(void); + +#endif /* guard */
Modified: debugger/src/breakpoint.c 2 files changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -30,7 +30,7 @@ /* * create new empty breakpoint */ -breakpoint* break_new() +breakpoint* break_new(void) { breakpoint* bp = (breakpoint*)g_malloc(sizeof(breakpoint)); memset(bp, 0 , sizeof(breakpoint));
Modified: debugger/src/breakpoint.h 12 files changed, 10 insertions(+), 2 deletions(-) =================================================================== @@ -18,7 +18,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ - + +#ifndef BREAKPOINT_H +#define BREAKPOINT_H + +#include <glib.h> +#include <gtk/gtk.h> + /* maximum condition length */ #define CONDITION_MAX_LENGTH 1024
@@ -32,5 +38,7 @@ GtkTreeIter iter; } breakpoint;
-breakpoint* break_new(); +breakpoint* break_new(void); breakpoint* break_new_full(const char* file, int line, const char* condition, int enabled, int hitscount); + +#endif /* guard */
Modified: debugger/src/breakpoints.c 58 files changed, 34 insertions(+), 24 deletions(-) =================================================================== @@ -49,7 +49,7 @@ /* * Iterates through GTree for the particular file */ -gboolean tree_foreach_call_function(gpointer key, gpointer value, gpointer data) +static gboolean tree_foreach_call_function(gpointer key, gpointer value, gpointer data) { ((breaks_iterate_function)data)(value); return FALSE; @@ -58,7 +58,7 @@ gboolean tree_foreach_call_function(gpointer key, gpointer value, gpointer data) /* * Iterates through hash table of GTree-s */ -void hash_table_foreach_call_function(gpointer key, gpointer value, gpointer user_data) +static void hash_table_foreach_call_function(gpointer key, gpointer value, gpointer user_data) { g_tree_foreach((GTree*)value, tree_foreach_call_function, user_data); } @@ -67,7 +67,7 @@ void hash_table_foreach_call_function(gpointer key, gpointer value, gpointer use * Iterates through GTree * adding each item to GList that is passed through data variable */ -gboolean tree_foreach_add_to_list(gpointer key, gpointer value, gpointer data) +static gboolean tree_foreach_add_to_list(gpointer key, gpointer value, gpointer data) { GList **list = (GList**)data; *list = g_list_append(*list, value); @@ -78,7 +78,7 @@ gboolean tree_foreach_add_to_list(gpointer key, gpointer value, gpointer data) * Iterates through hash table of GTree-s * calling list collection functions on each tree */ -void hash_table_foreach_add_to_list(gpointer key, gpointer value, gpointer user_data) +static void hash_table_foreach_add_to_list(gpointer key, gpointer value, gpointer user_data) { g_tree_foreach((GTree*)value, tree_foreach_add_to_list, user_data); } @@ -96,12 +96,14 @@ static void on_add(breakpoint *bp) } static void on_remove(breakpoint *bp) { + GTree *tree; + /* remove marker */ markers_remove_breakpoint(bp); /* remove from breakpoints tab */ bptree_remove_breakpoint(bp); /* remove from internal storage */ - GTree *tree = g_hash_table_lookup(files, bp->file); + tree = g_hash_table_lookup(files, bp->file); g_tree_remove(tree, GINT_TO_POINTER(bp->line)); } static void on_set_hits_count(breakpoint *bp) @@ -168,7 +170,7 @@ static void on_remove_list(GList *list) * b - second integer * user_data - not used */ -gint compare_func(gconstpointer a, gconstpointer b, gpointer user_data) +static gint compare_func(gconstpointer a, gconstpointer b, gpointer user_data) { return GPOINTER_TO_INT(a) - GPOINTER_TO_INT(b); } @@ -330,7 +332,7 @@ gboolean breaks_init(move_to_line_cb cb) /* * Frees breaks related data. */ -void breaks_destroy() +void breaks_destroy(void) { /* remove all markers */ GList *breaks, *iter; @@ -360,17 +362,19 @@ void breaks_destroy() */ void breaks_add(const char* file, int line, char* condition, int enabled, int hitscount) { + GTree *tree; + breakpoint* bp; + enum dbs state = debug_get_state(); + /* do not process async break manipulation on modules that do not support async interuppt */ - enum dbs state = debug_get_state(); if (DBS_RUNNING == state && !debug_supports_async_breaks()) return; /* allocate memory */ - breakpoint* bp = break_new_full(file, line, condition, enabled, hitscount); + bp = break_new_full(file, line, condition, enabled, hitscount); /* check whether GTree for this file exists and create if doesn't */ - GTree *tree; if (!(tree = g_hash_table_lookup(files, bp->file))) { char *newfile = g_strdup(bp->file); @@ -402,14 +406,15 @@ void breaks_add(const char* file, int line, char* condition, int enabled, int hi */ void breaks_remove(const char* file, int line) { + breakpoint* bp = NULL; + enum dbs state = debug_get_state(); + /* do not process async break manipulation on modules that do not support async interuppt */ - enum dbs state = debug_get_state(); if (DBS_RUNNING == state && !debug_supports_async_breaks()) return;
/* lookup for breakpoint */ - breakpoint* bp = NULL; if (!(bp = breaks_lookup_breakpoint(file, line))) return;
@@ -458,7 +463,7 @@ void breaks_remove_list(GList *list) * Removes all breakpoints. * arguments: */ -void breaks_remove_all() +void breaks_remove_all(void) { g_hash_table_foreach(files, hash_table_foreach_call_function, (gpointer)on_remove); g_hash_table_remove_all(files); @@ -470,15 +475,17 @@ void breaks_remove_all() * file - list of breakpoints * enabled - anble or disable breakpoints */ -void breaks_set_enabled_for_file(const const char *file, gboolean enabled) +void breaks_set_enabled_for_file(const char *file, gboolean enabled) { + GList *breaks; + enum dbs state = debug_get_state(); + /* do not process async break manipulation on modules that do not support async interuppt */ - enum dbs state = debug_get_state(); if (DBS_RUNNING == state && !debug_supports_async_breaks()) return;
- GList *breaks = breaks_get_for_document(file); + breaks = breaks_get_for_document(file);
/* handle switching instantly if debugger is idle or stopped and request debug module interruption overwise */ @@ -502,14 +509,15 @@ void breaks_set_enabled_for_file(const const char *file, gboolean enabled) */ void breaks_switch(const char* file, int line) { + breakpoint* bp = NULL; + enum dbs state = debug_get_state(); + /* do not process async break manipulation on modules that do not support async interuppt */ - enum dbs state = debug_get_state(); if (DBS_RUNNING == state && !debug_supports_async_breaks()) return;
/* lookup for breakpoint */ - breakpoint* bp = NULL; if (!(bp = breaks_lookup_breakpoint(file, line))) return; @@ -538,14 +546,15 @@ void breaks_switch(const char* file, int line) */ void breaks_set_hits_count(const char* file, int line, int count) { + breakpoint* bp = NULL; + enum dbs state = debug_get_state(); + /* do not process async break manipulation on modules that do not support async interuppt */ - enum dbs state = debug_get_state(); if (DBS_RUNNING == state && !debug_supports_async_breaks()) return;
/* lookup for breakpoint */ - breakpoint* bp = NULL; if (!(bp = breaks_lookup_breakpoint(file, line))) return; @@ -574,14 +583,15 @@ void breaks_set_hits_count(const char* file, int line, int count) */ void breaks_set_condition(const char* file, int line, const char* condition) { + breakpoint* bp = NULL; + enum dbs state = debug_get_state(); + /* do not process async break manipulation on modules that do not support async interuppt */ - enum dbs state = debug_get_state(); if (DBS_RUNNING == state && !debug_supports_async_breaks()) return;
/* lookup for breakpoint */ - breakpoint* bp = NULL; if (!(bp = breaks_lookup_breakpoint(file, line))) return; @@ -637,9 +647,9 @@ void breaks_move_to_line(const char* file, int line_from, int line_to) break_state breaks_get_state(const char* file, int line) { break_state bs = BS_NOT_SET; + GTree *tree; /* first look for the tree for the given file */ - GTree *tree; if ( (tree = g_hash_table_lookup(files, file)) ) { breakpoint *bp = g_tree_lookup(tree, GINT_TO_POINTER(line)); @@ -688,7 +698,7 @@ breakpoint* breaks_lookup_breakpoint(const gchar* file, int line) * Gets all breakpoints * arguments: */ -GList* breaks_get_all() +GList* breaks_get_all(void) { GList *breaks = NULL; g_hash_table_foreach(files, hash_table_foreach_add_to_list, &breaks);
Modified: debugger/src/breakpoints.h 15 files changed, 11 insertions(+), 4 deletions(-) =================================================================== @@ -19,6 +19,11 @@ * MA 02110-1301, USA. */
+#ifndef BREAKPOINTS_H +#define BREAKPOINTS_H + +#include <glib.h> + #include "breakpoint.h"
typedef enum _break_state { @@ -31,17 +36,19 @@ typedef void (*select_frame_cb)(int frame_number);
gboolean breaks_init(move_to_line_cb callback); -void breaks_destroy(); +void breaks_destroy(void); void breaks_add(const char* file, int line, char* condition, int enable, int hitscount); void breaks_remove(const char* file, int line); void breaks_remove_list(GList *list); -void breaks_remove_all(); +void breaks_remove_all(void); void breaks_switch(const char *file, int line); void breaks_set_hits_count(const char *file, int line, int count); void breaks_set_condition(const char *file, int line, const char* condition); -void breaks_set_enabled_for_file(const const char *file, gboolean enabled); +void breaks_set_enabled_for_file(const char *file, gboolean enabled); void breaks_move_to_line(const char* file, int line_from, int line_to); break_state breaks_get_state(const char* file, int line); GList* breaks_get_for_document(const char* file); -GList* breaks_get_all(); +GList* breaks_get_all(void); breakpoint* breaks_lookup_breakpoint(const gchar* file, int line); + +#endif /* guard */
Modified: debugger/src/btnpanel.c 4 files changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -60,7 +60,7 @@ /* * calls settings dialog */ -void on_settings(GtkButton *button, gpointer user_data) +static void on_settings(GtkButton *button, gpointer user_data) { plugin_show_configure(geany_plugin); } @@ -68,7 +68,7 @@ void on_settings(GtkButton *button, gpointer user_data) /* * gets current file and line and calls debug function */ -void on_execute_until(GtkButton *button, gpointer user_data) +static void on_execute_until(GtkButton *button, gpointer user_data) { GeanyDocument *doc = document_get_current(); if (doc)
Modified: debugger/src/btnpanel.h 10 files changed, 10 insertions(+), 0 deletions(-) =================================================================== @@ -19,7 +19,17 @@ * MA 02110-1301, USA. */
+#ifndef BTNPANEL_H +#define BTNPANEL_H + +#include <glib.h> +#include <gtk/gtk.h> + +#include "debug_module.h" + typedef void (*on_toggle)(GtkToggleButton *button, gpointer user_data);
GtkWidget* btnpanel_create(on_toggle cb); void btnpanel_set_debug_state(enum dbs state); + +#endif /* guard */
Modified: debugger/src/callbacks.c 19 files changed, 12 insertions(+), 7 deletions(-) =================================================================== @@ -31,6 +31,7 @@ #endif #include <geanyplugin.h>
+#include "callbacks.h" #include "breakpoints.h" #include "debug.h" #include "keys.h" @@ -48,7 +49,7 @@ /* * Set breakpoint and stack markers for a file */ -void set_markers_for_file(const gchar* file) +static void set_markers_for_file(const gchar* file) { GList *breaks; if ( (breaks = breaks_get_for_document(file)) ) @@ -116,7 +117,6 @@ void on_document_before_save(GObject *obj, GeanyDocument *doc, gpointer user_dat /* * Occures on saving document */ -void on_document_open(GObject *obj, GeanyDocument *doc, gpointer user_data); void on_document_save(GObject *obj, GeanyDocument *doc, gpointer user_data) { if (_unexisting_file) @@ -187,13 +187,17 @@ gboolean on_editor_notify( { case SCN_MARGINCLICK: { + char* file; + int line; + break_state bs; + if (!editor->document->real_path || 1 != nt->margin) break; - char* file = editor->document->file_name; - int line = sci_get_line_from_position(editor->sci, nt->position) + 1; + file = editor->document->file_name; + line = sci_get_line_from_position(editor->sci, nt->position) + 1;
- break_state bs = breaks_get_state(file, line); + bs = breaks_get_state(file, line); if (BS_NOT_SET == bs) breaks_add(file, line, NULL, TRUE, 0); else if (BS_ENABLED == bs) @@ -207,12 +211,13 @@ gboolean on_editor_notify( } case SCN_DWELLSTART: { + GString *word; + if (DBS_STOPPED != debug_get_state ()) break;
/* get a word under the cursor */ - GString *word = get_word_at_position(editor->sci, nt->position); - + word = get_word_at_position(editor->sci, nt->position); if (word->len) { gchar *calltip = debug_get_calltip_for_expression(word->str);
Modified: debugger/src/callbacks.h 9 files changed, 9 insertions(+), 0 deletions(-) =================================================================== @@ -19,8 +19,17 @@ * MA 02110-1301, USA. */
+#ifndef CALLBACKS_H +#define CALLBACKS_H + +#include <glib.h> +#include <glib-object.h> +#include "geanyplugin.h" + void on_document_open(GObject *obj, GeanyDocument *doc, gpointer user_data); void on_document_save(GObject *obj, GeanyDocument *doc, gpointer user_data); void on_document_before_save(GObject *obj, GeanyDocument *doc, gpointer user_data); gboolean on_editor_notify(GObject *object, GeanyEditor *editor, SCNotification *nt, gpointer data); gboolean keys_callback(guint key_id); + +#endif /* guard */
Modified: debugger/src/calltip.h 11 files changed, 10 insertions(+), 1 deletions(-) =================================================================== @@ -18,8 +18,17 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ - + +#ifndef CALLTIP_H +#define CALLTIP_H + +#include <glib.h> + +#include "debug_module.h" + #define MAX_CALLTIP_LENGTH 140 #define MAX_CALLTIP_HEIGHT 20
GString* get_calltip_line(variable *var, gboolean firstline); + +#endif /* guard */
Modified: debugger/src/cell_renderers/cellrendererbreakicon.c 15 files changed, 10 insertions(+), 5 deletions(-) =================================================================== @@ -278,12 +278,12 @@ static gint cell_renderer_break_icon_activate(GtkCellRenderer *cell, GdkEvent *e */ static void cell_renderer_break_icon_init (CellRendererBreakIcon *cell) { + GtkCellRenderer *cell_renderer = (GtkCellRenderer*)cell; + cell->enabled = TRUE; cell->condition = NULL; cell->hitscount = 0; - GtkCellRenderer *cell_renderer = (GtkCellRenderer*)cell; - cell_renderer->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE;
cell->pixbuf_enabled = cell->pixbuf_disabled = cell->pixbuf_conditional = cell->pixbuf_file = 0; @@ -295,9 +295,14 @@ static void cell_renderer_break_icon_init (CellRendererBreakIcon *cell) static void cell_renderer_break_icon_finalize (GObject *object) { CellRendererBreakIcon *cell = (CellRendererBreakIcon*)object; - - GdkPixbuf *pixbufs[] = { cell->pixbuf_enabled, cell->pixbuf_disabled, cell->pixbuf_conditional, cell->pixbuf_file }; + GdkPixbuf *pixbufs[4]; int i; + + pixbufs[0] = cell->pixbuf_enabled; + pixbufs[1] = cell->pixbuf_disabled; + pixbufs[2] = cell->pixbuf_conditional; + pixbufs[3] = cell->pixbuf_file; + for(i = 0; i < 4; i++) { if (pixbufs[i]) @@ -449,7 +454,7 @@ GType cell_renderer_break_icon_get_type(void) /* * creates new renderer */ -GtkCellRenderer* cell_renderer_break_icon_new() +GtkCellRenderer* cell_renderer_break_icon_new(void) { return g_object_new(TYPE_CELL_RENDERER_BREAK_ICON, NULL); }
Modified: debugger/src/cell_renderers/cellrendererframeicon.c 13 files changed, 8 insertions(+), 5 deletions(-) =================================================================== @@ -222,10 +222,10 @@ static void cell_renderer_frame_icon_render(GtkCellRenderer *cell, GdkDrawable * */ static void cell_renderer_frame_icon_init (CellRendererFrameIcon *cell) { - cell->active_frame = FALSE; - GtkCellRenderer *cell_renderer = (GtkCellRenderer*)cell; + cell->active_frame = FALSE; + cell_renderer->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE;
cell->pixbuf_active = cell->pixbuf_highlighted = 0; @@ -237,9 +237,12 @@ static void cell_renderer_frame_icon_init (CellRendererFrameIcon *cell) static void cell_renderer_frame_icon_finalize (GObject *object) { CellRendererFrameIcon *cell = (CellRendererFrameIcon*)object; - - GdkPixbuf *pixbufs[] = { cell->pixbuf_active, cell->pixbuf_highlighted }; + GdkPixbuf *pixbufs[2]; int i; + + pixbufs[0] = cell->pixbuf_active; + pixbufs[1] = cell->pixbuf_highlighted; + for(i = 0; i < 2; i++) { if (pixbufs[i]) @@ -349,7 +352,7 @@ GType cell_renderer_frame_icon_get_type(void) /* * creates new renderer */ -GtkCellRenderer* cell_renderer_frame_icon_new() +GtkCellRenderer* cell_renderer_frame_icon_new(void) { return g_object_new(TYPE_CELL_RENDERER_FRAME_ICON, NULL); }
Modified: debugger/src/cell_renderers/cellrenderertoggle.c 2 files changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -100,7 +100,7 @@ GType cell_renderer_toggle_get_type(void) /* * creates new renderer */ -GtkCellRenderer* cell_renderer_toggle_new() +GtkCellRenderer* cell_renderer_toggle_new(void) { return g_object_new(TYPE_CELL_RENDERER_TOGGLE, NULL); }
Modified: debugger/src/dbm_gdb.c 370 files changed, 202 insertions(+), 168 deletions(-) =================================================================== @@ -122,16 +122,16 @@ enum sr { static int active_frame = 0;
/* forward declarations */ -void stop(); -variable* add_watch(gchar* expression); -void update_watches(); -void update_autos(); -void update_files(); +static void stop(void); +static variable* add_watch(gchar* expression); +static void update_watches(void); +static void update_autos(void); +static void update_files(void);
/* * print message using color, based on message type */ -void colorize_message(gchar *message) +static void colorize_message(gchar *message) { const gchar *color; if ('=' == *message) @@ -200,7 +200,7 @@ static void on_gdb_exit(GPid pid, gint status, gpointer data) /* * reads gdb_out until "(gdb)" prompt met */ -static GList* read_until_prompt() +static GList* read_until_prompt(void) { GList *lines = NULL;
@@ -221,7 +221,7 @@ static GList* read_until_prompt() /* * write a command to a gdb channel and flush with a newlinw character */ -void gdb_input_write_line(const gchar *line) +static void gdb_input_write_line(const gchar *line) { GIOStatus st; GError *err = NULL; @@ -302,7 +302,7 @@ static GList* add_to_queue(GList* queue, const gchar *message, const gchar *comm * reads from startup async commands. * looks for a command completion (normal or abnormal), if noraml - executes next command */ -void exec_async_command(const gchar* command); +static void exec_async_command(const gchar* command); static gboolean on_read_async_output(GIOChannel * src, GIOCondition cond, gpointer data) { gchar *line; @@ -317,13 +317,17 @@ static gboolean on_read_async_output(GIOChannel * src, GIOCondition cond, gpoint { /* got some result */
+ GList *lines; + GList *commands = (GList*)data; + gchar *coma; + g_source_remove(gdb_id_out);
- GList *lines = read_until_prompt(); + lines = read_until_prompt(); g_list_foreach(lines, (GFunc)g_free, NULL); g_list_free (lines);
- gchar* coma = strchr(line, ','); + coma = strchr(line, ','); if (coma) { *coma = '\0'; @@ -332,16 +336,16 @@ static gboolean on_read_async_output(GIOChannel * src, GIOCondition cond, gpoint else coma = line + strlen(line); - GList *commands = (GList*)data; - if (!strcmp(line, "^done")) { /* command completed succesfully - run next command if exists */ if (commands->next) { /* if there are commads left */ + queue_item *item; + commands = commands->next; - queue_item *item = (queue_item*)commands->data; + item = (queue_item*)commands->data;
/* send message to debugger messages window */ if (item->message) @@ -406,16 +410,17 @@ static gboolean on_read_async_output(GIOChannel * src, GIOCondition cond, gpoint * asyncronous gdb output reader * looks for a stopped event, then notifies "debug" module and removes async handler */ -enum dbs debug_get_state(); +enum dbs debug_get_state(void); static gboolean on_read_from_gdb(GIOChannel * src, GIOCondition cond, gpointer data) { gchar *line; gsize length; + gboolean prompt; if (G_IO_STATUS_NORMAL != g_io_channel_read_line(src, &line, NULL, &length, NULL)) return TRUE;
- gboolean prompt = !strcmp(line, GDB_PROMPT); + prompt = !strcmp(line, GDB_PROMPT); *(line + length) = '\0';
@@ -440,14 +445,18 @@ static gboolean on_read_from_gdb(GIOChannel * src, GIOCondition cond, gpointer d } else if (g_str_has_prefix(line, "=thread-created")) { + int thread_id; + *(strrchr(line, ',') - 1) = '\0'; - int thread_id = atoi(line + strlen("=thread-created,id="")); + thread_id = atoi(line + strlen("=thread-created,id="")); dbg_cbs->add_thread(thread_id); } else if (g_str_has_prefix(line, "=thread-exited")) { + int thread_id; + *(strrchr(line, ',') - 1) = '\0'; - int thread_id = atoi(line + strlen("=thread-exited,id="")); + thread_id = atoi(line + strlen("=thread-exited,id="")); dbg_cbs->remove_thread(thread_id); } else if (g_str_has_prefix(line, "=library-loaded") || g_str_has_prefix(line, "=library-unloaded")) @@ -470,14 +479,17 @@ static gboolean on_read_from_gdb(GIOChannel * src, GIOCondition cond, gpointer d dbg_cbs->set_run(); else if (!strcmp(line, "*stopped")) { + char *reason; + /* removing read callback (will pulling all output left manually) */ g_source_remove(gdb_id_out);
/* looking for a reason to stop */ - char *next = NULL; - char *reason = strstr(record, "reason=""); + reason = strstr(record, "reason=""); if (reason) { + char *next; + reason += strlen("reason=""); next = strstr(reason, """) + 1; *(next - 1) = '\0'; @@ -538,9 +550,12 @@ static gboolean on_read_from_gdb(GIOChannel * src, GIOCondition cond, gpointer d { if (stop_reason == SR_EXITED_WITH_CODE) { - gchar *code = strstr(reason + strlen(reason) + 1,"exit-code="") + strlen("exit-code=""); + gchar *code; + gchar *message; + + code = strstr(reason + strlen(reason) + 1,"exit-code="") + strlen("exit-code=""); *(strchr(code, '"')) = '\0'; - gchar *message = g_strdup_printf(_("Program exited with code "%i""), (int)(char)strtol(code, NULL, 8)); + message = g_strdup_printf(_("Program exited with code "%i""), (int)(char)strtol(code, NULL, 8)); dbg_cbs->report_error(message);
g_free(message); @@ -552,6 +567,9 @@ static gboolean on_read_from_gdb(GIOChannel * src, GIOCondition cond, gpointer d } else if (g_str_has_prefix (line, "^error")) { + GList *lines, *iter; + char *msg; + /* removing read callback (will pulling all output left manually) */ g_source_remove(gdb_id_out);
@@ -565,21 +583,18 @@ static gboolean on_read_from_gdb(GIOChannel * src, GIOCondition cond, gpointer d }
/* get message */ - char *msg = strstr(line, "msg="") + strlen("msg=""); + msg = strstr(line, "msg="") + strlen("msg=""); *strrchr(msg, '"') = '\0'; msg = g_strcompress(msg); /* reading until prompt */ - GList *lines = read_until_prompt(); - GList *iter = lines; - while(iter) + lines = read_until_prompt(); + for (iter = lines; iter; iter = iter->next) { gchar *l = (gchar*)iter->data; if (strcmp(l, GDB_PROMPT)) colorize_message(l); g_free(l); - - iter = iter->next; } g_list_free (lines);
@@ -600,7 +615,7 @@ static gboolean on_read_from_gdb(GIOChannel * src, GIOCondition cond, gpointer d * connects reader to output channel and exits * after execution */ -void exec_async_command(const gchar* command) +static void exec_async_command(const gchar* command) { #ifdef DEBUG_OUTPUT dbg_cbs->send_message(command, "red"); @@ -617,8 +632,10 @@ void exec_async_command(const gchar* command) * i.e. reading output right * after execution */ -result_class exec_sync_command(const gchar* command, gboolean wait4prompt, gchar** command_record) +static result_class exec_sync_command(const gchar* command, gboolean wait4prompt, gchar** command_record) { + GList *lines, *iter; + result_class rc;
#ifdef DEBUG_OUTPUT dbg_cbs->send_message(command, "red"); @@ -630,21 +647,18 @@ result_class exec_sync_command(const gchar* command, gboolean wait4prompt, gchar if (!wait4prompt) return RC_DONE; - GList *lines = read_until_prompt(); + lines = read_until_prompt();
#ifdef DEBUG_OUTPUT - GList *line = lines; - while (line) + for (iter = lines; iter; iter = iter->next) { - dbg_cbs->send_message((gchar*)line->data, "red"); - line = line->next; + dbg_cbs->send_message((gchar*)iter->data, "red"); } #endif
- result_class rc = RC_ERROR; - GList *iter = lines; + rc = RC_ERROR;
- while (iter) + for (iter = lines; iter; iter = iter->next) { gchar *line = (gchar*)iter->data;
@@ -683,9 +697,7 @@ result_class exec_sync_command(const gchar* command, gboolean wait4prompt, gchar { colorize_message (line); } - - iter = iter->next; - } + } g_list_foreach(lines, (GFunc)g_free, NULL); g_list_free(lines); @@ -696,16 +708,21 @@ result_class exec_sync_command(const gchar* command, gboolean wait4prompt, gchar /* * starts gdb, collects commands and start the first one */ -gboolean run(const gchar* file, const gchar* commandline, GList* env, GList *witer, GList *biter, const gchar* terminal_device, dbg_callbacks* callbacks) +static gboolean run(const gchar* file, const gchar* commandline, GList* env, GList *witer, GList *biter, const gchar* terminal_device, dbg_callbacks* callbacks) { GError *err = NULL; + const gchar *exclude[] = { "LANG", NULL }; + gchar **gdb_env = utils_copy_environment(exclude, "LANG", "C", NULL); + gchar *working_directory = g_path_get_dirname(file); + GList *lines, *iter; + GList *commands = NULL; + GString *command; + int bp_index; + queue_item *item;
dbg_cbs = callbacks;
/* spawn GDB */ - const gchar *exclude[] = { "LANG", NULL }; - gchar **gdb_env = utils_copy_environment(exclude, "LANG", "C", NULL); - gchar *working_directory = g_path_get_dirname(file); if (!g_spawn_async_with_pipes(working_directory, (gchar**)gdb_args, gdb_env, GDB_SPAWN_FLAGS, NULL, NULL, &gdb_pid, &gdb_in, &gdb_out, NULL, &err)) @@ -730,16 +747,14 @@ gboolean run(const gchar* file, const gchar* commandline, GList* env, GList *wit gdb_ch_out = g_io_channel_unix_new(gdb_out);
/* reading starting gdb messages */ - GList *lines = read_until_prompt(); - GList *line = lines; - while (line) + lines = read_until_prompt(); + for (iter = lines; iter; iter = iter->next) { - gchar *unescaped = g_strcompress((gchar*)line->data); + gchar *unescaped = g_strcompress((gchar*)iter->data); if (strlen(unescaped)) { - colorize_message((gchar*)line->data); + colorize_message((gchar*)iter->data); } - line = line->next; } g_list_foreach(lines, (GFunc)g_free, NULL); g_list_free(lines); @@ -756,10 +771,9 @@ gboolean run(const gchar* file, const gchar* commandline, GList* env, GList *wit }
/* collect commands */ - GList *commands = NULL;
/* loading file */ - GString *command = g_string_new(""); + command = g_string_new(""); g_string_printf(command, "-file-exec-and-symbols "%s"", file); commands = add_to_queue(commands, _("~"Loading target file.\n""), command->str, _("Error loading file"), FALSE); g_string_free(command, TRUE); @@ -786,14 +800,15 @@ gboolean run(const gchar* file, const gchar* commandline, GList* env, GList *wit g_string_free(command, TRUE);
/* set passed evironment */ - GList *iter = env; + iter = env; while (iter) { - gchar *name = (gchar*)iter->data; + gchar *name, *value; + + name = (gchar*)iter->data; iter = iter->next; - - gchar *value = (gchar*)iter->data; - + value = (gchar*)iter->data; + command = g_string_new(""); g_string_printf(command, "-gdb-set environment %s=%s", name, value);
@@ -804,14 +819,15 @@ gboolean run(const gchar* file, const gchar* commandline, GList* env, GList *wit }
/* set breaks */ - int bp_index = 1; + bp_index = 1; while (biter) { breakpoint *bp = (breakpoint*)biter->data; + GString *error_message = g_string_new(""); + command = g_string_new(""); g_string_printf(command, "-break-insert -f "\"%s\":%i"", bp->file, bp->line);
- GString *error_message = g_string_new(""); g_string_printf(error_message, _("Breakpoint at %s:%i cannot be set\nDebugger message: %s"), bp->file, bp->line, "%s"); commands = add_to_queue(commands, NULL, command->str, error_message->str, TRUE); @@ -855,7 +871,7 @@ gboolean run(const gchar* file, const gchar* commandline, GList* env, GList *wit /* connect read callback to the output chanel */ gdb_id_out = g_io_add_watch(gdb_ch_out, G_IO_IN, on_read_async_output, commands);
- queue_item *item = (queue_item*)commands->data; + item = (queue_item*)commands->data;
/* send message to debugger messages window */ if (item->message) @@ -872,7 +888,7 @@ gboolean run(const gchar* file, const gchar* commandline, GList* env, GList *wit /* * starts debugging */ -void restart(char* terminal_device) +static void restart(void) { dbg_cbs->clear_messages(); exec_async_command("-exec-run &"); @@ -881,7 +897,7 @@ void restart(char* terminal_device) /* * stops GDB */ -void stop() +static void stop(void) { exec_sync_command("-gdb-exit", FALSE, NULL); } @@ -889,7 +905,7 @@ void stop() /* * resumes GDB */ -void resume() +static void resume(void) { exec_async_command("-exec-continue"); } @@ -897,7 +913,7 @@ void resume() /* * step over */ -void step_over() +static void step_over(void) { exec_async_command("-exec-next"); } @@ -905,7 +921,7 @@ void step_over() /* * step into */ -void step_into() +static void step_into(void) { exec_async_command("-exec-step"); } @@ -913,7 +929,7 @@ void step_into() /* * step out */ -void step_out() +static void step_out(void) { exec_async_command("-exec-finish"); } @@ -921,7 +937,7 @@ void step_out() /* * execute until */ -void execute_until(const gchar *file, int line) +static void execute_until(const gchar *file, int line) { gchar command[1000]; sprintf(command, "-exec-until %s:%i", file, line); @@ -931,29 +947,34 @@ void execute_until(const gchar *file, int line) /* * gets breakpoint number by file and line */ -int get_break_number(char* file, int line) +static int get_break_number(char* file, int line) { - gchar* record; + gchar *record, *bstart; + exec_sync_command("-break-list", TRUE, &record); - - gchar* bstart = record; + bstart = record; + while ( (bstart = strstr(bstart, "bkpt=")) ) { + gchar *fname, *file_quoted; + int num, bline; + gboolean break_found; + bstart += strlen("bkpt={number=""); *strchr(bstart, '"') = '\0'; - int num = atoi(bstart); + num = atoi(bstart); bstart += strlen(bstart) + 1; bstart = strstr(bstart, "original-location="") + strlen("original-location=""); *strchr(bstart, ':') = '\0'; - gchar *fname = bstart; + fname = bstart; bstart += strlen(bstart) + 1; *strchr(bstart, '"') = '\0'; - int bline = atoi(bstart); + bline = atoi(bstart); - gchar *file_quoted = g_strdup_printf("\"%s\"", file); - int break_found = !strcmp(fname, file_quoted) && bline == line; + file_quoted = g_strdup_printf("\"%s\"", file); + break_found = !strcmp(fname, file_quoted) && bline == line; g_free(file_quoted);
if (break_found) @@ -972,14 +993,17 @@ int get_break_number(char* file, int line) /* * set breakpoint */ -gboolean set_break(breakpoint* bp, break_set_activity bsa) +static gboolean set_break(breakpoint* bp, break_set_activity bsa) { char command[1000]; if (BSA_NEW_BREAK == bsa) { /* new breakpoint */ + + char *pos; + int number; gchar *record = NULL; - + /* 1. insert breakpoint */ sprintf (command, "-break-insert "\"%s\":%i"", bp->file, bp->line); if (RC_DONE != exec_sync_command(command, TRUE, &record)) @@ -993,9 +1017,9 @@ gboolean set_break(breakpoint* bp, break_set_activity bsa) } } /* lookup break-number */ - char *pos = strstr(record, "number="") + strlen("number=""); + pos = strstr(record, "number="") + strlen("number=""); *strchr(pos, '"') = '\0'; - int number = atoi(pos); + number = atoi(pos); g_free(record); /* 2. set hits count if differs from 0 */ if (bp->hitscount) @@ -1042,15 +1066,17 @@ gboolean set_break(breakpoint* bp, break_set_activity bsa) /* * removes breakpoint */ -gboolean remove_break(breakpoint* bp) +static gboolean remove_break(breakpoint* bp) { /* find break number */ int number = get_break_number(bp->file, bp->line); if (-1 != number) { + result_class rc; gchar command[100]; + sprintf(command, "-break-delete %i", number); - result_class rc = exec_sync_command(command, TRUE, NULL); + rc = exec_sync_command(command, TRUE, NULL); return RC_DONE == rc; } @@ -1060,7 +1086,7 @@ gboolean remove_break(breakpoint* bp) /* * get active frame */ -int get_active_frame() +static int get_active_frame(void) { return active_frame; } @@ -1068,7 +1094,7 @@ int get_active_frame() /* * select frame */ -void set_active_frame(int frame_number) +static void set_active_frame(int frame_number) { gchar *command = g_strdup_printf("-stack-select-frame %i", frame_number); if (RC_DONE == exec_sync_command(command, TRUE, NULL)) @@ -1083,23 +1109,27 @@ void set_active_frame(int frame_number) /* * gets stack */ -GList* get_stack() +static GList* get_stack(void) { gchar* record = NULL; - result_class rc = exec_sync_command("-stack-list-frames", TRUE, &record); + GList *stack = NULL; + gchar **frames, **next; + result_class rc; + + rc = exec_sync_command("-stack-list-frames", TRUE, &record); if (RC_DONE != rc) return NULL; - - GList *stack = NULL;
- gchar **frames = g_strsplit(record, "frame=", 0); - gchar **next = frames + 1; + frames = g_strsplit(record, "frame=", 0); + next = frames + 1; while (*next) { frame *f = frame_new(); + int line; + gchar *pos, *fullname, *file, *from; /* adresss */ - gchar* pos = strstr(*next, "addr="") + strlen("addr=""); + pos = strstr(*next, "addr="") + strlen("addr=""); *strchr(pos, '"') = '\0'; f->address = g_strdup(pos); pos += strlen(pos) + 1; @@ -1111,9 +1141,9 @@ GList* get_stack() pos += strlen(pos) + 1;
/* file: fullname | file | from */ - char* fullname = strstr(pos, "fullname=""); - char* file = strstr(pos, "file=""); - char* from = strstr(pos, "from=""); + fullname = strstr(pos, "fullname=""); + file = strstr(pos, "file=""); + from = strstr(pos, "from=""); if (fullname) { @@ -1148,7 +1178,7 @@ GList* get_stack() f->have_source = fullname ? TRUE : FALSE;
/* line */ - int line = 0; + line = 0; pos = strstr(pos, "line=""); if (pos) { @@ -1174,13 +1204,16 @@ GList* get_stack() * unescapes hex values (\0xXXX) to readable chars * converting it from wide character value to char */ -gchar* unescape_hex_values(gchar *src) +static gchar* unescape_hex_values(gchar *src) { GString *dest = g_string_new(""); gchar *slash; while ( (slash = strstr(src, "\x")) ) { + char hex[4] = { 0, 0, 0, '\0' }; + wchar_t wc; + /* append what has been missed unescaping it in advance */ if (slash - src) @@ -1192,10 +1225,9 @@ gchar* unescape_hex_values(gchar *src) g_free(unescaped); }
- char hex[4] = { 0, 0, 0, '\0' }; strncpy(hex, slash + 2, 3); - wchar_t wc = (wchar_t)strtol(hex, NULL, 16); - + wc = (wchar_t)strtol(hex, NULL, 16); + if (iswalpha(wc)) { gchar mb[5]; @@ -1223,7 +1255,7 @@ gchar* unescape_hex_values(gchar *src) * checks if pc pointer points to the * valid printable charater */ -gboolean isvalidcharacter(gchar *pc, gboolean utf8) +static gboolean isvalidcharacter(gchar *pc, gboolean utf8) { if (utf8) return -1 != g_utf8_get_char_validated(pc, -1); @@ -1234,7 +1266,7 @@ gboolean isvalidcharacter(gchar *pc, gboolean utf8) /* * unescapes string, handles octal characters representations */ -gchar* unescape_octal_values(gchar *text) +static gchar* unescape_octal_values(gchar *text) { GString *value = g_string_new(""); @@ -1285,7 +1317,7 @@ gchar* unescape_octal_values(gchar *text) /* * unescapes value string, handles hexidecimal and octal characters representations */ -gchar *unescape(gchar *text) +static gchar *unescape(gchar *text) { gchar *retval = NULL;
@@ -1310,7 +1342,7 @@ gchar *unescape(gchar *text) /* * updates variables from vars list */ -void get_variables (GList *vars) +static void get_variables (GList *vars) { while (vars) { @@ -1321,13 +1353,16 @@ void get_variables (GList *vars) gchar *varname = var->internal->str; gchar *record = NULL; gchar *pos; + gchar *expression; + int numchild; + gchar *value;
/* path expression */ sprintf(command, "-var-info-path-expression "%s"", varname); exec_sync_command(command, TRUE, &record); pos = strstr(record, "path_expr="") + strlen("path_expr=""); *(strrchr(pos, '"')) = '\0'; - gchar *expression = unescape(pos); + expression = unescape(pos); g_string_assign(var->expression, expression); g_free(expression); g_free(record); @@ -1337,7 +1372,7 @@ void get_variables (GList *vars) exec_sync_command(command, TRUE, &record); pos = strstr(record, "numchild="") + strlen("numchild=""); *(strchr(pos, '"')) = '\0'; - int numchild = atoi(pos); + numchild = atoi(pos); var->has_children = numchild > 0; g_free(record);
@@ -1354,7 +1389,7 @@ void get_variables (GList *vars) } pos += + strlen("value=""); *(strrchr(pos, '"')) = '\0'; - gchar *value = unescape(pos); + value = unescape(pos); g_string_assign(var->value, value); g_free(value); g_free(record); @@ -1374,8 +1409,12 @@ void get_variables (GList *vars) /* * updates files list */ -void update_files() +static void update_files(void) { + GHashTable *ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); + gchar *record = NULL; + gchar *pos; + if (files) { /* free previous list */ @@ -1384,11 +1423,8 @@ void update_files() files = NULL; }
- GHashTable *ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); - - gchar *record = NULL; exec_sync_command("-file-list-exec-source-files", TRUE, &record); - gchar *pos = record; + pos = record; while ( (pos = strstr(pos, "fullname="")) ) { pos += strlen("fullname=""); @@ -1409,13 +1445,14 @@ void update_files() /* * updates watches list */ -void update_watches() +static void update_watches(void) { gchar command[1000]; + GList *updating = NULL; + GList *iter;
/* delete all GDB variables */ - GList *iter = watches; - while (iter) + for (iter = watches; iter; iter = iter->next) { variable *var = (variable*)iter->data; @@ -1427,22 +1464,19 @@ void update_watches() /* reset all variables fields */ variable_reset(var); - - iter = iter->next; } /* create GDB variables, adding successfully created variables to the list then passed for updatind */ - GList *updating = NULL; - iter = watches; - while (iter) + for (iter = watches; iter; iter = iter->next) { variable *var = (variable*)iter->data; - - /* try to create variable */ - gchar *record = NULL; + gchar *record = NULL; + gchar *pos; + gchar *escaped;
- gchar *escaped = g_strescape(var->name->str, NULL); + /* try to create variable */ + escaped = g_strescape(var->name->str, NULL); sprintf(command, "-var-create - * "%s"", escaped); g_free(escaped);
@@ -1451,14 +1485,13 @@ void update_watches() /* do not include to updating list, move to next watch */ var->evaluated = FALSE; g_string_assign(var->internal, ""); - g_free(record); - iter = iter->next; + g_free(record); continue; } /* find and assign internal name */ - gchar *pos = strstr(record, "name="") + strlen("name=""); + pos = strstr(record, "name="") + strlen("name=""); *strchr(pos, '"') = '\0'; g_string_assign(var->internal, pos); g_free(record); @@ -1467,8 +1500,6 @@ void update_watches()
/* add to updating list */ updating = g_list_append(updating, var); - - iter = iter->next; } /* update watches */ @@ -1481,20 +1512,20 @@ void update_watches() /* * updates autos list */ -void update_autos() +static void update_autos(void) { gchar command[1000]; + GList *unevaluated = NULL, *iter; + const char *gdb_commands[2]; + int i;
/* remove all previous GDB variables for autos */ - GList *iter = autos; - while (iter) + for (iter = autos; iter; iter = iter->next) { variable *var = (variable*)iter->data; sprintf(command, "-var-delete %s", var->internal->str); exec_sync_command(command, TRUE, NULL); - - iter = iter->next; }
g_list_foreach(autos, (GFunc)variable_free, NULL); @@ -1502,29 +1533,30 @@ void update_autos() autos = NULL; /* add current autos to the list */ - GList *unevaluated = NULL; - const char *gdb_commands[] = { g_strdup_printf("-stack-list-arguments 0 %i %i", active_frame, active_frame), "-stack-list-locals 0" }; - int i, size = sizeof (gdb_commands) / sizeof(char*); - for (i = 0; i < size; i++) + gdb_commands[0] = g_strdup_printf("-stack-list-arguments 0 %i %i", active_frame, active_frame); + gdb_commands[1] = "-stack-list-locals 0"; + for (i = 0; i < sizeof (gdb_commands) / sizeof(*gdb_commands); i++) { - gchar *record = NULL; + gchar *record = NULL, *pos; + result_class rc = exec_sync_command(gdb_commands[i], TRUE, &record); if (RC_DONE != rc) break;
- gchar *pos = record; + pos = record; while ((pos = strstr(pos, "name=""))) { + variable *var; + gchar *create_record = NULL, *escaped; + pos += strlen("name=""); *(strchr(pos, '"')) = '\0';
- variable *var = variable_new(pos, i ? VT_LOCAL : VT_ARGUMENT); + var = variable_new(pos, i ? VT_LOCAL : VT_ARGUMENT);
/* create new gdb variable */ - gchar *create_record = NULL; - - gchar *escaped = g_strescape(pos, NULL); + escaped = g_strescape(pos, NULL); sprintf(command, "-var-create - * "%s"", escaped); g_free(escaped);
@@ -1562,7 +1594,7 @@ void update_autos() /* * get autos list */ -GList* get_autos () +static GList* get_autos (void) { return g_list_copy(autos); } @@ -1570,7 +1602,7 @@ GList* get_autos () /* * get watches list */ -GList* get_watches () +static GList* get_watches (void) { return g_list_copy(watches); } @@ -1578,7 +1610,7 @@ GList* get_watches () /* * get files list */ -GList* get_files () +static GList* get_files (void) { return g_list_copy(files); } @@ -1586,7 +1618,7 @@ GList* get_files () /* * get list of children */ -GList* get_children (gchar* path) +static GList* get_children (gchar* path) { GList *children = NULL; @@ -1594,6 +1626,7 @@ GList* get_children (gchar* path) result_class rc; gchar *record = NULL; gchar *pos = NULL; + int numchild;
/* children number */ sprintf(command, "-var-info-num-children "%s"", path); @@ -1602,7 +1635,7 @@ GList* get_children (gchar* path) return NULL; pos = strstr(record, "numchild="") + strlen("numchild=""); *(strchr(pos, '"')) = '\0'; - int numchild = atoi(pos); + numchild = atoi(pos); g_free(record); if (!numchild) return NULL; @@ -1616,6 +1649,7 @@ GList* get_children (gchar* path) while ( (pos = strstr(pos, "child={")) ) { gchar *name, *internal; + variable *var; /* name */ pos = strstr(pos, "name="") + strlen("name=""); @@ -1629,7 +1663,7 @@ GList* get_children (gchar* path) name = g_strcompress(pos); - variable *var = variable_new2(name, internal, VT_CHILD); + var = variable_new2(name, internal, VT_CHILD); var->evaluated = TRUE; pos += strlen(pos) + 1; @@ -1649,17 +1683,17 @@ GList* get_children (gchar* path) /* * add new watch */ -variable* add_watch(gchar* expression) +static variable* add_watch(gchar* expression) { gchar command[1000]; - + gchar *record = NULL, *escaped, *pos; + GList *vars = NULL; variable *var = variable_new(expression, VT_WATCH); + watches = g_list_append(watches, var);
/* try to create a variable */ - gchar *record = NULL; - - gchar *escaped = g_strescape(expression, NULL); + escaped = g_strescape(expression, NULL); sprintf(command, "-var-create - * "%s"", escaped); g_free(escaped);
@@ -1669,12 +1703,12 @@ variable* add_watch(gchar* expression) return var; } - gchar *pos = strstr(record, "name="") + strlen("name=""); + pos = strstr(record, "name="") + strlen("name=""); *strchr(pos, '"') = '\0'; g_string_assign(var->internal, pos); var->evaluated = TRUE;
- GList *vars = g_list_append(NULL, var); + vars = g_list_append(NULL, var); get_variables(vars);
g_free(record); @@ -1686,7 +1720,7 @@ variable* add_watch(gchar* expression) /* * remove watch */ -void remove_watch(gchar* internal) +static void remove_watch(gchar* internal) { GList *iter = watches; while (iter) @@ -1707,13 +1741,14 @@ void remove_watch(gchar* internal) /* * evaluates given expression and returns the result */ -gchar *evaluate_expression(gchar *expression) +static gchar *evaluate_expression(gchar *expression) { - gchar *record = NULL; - + gchar *record = NULL, *pos; char command[1000]; + result_class rc; + sprintf (command, "-data-evaluate-expression "%s"", expression); - result_class rc = exec_sync_command(command, TRUE, &record); + rc = exec_sync_command(command, TRUE, &record); if (RC_DONE != rc) { @@ -1721,17 +1756,16 @@ gchar *evaluate_expression(gchar *expression) return NULL; }
- gchar *pos = strstr(record, "value="") + strlen("value=""); + pos = strstr(record, "value="") + strlen("value=""); *(strrchr(pos, '"')) = '\0'; - gchar *retval = unescape(pos); - - return retval; + + return unescape(pos); }
/* * request GDB interrupt */ -gboolean request_interrupt() +static gboolean request_interrupt(void) { #ifdef DEBUG_OUTPUT char msg[1000]; @@ -1748,7 +1782,7 @@ gboolean request_interrupt() /* * get GDB error messages */ -gchar* error_message() +static gchar* error_message(void) { return err_message; }
Modified: debugger/src/dconfig.c 146 files changed, 77 insertions(+), 69 deletions(-) =================================================================== @@ -79,20 +79,16 @@ /* * creates a copy of a specified keyfile */ -GKeyFile *create_copy_keyfile(GKeyFile *keyfile) +static GKeyFile *create_copy_keyfile(GKeyFile *keyfile) { - gchar *path; - close(g_file_open_tmp(NULL, &path, NULL)); - - gchar *config_data = g_key_file_to_data(keyfile, NULL, NULL); - g_file_set_contents(path, config_data, -1, NULL); - g_free(config_data); - - GKeyFile *copy = g_key_file_new(); - g_key_file_load_from_file(copy, path, G_KEY_FILE_NONE, NULL); + GKeyFile *copy; + gchar *data; + gsize length;
- g_remove(path); - g_free(path); + data = g_key_file_to_data(keyfile, &length, NULL); + copy = g_key_file_new(); + g_key_file_load_from_data(copy, data, length, G_KEY_FILE_NONE, NULL); + g_free(data);
return copy; } @@ -100,11 +96,13 @@ GKeyFile *create_copy_keyfile(GKeyFile *keyfile) /* * loads debug session from a keyfile and updates GUI */ -void debug_load_from_keyfile(GKeyFile *keyfile) +static void debug_load_from_keyfile(GKeyFile *keyfile) { + gchar *value; + int i, count; + debug_config_loading = TRUE; - gchar *value; /* target */ tpage_set_target(value = g_key_file_get_string(keyfile, DEBUGGER_GROUP, "target", NULL)); g_free(value); @@ -115,16 +113,14 @@ void debug_load_from_keyfile(GKeyFile *keyfile) tpage_set_commandline(value = g_key_file_get_string(keyfile, DEBUGGER_GROUP, "arguments", NULL)); g_free(value);
- int i; - /* environment */ - int envcount = g_key_file_get_integer(keyfile, DEBUGGER_GROUP, "envvar_count", NULL); - for (i = 0; i < envcount; i++) + count = g_key_file_get_integer(keyfile, DEBUGGER_GROUP, "envvar_count", NULL); + for (i = 0; i < count; i++) { gchar *env_name_id = g_strdup_printf("envvar_%i_name", i); gchar *env_value_id = g_strdup_printf("envvar_%i_value", i); - gchar *name = g_key_file_get_string(keyfile, DEBUGGER_GROUP, env_name_id, NULL); + value = g_key_file_get_string(keyfile, DEBUGGER_GROUP, env_value_id, NULL);
tpage_add_environment(name, value); @@ -137,8 +133,8 @@ void debug_load_from_keyfile(GKeyFile *keyfile) }
/* watches */ - int wcount = g_key_file_get_integer(keyfile, DEBUGGER_GROUP, "watches_count", NULL); - for (i = 0; i < wcount; i++) + count = g_key_file_get_integer(keyfile, DEBUGGER_GROUP, "watches_count", NULL); + for (i = 0; i < count; i++) { gchar *watch_id = g_strdup_printf("watch_%i", i); wtree_add_watch(value = g_key_file_get_string(keyfile, DEBUGGER_GROUP, watch_id, NULL)); @@ -147,8 +143,8 @@ void debug_load_from_keyfile(GKeyFile *keyfile) }
/* breakpoints */ - int bcount = g_key_file_get_integer(keyfile, DEBUGGER_GROUP, "breaks_count", NULL); - for (i = 0; i < bcount; i++) + count = g_key_file_get_integer(keyfile, DEBUGGER_GROUP, "breaks_count", NULL); + for (i = 0; i < count; i++) { gchar *break_file_id = g_strdup_printf("break_%i_file", i); gchar *break_line_id = g_strdup_printf("break_%i_line", i); @@ -181,8 +177,11 @@ void debug_load_from_keyfile(GKeyFile *keyfile) /* * saves debug session to a keyfile using values from GUI */ -void save_to_keyfile(GKeyFile *keyfile) +static void save_to_keyfile(GKeyFile *keyfile) { + GList *_env, *watches, *_breaks, *iter; + int env_index, watch_index, bp_index; + g_key_file_remove_group(keyfile, DEBUGGER_GROUP, NULL); g_key_file_set_string(keyfile, DEBUGGER_GROUP, "target", tpage_get_target()); @@ -190,19 +189,20 @@ void save_to_keyfile(GKeyFile *keyfile) g_key_file_set_string(keyfile, DEBUGGER_GROUP, "arguments", tpage_get_commandline()); /* environment */ - GList *_env = tpage_get_environment(); + _env = tpage_get_environment(); g_key_file_set_integer(keyfile, DEBUGGER_GROUP, "envvar_count", g_list_length(_env) / 2); - GList *iter = _env; - int env_index = 0; + iter = _env; + env_index = 0; while(iter) { - gchar *name = (gchar*)iter->data; - iter = iter->next; - gchar *value = (gchar*)iter->data; - + gchar *name, *value; gchar *env_name_id = g_strdup_printf("envvar_%i_name", env_index); gchar *env_value_id = g_strdup_printf("envvar_%i_value", env_index); - + + name = (gchar*)iter->data; + iter = iter->next; + value = (gchar*)iter->data; + g_key_file_set_string(keyfile, DEBUGGER_GROUP, env_name_id, name); g_key_file_set_string(keyfile, DEBUGGER_GROUP, env_value_id, value);
@@ -216,13 +216,12 @@ void save_to_keyfile(GKeyFile *keyfile) g_list_free(_env); /* watches */ - GList *watches = wtree_get_watches(); + watches = wtree_get_watches(); g_key_file_set_integer(keyfile, DEBUGGER_GROUP, "watches_count", g_list_length(watches)); - int watch_index = 0; - GList *biter = watches; - while (biter) + watch_index = 0; + for (iter = watches; iter; iter = iter->next) { - gchar *watch = (gchar*)biter->data; + gchar *watch = (gchar*)iter->data; gchar *watch_id = g_strdup_printf("watch_%i", watch_index); g_key_file_set_string(keyfile, DEBUGGER_GROUP, watch_id, watch); @@ -230,19 +229,17 @@ void save_to_keyfile(GKeyFile *keyfile) g_free(watch_id);
watch_index++; - biter = biter->next; } g_list_foreach(watches, (GFunc)g_free, NULL); g_list_free(watches);
/* breakpoints */ - GList *_breaks = breaks_get_all(); + _breaks = breaks_get_all(); g_key_file_set_integer(keyfile, DEBUGGER_GROUP, "breaks_count", g_list_length(_breaks)); - int bp_index = 0; - biter = _breaks; - while (biter) + bp_index = 0; + for (iter = _breaks; iter; iter = iter->next) { - breakpoint *bp = (breakpoint*)biter->data; + breakpoint *bp = (breakpoint*)iter->data; gchar *break_file_id = g_strdup_printf("break_%i_file", bp_index); gchar *break_line_id = g_strdup_printf("break_%i_line", bp_index); @@ -261,9 +258,8 @@ void save_to_keyfile(GKeyFile *keyfile) g_free(break_condition_id); g_free(break_hits_id); g_free(break_enabled_id); - + bp_index++; - biter = biter->next; } g_list_free(_breaks); } @@ -284,6 +280,8 @@ static gpointer saving_thread_func(gpointer data) (debug_config_changed && DEBUG_STORE_PLUGIN == dstore) ) { + gchar *config_data; + /* if all saving is going to be done to a plugin keyfile */ if (debug_config_changed) { @@ -291,7 +289,7 @@ static gpointer saving_thread_func(gpointer data) debug_config_changed = FALSE; } - gchar *config_data = g_key_file_to_data(keyfile_plugin, NULL, NULL); + config_data = g_key_file_to_data(keyfile_plugin, NULL, NULL); g_file_set_contents(plugin_config_path, config_data, -1, NULL); g_free(config_data);
@@ -300,10 +298,12 @@ static gpointer saving_thread_func(gpointer data) if (debug_config_changed && DEBUG_STORE_PROJECT == dstore) { + gchar *config_data; + /* if debug is saved into a project and has been changed */ save_to_keyfile(keyfile_project);
- gchar *config_data = g_key_file_to_data(keyfile_project, NULL, NULL); + config_data = g_key_file_to_data(keyfile_project, NULL, NULL); g_file_set_contents(geany_data->app->project->file_name, config_data, -1, NULL); g_free(config_data); @@ -324,7 +324,7 @@ static gpointer saving_thread_func(gpointer data) /* * set "debug changed" flag to save it on "saving_thread" thread */ -void config_set_debug_changed() +void config_set_debug_changed(void) { if (!debug_config_loading) { @@ -339,9 +339,10 @@ void config_set_debug_changed() */ void config_set_panel(int config_part, gpointer config_value, ...) { + va_list ap; + g_mutex_lock(change_config_mutex); - va_list ap; va_start(ap, config_value); while(config_part) @@ -402,7 +403,7 @@ void config_set_panel(int config_part, gpointer config_value, ...) /* * set default debug session values to a keyfile */ -void config_set_debug_defaults(GKeyFile *keyfile) +static void config_set_debug_defaults(GKeyFile *keyfile) { g_key_file_set_string(keyfile, DEBUGGER_GROUP, "target", ""); g_key_file_set_string(keyfile, DEBUGGER_GROUP, "debugger", ""); @@ -416,18 +417,20 @@ void config_set_debug_defaults(GKeyFile *keyfile) /* * set default panel config values in a GKeyFile */ -void config_set_panel_defaults(GKeyFile *keyfile) +static void config_set_panel_defaults(GKeyFile *keyfile) { - g_key_file_set_boolean(keyfile_plugin, "tabbed_mode", "enabled", FALSE); - int all_tabs[] = { TID_TARGET, TID_BREAKS, TID_AUTOS, TID_WATCH, TID_STACK, TID_TERMINAL, TID_MESSAGES }; + int left_tabs[] = { TID_TARGET, TID_BREAKS, TID_AUTOS, TID_WATCH }; + int right_tabs[] = { TID_STACK, TID_TERMINAL, TID_MESSAGES }; + + g_key_file_set_boolean(keyfile_plugin, "tabbed_mode", "enabled", FALSE); + /* all tabs */ g_key_file_set_integer_list(keyfile, "one_panel_mode", "tabs", all_tabs, sizeof(all_tabs) / sizeof(int)); g_key_file_set_integer(keyfile, "one_panel_mode", "selected_tab_index", 0); - - int left_tabs[] = { TID_TARGET, TID_BREAKS, TID_AUTOS, TID_WATCH }; + /* left tabs */ g_key_file_set_integer_list(keyfile, "two_panels_mode", "left_tabs", left_tabs, sizeof(left_tabs) / sizeof(int)); g_key_file_set_integer(keyfile, "two_panels_mode", "left_selected_tab_index", 0); - int right_tabs[] = { TID_STACK, TID_TERMINAL, TID_MESSAGES }; + /* right tabs */ g_key_file_set_integer_list(keyfile, "two_panels_mode", "right_tabs", right_tabs, sizeof(right_tabs) / sizeof(int)); g_key_file_set_integer(keyfile, "two_panels_mode", "right_selected_tab_index", 0);
@@ -437,7 +440,7 @@ void config_set_panel_defaults(GKeyFile *keyfile) /* * initialize */ -void config_init() +void config_init(void) { /* read config */ gchar *config_dir = g_build_path(G_DIR_SEPARATOR_S, geany_data->app->configdir, "plugins", "debugger", NULL); @@ -449,8 +452,10 @@ void config_init() keyfile_plugin = g_key_file_new(); if (!g_key_file_load_from_file(keyfile_plugin, plugin_config_path, G_KEY_FILE_NONE, NULL)) { + gchar *data; + config_set_panel_defaults(keyfile_plugin); - gchar *data = g_key_file_to_data(keyfile_plugin, NULL, NULL); + data = g_key_file_to_data(keyfile_plugin, NULL, NULL); g_file_set_contents(plugin_config_path, data, -1, NULL); g_free(data); } @@ -463,7 +468,7 @@ void config_init() /* * destroy */ -void config_destroy() +void config_destroy(void) { g_cond_signal(cond); /* ??? g_thread_join(saving_thread); */ @@ -484,12 +489,12 @@ void config_destroy() * config parts getters */ /* saving option */ -gboolean config_get_save_to_project() +gboolean config_get_save_to_project(void) { return g_key_file_get_boolean(keyfile_plugin, "saving_settings", "save_to_project", NULL); } /* panel config */ -gboolean config_get_tabbed() +gboolean config_get_tabbed(void) { return g_key_file_get_boolean(keyfile_plugin, "tabbed_mode", "enabled", NULL); } @@ -497,7 +502,7 @@ int* config_get_tabs(gsize *length) { return g_key_file_get_integer_list(keyfile_plugin, "one_panel_mode", "tabs", length, NULL); } -int config_get_selected_tab_index() +int config_get_selected_tab_index(void) { return g_key_file_get_integer(keyfile_plugin, "one_panel_mode", "selected_tab_index", NULL); } @@ -505,7 +510,7 @@ int* config_get_left_tabs(gsize *length) { return g_key_file_get_integer_list(keyfile_plugin, "two_panels_mode", "left_tabs", length, NULL); } -int config_get_left_selected_tab_index() +int config_get_left_selected_tab_index(void) { return g_key_file_get_integer(keyfile_plugin, "two_panels_mode", "left_selected_tab_index", NULL); } @@ -513,7 +518,7 @@ int* config_get_right_tabs(gsize *length) { return g_key_file_get_integer_list(keyfile_plugin, "two_panels_mode", "right_tabs", length, NULL); } -int config_get_right_selected_tab_index() +int config_get_right_selected_tab_index(void) { return g_key_file_get_integer(keyfile_plugin, "two_panels_mode", "right_selected_tab_index", NULL); } @@ -524,20 +529,23 @@ int config_get_right_selected_tab_index() */ void config_set_debug_store(debug_store store) { + GKeyFile *keyfile; + dstore = store;
tpage_clear(); wtree_remove_all(); breaks_remove_all();
- GKeyFile *keyfile = DEBUG_STORE_PROJECT == dstore ? keyfile_project : keyfile_plugin; - + keyfile = DEBUG_STORE_PROJECT == dstore ? keyfile_project : keyfile_plugin; if (!g_key_file_has_group(keyfile, DEBUGGER_GROUP)) { + gchar *data, *file; + config_set_debug_defaults(keyfile); - gchar *data = g_key_file_to_data(keyfile, NULL, NULL); + data = g_key_file_to_data(keyfile, NULL, NULL);
- gchar *file = DEBUG_STORE_PROJECT == dstore ? geany_data->app->project->file_name : plugin_config_path; + file = DEBUG_STORE_PROJECT == dstore ? geany_data->app->project->file_name : plugin_config_path; g_file_set_contents(file, data, -1, NULL);
g_free(data); @@ -549,7 +557,7 @@ void config_set_debug_store(debug_store store) /* * updates keyfile_project from a current geany project path */ -void config_update_project_keyfile() +void config_update_project_keyfile(void) { if (keyfile_project) {
Modified: debugger/src/dconfig.h 25 files changed, 16 insertions(+), 9 deletions(-) =================================================================== @@ -19,7 +19,12 @@ * MA 02110-1301, USA. */
+#ifndef DCOFIG_H +#define DCOFIG_H + #include <stdarg.h> +#include <glib.h> +#include <gtk/gtk.h>
/* panel config parts */ #define CP_TABBED_MODE 1 @@ -37,31 +42,33 @@ } debug_store;
-void config_init(); -void config_destroy(); +void config_init(void); +void config_destroy(void);
void config_set_panel(int config_part, gpointer config_value, ...);
-gboolean config_get_save_to_project(); +gboolean config_get_save_to_project(void);
-gboolean config_get_tabbed(); +gboolean config_get_tabbed(void);
int* config_get_tabs(gsize *length); -int config_get_selected_tab_index(); +int config_get_selected_tab_index(void);
int* config_get_left_tabs(gsize *length); -int config_get_left_selected_tab_index(); +int config_get_left_selected_tab_index(void);
int* config_get_right_tabs(gsize *length); -int config_get_right_selected_tab_index(); +int config_get_right_selected_tab_index(void);
-void config_set_debug_changed(); +void config_set_debug_changed(void); void config_set_debug_store(debug_store store);
void config_on_project_open(GObject *obj, GKeyFile *config, gpointer user_data); void config_on_project_close(GObject *obj, gpointer user_data); void config_on_project_save(GObject *obj, GKeyFile *config, gpointer user_data);
-void config_update_project_keyfile(); +void config_update_project_keyfile(void);
GtkWidget *config_plugin_configure(GtkDialog *dialog); + +#endif /* guard */
Modified: debugger/src/debug.c 176 files changed, 102 insertions(+), 74 deletions(-) =================================================================== @@ -153,7 +153,7 @@ /* * remove stack margin markers */ - void remove_stack_markers() +static void remove_stack_markers(void) { int active_frame_index = active_module->get_active_frame(); @@ -182,7 +182,7 @@ /* * add stack margin markers */ -static void add_stack_markers() +static void add_stack_markers(void) { int active_frame_index = active_module->get_active_frame(); @@ -219,32 +219,36 @@ static void on_watch_changed(GtkCellRendererText *renderer, gchar *path, gchar * { /* get iterator to the changed row */ GtkTreeIter iter; + gchar *oldvalue; + gchar *internal = NULL; + GtkTreePath *empty_path; GtkTreePath *tree_path = gtk_tree_path_new_from_string (path); + gboolean is_empty_row; + gchar *striped; + gtk_tree_model_get_iter ( gtk_tree_view_get_model(GTK_TREE_VIEW(wtree)), &iter, tree_path); /* get oldvalue */ - gchar* oldvalue; gtk_tree_model_get ( wmodel, &iter, W_NAME, &oldvalue, - -1); - gchar *internal = NULL; - gtk_tree_model_get ( + -1); + gtk_tree_model_get ( wmodel, &iter, W_INTERNAL, &internal, -1);
/* check if it is empty row */ - GtkTreePath *empty_path = wtree_empty_path(); - gboolean is_empty_row = !gtk_tree_path_compare (tree_path, empty_path); + empty_path = wtree_empty_path(); + is_empty_row = !gtk_tree_path_compare (tree_path, empty_path); gtk_tree_path_free(empty_path);
- gchar *striped = g_strstrip(g_strdup(new_text)); + striped = g_strstrip(g_strdup(new_text)); if (!strlen(striped) && !is_empty_row && dialogs_show_question(_("Delete variable?"))) @@ -272,8 +276,10 @@ static void on_watch_changed(GtkCellRendererText *renderer, gchar *path, gchar * /* if debug is active - remove old watch and add new one */ if (DBS_STOPPED == debug_state) { + variable *newvar; + active_module->remove_watch(internal); - variable *newvar = active_module->add_watch(striped); + newvar = active_module->add_watch(striped); change_watch(GTK_TREE_VIEW(wtree), is_empty_row ? &newiter : &iter, newvar); } @@ -306,14 +312,16 @@ static void on_watch_dragged_callback(GtkWidget *wgt, GdkDragContext *context, i { /* string that is dragged */ gchar *expression = (gchar*)seldata->data; - - /* lookup for where the text has been dropped */ GtkTreePath *path = NULL; GtkTreeViewDropPosition pos; + GtkTreePath *empty_path; + GtkTreeIter newvar; + + /* lookup for where the text has been dropped */ gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(wtree), x, y, &path, &pos);
/* if dropped into last row - insert before it */ - GtkTreePath *empty_path = wtree_empty_path(); + empty_path = wtree_empty_path(); if (!gtk_tree_path_compare(empty_path, path)) pos = GTK_TREE_VIEW_DROP_BEFORE; gtk_tree_path_free(empty_path); @@ -327,7 +335,6 @@ static void on_watch_dragged_callback(GtkWidget *wgt, GdkDragContext *context, i } /* insert new row */ - GtkTreeIter newvar; if (path) { GtkTreeIter sibling; @@ -340,7 +347,9 @@ static void on_watch_dragged_callback(GtkWidget *wgt, GdkDragContext *context, i } else { - GtkTreeIter empty = wtree_empty_row(); + GtkTreeIter empty; + + wtree_empty_row(&empty); gtk_tree_store_insert_before(wstore, &newvar, NULL, &empty); } @@ -362,18 +371,21 @@ static void on_watch_dragged_callback(GtkWidget *wgt, GdkDragContext *context, i */ static gboolean on_watch_key_pressed_callback(GtkWidget *widget, GdkEvent *event, gpointer user_data) { + GtkTreeSelection *selection; + GList *rows; + GtkTreePath *empty_path; + /* handling only Delete button pressing * that means "delete selected rows" */ - int keyval = ((GdkEventKey*)event)->keyval; - if (keyval != GDK_Delete) + if (((GdkEventKey*)event)->keyval != GDK_Delete) return FALSE;
/* get selected rows */ - GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(wtree)); - GList *rows = gtk_tree_selection_get_selected_rows(selection, &wmodel); + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(wtree)); + rows = gtk_tree_selection_get_selected_rows(selection, &wmodel); /* empty row path */ - GtkTreePath *empty_path = wtree_empty_path(); + empty_path = wtree_empty_path();
/* check whether only empty row was selected */ if (1 != gtk_tree_selection_count_selected_rows(selection) || @@ -381,6 +393,7 @@ static gboolean on_watch_key_pressed_callback(GtkWidget *widget, GdkEvent *even { /* path reference to select after deleteing finishes */ GtkTreeRowReference *reference_to_select = NULL; + GtkTreePath *path_to_select;
/* get references to the rows */ GList *references = NULL; @@ -411,6 +424,7 @@ static gboolean on_watch_key_pressed_callback(GtkWidget *widget, GdkEvent *even current reference was already deleted */ if (gtk_tree_row_reference_valid(reference)) { + GtkTreeIter titer; GtkTreePath *path = gtk_tree_row_reference_get_path(reference);
if (!reference_to_select) @@ -428,7 +442,6 @@ static gboolean on_watch_key_pressed_callback(GtkWidget *widget, GdkEvent *even }
/* get iterator */ - GtkTreeIter titer; gtk_tree_model_get_iter(wmodel, &titer, path);
/* remove from the debug session, if it's active */ @@ -467,7 +480,7 @@ static gboolean on_watch_key_pressed_callback(GtkWidget *widget, GdkEvent *even
/* set selection */ gtk_tree_selection_unselect_all(selection); - GtkTreePath *path_to_select = gtk_tree_row_reference_get_path(reference_to_select); + path_to_select = gtk_tree_row_reference_get_path(reference_to_select); gtk_tree_selection_select_path(selection, path_to_select); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(widget), path_to_select, NULL, TRUE, 0.5, 0.5); gtk_tree_path_free(path_to_select); @@ -491,7 +504,7 @@ static gboolean on_watch_key_pressed_callback(GtkWidget *widget, GdkEvent *even /* * mouse button has been pressed while being in watch(autos) tree view */ -gboolean on_watch_button_pressed_callback(GtkWidget *treeview, GdkEventButton *event, gpointer userdata) +static gboolean on_watch_button_pressed_callback(GtkWidget *treeview, GdkEventButton *event, gpointer userdata) { if (event->type == GDK_2BUTTON_PRESS && event->button == 1) { @@ -500,19 +513,20 @@ gboolean on_watch_button_pressed_callback(GtkWidget *treeview, GdkEventButton *e GTK_TREE_VIEW(treeview), (int)event->x, (int)event->y, &path, NULL, NULL, NULL)) { + gchar *expression = NULL; GtkTreeIter iter; GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview)); gtk_tree_model_get_iter (model, &iter, path);
- gchar *expression = NULL; gtk_tree_model_get(model, &iter, W_EXPRESSION, &expression, -1);
if (strlen(expression)) { - GtkTreeIter newvar; - GtkTreeIter empty = wtree_empty_row(); + GtkTreeIter newvar, empty; + + wtree_empty_row(&empty); gtk_tree_store_insert_before(wstore, &newvar, NULL, &empty); /* if debugger is active (in stopped condition) - add to run-time watch list @@ -556,8 +570,10 @@ static void on_watch_expanded_callback(GtkTreeView *tree, GtkTreeIter *iter, Gtk if (only_stub) { - /* if item has not been expanded before */ + GList *children; gchar *internal; + + /* if item has not been expanded before */ gtk_tree_model_get ( model, iter, @@ -565,7 +581,7 @@ static void on_watch_expanded_callback(GtkTreeView *tree, GtkTreeIter *iter, Gtk -1); /* get children list */ - GList *children = active_module->get_children(internal); + children = active_module->get_children(internal); /* remove stub and add children */ expand_stub(tree, iter, children); @@ -605,7 +621,7 @@ static void enable_sensitive_widgets(gboolean enable) /* * called from debug module when debugger is being run */ -static void on_debugger_run () +static void on_debugger_run (void) { /* update debug state */ debug_state = DBS_RUNNING; @@ -634,6 +650,8 @@ static void on_debugger_run () */ static void on_debugger_stopped (int thread_id) { + GList *iter, *files, *autos, *watches; + /* update debug state */ debug_state = DBS_STOPPED;
@@ -671,18 +689,15 @@ static void on_debugger_stopped (int thread_id)
/* get current stack trace and put in the tree view */ stack = active_module->get_stack(); - - GList *iter = stack; - while (iter) + for (iter = stack; iter; iter = iter->next) { 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(); + files = active_module->get_files(); /* remove from list and make writable those files, that are not in the current list */ iter = read_only_pages; @@ -690,6 +705,8 @@ static void on_debugger_stopped (int thread_id) { if (!g_list_find_custom(files, iter->data, (GCompareFunc)g_strcmp0)) { + GList *next; + /* set document writable */ GeanyDocument *doc = document_find_by_real_path((const gchar*)iter->data); if (doc) @@ -698,7 +715,7 @@ static void on_debugger_stopped (int thread_id) /* free file name */ g_free(iter->data); /* save next item pointer */ - GList *next = iter->next; + next = iter->next; /* remove current item */ read_only_pages = g_list_delete_link(read_only_pages, iter);
@@ -729,11 +746,11 @@ static void on_debugger_stopped (int thread_id) g_list_free(files);
/* autos */ - GList *autos = active_module->get_autos(); + autos = active_module->get_autos(); update_variables(GTK_TREE_VIEW(atree), NULL, autos); /* watches */ - GList *watches = active_module->get_watches(); + watches = active_module->get_watches(); update_variables(GTK_TREE_VIEW(wtree), NULL, watches);
if (stack) @@ -763,6 +780,10 @@ static void on_debugger_stopped (int thread_id) */ static void on_debugger_exited (int code) { + GtkTextIter start, end; + GtkTextBuffer *buffer; + GList *iter; + /* remove marker for current instruction if was set */ if (stack) { @@ -785,8 +806,7 @@ static void on_debugger_exited (int code) 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)); + 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);
@@ -798,8 +818,7 @@ static void on_debugger_exited (int code) bptree_set_readonly(FALSE); /* set files that was readonly during debug writable */ - GList *iter = read_only_pages; - while (iter) + for (iter = read_only_pages; iter; iter = iter->next) { GeanyDocument *doc = document_find_by_real_path((const gchar*)iter->data); if (doc) @@ -807,8 +826,6 @@ static void on_debugger_exited (int code)
/* free file name */ g_free(iter->data); - - iter = iter->next; } g_list_free(read_only_pages); read_only_pages = NULL; @@ -830,7 +847,7 @@ static void on_debugger_exited (int code) /* * called from debugger module to show a message in debugger messages pane */ -void on_debugger_message (const gchar* message, const gchar *color) +static void on_debugger_message (const gchar* message, const gchar *color) { gchar *msg = g_strdup_printf("%s\n", message);
@@ -848,7 +865,7 @@ void on_debugger_message (const gchar* message, const gchar *color) /* * called from debugger module to clear messages tab */ -static void on_debugger_messages_clear () +static void on_debugger_messages_clear (void) { /* clear debug messages window */ GtkTextIter start, end; @@ -902,6 +919,7 @@ static void on_thread_added (int thread_id) */ static void on_select_frame(int frame_number) { + GList *autos, *watches; frame *f = (frame*)g_list_nth(stack, active_module->get_active_frame())->data; markers_remove_current_instruction(f->file, f->line); markers_add_frame(f->file, f->line); @@ -912,11 +930,11 @@ static void on_select_frame(int frame_number) g_hash_table_remove_all(calltips); /* autos */ - GList *autos = active_module->get_autos(); + autos = active_module->get_autos(); update_variables(GTK_TREE_VIEW(atree), NULL, autos); /* watches */ - GList *watches = active_module->get_watches(); + watches = active_module->get_watches(); update_variables(GTK_TREE_VIEW(wtree), NULL, watches);
f = (frame*)g_list_nth(stack, frame_number)->data; @@ -928,8 +946,15 @@ static void on_select_frame(int frame_number) * init debug related GUI (watch tree view) * arguments: */ -void debug_init() +void debug_init(void) { + GtkWidget *scrollbar; + GtkWidget *hbox; + GKeyFile *config; + gchar *configfile; + gchar *font; + GtkTextBuffer *buffer; + /* create watch page */ wtree = wtree_init(on_watch_expanded_callback, on_watch_dragged_callback, @@ -979,11 +1004,11 @@ void debug_init() grantpt(pty_master); unlockpt(pty_master); vte_terminal_set_pty(VTE_TERMINAL(terminal), pty_master); - GtkWidget *scrollbar = gtk_vscrollbar_new(GTK_ADJUSTMENT(VTE_TERMINAL(terminal)->adjustment)); + scrollbar = gtk_vscrollbar_new(GTK_ADJUSTMENT(VTE_TERMINAL(terminal)->adjustment)); GTK_WIDGET_UNSET_FLAGS(scrollbar, GTK_CAN_FOCUS); tab_terminal = gtk_frame_new(NULL); gtk_frame_set_shadow_type (GTK_FRAME(tab_terminal), GTK_SHADOW_NONE); - GtkWidget *hbox = gtk_hbox_new(FALSE, 0); + hbox = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(tab_terminal), hbox); gtk_box_pack_start(GTK_BOX(hbox), terminal, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), scrollbar, FALSE, FALSE, 0); @@ -992,10 +1017,10 @@ void debug_init() gtk_widget_set_size_request(GTK_WIDGET(terminal), 10, 10); vte_terminal_set_size(VTE_TERMINAL(terminal), 30, 1); /* set terminal font. */ - GKeyFile *config = g_key_file_new(); - gchar *configfile = g_strconcat(geany_data->app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL); + config = g_key_file_new(); + configfile = g_strconcat(geany_data->app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL); g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL); - gchar *font = utils_get_setting_string(config, "VTE", "font", "Monospace 10"); + font = utils_get_setting_string(config, "VTE", "font", "Monospace 10"); vte_terminal_set_font_from_string (VTE_TERMINAL(terminal), font); /* debug messages page */ @@ -1011,7 +1036,7 @@ void debug_init() gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tab_messages), debugger_messages_textview); /* create tex tags */ - GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(debugger_messages_textview)); + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(debugger_messages_textview)); gtk_text_buffer_create_tag(buffer, "black", "foreground", "#000000", NULL); gtk_text_buffer_create_tag(buffer, "grey", "foreground", "#AAAAAA", NULL); gtk_text_buffer_create_tag(buffer, "red", "foreground", "#FF0000", NULL); @@ -1025,7 +1050,7 @@ void debug_init() /* * called when plugin is being unloaded to remove current instruction marker */ -void debug_destroy() +void debug_destroy(void) { /* close PTY file descriptors */ close(pty_master); @@ -1046,7 +1071,7 @@ void debug_destroy() /* * gets current debug state */ -enum dbs debug_get_state() +enum dbs debug_get_state(void) { return debug_state; } @@ -1054,7 +1079,7 @@ enum dbs debug_get_state() /* * gets current stack frames lisy */ -GList* debug_get_stack() +GList* debug_get_stack(void) { return stack; } @@ -1080,7 +1105,7 @@ int debug_get_module_index(const gchar *modulename) /* * gets GList with all debug modules pointers */ -GList* debug_get_modules() +GList* debug_get_modules(void) { GList *mods = NULL; module_description *desc = modules; @@ -1096,7 +1121,7 @@ GList* debug_get_modules() /* * checks whether currently active debug module supports asyncronous breaks */ -gboolean debug_supports_async_breaks() +gboolean debug_supports_async_breaks(void) { return active_module->features & MF_ASYNC_BREAKS; } @@ -1104,20 +1129,23 @@ gboolean debug_supports_async_breaks() /* * starts or continues debug process */ -void debug_run() +void debug_run(void) { if (DBS_IDLE == debug_state) { - gchar *target = g_strstrip(tpage_get_target()); + gchar *target, *commandline; + GList *env, *watches, *breaks; + + target = g_strstrip(tpage_get_target()); if (!strlen(target)) { g_free(target); return; } - gchar *commandline = tpage_get_commandline(); - GList *env = tpage_get_environment(); - GList *watches = get_root_items(GTK_TREE_VIEW(wtree)); - GList *breaks = breaks_get_all(); + 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; @@ -1157,7 +1185,7 @@ void debug_run() /* * restarts debug process */ -void debug_restart() +void debug_restart(void) { if (DBS_STOPPED == debug_state) { @@ -1171,7 +1199,7 @@ void debug_restart() /* * stops debug process */ -void debug_stop() +void debug_stop(void) { if (DBS_STOPPED == debug_state) { @@ -1190,7 +1218,7 @@ void debug_stop() /* * step over */ -void debug_step_over() +void debug_step_over(void) { if (DBS_STOPPED == debug_state) active_module->step_over(); @@ -1199,7 +1227,7 @@ void debug_step_over() /* * step into */ -void debug_step_into() +void debug_step_into(void) { if (DBS_STOPPED == debug_state) active_module->step_into(); @@ -1208,7 +1236,7 @@ void debug_step_into() /* * step out */ -void debug_step_out() +void debug_step_out(void) { if (DBS_STOPPED == debug_state) active_module->step_out(); @@ -1271,7 +1299,7 @@ void debug_request_interrupt(bs_callback cb, gpointer data) /* * gets debug modules error message */ -gchar* debug_error_message() +gchar* debug_error_message(void) { return active_module->error_message(); } @@ -1340,7 +1368,7 @@ gchar* debug_get_calltip_for_expression(gchar* expression) * check whether source for the current instruction * is avaiable */ -gboolean debug_current_instruction_have_sources() +gboolean @@ Diff output truncated at 100000 characters. @@
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: TBD).