Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Tue, 09 Feb 2016 01:17:45 UTC Commit: fb28b3d9fa0a8070f916b1ab891a1f087f513ea6 https://github.com/geany/geany-plugins/commit/fb28b3d9fa0a8070f916b1ab891a1f...
Log Message: ----------- Merge branch 'debugger/thread-support' into debugger/master
Modified Paths: -------------- debugger/src/breakpoints.h debugger/src/dbm_gdb.c debugger/src/debug.c debugger/src/debug_module.h debugger/src/stree.c debugger/src/stree.h
Modified: debugger/src/breakpoints.h 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -33,6 +33,7 @@ typedef enum _break_state { } break_state;
typedef void (*move_to_line_cb)(const char* file, int line); +typedef void (*select_thread_cb)(int thread_id); typedef void (*select_frame_cb)(int frame_number);
gboolean breaks_init(move_to_line_cb callback);
Modified: debugger/src/dbm_gdb.c 28 lines changed, 28 insertions(+), 0 deletions(-) =================================================================== @@ -1082,6 +1082,34 @@ static void set_active_frame(int frame_number) g_free(command); }
+static int get_active_thread(void) +{ + struct gdb_mi_record *record = NULL; + int current_thread = 0; + + if (RC_DONE == exec_sync_command("-thread-info", TRUE, &record)) + { + const gchar *id = gdb_mi_result_var(record->first, "current-thread-id", GDB_MI_VAL_STRING); + current_thread = id ? atoi(id) : 0; + } + gdb_mi_record_free(record); + + return current_thread; +} + +static gboolean set_active_thread(int thread_id) +{ + gchar *command = g_strdup_printf("-thread-select %i", thread_id); + gboolean success = (RC_DONE == exec_sync_command(command, TRUE, NULL)); + + if (success) + set_active_frame(0); + + g_free(command); + + return success; +} + /* * gets stack */
Modified: debugger/src/debug.c 31 lines changed, 30 insertions(+), 1 deletions(-) =================================================================== @@ -960,6 +960,35 @@ static void on_select_frame(int frame_number) }
/* + * called when a thread should been selected + */ +static void on_select_thread(int thread_id) +{ + gboolean success; + + if (stack) + remove_stack_markers(); + + if ((success = active_module->set_active_thread(thread_id))) + { + g_list_free_full(stack, (GDestroyNotify)frame_unref); + stack = active_module->get_stack(); + + /* update the stack tree */ + stree_remove_frames(); + stree_set_active_thread_id(thread_id); + stree_add(stack); + stree_select_first_frame(TRUE); + } + + if (stack) + add_stack_markers(); + + if (success) + on_select_frame(0); +} + +/* * init debug related GUI (watch tree view) * arguments: */ @@ -1002,7 +1031,7 @@ void debug_init(void) gtk_container_add(GTK_CONTAINER(tab_autos), atree); /* create stack trace page */ - stree = stree_init(editor_open_position, on_select_frame); + stree = stree_init(editor_open_position, on_select_thread, on_select_frame); tab_call_stack = gtk_scrolled_window_new( gtk_tree_view_get_hadjustment(GTK_TREE_VIEW(stree )), gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(stree ))
Modified: debugger/src/debug_module.h 7 lines changed, 6 insertions(+), 1 deletions(-) =================================================================== @@ -121,7 +121,10 @@ typedef struct _dbg_module {
void (*set_active_frame)(int frame_number); int (*get_active_frame)(void); - + + gboolean (*set_active_thread)(int thread_id); + int (*get_active_thread)(void); + GList* (*get_autos) (void); GList* (*get_watches) (void); @@ -155,6 +158,8 @@ typedef struct _dbg_module { get_stack, \ set_active_frame, \ get_active_frame, \ + set_active_thread, \ + get_active_thread, \ get_autos, \ get_watches, \ get_files, \
Modified: debugger/src/stree.c 31 lines changed, 16 insertions(+), 15 deletions(-) =================================================================== @@ -54,6 +54,7 @@ static int active_frame_index = 0;
/* callbacks */ static select_frame_cb select_frame = NULL; +static select_thread_cb select_thread = NULL; static move_to_line_cb move_to_line = NULL;
/* tree view, model and store handles */ @@ -284,26 +285,20 @@ static gboolean on_msgwin_button_press(GtkWidget *widget, GdkEventButton *event, static void on_cursor_changed(GtkTreeView *treeview, gpointer user_data) { GtkTreePath *path; + GtkTreeIter iter; + frame *f; + int thread_id;
gtk_tree_view_get_cursor(treeview, &path, NULL); if (! path) return;
- if (2 == gtk_tree_path_get_depth(path)) - { - frame *f; - GtkTreeIter iter; + gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_model_get (model, &iter, + S_FRAME, &f, S_THREAD_ID, &thread_id, -1);
- gtk_tree_model_get_iter ( - model, - &iter, - path); - gtk_tree_model_get ( - gtk_tree_view_get_model(GTK_TREE_VIEW(tree)), - &iter, - S_FRAME, &f, - -1); - + if (f) /* frame */ + { /* check if file name is not empty and we have source files for the frame */ if (f->have_source) { @@ -311,6 +306,11 @@ static void on_cursor_changed(GtkTreeView *treeview, gpointer user_data) } frame_unref(f); } + else /* thread */ + { + if (thread_id != active_thread_id) + select_thread(thread_id); + }
gtk_tree_path_free(path); } @@ -356,12 +356,13 @@ static void on_render_address (GtkTreeViewColumn *tree_column, GtkCellRenderer * /* * inits stack trace tree */ -GtkWidget* stree_init(move_to_line_cb ml, select_frame_cb sf) +GtkWidget* stree_init(move_to_line_cb ml, select_thread_cb st, select_frame_cb sf) { GtkTreeViewColumn *column; GtkCellRenderer *renderer;
move_to_line = ml; + select_thread = st; select_frame = sf;
/* create tree view */
Modified: debugger/src/stree.h 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -28,7 +28,7 @@ #include "breakpoints.h" #include "debug_module.h"
-GtkWidget* stree_init(move_to_line_cb ml, select_frame_cb sf); +GtkWidget* stree_init(move_to_line_cb ml, select_thread_cb st, select_frame_cb sf); void stree_destroy(void);
void stree_add(GList *frames);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org