Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Sun, 07 Feb 2016 13:54:51 UTC Commit: 138e3d3f5b9339a7dd9607d1f9bc7e709ae56429 https://github.com/geany/geany-plugins/commit/138e3d3f5b9339a7dd9607d1f9bc7e...
Log Message: ----------- Merge branch 'debugger/frame-speedup' into debugger/master
Closes #347.
Modified Paths: -------------- debugger/src/breakpoints.c debugger/src/dbm_gdb.c debugger/src/debug.c debugger/src/debug_module.c debugger/src/debug_module.h debugger/src/envtree.c debugger/src/gdb_mi.c debugger/src/stree.c debugger/src/stree.h debugger/src/watch_model.c
Modified: debugger/src/breakpoints.c 6 lines changed, 3 insertions(+), 3 deletions(-) =================================================================== @@ -70,7 +70,7 @@ static void hash_table_foreach_call_function(gpointer key, gpointer value, gpoin static gboolean tree_foreach_add_to_list(gpointer key, gpointer value, gpointer data) { GList **list = (GList**)data; - *list = g_list_append(*list, value); + *list = g_list_prepend(*list, value); return FALSE; }
@@ -675,7 +675,7 @@ GList* breaks_get_for_document(const char* file) { g_tree_foreach(tree, tree_foreach_add_to_list, &breaks); } - return breaks; + return g_list_reverse(breaks); }
/* @@ -702,5 +702,5 @@ GList* breaks_get_all(void) { GList *breaks = NULL; g_hash_table_foreach(files, hash_table_foreach_add_to_list, &breaks); - return breaks; + return g_list_reverse(breaks); }
Modified: debugger/src/dbm_gdb.c 14 lines changed, 8 insertions(+), 6 deletions(-) =================================================================== @@ -213,10 +213,10 @@ static GList* read_until_prompt(void) break;
line[terminator] = '\0'; - lines = g_list_append (lines, line); + lines = g_list_prepend (lines, line); } - return lines; + return g_list_reverse(lines); }
/* @@ -1129,11 +1129,11 @@ static GList* get_stack(void) /* line */ f->line = line ? atoi(line) : 0;
- stack = g_list_append(stack, f); + stack = g_list_prepend(stack, f); } gdb_mi_record_free(record); - return stack; + return g_list_reverse(stack); }
/* @@ -1293,8 +1293,9 @@ static void update_watches(void) var->evaluated = name != NULL;
/* add to updating list */ - updating = g_list_append(updating, var); + updating = g_list_prepend(updating, var); } + updating = g_list_reverse(updating); /* update watches */ get_variables(updating); @@ -1465,11 +1466,12 @@ static GList* get_children (gchar* path) var = variable_new2(name, internal, VT_CHILD); var->evaluated = TRUE;
- children = g_list_append(children, var); + children = g_list_prepend(children, var); } } gdb_mi_record_free(record); + children = g_list_reverse(children); get_variables(children);
return children;
Modified: debugger/src/debug.c 20 lines changed, 8 insertions(+), 12 deletions(-) =================================================================== @@ -418,13 +418,13 @@ static gboolean on_watch_key_pressed_callback(GtkWidget *widget, GdkEvent *even
/* add path reference if it's not an empty row*/ if (gtk_tree_path_compare(path, empty_path)) - references = g_list_append(references, gtk_tree_row_reference_new(wmodel, path)); + references = g_list_prepend(references, gtk_tree_row_reference_new(wmodel, path));
iter = iter->next; }
/* iterate through references and remove */ - iter = references; + iter = g_list_reverse(references); while (iter) { GtkTreeRowReference *reference = (GtkTreeRowReference*)iter->data; @@ -640,7 +640,7 @@ static void on_debugger_run (void) if (stack) { remove_stack_markers(); - g_list_foreach(stack, (GFunc)frame_free, NULL); + g_list_foreach(stack, (GFunc)frame_unref, NULL); g_list_free(stack); stack = NULL;
@@ -700,11 +700,7 @@ static void on_debugger_stopped (int thread_id)
/* get current stack trace and put in the tree view */ stack = active_module->get_stack(); - for (iter = stack; iter; iter = iter->next) - { - frame *f = (frame*)iter->data; - stree_add(f); - } + stree_add (stack); stree_select_first_frame(TRUE);
/* files */ @@ -799,7 +795,7 @@ static void on_debugger_exited (int code) if (stack) { remove_stack_markers(); - g_list_foreach(stack, (GFunc)frame_free, NULL); + g_list_foreach(stack, (GFunc)frame_unref, NULL); g_list_free(stack); stack = NULL; } @@ -1075,7 +1071,7 @@ void debug_destroy(void) if (stack) { remove_stack_markers(); - g_list_foreach(stack, (GFunc)frame_free, NULL); + g_list_foreach(stack, (GFunc)frame_unref, NULL); g_list_free(stack); stack = NULL; } @@ -1126,11 +1122,11 @@ GList* debug_get_modules(void) module_description *desc = modules; while (desc->title) { - mods = g_list_append(mods, (gpointer)desc->title); + mods = g_list_prepend(mods, (gpointer)desc->title); desc++; } - return mods; + return g_list_reverse(mods); }
/*
Modified: debugger/src/debug_module.c 28 lines changed, 15 insertions(+), 13 deletions(-) =================================================================== @@ -79,26 +79,28 @@ void variable_reset(variable *var) /* creates new frame */ frame* frame_new(void) { - frame *f = (frame*)malloc(sizeof(frame)); - memset((void*)f, 0, sizeof(frame)); + frame *f = g_malloc0(sizeof *f); + f->ref_count = 1; return f; }
-/* frees a frame */ -void frame_free(frame* f) +/* refs a frame */ +frame* frame_ref(frame* f) { - if (f->address) + f->ref_count++; + return f; +} + +/* unrefs a frame */ +void frame_unref(frame* f) +{ + if (f->ref_count > 1) + f->ref_count--; + else { g_free(f->address); - } - if (f->function) - { g_free(f->function); - } - if (f->file) - { g_free(f->file); + g_free(f); } - - g_free(f); }
Modified: debugger/src/debug_module.h 6 lines changed, 4 insertions(+), 2 deletions(-) =================================================================== @@ -79,6 +79,7 @@ typedef struct _variable {
/* type to hold information about a stack frame */ typedef struct _frame { + gint ref_count; gchar *address; gchar *function; gchar *file; @@ -170,7 +171,8 @@ variable* variable_new(const gchar *name, variable_type vt); variable* variable_new2(const gchar *name, const gchar *internal, variable_type vt); void variable_reset(variable *var);
-frame* frame_new(void); -void frame_free(frame* f); +frame* frame_new(void); +frame* frame_ref(frame* f); +void frame_unref(frame* f);
#endif /* guard */
Modified: debugger/src/envtree.c 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -135,7 +135,7 @@ static void delete_selected_rows(void) } if (gtk_tree_path_compare(path, empty_path)) - references = g_list_append(references, gtk_tree_row_reference_new(model, path)); + references = g_list_prepend(references, gtk_tree_row_reference_new(model, path)); iter = iter->next; } @@ -145,7 +145,7 @@ static void delete_selected_rows(void) if (!reference_to_select) reference_to_select = gtk_tree_row_reference_copy (empty_row);
- iter = references; + iter = g_list_reverse(references); while (iter) { GtkTreeIter titer;
Modified: debugger/src/gdb_mi.c 51 lines changed, 36 insertions(+), 15 deletions(-) =================================================================== @@ -98,13 +98,17 @@ static gchar *parse_cstring(const gchar **p)
if (**p == '"') { + const gchar *base; + (*p)++; + base = *p; while (**p != '"') { gchar c = **p; /* TODO: check expansions here */ if (c == '\') { + g_string_append_len(str, base, (*p) - base); (*p)++; c = **p; switch (g_ascii_tolower(c)) @@ -159,12 +163,14 @@ static gchar *parse_cstring(const gchar **p) } break; } + g_string_append_c(str, c); + base = (*p) + 1; } - if (**p == '\0') + else if (**p == '\0') break; - g_string_append_c(str, c); (*p)++; } + g_string_append_len(str, base, (*p) - base); if (**p == '"') (*p)++; } @@ -176,15 +182,15 @@ static gchar *parse_cstring(const gchar **p) * the docs aren't clear on this */ static gchar *parse_string(const gchar **p) { - GString *str = g_string_new(NULL); + const gchar *base = *p;
if (g_ascii_isalpha(**p) || strchr("-_.", **p)) { - g_string_append_c(str, **p); for ((*p)++; g_ascii_isalnum(**p) || strchr("-_.", **p); (*p)++) - g_string_append_c(str, **p); + ; } - return g_string_free(str, FALSE); + + return g_strndup (base, *p - base); }
/* parses: string "=" value */ @@ -205,15 +211,17 @@ static gboolean parse_result(struct gdb_mi_result *result, const gchar **p) * Actually, this is more permissive and allows mixed tuples/lists */ static struct gdb_mi_value *parse_value(const gchar **p) { - struct gdb_mi_value *val = g_malloc0(sizeof *val); + struct gdb_mi_value *val = NULL; if (**p == '"') { + val = g_malloc0(sizeof *val); val->type = GDB_MI_VAL_STRING; val->string = parse_cstring(p); } else if (**p == '{' || **p == '[') { struct gdb_mi_result *prev = NULL; + val = g_malloc0(sizeof *val); val->type = GDB_MI_VAL_LIST; gchar end = **p == '{' ? '}' : ']'; (*p)++; @@ -242,11 +250,6 @@ static struct gdb_mi_value *parse_value(const gchar **p) if (**p == end) (*p)++; } - else - { - gdb_mi_value_free(val); - val = NULL; - } return val; }
@@ -479,17 +482,35 @@ static void gdb_mi_record_dump(const struct gdb_mi_record *record) gdb_mi_result_dump(record->first, TRUE, 2); }
-int main(void) +static gchar *read_line(FILE *fp) { char buf[1024] = {0}; + GString *line = g_string_new(NULL); + + while (fgets(buf, sizeof buf, fp)) + { + g_string_append(line, buf); + if (line->len < 1 || line->str[line->len - 1] == '\n') + break; + } + + return g_string_free(line, line->len < 1); +}
- while (fgets(buf, sizeof buf, stdin)) +int main(int argc, char **argv) +{ + gchar *line; + + while ((line = read_line(stdin)) != NULL) { - struct gdb_mi_record *record = gdb_mi_record_parse(buf); + struct gdb_mi_record *record = gdb_mi_record_parse(line);
gdb_mi_record_dump(record); gdb_mi_record_free(record); + + g_free(line); } + return 0; }
Modified: debugger/src/stree.c 301 lines changed, 150 insertions(+), 151 deletions(-) =================================================================== @@ -42,20 +42,12 @@ /* Tree view columns */ enum { - S_ADRESS, - S_FUNCTION, - S_FILEPATH, - S_LINE, - S_LAST_VISIBLE, - S_HAVE_SOURCE, + S_FRAME, /* the frame if it's a frame, or NULL if it's a thread */ S_THREAD_ID, S_ACTIVE, S_N_COLUMNS };
-/* hash table to keep thread nodes in the tree */ -static GHashTable *threads; - /* active thread and frame */ static glong active_thread_id = 0; static int active_frame_index = 0; @@ -69,9 +61,37 @@ static GtkWidget *tree = NULL; static GtkTreeModel *model = NULL; static GtkTreeStore *store = NULL;
+static GtkTreeViewColumn *column_filepath = NULL; +static GtkTreeViewColumn *column_address = NULL; + /* cell renderer for a frame arrow */ static GtkCellRenderer *renderer_arrow = NULL;
+static GType frame_get_type (void); +G_DEFINE_BOXED_TYPE(frame, frame, frame_ref, frame_unref) +#define STREE_TYPE_FRAME (frame_get_type ()) + +/* finds the iter for thread @thread_id */ +static gboolean find_thread_iter (gint thread_id, GtkTreeIter *iter) +{ + gboolean found = FALSE; + + if (gtk_tree_model_get_iter_first(model, iter)) + { + do + { + gint existing_thread_id; + + gtk_tree_model_get(model, iter, S_THREAD_ID, &existing_thread_id, -1); + if (existing_thread_id == thread_id) + found = TRUE; + } + while (! found && gtk_tree_model_iter_next(model, iter)); + } + + return found; +} + /* * frame arrow clicked callback */ @@ -80,10 +100,13 @@ static void on_frame_arrow_clicked(CellRendererFrameIcon *cell_renderer, gchar * GtkTreePath *new_active_frame = gtk_tree_path_new_from_string (path); if (gtk_tree_path_get_indices(new_active_frame)[1] != active_frame_index) { + GtkTreeIter thread_iter; GtkTreeIter iter; + GtkTreePath *old_active_frame; + + find_thread_iter (active_thread_id, &thread_iter); + old_active_frame = gtk_tree_model_get_path (model, &thread_iter);
- GtkTreeRowReference *reference = (GtkTreeRowReference*)g_hash_table_lookup(threads, (gpointer)active_thread_id); - GtkTreePath *old_active_frame = gtk_tree_row_reference_get_path(reference); gtk_tree_path_append_index(old_active_frame, active_frame_index);
gtk_tree_model_get_iter(model, &iter, old_active_frame); @@ -119,23 +142,23 @@ static gboolean on_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean key gint start_pos, width; gtk_tree_view_column_cell_get_position(column, renderer_arrow, &start_pos, &width); - if (column == gtk_tree_view_get_column(GTK_TREE_VIEW(widget), S_FILEPATH)) + if (column == column_filepath) { - gchar *path = NULL; + frame *f; GtkTreeIter iter; gtk_tree_model_get_iter(model, &iter, tpath); - gtk_tree_model_get(model, &iter, S_FILEPATH, &path, -1); + gtk_tree_model_get(model, &iter, S_FRAME, &f, -1); - gtk_tooltip_set_text(tooltip, path); + gtk_tooltip_set_text(tooltip, f->file); gtk_tree_view_set_tooltip_row(GTK_TREE_VIEW(widget), tooltip, tpath); show = TRUE;
- g_free(path); + frame_unref(f); } - else if (column == gtk_tree_view_get_column(GTK_TREE_VIEW(widget), S_ADRESS && bx >= start_pos && bx < start_pos + width)) + else if (column == column_address && bx >= start_pos && bx < start_pos + width) { gtk_tooltip_set_text(tooltip, gtk_tree_path_get_indices(tpath)[1] == active_frame_index ? _("Active frame") : _("Click an arrow to switch to a frame")); gtk_tree_view_set_tooltip_row(GTK_TREE_VIEW(widget), tooltip, tpath); @@ -165,14 +188,23 @@ static void on_render_arrow(GtkTreeViewColumn *tree_column, GtkCellRenderer *cel static void on_render_line(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) { - GtkTreePath *tpath = gtk_tree_model_get_path(model, iter); + frame *f;
- if (1 == gtk_tree_path_get_depth(tpath)) - { + gtk_tree_model_get (model, iter, S_FRAME, &f, -1); + + if (! f) g_object_set(cell, "text", "", NULL); - } + else + { + GValue value = {0};
- gtk_tree_path_free(tpath); + g_value_init(&value, G_TYPE_INT); + g_value_set_int (&value, f->line); + g_object_set_property (G_OBJECT (cell), "text", &value); + + g_value_unset (&value); + frame_unref (f); + } }
/* @@ -181,28 +213,22 @@ static void on_render_line(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell static void on_render_filename(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) { - GtkTreePath *tpath = gtk_tree_model_get_path(model, iter); - - if (1 != gtk_tree_path_get_depth(tpath)) - { - gchar *path = NULL, *name; - gtk_tree_model_get(model, iter, S_FILEPATH, &path, -1); + frame *f;
- name = path ? g_path_get_basename(path) : NULL; - g_object_set(cell, "text", name ? name : path, NULL); + gtk_tree_model_get(model, iter, S_FRAME, &f, -1);
- g_free(name); - if (path) - { - g_free(path); - } - } + if (! f) + g_object_set(cell, "text", "", NULL); else { - g_object_set(cell, "text", "", NULL); - } + gchar *name;
- gtk_tree_path_free(tpath); + name = f->file ? g_path_get_basename(f->file) : NULL; + g_object_set(cell, "text", name ? name : f->file, NULL); + + g_free(name); + frame_unref (f); + } }
/* @@ -224,34 +250,22 @@ static gboolean on_msgwin_button_press(GtkWidget *widget, GdkEventButton *event,
if (!gtk_tree_path_compare(pressed_path, selected_path)) { - gboolean have_source; + frame *f; GtkTreeIter iter; gtk_tree_model_get_iter ( model, &iter, pressed_path);
- gtk_tree_model_get ( - model, - &iter, - S_HAVE_SOURCE, &have_source, - -1); + gtk_tree_model_get (model, &iter, S_FRAME, &f, -1); /* check if file name is not empty and we have source files for the frame */ - if (have_source) + if (f->have_source) { - gchar *file; - gint line; - gtk_tree_model_get ( - model, - &iter, - S_FILEPATH, &file, - S_LINE, &line, - -1); - move_to_line(file, line); - - g_free(file); + move_to_line(f->file, f->line); } + + frame_unref(f); }
g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL); @@ -283,7 +297,7 @@ static void on_selection_changed(GtkTreeSelection *treeselection, gpointer user_
if (2 == gtk_tree_path_get_depth(path)) { - gboolean have_source; + frame *f; GtkTreeIter iter;
gtk_tree_model_get_iter ( @@ -293,30 +307,59 @@ static void on_selection_changed(GtkTreeSelection *treeselection, gpointer user_ gtk_tree_model_get ( gtk_tree_view_get_model(GTK_TREE_VIEW(tree)), &iter, - S_HAVE_SOURCE, &have_source, + S_FRAME, &f, -1); /* check if file name is not empty and we have source files for the frame */ - if (have_source) + if (f->have_source) { - gchar *file; - gint line; - gtk_tree_model_get ( - model, - &iter, - S_FILEPATH, &file, - S_LINE, &line, - -1); - - move_to_line(file, line); - g_free(file); + move_to_line(f->file, f->line); } + frame_unref(f); }
g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL); g_list_free(rows); }
+static void on_render_function (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, + GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) +{ + frame *f; + + gtk_tree_model_get (tree_model, iter, S_FRAME, &f, -1); + if (! f) + g_object_set (cell, "text", "", NULL); + else + { + g_object_set (cell, "text", f->function, NULL); + frame_unref (f); + } +} + +static void on_render_address (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, + GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) +{ + frame *f; + + gtk_tree_model_get (tree_model, iter, S_FRAME, &f, -1); + if (f) + { + g_object_set (cell, "text", f->address, NULL); + frame_unref (f); + } + else + { + gint thread_id; + gchar *thread_label; + + gtk_tree_model_get (model, iter, S_THREAD_ID, &thread_id, -1); + thread_label = g_strdup_printf(_("Thread %i"), thread_id); + g_object_set (cell, "text", thread_label, NULL); + g_free(thread_label); + } +} + /* * inits stack trace tree */ @@ -331,14 +374,9 @@ GtkWidget* stree_init(move_to_line_cb ml, select_frame_cb sf) /* create tree view */ store = gtk_tree_store_new ( S_N_COLUMNS, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_INT, - G_TYPE_STRING, - G_TYPE_INT, - G_TYPE_INT, - G_TYPE_INT); + STREE_TYPE_FRAME, /* frame */ + G_TYPE_INT /* thread ID */, + G_TYPE_BOOLEAN /* active */); model = GTK_TREE_MODEL(store); tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store)); @@ -359,7 +397,7 @@ GtkWidget* stree_init(move_to_line_cb ml, select_frame_cb sf)
/* creating columns */ /* address */ - column = gtk_tree_view_column_new(); + column_address = column = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(column, _("Address"));
renderer_arrow = cell_renderer_frame_icon_new (); @@ -372,67 +410,59 @@ GtkWidget* stree_init(move_to_line_cb ml, select_frame_cb sf)
renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start(column, renderer, TRUE); - gtk_tree_view_column_set_attributes(column, renderer, "text", S_ADRESS, NULL); + gtk_tree_view_column_set_cell_data_func(column, renderer, on_render_address, NULL, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
/* function */ renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Function"), renderer, "text", S_FUNCTION, NULL); + column = gtk_tree_view_column_new_with_attributes (_("Function"), renderer, NULL); + gtk_tree_view_column_set_cell_data_func(column, renderer, on_render_function, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column); /* file */ renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("File"), renderer, NULL); + column_filepath = column = gtk_tree_view_column_new_with_attributes (_("File"), renderer, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column); gtk_tree_view_column_set_cell_data_func(column, renderer, on_render_filename, NULL, NULL); /* line */ renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Line"), renderer, "text", S_LINE, NULL); + column = gtk_tree_view_column_new_with_attributes (_("Line"), renderer, NULL); gtk_tree_view_column_set_cell_data_func(column, renderer, on_render_line, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
/* Last invisible column */ - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes ("", renderer, "text", S_LAST_VISIBLE, NULL); + column = gtk_tree_view_column_new (); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
- /* create threads hash table */ - threads = g_hash_table_new_full( - g_direct_hash, - g_direct_equal, - NULL, - (GDestroyNotify)gtk_tree_row_reference_free - ); - return tree; }
/* - * add frame to the tree view + * add frames to the tree view */ -void stree_add(frame *f) +void stree_add(GList *frames) { - GtkTreeRowReference *reference = (GtkTreeRowReference*)g_hash_table_lookup(threads, (gpointer)active_thread_id); - GtkTreeIter frame_iter; GtkTreeIter thread_iter; - GtkTreePath *path = gtk_tree_row_reference_get_path(reference); - gtk_tree_model_get_iter(model, &thread_iter, path); - gtk_tree_path_free(path); - - gtk_tree_store_insert_before(store, &frame_iter, &thread_iter, 0); - - gtk_tree_store_set (store, &frame_iter, - S_ADRESS, f->address, - S_FUNCTION, f->function, - S_FILEPATH, f->file, - S_LINE, f->line, - S_HAVE_SOURCE, f->have_source, - -1); + GList *item; + + g_object_ref (model); + gtk_tree_view_set_model (GTK_TREE_VIEW (tree), NULL); + + find_thread_iter (active_thread_id, &thread_iter); + /* prepending is a *lot* faster than appending, so prepend with a reversed data set */ + for (item = g_list_last (frames); item; item = item->prev) + { + gtk_tree_store_insert_with_values (store, NULL, &thread_iter, 0, + S_FRAME, item->data, -1); + } + + gtk_tree_view_set_model (GTK_TREE_VIEW (tree), model); + g_object_unref (model); }
/* @@ -441,7 +471,6 @@ void stree_add(frame *f) void stree_clear(void) { gtk_tree_store_clear(store); - g_hash_table_remove_all(threads); }
/* @@ -449,17 +478,12 @@ void stree_clear(void) */ void stree_select_first_frame(gboolean make_active) { - GtkTreeRowReference *reference; GtkTreeIter thread_iter, frame_iter; - GtkTreePath *active_path;
gtk_tree_view_expand_all(GTK_TREE_VIEW(tree)); - - reference = (GtkTreeRowReference*)g_hash_table_lookup(threads, (gpointer)active_thread_id); - 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)) + + if (find_thread_iter (active_thread_id, &thread_iter) && + gtk_tree_model_iter_children(model, &frame_iter, &thread_iter)) { GtkTreePath* path;
@@ -484,11 +508,6 @@ void stree_select_first_frame(gboolean make_active) */ void stree_destroy(void) { - if (threads) - { - g_hash_table_destroy(threads); - threads = NULL; - } }
/* @@ -496,9 +515,6 @@ void stree_destroy(void) */ void stree_add_thread(int thread_id) { - gchar *thread_label; - GtkTreePath *tpath; - GtkTreeRowReference *reference; GtkTreeIter thread_iter, new_thread_iter;
if (gtk_tree_model_get_iter_first(model, &thread_iter)) @@ -507,7 +523,7 @@ void stree_add_thread(int thread_id) do { int existing_thread_id; - gtk_tree_model_get(model, &thread_iter, S_THREAD_ID, &existing_thread_id); + gtk_tree_model_get(model, &thread_iter, S_THREAD_ID, &existing_thread_id, -1); if (existing_thread_id > thread_id) { consecutive = &thread_iter; @@ -530,17 +546,10 @@ void stree_add_thread(int thread_id) gtk_tree_store_append (store, &new_thread_iter, NULL); }
- thread_label = g_strdup_printf(_("Thread %i"), thread_id); gtk_tree_store_set (store, &new_thread_iter, - S_ADRESS, thread_label, + S_FRAME, NULL, S_THREAD_ID, thread_id, -1); - g_free(thread_label); - - tpath = gtk_tree_model_get_path(model, &new_thread_iter); - reference = gtk_tree_row_reference_new(model, tpath); - g_hash_table_insert(threads, (gpointer)(long)thread_id,(gpointer)reference); - gtk_tree_path_free(tpath); }
/* @@ -548,17 +557,10 @@ void stree_add_thread(int thread_id) */ void stree_remove_thread(int thread_id) { - GtkTreeRowReference *reference = (GtkTreeRowReference*)g_hash_table_lookup(threads, (gpointer)(glong)thread_id); - GtkTreePath *tpath = gtk_tree_row_reference_get_path(reference); - GtkTreeIter iter; - gtk_tree_model_get_iter(model, &iter, tpath);
- gtk_tree_store_remove(store, &iter); - - g_hash_table_remove(threads, (gpointer)(glong)thread_id); - - gtk_tree_path_free(tpath); + if (find_thread_iter (thread_id, &iter)) + gtk_tree_store_remove(store, &iter); }
/* @@ -566,14 +568,11 @@ void stree_remove_thread(int thread_id) */ void stree_remove_frames(void) { - GtkTreeRowReference *reference = (GtkTreeRowReference*)g_hash_table_lookup(threads, (gpointer)active_thread_id); GtkTreeIter child; GtkTreeIter thread_iter; - GtkTreePath *tpath = gtk_tree_row_reference_get_path(reference); - gtk_tree_model_get_iter(model, &thread_iter, tpath); - gtk_tree_path_free(tpath);
- if (gtk_tree_model_iter_children(model, &child, &thread_iter)) + if (find_thread_iter (active_thread_id, &thread_iter) && + gtk_tree_model_iter_children(model, &child, &thread_iter)) { while(gtk_tree_store_remove(GTK_TREE_STORE(model), &child)) ;
Modified: debugger/src/stree.h 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -31,7 +31,7 @@ GtkWidget* stree_init(move_to_line_cb ml, select_frame_cb sf); void stree_destroy(void);
-void stree_add(frame *f); +void stree_add(GList *frames); void stree_clear(void);
void stree_add_thread(int thread_id);
Modified: debugger/src/watch_model.c 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -476,9 +476,9 @@ GList *get_root_items(GtkTreeView *tree) -1); if (strlen(name)) - names = g_list_append(names, name); + names = g_list_prepend(names, name); } while (gtk_tree_model_iter_next(model, &child)); - return names; + return g_list_reverse(names); }
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).