diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2009-07-30 13:12:54 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2009-07-30 13:12:54 +0000 |
commit | 54333c3bf8e54fd15d4d3603c3877e080542b662 (patch) | |
tree | 650dff88223c7b6fea87a5e59e618ce508117ff4 /gdb/mi/mi-cmd-var.c | |
parent | cab7e4d9d5c513292e9c0b61f3eabab812ea9fb8 (diff) | |
download | gdb-54333c3bf8e54fd15d4d3603c3877e080542b662.zip gdb-54333c3bf8e54fd15d4d3603c3877e080542b662.tar.gz gdb-54333c3bf8e54fd15d4d3603c3877e080542b662.tar.bz2 |
gdb/
Replace public function varobj_list by all_root_varobjs iterator.
* mi/mi-cmd-var.c (struct mi_cmd_var_update, mi_cmd_var_update_iter):
New.
(mi_cmd_var_update): Replace the varobj_list call by all_root_varobjs.
Remove the variables rootlist, cr. New variable data.
* varobj.c (rootcount, varobj_list): Remove.
(install_variable, uninstall_variable): Remove the rootcount updates.
(all_root_varobjs): New function.
(varobj_invalidate): Use the all_root_varobjs call. Move the code to...
(varobj_invalidate_iter): ... a new function.
* varobj.h (varobj_list): Remove the prototype.
(all_root_varobjs): New prototype.
Diffstat (limited to 'gdb/mi/mi-cmd-var.c')
-rw-r--r-- | gdb/mi/mi-cmd-var.c | 64 |
1 files changed, 42 insertions, 22 deletions
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c index 55ccdbd..0cf03d9 100644 --- a/gdb/mi/mi-cmd-var.c +++ b/gdb/mi/mi-cmd-var.c @@ -566,6 +566,41 @@ mi_cmd_var_assign (char *command, char **argv, int argc) ui_out_field_string (uiout, "value", varobj_get_value (var)); } +/* Type used for parameters passing to mi_cmd_var_update_iter. */ + +struct mi_cmd_var_update + { + int only_floating; + enum print_values print_values; + }; + +/* Helper for mi_cmd_var_update - update each VAR. */ + +static void +mi_cmd_var_update_iter (struct varobj *var, void *data_pointer) +{ + struct mi_cmd_var_update *data = data_pointer; + int thread_id, thread_stopped; + + thread_id = varobj_get_thread_id (var); + + if (thread_id == -1 && is_stopped (inferior_ptid)) + thread_stopped = 1; + else + { + struct thread_info *tp = find_thread_id (thread_id); + + if (tp) + thread_stopped = is_stopped (tp->ptid); + else + thread_stopped = 1; + } + + if (thread_stopped) + if (!data->only_floating || varobj_floating_p (var)) + varobj_update_one (var, data->print_values, 0 /* implicit */); +} + void mi_cmd_var_update (char *command, char **argv, int argc) { @@ -596,31 +631,16 @@ mi_cmd_var_update (char *command, char **argv, int argc) if ((*name == '*' || *name == '@') && (*(name + 1) == '\0')) { - struct varobj **rootlist, **cr; + struct mi_cmd_var_update data; - varobj_list (&rootlist); - make_cleanup (xfree, rootlist); + data.only_floating = *name == '@'; + data.print_values = print_values; - for (cr = rootlist; *cr != NULL; cr++) - { - int thread_id = varobj_get_thread_id (*cr); - int thread_stopped = 0; + /* varobj_update_one automatically updates all the children of VAROBJ. + Therefore update each VAROBJ only once by iterating only the root + VAROBJs. */ - if (thread_id == -1 && is_stopped (inferior_ptid)) - thread_stopped = 1; - else - { - struct thread_info *tp = find_thread_id (thread_id); - if (tp) - thread_stopped = is_stopped (tp->ptid); - else - thread_stopped = 1; - } - - if (thread_stopped) - if (*name == '*' || varobj_floating_p (*cr)) - varobj_update_one (*cr, print_values, 0 /* implicit */); - } + all_root_varobjs (mi_cmd_var_update_iter, &data); } else { |