This patch does some cleanups, removing some language-related stuff.
Note that mi_cmd_var_info_expression uses varobj_language_string,
which is redundant, because we can get language name from
lang->la_natural_name.
varobj_language_string doesn't have "Ada", which looks like a bug to
me. With this patch applied, this problem doesn't exist, because the
language name is got from the same place (field la_natural_name).
gdb:
2013-11-07 Yao Qi <yao@codesourcery.com>
* mi/mi-cmd-var.c: Include "language.h".
(mi_cmd_var_info_expression): Get language name from
language_defn.
* varobj.c (varobj_language_string): Remove.
(variable_language): Remove declaration.
(languages): Remove.
(varobj_get_language): Change the type of return value.
(variable_language): Remove.
* varobj.h (enum varobj_languages): Remove.
(varobj_language_string): Remove declaration.
(varobj_get_language): Update declaration.
gdb/doc:
2013-11-07 Yao Qi <yao@codesourcery.com>
* gdb.texinfo (GDB/MI Variable Objects): Update doc about the
output of "-var-info-expression".
This is a follow-up series to move language stuff out of varobj.c.
This patch adds a new field la_varobj_ops in struct language_defn so
that each language has varobj-related options. Not every language
supports varobj, and the operations are identical to operations of c
languages.
'struct language_defn' is the ideal place to save all language-related
operations. After this patch, some cleanups can be done in patch 2/2,
which removes language-related stuff completely from varobj.c.
Regression tested on x86_64-linux.
gdb:
2013-10-25 Yao Qi <yao@codesourcery.com>
* language.h (struct lang_varobj_ops): Declare.
(struct language_defn) <la_varobj_ops>: New field.
* ada-lang.c: Include "varobj.h"
(defn ada_language_defn): Initialize field 'la_varobj_ops' by
ada_varobj_ops.
* c-lang.c: Include "varobj.h"
(c_language_defn): Initialize field 'la_varobj_ops' by
c_varobj_ops.
(cplus_language_defn): Initialize field 'la_varobj_ops' by
cplus_varobj_ops.
(asm_language_defn): Initialize field 'la_varobj_ops' by
default_varobj_ops.
(minimal_language_defn): Likewise.
* d-lang.c (d_language_defn): Likewise.
* f-lang.c (f_language_defn): Likewise.
* go-lang.c (go_language_defn): Likewise.
* m2-lang.c (m2_language_defn): Likewise.
* objc-lang.c (objc_language_defn): Likewise.
* opencl-lang.c (opencl_language_defn): Likewise.
* p-lang.c (pascal_language_defn): Likewise.
* language.c (unknown_language_defn): Likewise.
(auto_language_defn): Likewise.
(local_language_defn): Likewise.
* jv-lang.c (java_language_defn): Initialize field
'la_varobj_ops' by java_varobj_ops.
* varobj.c (varobj_create): Update.
* varobj.h (default_varobj_ops): Define macro.
Two modifications:
1. The addition of 2013 to the copyright year range for every file;
2. The use of a single year range, instead of potentially multiple
year ranges, as approved by the FSF.
* varobj.h (varobj_languages): Add vlang_ada definition to the list
of supported languages.
* varobj.c: Add top definitions and basic implementation of the
following callbacks: ada_number_of_children, ada_name_of_variable,
ada_name_of_child, ada_path_expr_of_child, ada_value_of_root,
ada_value_of_child, ada_type_of_child, ada_value_of_variable.
(languages): Register Ada-specific callbacks.
(variable_language): Add the Ada case in the language setter switch.
Put prototype declaration on same line as return type.
* objc-exp.y: Ditto.
* p-exp.y: Ditto.
* python/py-stopevent.h: Ditto.
For long function names, split parameters to allow function name
on same line as return type.
* solib-pa64.c: Ditto.
* varobj.c: Ditto.
* varobj.h: Ditto.
For long function declaration, use single line.
* hppa-tdep.h: Ditto.
* inferior.h: Ditto.
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.
* varobj.c (varobj_update): Report changes as vector. Also
return not just a list of varobj, but a list of special structures
that tell what exactly has changed.
* varobj.h (enum varobj_update_error): Rename to
varobj_scope_status.
(struct varobj_update_result_t): New.
(varobj_update): Adjust prototype.
* mi/mi-cmd-var.c: Adjust for changes.
2008-04-09 Marc Khouzam <marc.khouzam@ericsson.com>
* mi/mi-cmd-var.c: Include "mi-getopt.h".
(mi_parse_format): New. Factored out from mi_cmd_var_set_format.
(mi_cmd_var_set_format): Use new mi_parse_format.
(mi_cmd_var_evaluate_expression): Support for -f option to specify
format.
* Makefile.in (mi-cmd-var.o): Update dependencies.
* varobj.h (varobj_get_formatted_value): Declare.
* varobj.c (my_value_of_variable): Added format parameter.
(cplus_value_of_variable): Likewise.
(java_value_of_variable): Likewise.
(c_value_of_variable): Likewise. Evaluate expression based
on format parameter.
(struct language_specific): Add format parameter to function member
*value_of_variable.
(varobj_get_formatted_value): New.
(varobj_get_value): Added format parameter to method call.
gdb/doc/ChangeLog
2008-04-09 Marc Khouzam <marc.khouzam@ericsson.com>
* gdb.texinfo (GDB/MI Variable Objects): Add anchor to
-var-set-format. Add -f option to -var-evaluate-expression.
gdb/testsuite/ChangeLog
2008-04-09 Marc Khouzam <marc.khouzam@ericsson.com>
* gdb.mi/mi2-var-display.exp: Added tests for the new -f
option of -var-evaluate-expression.
* gdb.mi/mi2-var-display.exp: Likewise.
(varobj_get_thread_id, check_scope): New functions.
(c_value_of_root): Use check_scope. Switch to the
proper thread if necessary.
* varobj.h (varobj_get_thread_id): New extern.
* mi/mi-cmd-var.c (print_varobj): Add thread-id field.
(varobj_get_frozen): New.
(varobj_update): New parameter explicit.
* varobj.c (struct varobj): New fields frozen
and not_fetched.
(varobj_set_frozen, varobj_get_frozen): New.
(install_new_value): Don't fetch values for
frozen variable object, or children thereof. Allow
a frozen variable object to have non-fetched value.
(varobj_update): Allow updating child variables.
Don't traverse frozen children.
(new_variable): Initialize the frozen field.
(c_value_of_variable): Return NULL for frozen
variable without any value yet.
* mi/mi-cmd-var.c (varobj_update_one): New parameter
'explicit'.
(mi_cmd_var_create): Output the 'frozen' field,
as soon as testsuite is adjusted to expect that field.
(mi_cmd_var_set_frozen): New.
(mi_cmd_var_update): Pass the 'explicit' parameter to
varobj_update_one.
* mi/mi-cmds.c (mi_cmds): Register '-var-set-frozen'.
* mi/mi-cmds.h (mi_cmd_var_set_frozen): Declare.
* varobj.h (enum varobj_update_error): New enum.
* varobj.c (struct varobj_root): Add is_valid member.
(varobj_get_type): Check for invalid varobj.
(varobj_get_attributes): Likewise.
(variable_editable):Likewise.
(varobj_update): Likewise. Use varobj_update_error.
(new_root_variable): Set root varobj as valid by default.
(varobj_invalidate): New function.
* symfile.c (clear_symtab_users): Use varobj_invalidate.
* mi/mi-cmd-var.c (varobj_update_one): Change return type to void.
Use varobj_update_error.
Daniel Jacobowitz <dan@codesourcery.com>
* mi/mi-cmds.h (mi_no_values, mi_simple_values, mi_all_values): New
declarations.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_locals): Use string
constants instead of literals for MI command options.
* mi/mi-cmd-var.c (mi_no_values, mi_simple_values, mi_all_values):
New variables.
(mi_parse_values_option, mi_print_value_p): New functions.
(mi_cmd_var_list_children): Use mi_parse_values_option and
mi_print_value_p.
(mi_cmd_var_update): Support a PRINT_VALUES option. Update calls
to varobj_update_one.
(varobj_update_one): Take a print_values argument. Call
mi_print_value_p.
* varobj.c (varobj_get_gdb_type): New function.
* varobj.h (varobj_get_gdb_type): New prototype.
pointer to struct varobj*. This function can delete
varobjs, so we need to give callers the new varobj
when this happens.
(value_of_root): Update "var", too, if "var_handle"
changes.
* varobj.h (varobj_update): Likewise.
Add support for a variable object that tries to evaluate itself in
the currently selected frame, rather than in a fixed frame.
* wrapper.c,h (gdb_parse_exp_1): Added a wrapper for
gdb_parse_exp_1.
* varobj.h: Added USE_CURRENT_FRAME to varobj_type & changed def'n
of varobj_create.
* varobj.c (varobj_list): Return type indicates whether the
variable's type has changed (for current frame variables).
(varobj_update): Handle the case where the variable's type has
changed.
(delete_variable_1): Allow for deletion of variables that have not
been installed yet.
(new_root_variable): Initialize use_selected_frame variable.
(value_of_root): This is where most of the work to handle "current
frame" variables was added. Most of the complexity involves
handling the case where the type of the variable has changed.
(varobj_create): Add a "type" argument, to tell if the
variable is one of these "current frame" variables. Also protect
call to parse_exp_1 from long jumping.
* mi-var-block.exp: The error report from varobj_create changed
since I am now trapping parse_exp_1 errors. Change the tests to
match the new error message.
* mi-var-child.exp: Ditto.
* mi-var-cmd.exp: Ditto.
* lib/gdb.exp: Fix the gdbtk_start routine to correctly find all
the library directories.
* gdbtk-varobj.c (variable_create): Pass the correct
"how_specified" flag to the varobj_create routine.