Branch: refs/heads/master Author: Dimitar Zhekov dimitar.zhekov@gmail.com Committer: Dimitar Zhekov dimitar.zhekov@gmail.com Date: Thu, 13 Dec 2012 19:32:32 UTC Commit: daf403f29617605c8a04d7f3d62cbf20cda56cb6 https://github.com/geany/geany-plugins/commit/daf403f29617605c8a04d7f3d62cbf...
Log Message: ----------- scope - per-function @entry arguments, small fixes
Modified Paths: -------------- scope/ChangeLog scope/NOTES scope/TODO scope/data/scope.glade scope/docs/scope.html scope/src/inspect.c scope/src/local.c scope/src/menu.c scope/src/parse.c scope/src/parse.h scope/src/scope.c scope/src/stack.c scope/src/stack.h scope/src/thread.c
Modified: scope/ChangeLog 10 files changed, 10 insertions(+), 0 deletions(-) =================================================================== @@ -1 +1,11 @@ +2011-12-13 Dimitar Zhekov dimitar.zhekov@gmail.com
+ * data/scope.glade, src/local.c, src/parse.c, src/parse.h, + src/stack.c, src/stack.h: + Per-function display of @entry arguments. + * src/inspect.c, src/menu.c: + Small per-function @entry arguments related changes. + * src/inspect.c, src/local.c + (int) strlen(...) to avoid format warnings. + * docs/scope.html, src/scope.c: + Increased version to 0.76, small fixes and clarifications.
Modified: scope/NOTES 3 files changed, 3 insertions(+), 0 deletions(-) =================================================================== @@ -1,3 +1,6 @@ +modifying a local function argument refreshes all stack frames - it may be +a struct or reference argument in other frames + the only way to fix unnecessary inspect drop target expansion is to block INTO, so deriving GtkTreeStore and altering GtkTreeDragDest make no sense
Modified: scope/TODO 2 files changed, 0 insertions(+), 2 deletions(-) =================================================================== @@ -1,7 +1,5 @@ wscript_*
-per-function [ ] Show @entry arguments - evaluate expressions with quotes
various tests, source code checks etc.
Modified: scope/data/scope.glade 14 files changed, 14 insertions(+), 0 deletions(-) =================================================================== @@ -651,6 +651,18 @@ </object> </child> <child> + <object class="GtkCheckMenuItem" id="stack_show_entry"> + <property name="visible">True</property> + <property name="label" translatable="yes">Show _@entry</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkSeparatorMenuItem" id="stack_separator2"> + <property name="visible">True</property> + </object> + </child> + <child> <object class="GtkCheckMenuItem" id="stack_show_address"> <property name="visible">True</property> <property name="label" translatable="yes">Show _Address</property> @@ -1186,6 +1198,8 @@ <column type="gchararray"/> <!-- column-name stack_store_addr --> <column type="gchararray"/> + <!-- column-name stack_store_entry --> + <column type="gboolean"/> </columns> </object> <object class="GtkListStore" id="local_store">
Modified: scope/docs/scope.html 20 files changed, 11 insertions(+), 9 deletions(-) =================================================================== @@ -385,12 +385,12 @@
<p><b><a name="stack">Stack</a></b></p>
-<p>The stack will be updated slightly faster if you keep it unsorted or ordered by frame # -ascending.</p> - <p>The function arguments are subject to 8-bit text conversion. Their individual modes may be set via <em>Locals</em>.</p>
+<p><em>Show @entry</em> - display any @entry arguments for the current function. Applies to +<em>Locals</em> too.</p> + <p><b><a name="local">Locals</a></b></p>
<p>The first column is "1" for arguments, empty for local variables.</p> @@ -550,6 +550,8 @@ <p>A disabled check button or check menu item means that the respective functionality is unavailable; it doesn't matter if the interface element is checked or not.</p>
+<p>All subpages will be updated faster if you keep them unsorted.</p> + <p><b><a name="editing_values">Editing values</a></b></p>
<div>GDB often displays values in format unsuitable for assigning. So when editing a value, @@ -575,13 +577,13 @@ with backslash will fail. If parsing errors are detected when editing the <em>Value</em> column, the entire value will be cleared - but that is not guaranteed to work either.</p>
-<p><b><a name="keeping_modes">Editing values</a></b></p> +<p><b><a name="keeping_modes">Keeping modes</a></b></p>
-<p>The 7-bit and .names modes for temporary objects, such as local variables, are not saved. -However, there is a global list with names and modes, and whenever you change a mode, it's -saved in that list. When a temporary object is created, Scope searches the list, and sets the +<p>The 7-bit, .names etc. modes for temporary objects, such as local variables, are not saved. +However, there is a global list with names and modes, and when you change a mode, it's saved +in that list. Then, when a temporary object is created, Scope searches the list, and sets the modes (if any) for that object. For inspect children, the displayed names are used (including -numbers for array elements), not the not the fully qualified names.</p> +numbers for array elements), not the fully qualified names.</p>
<p><b><a name="xos4_colors">Sample dark colors</a></b></p>
@@ -668,7 +670,7 @@
<b><a name="copyright">Copyright</a></b>
-<p>Scope 0.75, Copyright (C) 2012 Dimitar Toshkov Zhekov</p> +<p>Scope 0.76, Copyright (C) 2012 Dimitar Toshkov Zhekov</p>
<p>The menu and toolbar icons are from <a href="http://netbeans.org">Netbeans</a>, except for BreakPoint.</p>
Modified: scope/src/inspect.c 4 files changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -158,7 +158,7 @@ static void inspect_expand(GtkTreeIter *iter) gtk_tree_model_get(model, iter, INSPECT_VAR1, &var1, INSPECT_START, &start, INSPECT_COUNT, &count, INSPECT_NUMCHILD, &numchild, -1); s = g_strdup_printf("%d", start); - debug_send_format(N, "07%c%d%d-var-list-children 1 %s %d %d", '0' + strlen(s) - 1, + debug_send_format(N, "07%c%d%d-var-list-children 1 %s %d %d", '0' + (int) strlen(s) - 1, start, scid, var1, start, count ? start + count : numchild); g_free(s); } @@ -914,7 +914,7 @@ static void on_inspect_hbit_update(const MenuItem *menu_item) gtk_tree_selection_get_selected(selection, NULL, &iter); gtk_tree_model_get(model, &iter, INSPECT_EXPR, &expr, INSPECT_NAME, &name, -1); inspect_hbit_update_iter(&iter, hb_mode); - parse_mode_update(expr, hb_mode, TRUE); + parse_mode_update(expr, MODE_HBIT, hb_mode);
if (name) {
Modified: scope/src/local.c 21 files changed, 14 insertions(+), 7 deletions(-) =================================================================== @@ -64,7 +64,13 @@ static void on_local_display_edited(G_GNUC_UNUSED GtkCellRendererText *renderer, { NULL, NULL } };
-static void local_node_variable(const ParseNode *node, const char *name) +typedef struct _LocalData +{ + char *name; + gboolean entry; +} LocalData; + +static void local_node_variable(const ParseNode *node, const LocalData *ld) { iff (node->type == PT_ARRAY, "variables: contains value") { @@ -76,14 +82,14 @@ static void local_node_variable(const ParseNode *node, const char *name) GtkTreeIter iter; const char *arg1 = parse_find_value(nodes, "arg");
- //if (!arg1 || show entry arguments || !g_str_has_suffix(var.name, "@entry")) + if (!arg1 || ld->entry || !g_str_has_suffix(var.name, "@entry")) { gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, LOCAL_NAME, var.name, LOCAL_DISPLAY, var.display, LOCAL_VALUE, var.value, LOCAL_HB_MODE, var.hb_mode, LOCAL_MR_MODE, var.mr_mode, LOCAL_ARG1, arg1, -1);
- if (name && !strcmp(var.name, name)) + if (!g_strcmp0(var.name, ld->name)) gtk_tree_selection_select_iter(selection, &iter); } parse_variable_free(&var); @@ -101,16 +107,17 @@ void on_local_variables(GArray *nodes) { char *name = NULL; GtkTreeIter iter; + LocalData ld = { NULL, stack_entry() };
if (gtk_tree_selection_get_selected(selection, NULL, &iter)) { - gtk_tree_model_get(model, &iter, LOCAL_NAME, &name, -1); + gtk_tree_model_get(model, &iter, LOCAL_NAME, &ld.name, -1); name = g_strdup(name); }
locals_clear(); - array_foreach(parse_lead_array(nodes), (GFunc) local_node_variable, name); - g_free(name); + array_foreach(parse_lead_array(nodes), (GFunc) local_node_variable, &ld); + g_free(ld.name); } }
@@ -131,7 +138,7 @@ void locals_clear(void) static void local_send_update(char token) { debug_send_format(F, "0%c%c%s%s-stack-list-variables 1", token, - '0' + strlen(thread_id) - 1, thread_id, frame_id); + '0' + (int) strlen(thread_id) - 1, thread_id, frame_id); }
gboolean locals_update(void)
Modified: scope/src/menu.c 2 files changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -234,7 +234,7 @@ void menu_mode_update(GtkTreeSelection *selection, gint new_mode, gboolean hbit) gtk_tree_selection_get_selected(selection, &model, &iter); gtk_tree_model_get(model, &iter, COLUMN_NAME, &name, -1); menu_mode_update_iter(model, &iter, new_mode, hbit); - parse_mode_update(name, new_mode, hbit); + parse_mode_update(name, hbit ? MODE_HBIT : MODE_MEMBER, new_mode);
if (hbit) {
Modified: scope/src/parse.c 27 files changed, 17 insertions(+), 10 deletions(-) =================================================================== @@ -482,6 +482,7 @@ static gboolean parse_mode_load(GKeyFile *config, const char *section) char *name = utils_key_file_get_string(config, section, "name"); gint hb_mode = g_key_file_get_integer(config, section, "hbit", NULL); gint mr_mode = g_key_file_get_integer(config, section, "member", NULL); + gboolean entry = g_key_file_get_boolean(config, section, "entry", NULL);
if (name && (unsigned) hb_mode < HB_COUNT && (unsigned) mr_mode < MR_MODIFY) { @@ -490,6 +491,7 @@ static gboolean parse_mode_load(GKeyFile *config, const char *section) pm->name = name; pm->hb_mode = hb_mode; pm->mr_mode = mr_mode; + pm->entry = entry; return TRUE; }
@@ -502,10 +504,11 @@ static gboolean parse_mode_save(GKeyFile *config, const char *section, ParseMode g_key_file_set_string(config, section, "name", pm->name); g_key_file_set_integer(config, section, "hbit", pm->hb_mode); g_key_file_set_integer(config, section, "member", pm->mr_mode); + g_key_file_set_boolean(config, section, "entry", pm->entry); return TRUE; }
-static ParseMode parse_mode_default = { NULL, HB_DEFAULT, MR_DEFAULT }; +static ParseMode parse_mode_default = { NULL, HB_DEFAULT, MR_DEFAULT, TRUE };
char *parse_mode_reentry(const char *name) { @@ -526,7 +529,7 @@ const ParseMode *parse_mode_find(const char *name) return pm ? pm : &parse_mode_default; }
-void parse_mode_update(const char *name, gint new_mode, gboolean hbit) +void parse_mode_update(const char *name, gint mode, gint value) { char *pm_name = parse_mode_pm_name(name); ParseMode *pm = (ParseMode *) array_find(parse_modes, pm_name, FALSE); @@ -537,19 +540,23 @@ void parse_mode_update(const char *name, gint new_mode, gboolean hbit) pm->name = strdup(pm_name); pm->hb_mode = HB_DEFAULT; pm->mr_mode = MR_DEFAULT; + pm->entry = TRUE; } g_free(pm_name);
- if (hbit) - pm->hb_mode = new_mode; - else - pm->mr_mode = new_mode; - - if (pm->hb_mode == HB_DEFAULT && pm->mr_mode == MR_DEFAULT) + switch (mode) { - array_remove(parse_modes, pm); - pm = &parse_mode_default; + case MODE_HBIT : pm->hb_mode = value; break; + case MODE_MEMBER : pm->mr_mode = value; break; + default : + { + g_assert(mode == MODE_ENTRY); + pm->entry = value; + } } + + if (pm->hb_mode == HB_DEFAULT && pm->mr_mode == MR_DEFAULT && pm->entry == TRUE) + array_remove(parse_modes, pm); }
gboolean parse_variable(GArray *nodes, ParseVariable *var, const char *children)
Modified: scope/src/parse.h 10 files changed, 9 insertions(+), 1 deletions(-) =================================================================== @@ -82,11 +82,19 @@ enum MR_EDITVC };
+enum +{ + MODE_HBIT, + MODE_MEMBER, + MODE_ENTRY +}; + typedef struct _ParseMode { char *name; gint hb_mode; gint mr_mode; + gboolean entry; } ParseMode;
typedef struct _ParseVariable @@ -104,7 +112,7 @@ enum
char *parse_mode_reentry(const char *name); const ParseMode *parse_mode_find(const char *name); -void parse_mode_update(const char *name, gint new_mode, gboolean hbit); +void parse_mode_update(const char *name, gint mode, gint value); gboolean parse_variable(GArray *nodes, ParseVariable *var, const char *children); #define parse_variable_free(var) g_free((var)->display)
Modified: scope/src/scope.c 2 files changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -32,7 +32,7 @@ PLUGIN_VERSION_CHECK(215)
PLUGIN_SET_TRANSLATABLE_INFO(LOCALEDIR, GETTEXT_PACKAGE, _("Scope Debugger"), - _("Simple GDB front-end."), "0.75" , "Dimitar Toshkov Zhekov dimitar.zhekov@gmail.com") + _("Simple GDB front-end."), "0.76" , "Dimitar Toshkov Zhekov dimitar.zhekov@gmail.com")
/* Keybinding(s) */ enum
Modified: scope/src/stack.c 106 files changed, 88 insertions(+), 18 deletions(-) =================================================================== @@ -29,7 +29,8 @@ enum STACK_BASE_NAME, STACK_FUNC, STACK_ARGS, - STACK_ADDR + STACK_ADDR, + STACK_ENTRY };
static GtkListStore *store; @@ -53,7 +54,8 @@ static void stack_node_location(const ParseNode *node, const char *fid) gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, STACK_ID, id, STACK_FILE, loc.file, STACK_LINE, loc.line, STACK_BASE_NAME, loc.base_name, STACK_FUNC, - loc.func, STACK_ARGS, NULL, STACK_ADDR, loc.addr, -1); + loc.func, STACK_ARGS, NULL, STACK_ADDR, loc.addr, STACK_ENTRY, + loc.func ? parse_mode_find(loc.func)->entry : TRUE, -1); parse_location_free(&loc);
if (!g_strcmp0(id, fid)) @@ -86,23 +88,30 @@ void on_stack_frames(GArray *nodes) } }
-static void append_argument_variable(const ParseNode *node, GString *string) +typedef struct _StackData +{ + GString *string; + gboolean entry; +} StackData; + +static void append_argument_variable(const ParseNode *node, const StackData *sd) { iff (node->type == PT_ARRAY, "args: contains value") { ParseVariable var;
- if (parse_variable((GArray *) node->value, &var, NULL)) //&& - //(show entry arguments || !g_str_has_suffix(var.name, "@entry"))) + if (parse_variable((GArray *) node->value, &var, NULL) && + (sd->entry || !g_str_has_suffix(var.name, "@entry"))) { - if (string->len) - g_string_append(string, ", "); + if (sd->string->len) + g_string_append(sd->string, ", "); + if (option_argument_names) { - g_string_append_printf(string, + g_string_append_printf(sd->string, option_long_mr_format ? "%s = " : "%s=", var.name); } - g_string_append(string, var.display); + g_string_append(sd->string, var.display); parse_variable_free(&var); } } @@ -139,11 +148,13 @@ static void stack_node_arguments(const ParseNode *node, ArgsData *ad)
iff (ad->valid, "%s: level not found", id) { - GString *string = g_string_sized_new(0xFF); + StackData sd;
- array_foreach(nodes, (GFunc) append_argument_variable, string); - gtk_list_store_set(store, &ad->iter, STACK_ARGS, string->str, -1); - g_string_free(string, TRUE); + sd.string = g_string_sized_new(0xFF); + gtk_tree_model_get(model, &ad->iter, STACK_ENTRY, &sd.entry, -1); + array_foreach(nodes, (GFunc) append_argument_variable, &sd); + gtk_list_store_set(store, &ad->iter, STACK_ARGS, sd.string->str, -1); + g_string_free(sd.string, TRUE); ad->valid = ad->sorted && gtk_tree_model_iter_next(model, &ad->iter); } } @@ -165,6 +176,16 @@ void on_stack_arguments(GArray *nodes) array_foreach(parse_lead_array(nodes), (GFunc) stack_node_arguments, &ad); }
+gboolean stack_entry(void) +{ + GtkTreeIter iter; + gboolean entry; + + gtk_tree_selection_get_selected(selection, NULL, &iter); + gtk_tree_model_get(model, &iter, STACK_ENTRY, &entry, -1); + return entry; +} + void stack_clear(void) { gtk_list_store_clear(store); @@ -225,29 +246,78 @@ static void on_stack_show_address(const MenuItem *menu_item) view_column_set_visible("stack_addr_column", stack_show_address); }
+static void on_stack_show_entry(const MenuItem *menu_item) +{ + gboolean entry = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_item->widget)); + GtkTreeIter iter; + const char *func; + guint count = 0; + + view_dirty(VIEW_LOCALS); + gtk_tree_selection_get_selected(selection, NULL, &iter); + gtk_tree_model_get(model, &iter, STACK_FUNC, &func, -1); + parse_mode_update(func, MODE_ENTRY, entry); + gtk_tree_model_get_iter_first(model, &iter); + do + { + const char *func1; + + gtk_tree_model_get(model, &iter, STACK_FUNC, &func1, -1); + if (!strcmp(func, func1)) + { + gtk_list_store_set(store, &iter, STACK_ENTRY, entry, -1); + count++; + } + } while (gtk_tree_model_iter_next(model, &iter)); + + if (count == 1) + { + debug_send_format(T, "04%s-stack-list-arguments 1 %s %s", thread_id, frame_id, + frame_id); + } + else + debug_send_format(T, "04%s-stack-list-arguments 1", thread_id); +} + #define DS_FRESHABLE (DS_DEBUG | DS_EXTRA_1) -#define DS_VIEWABLE (DS_BASICS | DS_EXTRA_2) +#define DS_ENTRABLE (DS_ACTIVE | DS_EXTRA_2) +#define DS_VIEWABLE (DS_ACTIVE | DS_EXTRA_3)
static MenuItem stack_menu_items[] = { { "stack_refresh", on_stack_refresh, DS_FRESHABLE, NULL, NULL }, { "stack_unsorted", on_stack_unsorted, DS_SORTABLE, NULL, NULL }, { "stack_view_source", on_stack_view_source, DS_VIEWABLE, NULL, NULL }, + { "stack_show_entry", on_stack_show_entry, DS_ENTRABLE, NULL, NULL }, { "stack_show_address", on_stack_show_address, 0, NULL, &stack_show_address }, { NULL, NULL, 0, NULL, NULL } };
static guint stack_menu_extra_state(void) { - return ((thread_id != NULL) << DS_INDEX_1) | - (gtk_tree_selection_get_selected(selection, NULL, NULL) << DS_INDEX_2); + GtkTreeIter iter; + const char *func = NULL; + + if (gtk_tree_selection_get_selected(selection, NULL, &iter)) + gtk_tree_model_get(model, &iter, STACK_FUNC, &func, -1); + + return ((thread_id != NULL) << DS_INDEX_1) | ((func != NULL) << DS_INDEX_2) | + ((frame_id != NULL) << DS_INDEX_3); }
static MenuInfo stack_menu_info = { stack_menu_items, stack_menu_extra_state, 0 };
static void on_stack_menu_show(G_GNUC_UNUSED GtkWidget *widget, const MenuItem *menu_item) { - menu_item_set_active(menu_item, stack_show_address); + GtkTreeIter iter; + + if (gtk_tree_selection_get_selected(selection, NULL, &iter)) + { + gboolean entry; + gtk_tree_model_get(model, &iter, STACK_ENTRY, &entry, -1); + menu_item_set_active(menu_item, entry); + } + menu_item_set_active(menu_item + 1, stack_show_address); }
void stack_init(void) @@ -270,5 +340,5 @@ void stack_init(void) stack_seek_selected); g_signal_connect(selection, "changed", G_CALLBACK(on_stack_selection_changed), NULL); g_signal_connect(menu, "show", G_CALLBACK(on_stack_menu_show), - (gpointer) menu_item_find(stack_menu_items, "stack_show_address")); + (gpointer) menu_item_find(stack_menu_items, "stack_show_entry")); }
Modified: scope/src/stack.h 1 files changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -24,6 +24,7 @@ void on_stack_frames(GArray *nodes); void on_stack_arguments(GArray *nodes);
+gboolean stack_entry(void); void stack_clear(void); gboolean stack_update(void);
Modified: scope/src/thread.c 2 files changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -773,7 +773,7 @@ static void on_thread_show_core(const MenuItem *menu_item) #define DS_INTRABLE (DS_ACTIVE | DS_EXTRA_2) #define DS_TERMABLE (DS_ACTIVE | DS_EXTRA_2) #define DS_SIGNABLE (DS_ACTIVE | DS_EXTRA_2) -#define DS_VIEWABLE (DS_BASICS | DS_EXTRA_3) +#define DS_VIEWABLE (DS_ACTIVE | DS_EXTRA_3)
static MenuItem thread_menu_items[] = {
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
plugins-commits@lists.geany.org