* varobj.c (varobj_invalidate): Unconditionally free
all_rootvarobj.
* symfile.c (syms_from_objfile): Free local_addr when returning
normally.
* exec.c (exec_file_attach): Do cleanups before returning.
(exec_file_command): Likewise.
* corefile.c (reopen_exec_file): Do cleanups before returning.
* breakpoint.c (insert_breakpoint_locations): Do cleanups before
returning.
(do_vec_free): New function.
(update_global_location_list): Make a cleanup for old_locations.
Do cleanups before returning. Remove unused variable 'e'.
(find_condition_and_thread): Free result of parsing the
expression.
(print_it_typical): Do cleanups before returning.
(breakpoint_re_set_one): Always free sals.sals.
Replace TYPE_ARRAY_{UPPER,LOWER}_BOUND_TYPE by a bit if {un,}defined.
* c-typeprint.c (c_type_print_varspec_suffix), m2-typeprint.c
(m2_array), p-typeprint.c (pascal_type_print_varspec_prefix),
valops.c (value_cast), varobj.c (c_number_of_children): Replace
TYPE_ARRAY_UPPER_BOUND_TYPE compared to BOUND_CANNOT_BE_DETERMINED by
TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED.
* parse.c (follow_types): Use TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED.
* f-valprint.c (f77_get_dynamic_upperbound): Replace with ...
(f77_get_upperbound): ... this function handling now only
TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED.
(f77_get_dynamic_lowerbound): Replace with ...
(f77_get_lowerbound): ... this function handling now only
TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED.
(f77_get_dynamic_length_of_aggregate, f77_create_arrayprint_offset_tbl):
Update their callers.
* eval.c (evaluate_subexp_standard): Update their callers.
* f-lang.h (f77_get_dynamic_upperbound, f77_get_upperbound)
(f77_get_dynamic_lowerbound, f77_get_lowerbound): Update their
prototypes.
(BOUND_FETCH_OK, BOUND_FETCH_ERROR): Remove.
* f-typeprint.c (f_type_print_varspec_suffix, f_type_print_base): Remove
the lower_bound_was_default variable. Update the
f77_get_dynamic_upperbound, f77_get_upperbound and
TYPE_ARRAY_UPPER_BOUND_TYPE calls.
* gdbtypes.c (print_bound_type): Remove the function.
(recursive_dump_type): Remove its calls printing UPPER_BOUND_TYPE and
LOWER_BOUND_TYPE.
* gdbtypes.h (enum array_bound_type): Remove.
(struct main_type): Remove the fields upper_bound_type and
lower_bound_type. Comment the new overload of the field artificial.
(TYPE_ARRAY_UPPER_BOUND_TYPE): Replace by ...
(TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED): ... this macro.
(TYPE_ARRAY_LOWER_BOUND_TYPE): Replace by ...
(TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED): ... this macro.
gdb/testsuite/
* gdb.base/maint.exp (maint print type): Remove printing
UPPER_BOUND_TYPE and LOWER_BOUND_TYPE.
* tracepoint.c (stringify_collection_list): Use xfree.
* remote-fileio.c (remote_fileio_reset): Use xfree.
* mipsread.c (read_alphacoff_dynamic_symtab): Use xfree.
* dfp.c (decimal_from_floating): Use xfree, xstrprintf. Don't use
asprintf.
* cp-support.c (mangled_name_to_comp): Use xfree.
* thread.c (enum thread_state): New.
(thread_state main_thread_running): Delete, in favor of...
(thread_state main_thread_state): ... this. Update throughout.
(clear_thread_inferior_resources): New, split from free_thread.
(free_thread): Call clear_thread_inferior_resources.
(init_thread_list): Set main thread to stopped state.
(add_thread_silent): Take care of PTID reuses.
(delete_thread): If deleting inferior_ptid or a thread with
refcount > 0, mark it as exited, but still keep it in the list.
Only notify of thread exits, if we haven't done so yet.
(iterate_over_threads): Make it safe to delete threads while
iterating over them.
(do_captured_list_thread_ids): Don't account for exited threads.
(thread_alive): Check for the THREAD_EXITED state, and don't set
ptid to -1 on exited threads.
(set_running): Update to account for extra possible states.
(is_thread_state): New.
(is_stopped, is_exited): New.
(is_running): Implement in terms of is_thread_state.
(any_running): Update.
(print_thread_info): Update. Account for exited threads. Don't
warn about missed frame restoring here, its done in the cleanup.
(switch_to_thread): Don't read from a thread that has gone.
(restore_current_thread): In non-stop mode, do a full context
switch.
(restore_selected_frame): Add a frame_level argument. Rewrite.
(struct current_thread_cleanup): Add selected_frame_level and
was_stopped members.
(do_restore_current_thread_cleanup): Check if thread was stopped
and still is, and if the target has registers, stack and memory
before restoring the selected frame. Don't delete the cleanup
argument here.
(restore_current_thread_cleanup_dtor): New.
(make_cleanup_restore_current_thread): Remove all arguments.
Rewrite.
(thread_apply_all_command): Update. Prune threads.
(thread_apply_command): Update.
(thread_command): Account for currently selected exited thread.
(do_captured_thread_select): Check for a running thread. Prune
threads.
(_initialize_thread): Make "info threads", "thread", "thread
apply", and "thread apply all" appliable without a selected thread.
* gdbthread.h (struct thread_info): Replace running_ by state_.
Add refcount.
(is_exited, is_stopped): Declare.
(make_cleanup_restore_current_thread): Remove all arguments.
* infrun.c: Include "event-top.h".
(fetch_inferior_event): In non-stop mode, restore selected thread
and frame after handling the event and running breakpoint
commands. Display GDB prompt if needed.
(normal_stop): In non-stop mode, don't print thread switching
notice.
* cli/cli-decode.c (set_cmd_no_selected_thread_ok)
(get_cmd_no_selected_thread_ok): New.
* cli/cli-decode.h (CMD_NO_SELECTED_THREAD_OK): New.
(set_cmd_no_selected_thread_ok, get_cmd_no_selected_thread_ok):
Declare.
* cli/cli-cmds.c: Set "pwd", "help", "info", "show" as
no-selected-thread ok.
* top.c (execute_command): Check for non no-selected-thread-ok
commands.
* linux-nat.c (struct saved_ptids, threads_to_delete)
(record_dead_thread, prune_lwps): Delete.
(exit_lwp): Unconditionally delete thread.
(linux_nat_resume): Remove prune_lwps call.
* infcmd.c (proceed_thread_callback): Check if !is_stopped instead
of is_running. Adjust to make_cleanup_restore_current_thread
interface change.
* mi/mi-main.c (mi_cmd_execute): Only allow a few commands if the
selected thread has exited.
* inf-loop.c (inferior_event_handler): Don't display the prompt
here.
* varobj.c (c_value_of_root): Update.
* defs.h (make_cleanup_dtor): Declare.
* utils.c (make_cleanup_dtor): New.
* Makefile.in (infrun.o): Depend on $(event_top_h).
* 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.
floating, and clarify the meaning.
(varobj_create, varobj_update, new_root_variable): Adjust.
(value_of_root): Don't use type_changed as in variable,
adjust comment.
(c_value_of_root): Adjust.
(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 (adjust_value_for_child_access): Added checking for
returned value from gdb_value_ind.
(c_describe_child): Likewise.
(cplus_describe_child): Fixed a typo.
(java_variable_editable, variable_editable): Delete.
(varobj_editable_p): Replace above functions with one language
independent function. Check for an lvalue.
(varobj_get_attributes, varobj_set_value): Use varobj_editable_p.
(struct language_specific): Delete variable_editable 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.
for varobjs in C++.
* varobj.c (get_type_deref): Remove.
(adjust_value_for_child_access): New.
(c_number_of_children): Use the above.
(c_describe_child): Likewise.
(enum accessibility): New.
(match_accessibility): New function.
(cplus_describe_child): New function.
(cplus_name_of_child, cplus_value_of_child)
(cplus_type_of_child): Reimplement in terms
of cplus_describe_child.
(cplus_number_of_children): Use
adjust_value_for_child_access.
value changeability for for references.
* varobj.c (get_value_type): New function.
(c_variable_editable): Use get_value_type.
(varobj_value_is_changeable): Likewise.
* varobj.c (struct varobj): Remove the error field.
(varobj_set_value): Don't check var->error.
(install_new_value): Don't set var->error.
(varobj_update): Always pass the new value
of the root via install_new_value.
(create_child): Don't set error field.
(new_variable): Likewise.
(c_value_of_root): Always reevaluate the value
of selected frame varobjs in the selected frame.
Don't call reinit_frame_cache.
(value_get_print_value): Immediately return NULL for missing
values.
* gdb.mi/mi-var-cmd.exp: Expect lpcharacter to update when
lcharacter or linteger change. Correct duplicated test name.
* gdb.mi/mi2-var-cmd.exp: Likewise.
(install_new_value): Compare last printed value with current one
instead of contents.
(new_variable): Initialize var->print_value to NULL.
(free_variable): Free var->print_value.
(value_get_print_value): New function derived from
c_value_of_variable.
(c_value_of_variable): Use value_get_print_value.
* eval.c: Include "ui-out.h" and "exceptions.h".
(evaluate_subexp_standard): Use TRY_CATCH around value_of_variable.
Use value_zero if an error occurs when avoiding side effects.
* varobj.c (c_value_of_root): Initialize new_val.
* gdb.mi/mi-var-cmd.exp: Add tests for unreadable varobjs.
variable objects in C.
* varobj.c (value_struct_element_index): New function.
(c_describe_child): New function.
(c_name_of_child, c_value_of_child)
(c_type_of_child): Rewrite to use c_describe_child.
* varobj.c: Include "vec.h".
(varobj_p): New typedef, declare vector of those.
(struct varobj): Use vector for the 'children' member.
(child_exists): Remove.
(save_child_in_parent): Remove.
(remove_child_from_parent): Remove.
(struct varobj_child): Remove.
(struct vstack): Remove.
(vpush, vpop): Remove.
(varobj_list_children): Adjust to work work vector.
(varobj_update): Likewise. Use vectors for
working stack and result.
(delete_variable_1): Likewise.
* Makefile.in (varobj.o): Update dependencies.
gdb/
* varobj.c (type_changeable): Rename to...
(varobj_value_is_changeable_p): ...this. Adjust all callers.
(is_root_p): New function. Use it everywhere.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
Fetch varobj values from memory in a single place,
and only fetch the values that are really needed.
* varobj.c (struct varobj): Clarify comment.
(my_value_equal): Remove.
(install_new_value): New function.
(type_of_child): Remove.
(varobj_create): Use install_new_value.
(varobj_set_value): Use value_contents_equal, not
my_value_equal.
(varobj_update): Use install_new_value.
(create_child): Likewise. Inline type_of_child here.
(value_of_child): Don't fetch the value.
(c_value_of_root): Likewise.
(c_value_of_variable): Likewise.
(type_changeable): Improve comments.
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.
* value.c (value_contents_equal): New function.
* varobj.c: Include "exceptions.h" and "gdb_assert.h". Don't
include <math.h>.
(varobj_set_value): Initialize error to zero.
(varobj_update): Rename error2 to error and initialize it to zero.
Slightly change the wording of some comments.
(my_value_equal): Reimplement using TRY_CATCH and
value_contents_equal.
* blockframe.c (find_frame_addr_in_frame_chain): Move function
from here ...
* varobj.c (find_frame_addr_in_frame_chain): ... to here.
(varobj_create): Note that frame ID should be used.
* frame.h (find_frame_addr_in_frame_chain): Delete declaration.
* varobj.c (child_exists, cplus_number_of_children): Change
STREQ macro references to strcmp.
(cplus_name_of_child): Change code to handle the fact that
fields are not necessarily contiguous with regards to their
access control. This is a fix for PR gdb/792.
* NEWS: add recent mi fixes.
* varobj.c (struct varobj): Add new "updated" flag.
(new_variable): Default "updated" flag to 0.
(varobj_set_value): Set "updated" flag to 1 if value
changes.
(varobj_update): Check varobj "updated" flag before
comparing old and refreshed values. Fix for
PR gdb/702.
* varobj.c (struct varobj_root): Change frame from CORE_ADDR to
struct frame_id.
(varobj_create): Store frame_id for root.
(varobj_gen_name): Use xasprintf.
(varobj_update): Save and restore frame using get_frame_id() and
frame_find_by_id().
(create_child): Use xasprintf.
(new_root_variable): Initialize frame_id.
(c_name_of_child): Use xasprintf. Call find_frame_by_id().
(c_value_of_variable): Use xasprintf. Move mem_fileopen call
to prevent memory leak.