Branch: refs/heads/master Author: Alexander Petukhov devel@apetukhov.ru Committer: Alexander Petukhov devel@apetukhov.ru Date: Wed, 04 Apr 2012 09:57:19 Commit: 885c3d1e8173c8aa2b7bf28deba013abc1b850b6 https://github.com/geany/geany-plugins/commit/885c3d1e8173c8aa2b7bf28deba013...
Log Message: ----------- fixes several bugs (see Changelog)
Modified Paths: -------------- debugger/ChangeLog debugger/TODO debugger/src/bptree.c 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/debug.c debugger/src/envtree.c debugger/src/stree.c debugger/src/vtree.c debugger/src/wtree.c
Modified: debugger/ChangeLog 8 files changed, 8 insertions(+), 0 deletions(-) =================================================================== @@ -1,3 +1,11 @@ +04-04-2012 Alexander Petukhov devel@apetukhov.ru + + * fixing exiting with code case that was unhandled and caused SIGSEGV (gdb) + * set current directory to executable's one (gdb) + * handling spaces in target and breakpoints filenames (gdb) + * fixing memory leaks on gtk_tree_row_reference_get_path and tree/list stores + * fixing SIGSEGV when selecting a cell in custom cell renderers using a keyboard + 10-03-2012 Alexander Petukhov devel@apetukhov.ru
* switching between frames by clicking a frame arrow in the stack window
Modified: debugger/TODO 7 files changed, 3 insertions(+), 4 deletions(-) =================================================================== @@ -1,9 +1,7 @@ BUGS: -- terminal stops to produce any output after some debug seesions - tooltip appears even if a pointer in no longer inside editor window -- check possible memory leaks on a)gtk_tree_row_reference_get_path b)missing unrefs on tree/list stores -- cell_renderer_toogle SIGSEGV in cell_renderer_toggle_activate when activating a cell using a keyboard (event->button == NULL) -- debug geany with debugger project. switch frames then step over -> continue instead, then close geany being debugged -> dbm_gdb.c:502 (no step reason, probably the record from the previos step command???) +- when "Jump to current instruction" - two active frame icons in stack view +- no icons in stack and breaks after unload/load plugin
FEATURES: - custom tooltip with sticking facilities @@ -24,3 +22,4 @@ FEATURES: - custom tooltip on breaks and stack trace windows with code snippet around break or frame - font from the geany settings for a message window - a button in the upper right path of a right notebook for a hiding/showing button panel +- use left/right keys to collapse/expand in breakpoints tree
Modified: debugger/src/bptree.c 5 files changed, 4 insertions(+), 1 deletions(-) =================================================================== @@ -616,6 +616,7 @@ gboolean bptree_init(move_to_line_cb cb) G_TYPE_STRING); model = GTK_TREE_MODEL(store); tree = gtk_tree_view_new_with_model (model); + g_object_unref(store); /* set tree view properties */ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), 1); @@ -802,7 +803,9 @@ void bptree_add_breakpoint(breakpoint* bp) } else { - gtk_tree_model_get_iter(model, &file_iter, gtk_tree_row_reference_get_path(file_reference)); + GtkTreePath *path = gtk_tree_row_reference_get_path(file_reference); + gtk_tree_model_get_iter(model, &file_iter, path); + gtk_tree_path_free(path); } /* lookup where to insert new row */
Modified: debugger/src/cell_renderers/cellrendererbreakicon.c 8 files changed, 6 insertions(+), 2 deletions(-) =================================================================== @@ -261,8 +261,12 @@ static void cell_renderer_break_icon_render(GtkCellRenderer *cell, GdkDrawable * static gint cell_renderer_break_icon_activate(GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path, GdkRectangle *background_area, GdkRectangle *cell_area, GtkCellRendererState flags) { - if (event->button.x >= cell_area->x && - event->button.x < (cell_area->x + cell_area->width)) + if (!event || + ( + event->button.x >= cell_area->x && + event->button.x < (cell_area->x + cell_area->width) + ) + ) { g_signal_emit (cell, clicked_signal, 0, path); }
Modified: debugger/src/cell_renderers/cellrendererframeicon.c 8 files changed, 6 insertions(+), 2 deletions(-) =================================================================== @@ -45,8 +45,12 @@ enum { static gint cell_renderer_frame_icon_activate(GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path, GdkRectangle *background_area, GdkRectangle *cell_area, GtkCellRendererState flags) { - if (event->button.x >= cell_area->x && - event->button.x < (cell_area->x + cell_area->width)) + if (!event || + ( + event->button.x >= cell_area->x && + event->button.x < (cell_area->x + cell_area->width) + ) + ) { g_signal_emit (cell, clicked_signal, 0, path); }
Modified: debugger/src/cell_renderers/cellrenderertoggle.c 8 files changed, 6 insertions(+), 2 deletions(-) =================================================================== @@ -35,8 +35,12 @@ static gint cell_renderer_toggle_activate(GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path, GdkRectangle *background_area, GdkRectangle *cell_area, GtkCellRendererState flags) { - if (event->button.x >= cell_area->x && - event->button.x < (cell_area->x + cell_area->width)) + if (!event || + ( + event->button.x >= cell_area->x && + event->button.x < (cell_area->x + cell_area->width) + ) + ) { g_signal_emit_by_name(cell, "toggled", path); }
Modified: debugger/src/dbm_gdb.c 39 files changed, 31 insertions(+), 8 deletions(-) =================================================================== @@ -72,6 +72,7 @@ enum sr { SR_EXITED_NORMALLY, SR_SIGNAL_RECIEVED, SR_EXITED_SIGNALLED, + SR_EXITED_WITH_CODE, } stop_reason;
/* callbacks to use for messaging, error reporting and state change alerting */ @@ -490,6 +491,8 @@ static gboolean on_read_from_gdb(GIOChannel * src, GIOCondition cond, gpointer d stop_reason = SR_EXITED_NORMALLY; else if (!strcmp(reason, "exited-signalled")) stop_reason = SR_EXITED_SIGNALLED; + else if (!strcmp(reason, "exited")) + stop_reason = SR_EXITED_WITH_CODE; } else { @@ -531,8 +534,18 @@ static gboolean on_read_from_gdb(GIOChannel * src, GIOCondition cond, gpointer d dbg_cbs->set_stopped(atoi(thread_id)); } } - else if (stop_reason == SR_EXITED_NORMALLY || stop_reason == SR_EXITED_SIGNALLED) + else if (stop_reason == SR_EXITED_NORMALLY || stop_reason == SR_EXITED_SIGNALLED || stop_reason == SR_EXITED_WITH_CODE) { + if (stop_reason == SR_EXITED_WITH_CODE) + { + gchar *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)); + dbg_cbs->report_error(message); + + g_free(message); + } + stop(); } } @@ -692,13 +705,17 @@ gboolean run(const gchar* file, const gchar* commandline, GList* env, GList *wit /* spawn GDB */ const gchar *exclude[] = { "LANG", NULL }; gchar **gdb_env = utils_copy_environment(exclude, "LANG", "C", NULL); - if (!g_spawn_async_with_pipes(NULL, (gchar**)gdb_args, gdb_env, + 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)) { dbg_cbs->report_error(_("Failed to spawn gdb process")); + g_free(working_directory); + g_strfreev(gdb_env); return FALSE; } + g_free(working_directory); g_strfreev(gdb_env); /* move gdb to it's own process group */ @@ -743,8 +760,8 @@ gboolean run(const gchar* file, const gchar* commandline, GList* env, GList *wit
/* loading file */ GString *command = g_string_new(""); - g_string_printf(command, "-file-exec-and-symbols %s", file); - commands = add_to_queue(commands, _("~"Loading target file ...""), command->str, _("Error loading file"), FALSE); + 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);
/* setting asyncronous mode */ @@ -792,7 +809,7 @@ gboolean run(const gchar* file, const gchar* commandline, GList* env, GList *wit { breakpoint *bp = (breakpoint*)biter->data; command = g_string_new(""); - g_string_printf(command, "-break-insert -f %s:%i", bp->file, bp->line); + 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"); @@ -934,8 +951,14 @@ int get_break_number(char* file, int line) *strchr(bstart, '"') = '\0'; int bline = atoi(bstart); - if (!strcmp(fname, file) && bline == line) + gchar *file_quoted = g_strdup_printf("\"%s\"", file); + int break_found = !strcmp(fname, file_quoted) && bline == line; + g_free(file_quoted); + + if (break_found) + { return num; + } bstart += strlen(bstart) + 1; } @@ -957,11 +980,11 @@ gboolean set_break(breakpoint* bp, break_set_activity bsa) gchar *record = NULL; /* 1. insert breakpoint */ - sprintf (command, "-break-insert %s:%i", bp->file, bp->line); + sprintf (command, "-break-insert "\"%s\":%i"", bp->file, bp->line); if (RC_DONE != exec_sync_command(command, TRUE, &record)) { g_free(record); - sprintf (command, "-break-insert -f %s:%i", bp->file, bp->line); + sprintf (command, "-break-insert -f "\"%s\":%i"", bp->file, bp->line); if (RC_DONE != exec_sync_command(command, TRUE, &record)) { g_free(record);
Modified: debugger/src/debug.c 14 files changed, 12 insertions(+), 2 deletions(-) =================================================================== @@ -240,7 +240,9 @@ static void on_watch_changed(GtkCellRendererText *renderer, gchar *path, gchar * -1);
/* check if it is empty row */ - gboolean is_empty_row = !gtk_tree_path_compare (tree_path, wtree_empty_path()); + GtkTreePath *empty_path = wtree_empty_path(); + gboolean 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)); if (!strlen(striped) && @@ -447,6 +449,8 @@ static gboolean on_watch_key_pressed_callback(GtkWidget *widget, GdkEvent *even
gtk_tree_store_remove(wstore, &titer); + + gtk_tree_path_free(path); } iter = iter->next; @@ -455,7 +459,11 @@ static gboolean on_watch_key_pressed_callback(GtkWidget *widget, GdkEvent *even /* if all (with or without empty row) was selected - set empty row as a path to be selected after deleting */ if (!reference_to_select) - reference_to_select = gtk_tree_row_reference_new (gtk_tree_view_get_model(GTK_TREE_VIEW(wtree)), wtree_empty_path()); + { + GtkTreePath *path = wtree_empty_path(); + reference_to_select = gtk_tree_row_reference_new (gtk_tree_view_get_model(GTK_TREE_VIEW(wtree)), path); + gtk_tree_path_free(path); + }
/* set selection */ gtk_tree_selection_unselect_all(selection); @@ -471,6 +479,8 @@ static gboolean on_watch_key_pressed_callback(GtkWidget *widget, GdkEvent *even config_set_debug_changed(); }
+ gtk_tree_path_free(empty_path); + /* free rows list */ g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL); g_list_free (rows);
Modified: debugger/src/envtree.c 23 files changed, 18 insertions(+), 5 deletions(-) =================================================================== @@ -151,6 +151,7 @@ static void delete_selected_rows() gtk_tree_model_get_iter(model, &titer, path); gtk_list_store_remove(store, &titer);
+ gtk_tree_path_free(path); iter = iter->next; }
@@ -159,6 +160,7 @@ static void delete_selected_rows() GtkTreePath *path = gtk_tree_row_reference_get_path(reference_to_select); gtk_tree_selection_select_path(selection, path); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(tree), path, NULL, TRUE, 0.5, 0.5); + gtk_tree_path_free(path);
/* free references list */ g_list_foreach (references, (GFunc)gtk_tree_row_reference_free, NULL); @@ -168,6 +170,8 @@ static void delete_selected_rows() /* free selection reference */ gtk_tree_row_reference_free(reference_to_select);
+ gtk_tree_path_free(empty_path); + /* free rows list */ g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL); g_list_free (rows); @@ -213,9 +217,11 @@ static void on_render_value(GtkTreeViewColumn *tree_column, { /* do not allow to edit value for empty row */ GtkTreePath *path = gtk_tree_model_get_path(tree_model, iter); - gboolean empty = !gtk_tree_path_compare(path, gtk_tree_row_reference_get_path(empty_row)); + GtkTreePath *empty_path = gtk_tree_row_reference_get_path(empty_row); + gboolean empty = !gtk_tree_path_compare(path, empty_path); g_object_set (cell, "editable", entering_new_var || !empty, NULL); gtk_tree_path_free(path); + gtk_tree_path_free(empty_path); } }
@@ -226,8 +232,10 @@ static void on_value_changed(GtkCellRendererText *renderer, gchar *path, gchar * { GtkTreeIter iter; GtkTreePath *tree_path = gtk_tree_path_new_from_string (path); - - gboolean empty = !gtk_tree_path_compare(tree_path, gtk_tree_row_reference_get_path(empty_row)); + + GtkTreePath *empty_path = gtk_tree_row_reference_get_path(empty_row); + gboolean empty = !gtk_tree_path_compare(tree_path, empty_path); + gtk_tree_path_free(empty_path);
gtk_tree_model_get_iter ( model, @@ -300,7 +308,8 @@ static void on_value_editing_cancelled(GtkCellRenderer *renderer, gpointer user_ { /* check whether escape was pressed when editing new variable value cell */ - if(!gtk_tree_path_compare(being_edited_value, gtk_tree_row_reference_get_path(empty_row))) + GtkTreePath *empty_path = gtk_tree_row_reference_get_path(empty_row); + if(!gtk_tree_path_compare(being_edited_value, empty_path)) { /* if so - clear name sell */ GtkTreeIter iter; @@ -318,6 +327,7 @@ static void on_value_editing_cancelled(GtkCellRenderer *renderer, gpointer user_ g_object_set (renderer_value, "editable", FALSE, NULL);
gtk_tree_path_free(being_edited_value); + gtk_tree_path_free(empty_path); }
/* @@ -327,8 +337,9 @@ static void on_name_changed(GtkCellRendererText *renderer, gchar *path, gchar *n { GtkTreeIter iter; GtkTreePath *tree_path = gtk_tree_path_new_from_string (path); + GtkTreePath *empty_path = gtk_tree_row_reference_get_path(empty_row);
- gboolean empty = !gtk_tree_path_compare(tree_path, gtk_tree_row_reference_get_path(empty_row)); + gboolean empty = !gtk_tree_path_compare(tree_path, empty_path);
gtk_tree_model_get_iter ( model, @@ -371,6 +382,7 @@ static void on_name_changed(GtkCellRendererText *renderer, gchar *path, gchar *n } gtk_tree_path_free(tree_path); + gtk_tree_path_free(empty_path); g_free(oldvalue); g_free(striped); } @@ -387,6 +399,7 @@ static void on_name_changed(GtkCellRendererText *renderer, gchar *path, gchar *n G_TYPE_STRING); model = GTK_TREE_MODEL(store); tree = gtk_tree_view_new_with_model (model); + g_object_unref(store); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), TRUE); g_signal_connect(G_OBJECT(tree), "key-press-event", G_CALLBACK (on_envtree_keypressed), NULL);
Modified: debugger/src/stree.c 15 files changed, 12 insertions(+), 3 deletions(-) =================================================================== @@ -333,6 +333,7 @@ static void on_selection_changed(GtkTreeSelection *treeselection, gpointer user_ model = GTK_TREE_MODEL(store); tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store)); + g_object_unref(store); /* set tree view properties */ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), 1); @@ -411,7 +412,9 @@ void stree_add(frame *f) { GtkTreeRowReference *reference = (GtkTreeRowReference*)g_hash_table_lookup(threads, (gpointer)active_thread_id); GtkTreeIter thread_iter; - gtk_tree_model_get_iter(model, &thread_iter, gtk_tree_row_reference_get_path(reference)); + GtkTreePath *path = gtk_tree_row_reference_get_path(reference); + gtk_tree_model_get_iter(model, &thread_iter, path); + gtk_tree_path_free(path);
GtkTreeIter frame_iter; gtk_tree_store_insert_before(store, &frame_iter, &thread_iter, 0); @@ -443,7 +446,9 @@ void stree_select_first_frame() GtkTreeRowReference *reference = (GtkTreeRowReference*)g_hash_table_lookup(threads, (gpointer)active_thread_id); GtkTreeIter thread_iter, frame_iter; - gtk_tree_model_get_iter(model, &thread_iter, gtk_tree_row_reference_get_path(reference)); + GtkTreePath *active_path = gtk_tree_row_reference_get_path(reference); + gtk_tree_model_get_iter(model, &thread_iter, active_path); + gtk_tree_path_free(active_path); if(gtk_tree_model_iter_children(model, &frame_iter, &thread_iter)) { gtk_tree_store_set (store, &frame_iter, S_ACTIVE, TRUE, -1); @@ -534,6 +539,8 @@ void stree_remove_thread(int thread_id) gtk_tree_store_remove(store, &iter);
g_hash_table_remove(threads, (gpointer)(glong)thread_id); + + gtk_tree_path_free(tpath); }
/* @@ -543,7 +550,9 @@ void stree_remove_frames() { GtkTreeRowReference *reference = (GtkTreeRowReference*)g_hash_table_lookup(threads, (gpointer)active_thread_id); GtkTreeIter thread_iter; - gtk_tree_model_get_iter(model, &thread_iter, gtk_tree_row_reference_get_path(reference)); + GtkTreePath *tpath = gtk_tree_row_reference_get_path(reference); + gtk_tree_model_get_iter(model, &thread_iter, tpath); + gtk_tree_path_free(tpath);
GtkTreeIter child; if (gtk_tree_model_iter_children(model, &child, &thread_iter))
Modified: debugger/src/vtree.c 1 files changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -148,6 +148,7 @@ void render_value(GtkTreeViewColumn *tree_column, G_TYPE_INT, G_TYPE_INT); GtkWidget* tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store)); + g_object_unref(store); /* set tree view parameters */ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), TRUE);
Modified: debugger/src/wtree.c 6 files changed, 4 insertions(+), 2 deletions(-) =================================================================== @@ -99,10 +99,12 @@ static void on_render_name(GtkTreeViewColumn *tree_column, GtkTreeIter wtree_empty_row() { GtkTreeIter empty; - + + GtkTreePath *path = gtk_tree_row_reference_get_path(empty_row); gtk_tree_model_get_iter(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)), &empty, - gtk_tree_row_reference_get_path(empty_row)); + path); + gtk_tree_path_free(path); return empty; }
@@ Diff output truncated at 100000 characters. @@
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: TBD).