Commit Graph

368 Commits

Author SHA1 Message Date
Markus Metzger 33b4777ca1 btrace, frame: fix crash in get_frame_type
In skip_artificial_frames we repeatedly call get_prev_frame_always until we get
a non-inline and non-tailcall frame assuming that there must be such a frame
eventually.

For record targets, however, we may have a frame chain that consists only of
artificial frames.  This leads to a crash in get_frame_type when dereferencing a
NULL frame pointer.

Change skip_artificial_frames and skip_tailcall_frames to return NULL in such a
case and modify each caller to cope with a NULL return.

In frame_unwind_caller_pc and frame_unwind_caller_arch, we simply assert that
the returned value is not NULL.  Their caller was supposed to check
frame_unwind_caller_id before calling those functions.

In other cases, we thrown an error.

In infcmd further move the skip_tailcall_frames call to the forward-stepping
case since we don't need a frame for reverse execution and we don't want to fail
because of that.  Reverse-finish does make sense for a tailcall frame.

gdb/
	* frame.h (skip_tailcall_frames): Update comment.
	* frame.c (skip_artificial_frames, skip_tailcall_frames): Return NULL
	if only	artificial frames are found.  Update comment.
	(frame_unwind_caller_id): Handle NULL return.
	(frame_unwind_caller_pc, frame_unwind_caller_arch): Assert that
	skip_artificial_frames does not return NULL.
	(frame_pop): Add an error if only tailcall frames are found.
	* infcmd.c (finish_command): Move skip_tailcall_frames call into forward-
	execution case.  Add an error if only tailcall frames are found.

testsuite/
	* gdb.btrace/tailcall-only.exp: New.
	* gdb.btrace/tailcall-only.c: New.
	* gdb.btrace/x86_64-tailcall-only.S: New.
	* gdb.btrace/i686-tailcall-only.S: New.
2016-02-12 09:49:48 +01:00
Markus Metzger 2f3ef606b9 frame: add skip_tailcall_frames
Add a new function skip_tailcall_frames to skip TAILCALL_FRAME frames.

gdb/
	* frame.h (skip_tailcall_frames): New.
	* frame.c (skip_tailcall_frames): New.
	(frame_pop): Call skip_tailcall_frames.
	* infcmd.c (finish_command): Call skip_tailcall_frames.
2016-02-12 09:44:42 +01:00
Pedro Alves a911d87ad7 Fix PR19388: Can't access $_siginfo in breakpoint (catch signal) condition
This commit merges both the registers and $_siginfo "thread
running/executing" checks into a single function.

Accessing $_siginfo from a "catch signal" breakpoint condition doesn't
work.  The condition always fails with "Selected thread is running":

 (gdb) catch signal
 Catchpoint 3 (standard signals)
 (gdb)
 condition $bpnum $_siginfo.si_signo == 5
 (gdb) continue
 Continuing.
 Error in testing breakpoint condition:
 Selected thread is running.

 Catchpoint 3 (signal SIGUSR1), 0x0000003615e35877 in __GI_raise (sig=10) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
 56        return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
 (gdb)

When accessing the $_siginfo object, we check whether the thread is
marked running (external/public) state and refuse the access if so.
This is so "print $_siginfo" at the prompt fails nicelly when the
current thread is running.  While evaluating breakpoint conditionals,
we haven't decided yet whether the thread is going to stop, so
is_running still returns true, and we thus always error out.

Evaluating an expression that requires registers access is really
conceptually the same -- we could think of $_siginfo as a pseudo
register.  However, in that case we check whether the thread is marked
executing (internal/private state), not running (external/public
state).  Changing the $_siginfo validation to check is_executing as
well fixes the bug in question.

Note that checking is_executing is not fully correct, not even for
registers.  See PR 19389.  However, I think this is the lesser of two
evils and ends up as an improvement.  We at least now have a single
place to fix.

Tested on x86_64 GNU/Linux.

gdb/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	PR breakpoints/19388
	* frame.c (get_current_frame): Use validate_registers_access.
	* gdbthread.h (validate_registers_access): Declare.
	* infrun.c (validate_siginfo_access): Delete.
	(siginfo_value_read, siginfo_value_write): Use
	validate_registers_access.
	* thread.c (validate_registers_access): New function.

gdb/testsuite/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	PR breakpoints/19388
	* gdb.base/catch-signal-siginfo-cond.c: New file.
	* gdb.base/catch-signal-siginfo-cond.exp: New file.
2016-01-13 10:40:33 +00:00
Joel Brobecker 618f726fcb GDB copyright headers update after running GDB's copyright.py script.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2016-01-01 08:43:22 +04:00
Simon Marchi 9a3c826307 Add some more casts (1/2)
Note: I needed to split this patch in two, otherwise it's too big for
the mailing list.

This patch adds explicit casts to situations where a void pointer is
assigned to a pointer to the "real" type.  Building in C++ mode requires
those assignments to use an explicit cast.  This includes, for example:

 - callback arguments (cleanups, comparison functions, ...)
 - data attached to some object (objfile, program space, etc) in the form
   of a void pointer
 - "user data" passed to some function

This patch comes from the commit "(mostly) auto-generated patch to insert
casts needed for C++", taken from Pedro's C++ branch.

Only files built on x86 with --enable-targets=all are modified, so the
native files for other arches will need to be dealt with separately.

I built-tested this with --enable-targets=all and reg-tested.  To my
surprise, a test case (selftest.exp) had to be adjusted.

Here's the ChangeLog entry.  Again, this was relatively quick to make
despite the length, thanks to David Malcom's script, although I don't
believe it's very useful information in that particular case...

gdb/ChangeLog:

	* aarch64-tdep.c (aarch64_make_prologue_cache): Add cast(s).
	(aarch64_make_stub_cache): Likewise.
	(value_of_aarch64_user_reg): Likewise.
	* ada-lang.c (ada_inferior_data_cleanup): Likewise.
	(get_ada_inferior_data): Likewise.
	(get_ada_pspace_data): Likewise.
	(ada_pspace_data_cleanup): Likewise.
	(ada_complete_symbol_matcher): Likewise.
	(ada_exc_search_name_matches): Likewise.
	* ada-tasks.c (get_ada_tasks_pspace_data): Likewise.
	(get_ada_tasks_inferior_data): Likewise.
	* addrmap.c (addrmap_mutable_foreach_worker): Likewise.
	(splay_obstack_alloc): Likewise.
	(splay_obstack_free): Likewise.
	* alpha-linux-tdep.c (alpha_linux_supply_gregset): Likewise.
	(alpha_linux_collect_gregset): Likewise.
	(alpha_linux_supply_fpregset): Likewise.
	(alpha_linux_collect_fpregset): Likewise.
	* alpha-mdebug-tdep.c (alpha_mdebug_frame_unwind_cache): Likewise.
	* alpha-tdep.c (alpha_lds): Likewise.
	(alpha_sts): Likewise.
	(alpha_sigtramp_frame_unwind_cache): Likewise.
	(alpha_heuristic_frame_unwind_cache): Likewise.
	(alpha_supply_int_regs): Likewise.
	(alpha_fill_int_regs): Likewise.
	(alpha_supply_fp_regs): Likewise.
	(alpha_fill_fp_regs): Likewise.
	* alphanbsd-tdep.c (alphanbsd_supply_fpregset): Likewise.
	(alphanbsd_aout_supply_gregset): Likewise.
	(alphanbsd_supply_gregset): Likewise.
	* amd64-linux-tdep.c (amd64_linux_init_abi): Likewise.
	(amd64_x32_linux_init_abi): Likewise.
	* amd64-nat.c (amd64_supply_native_gregset): Likewise.
	(amd64_collect_native_gregset): Likewise.
	* amd64-tdep.c (amd64_frame_cache): Likewise.
	(amd64_sigtramp_frame_cache): Likewise.
	(amd64_epilogue_frame_cache): Likewise.
	(amd64_supply_fxsave): Likewise.
	(amd64_supply_xsave): Likewise.
	(amd64_collect_fxsave): Likewise.
	(amd64_collect_xsave): Likewise.
	* amd64-windows-tdep.c (amd64_windows_frame_cache): Likewise.
	* amd64obsd-tdep.c (amd64obsd_trapframe_cache): Likewise.
	* arm-linux-tdep.c (arm_linux_supply_gregset): Likewise.
	(arm_linux_collect_gregset): Likewise.
	(arm_linux_supply_nwfpe): Likewise.
	(arm_linux_collect_nwfpe): Likewise.
	(arm_linux_supply_vfp): Likewise.
	(arm_linux_collect_vfp): Likewise.
	* arm-tdep.c (arm_find_mapping_symbol): Likewise.
	(arm_prologue_unwind_stop_reason): Likewise.
	(arm_prologue_this_id): Likewise.
	(arm_prologue_prev_register): Likewise.
	(arm_exidx_data_free): Likewise.
	(arm_find_exidx_entry): Likewise.
	(arm_stub_this_id): Likewise.
	(arm_m_exception_this_id): Likewise.
	(arm_m_exception_prev_register): Likewise.
	(arm_normal_frame_base): Likewise.
	(gdb_print_insn_arm): Likewise.
	(arm_objfile_data_free): Likewise.
	(arm_record_special_symbol): Likewise.
	(value_of_arm_user_reg): Likewise.
	* armbsd-tdep.c (armbsd_supply_fpregset): Likewise.
	(armbsd_supply_gregset): Likewise.
	* auto-load.c (auto_load_pspace_data_cleanup): Likewise.
	(get_auto_load_pspace_data): Likewise.
	(hash_loaded_script_entry): Likewise.
	(eq_loaded_script_entry): Likewise.
	(clear_section_scripts): Likewise.
	(collect_matching_scripts): Likewise.
	* auxv.c (auxv_inferior_data_cleanup): Likewise.
	(get_auxv_inferior_data): Likewise.
	* avr-tdep.c (avr_frame_unwind_cache): Likewise.
	* ax-general.c (do_free_agent_expr_cleanup): Likewise.
	* bfd-target.c (target_bfd_xfer_partial): Likewise.
	(target_bfd_xclose): Likewise.
	(target_bfd_get_section_table): Likewise.
	* bfin-tdep.c (bfin_frame_cache): Likewise.
	* block.c (find_block_in_blockvector): Likewise.
	(call_site_for_pc): Likewise.
	(block_find_non_opaque_type_preferred): Likewise.
	* break-catch-sig.c (signal_catchpoint_insert_location): Likewise.
	(signal_catchpoint_remove_location): Likewise.
	(signal_catchpoint_breakpoint_hit): Likewise.
	(signal_catchpoint_print_one): Likewise.
	(signal_catchpoint_print_mention): Likewise.
	(signal_catchpoint_print_recreate): Likewise.
	* break-catch-syscall.c (get_catch_syscall_inferior_data): Likewise.
	* breakpoint.c (do_cleanup_counted_command_line): Likewise.
	(bp_location_compare_addrs): Likewise.
	(get_first_locp_gte_addr): Likewise.
	(check_tracepoint_command): Likewise.
	(do_map_commands_command): Likewise.
	(get_breakpoint_objfile_data): Likewise.
	(free_breakpoint_probes): Likewise.
	(do_captured_breakpoint_query): Likewise.
	(compare_breakpoints): Likewise.
	(bp_location_compare): Likewise.
	(bpstat_remove_breakpoint_callback): Likewise.
	(do_delete_breakpoint_cleanup): Likewise.
	* bsd-uthread.c (bsd_uthread_set_supply_uthread): Likewise.
	(bsd_uthread_set_collect_uthread): Likewise.
	(bsd_uthread_activate): Likewise.
	(bsd_uthread_fetch_registers): Likewise.
	(bsd_uthread_store_registers): Likewise.
	* btrace.c (check_xml_btrace_version): Likewise.
	(parse_xml_btrace_block): Likewise.
	(parse_xml_btrace_pt_config_cpu): Likewise.
	(parse_xml_btrace_pt_raw): Likewise.
	(parse_xml_btrace_pt): Likewise.
	(parse_xml_btrace_conf_bts): Likewise.
	(parse_xml_btrace_conf_pt): Likewise.
	(do_btrace_data_cleanup): Likewise.
	* c-typeprint.c (find_typedef_for_canonicalize): Likewise.
	* charset.c (cleanup_iconv): Likewise.
	(do_cleanup_iterator): Likewise.
	* cli-out.c (cli_uiout_dtor): Likewise.
	(cli_table_begin): Likewise.
	(cli_table_body): Likewise.
	(cli_table_end): Likewise.
	(cli_table_header): Likewise.
	(cli_begin): Likewise.
	(cli_end): Likewise.
	(cli_field_int): Likewise.
	(cli_field_skip): Likewise.
	(cli_field_string): Likewise.
	(cli_field_fmt): Likewise.
	(cli_spaces): Likewise.
	(cli_text): Likewise.
	(cli_message): Likewise.
	(cli_wrap_hint): Likewise.
	(cli_flush): Likewise.
	(cli_redirect): Likewise.
	(out_field_fmt): Likewise.
	(field_separator): Likewise.
	(cli_out_set_stream): Likewise.
	* cli/cli-cmds.c (compare_symtabs): Likewise.
	* cli/cli-dump.c (call_dump_func): Likewise.
	(restore_section_callback): Likewise.
	* cli/cli-script.c (clear_hook_in_cleanup): Likewise.
	(do_restore_user_call_depth): Likewise.
	(do_free_command_lines_cleanup): Likewise.
	* coff-pe-read.c (get_section_vmas): Likewise.
	(pe_as16): Likewise.
	(pe_as32): Likewise.
	* coffread.c (coff_symfile_read): Likewise.
	* common/agent.c (agent_look_up_symbols): Likewise.
	* common/filestuff.c (do_close_cleanup): Likewise.
	* common/format.c (free_format_pieces_cleanup): Likewise.
	* common/vec.c (vec_o_reserve): Likewise.
	* compile/compile-c-support.c (print_one_macro): Likewise.
	* compile/compile-c-symbols.c (hash_symbol_error): Likewise.
	(eq_symbol_error): Likewise.
	(del_symbol_error): Likewise.
	(error_symbol_once): Likewise.
	(gcc_convert_symbol): Likewise.
	(gcc_symbol_address): Likewise.
	(hash_symname): Likewise.
	(eq_symname): Likewise.
	* compile/compile-c-types.c (hash_type_map_instance): Likewise.
	(eq_type_map_instance): Likewise.
	(insert_type): Likewise.
	(convert_type): Likewise.
	* compile/compile-object-load.c (munmap_listp_free_cleanup): Likewise.
	(setup_sections): Likewise.
	(link_hash_table_free): Likewise.
	(copy_sections): Likewise.
	* compile/compile-object-run.c (do_module_cleanup): Likewise.
	* compile/compile.c (compile_print_value): Likewise.
	(do_rmdir): Likewise.
	(cleanup_compile_instance): Likewise.
	(cleanup_unlink_file): Likewise.
	* completer.c (free_completion_tracker): Likewise.
	* corelow.c (add_to_spuid_list): Likewise.
	* cp-namespace.c (reset_directive_searched): Likewise.
	* cp-support.c (reset_directive_searched): Likewise.
	* cris-tdep.c (cris_sigtramp_frame_unwind_cache): Likewise.
	(cris_frame_unwind_cache): Likewise.
	* d-lang.c (builtin_d_type): Likewise.
	* d-namespace.c (reset_directive_searched): Likewise.
	* dbxread.c (dbx_free_symfile_info): Likewise.
	(do_free_bincl_list_cleanup): Likewise.
	* disasm.c (hash_dis_line_entry): Likewise.
	(eq_dis_line_entry): Likewise.
	(dis_asm_print_address): Likewise.
	(fprintf_disasm): Likewise.
	(do_ui_file_delete): Likewise.
	* doublest.c (convert_floatformat_to_doublest): Likewise.
	* dummy-frame.c (pop_dummy_frame_bpt): Likewise.
	(dummy_frame_prev_register): Likewise.
	(dummy_frame_this_id): Likewise.
	* dwarf2-frame-tailcall.c (cache_hash): Likewise.
	(cache_eq): Likewise.
	(cache_find): Likewise.
	(tailcall_frame_this_id): Likewise.
	(dwarf2_tailcall_prev_register_first): Likewise.
	(tailcall_frame_prev_register): Likewise.
	(tailcall_frame_dealloc_cache): Likewise.
	(tailcall_frame_prev_arch): Likewise.
	* dwarf2-frame.c (dwarf2_frame_state_free): Likewise.
	(dwarf2_frame_set_init_reg): Likewise.
	(dwarf2_frame_init_reg): Likewise.
	(dwarf2_frame_set_signal_frame_p): Likewise.
	(dwarf2_frame_signal_frame_p): Likewise.
	(dwarf2_frame_set_adjust_regnum): Likewise.
	(dwarf2_frame_adjust_regnum): Likewise.
	(clear_pointer_cleanup): Likewise.
	(dwarf2_frame_cache): Likewise.
	(find_cie): Likewise.
	(dwarf2_frame_find_fde): Likewise.
	* dwarf2expr.c (dwarf_expr_address_type): Likewise.
	(free_dwarf_expr_context_cleanup): Likewise.
	* dwarf2loc.c (locexpr_find_frame_base_location): Likewise.
	(locexpr_get_frame_base): Likewise.
	(loclist_find_frame_base_location): Likewise.
	(loclist_get_frame_base): Likewise.
	(dwarf_expr_dwarf_call): Likewise.
	(dwarf_expr_get_base_type): Likewise.
	(dwarf_expr_push_dwarf_reg_entry_value): Likewise.
	(dwarf_expr_get_obj_addr): Likewise.
	(entry_data_value_coerce_ref): Likewise.
	(entry_data_value_copy_closure): Likewise.
	(entry_data_value_free_closure): Likewise.
	(get_frame_address_in_block_wrapper): Likewise.
	(dwarf2_evaluate_property): Likewise.
	(dwarf2_compile_property_to_c): Likewise.
	(needs_frame_read_addr_from_reg): Likewise.
	(needs_frame_get_reg_value): Likewise.
	(needs_frame_frame_base): Likewise.
	(needs_frame_frame_cfa): Likewise.
	(needs_frame_tls_address): Likewise.
	(needs_frame_dwarf_call): Likewise.
	(needs_dwarf_reg_entry_value): Likewise.
	(get_ax_pc): Likewise.
	(locexpr_read_variable): Likewise.
	(locexpr_read_variable_at_entry): Likewise.
	(locexpr_read_needs_frame): Likewise.
	(locexpr_describe_location): Likewise.
	(locexpr_tracepoint_var_ref): Likewise.
	(locexpr_generate_c_location): Likewise.
	(loclist_read_variable): Likewise.
	(loclist_read_variable_at_entry): Likewise.
	(loclist_describe_location): Likewise.
	(loclist_tracepoint_var_ref): Likewise.
	(loclist_generate_c_location): Likewise.
	* dwarf2read.c (line_header_hash_voidp): Likewise.
	(line_header_eq_voidp): Likewise.
	(dwarf2_has_info): Likewise.
	(dwarf2_get_section_info): Likewise.
	(locate_dwz_sections): Likewise.
	(hash_file_name_entry): Likewise.
	(eq_file_name_entry): Likewise.
	(delete_file_name_entry): Likewise.
	(dw2_setup): Likewise.
	(dw2_get_file_names_reader): Likewise.
	(dw2_find_pc_sect_compunit_symtab): Likewise.
	(hash_signatured_type): Likewise.
	(eq_signatured_type): Likewise.
	(add_signatured_type_cu_to_table): Likewise.
	(create_debug_types_hash_table): Likewise.
	(lookup_dwo_signatured_type): Likewise.
	(lookup_dwp_signatured_type): Likewise.
	(lookup_signatured_type): Likewise.
	(hash_type_unit_group): Likewise.
	(eq_type_unit_group): Likewise.
	(get_type_unit_group): Likewise.
	(process_psymtab_comp_unit_reader): Likewise.
	(sort_tu_by_abbrev_offset): Likewise.
	(process_skeletonless_type_unit): Likewise.
	(psymtabs_addrmap_cleanup): Likewise.
	(dwarf2_read_symtab): Likewise.
	(psymtab_to_symtab_1): Likewise.
	(die_hash): Likewise.
	(die_eq): Likewise.
	(load_full_comp_unit_reader): Likewise.
	(reset_die_in_process): Likewise.
	(free_cu_line_header): Likewise.
	(handle_DW_AT_stmt_list): Likewise.
	(hash_dwo_file): Likewise.
	(eq_dwo_file): Likewise.
	(hash_dwo_unit): Likewise.
	(eq_dwo_unit): Likewise.
	(create_dwo_cu_reader): Likewise.
	(create_dwo_unit_in_dwp_v1): Likewise.
	(create_dwo_unit_in_dwp_v2): Likewise.
	(lookup_dwo_unit_in_dwp): Likewise.
	(dwarf2_locate_dwo_sections): Likewise.
	(dwarf2_locate_common_dwp_sections): Likewise.
	(dwarf2_locate_v2_dwp_sections): Likewise.
	(hash_dwp_loaded_cutus): Likewise.
	(eq_dwp_loaded_cutus): Likewise.
	(lookup_dwo_cutu): Likewise.
	(abbrev_table_free_cleanup): Likewise.
	(dwarf2_free_abbrev_table): Likewise.
	(find_partial_die_in_comp_unit): Likewise.
	(free_line_header_voidp): Likewise.
	(follow_die_offset): Likewise.
	(follow_die_sig_1): Likewise.
	(free_heap_comp_unit): Likewise.
	(free_stack_comp_unit): Likewise.
	(dwarf2_free_objfile): Likewise.
	(per_cu_offset_and_type_hash): Likewise.
	(per_cu_offset_and_type_eq): Likewise.
	(get_die_type_at_offset): Likewise.
	(partial_die_hash): Likewise.
	(partial_die_eq): Likewise.
	(dwarf2_per_objfile_free): Likewise.
	(hash_strtab_entry): Likewise.
	(eq_strtab_entry): Likewise.
	(add_string): Likewise.
	(hash_symtab_entry): Likewise.
	(eq_symtab_entry): Likewise.
	(delete_symtab_entry): Likewise.
	(cleanup_mapped_symtab): Likewise.
	(add_indices_to_cpool): Likewise.
	(hash_psymtab_cu_index): Likewise.
	(eq_psymtab_cu_index): Likewise.
	(add_address_entry_worker): Likewise.
	(unlink_if_set): Likewise.
	(write_one_signatured_type): Likewise.
	(save_gdb_index_command): Likewise.
	* elfread.c (elf_symtab_read): Likewise.
	(elf_gnu_ifunc_cache_hash): Likewise.
	(elf_gnu_ifunc_cache_eq): Likewise.
	(elf_gnu_ifunc_record_cache): Likewise.
	(elf_gnu_ifunc_resolve_by_cache): Likewise.
	(elf_get_probes): Likewise.
	(probe_key_free): Likewise.
	* f-lang.c (builtin_f_type): Likewise.
	* frame-base.c (frame_base_append_sniffer): Likewise.
	(frame_base_set_default): Likewise.
	(frame_base_find_by_frame): Likewise.
	* frame-unwind.c (frame_unwind_prepend_unwinder): Likewise.
	(frame_unwind_append_unwinder): Likewise.
	(frame_unwind_find_by_frame): Likewise.
	* frame.c (frame_addr_hash): Likewise.
	(frame_addr_hash_eq): Likewise.
	(frame_stash_find): Likewise.
	(do_frame_register_read): Likewise.
	(unwind_to_current_frame): Likewise.
	(frame_cleanup_after_sniffer): Likewise.
	* frv-linux-tdep.c (frv_linux_sigtramp_frame_cache): Likewise.
	* frv-tdep.c (frv_frame_unwind_cache): Likewise.
	* ft32-tdep.c (ft32_frame_cache): Likewise.
	* gcore.c (do_bfd_delete_cleanup): Likewise.
	(gcore_create_callback): Likewise.
	* gdb_bfd.c (hash_bfd): Likewise.
	(eq_bfd): Likewise.
	(gdb_bfd_open): Likewise.
	(free_one_bfd_section): Likewise.
	(gdb_bfd_ref): Likewise.
	(gdb_bfd_unref): Likewise.
	(get_section_descriptor): Likewise.
	(gdb_bfd_map_section): Likewise.
	(gdb_bfd_crc): Likewise.
	(gdb_bfd_mark_parent): Likewise.
	(gdb_bfd_record_inclusion): Likewise.
	(gdb_bfd_requires_relocations): Likewise.
	(print_one_bfd): Likewise.
	* gdbtypes.c (type_pair_hash): Likewise.
	(type_pair_eq): Likewise.
	(builtin_type): Likewise.
	(objfile_type): Likewise.
	* gnu-v3-abi.c (vtable_ptrdiff_type): Likewise.
	(vtable_address_point_offset): Likewise.
	(gnuv3_get_vtable): Likewise.
	(hash_value_and_voffset): Likewise.
	(eq_value_and_voffset): Likewise.
	(compare_value_and_voffset): Likewise.
	(compute_vtable_size): Likewise.
	(gnuv3_get_typeid_type): Likewise.
	* go-lang.c (builtin_go_type): Likewise.
	* guile/scm-block.c (bkscm_hash_block_smob): Likewise.
	(bkscm_eq_block_smob): Likewise.
	(bkscm_objfile_block_map): Likewise.
	(bkscm_del_objfile_blocks): Likewise.
	* guile/scm-breakpoint.c (bpscm_build_bp_list): Likewise.
	* guile/scm-disasm.c (gdbscm_disasm_read_memory_worker): Likewise.
	(gdbscm_disasm_print_address): Likewise.
	* guile/scm-frame.c (frscm_hash_frame_smob): Likewise.
	(frscm_eq_frame_smob): Likewise.
	(frscm_inferior_frame_map): Likewise.
	(frscm_del_inferior_frames): Likewise.
	* guile/scm-gsmob.c (gdbscm_add_objfile_ref): Likewise.
	* guile/scm-objfile.c (ofscm_handle_objfile_deleted): Likewise.
	(ofscm_objfile_smob_from_objfile): Likewise.
	* guile/scm-ports.c (ioscm_write): Likewise.
	(ioscm_file_port_delete): Likewise.
	(ioscm_file_port_rewind): Likewise.
	(ioscm_file_port_put): Likewise.
	(ioscm_file_port_write): Likewise.
	* guile/scm-progspace.c (psscm_handle_pspace_deleted): Likewise.
	(psscm_pspace_smob_from_pspace): Likewise.
	* guile/scm-safe-call.c (scscm_recording_pre_unwind_handler): Likewise.
	(scscm_recording_unwind_handler): Likewise.
	(gdbscm_with_catch): Likewise.
	(scscm_call_0_body): Likewise.
	(scscm_call_1_body): Likewise.
	(scscm_call_2_body): Likewise.
	(scscm_call_3_body): Likewise.
	(scscm_call_4_body): Likewise.
	(scscm_apply_1_body): Likewise.
	(scscm_eval_scheme_string): Likewise.
	(gdbscm_safe_eval_string): Likewise.
	(scscm_source_scheme_script): Likewise.
	(gdbscm_safe_source_script): Likewise.
	* guile/scm-string.c (gdbscm_call_scm_to_stringn): Likewise.
	(gdbscm_call_scm_from_stringn): Likewise.
	* guile/scm-symbol.c (syscm_hash_symbol_smob): Likewise.
	(syscm_eq_symbol_smob): Likewise.
	(syscm_get_symbol_map): Likewise.
	(syscm_del_objfile_symbols): Likewise.
	* guile/scm-symtab.c (stscm_hash_symtab_smob): Likewise.
	(stscm_eq_symtab_smob): Likewise.
	(stscm_objfile_symtab_map): Likewise.
	(stscm_del_objfile_symtabs): Likewise.
	* guile/scm-type.c (tyscm_hash_type_smob): Likewise.
	(tyscm_eq_type_smob): Likewise.
	(tyscm_type_map): Likewise.
	(tyscm_copy_type_recursive): Likewise.
	(save_objfile_types): Likewise.
	* guile/scm-utils.c (extract_arg): Likewise.
	* h8300-tdep.c (h8300_frame_cache): Likewise.
	* hppa-linux-tdep.c (hppa_linux_sigtramp_frame_unwind_cache): Likewise.
	* hppa-tdep.c (compare_unwind_entries): Likewise.
	(find_unwind_entry): Likewise.
	(hppa_frame_cache): Likewise.
	(hppa_stub_frame_unwind_cache): Likewise.
	* hppanbsd-tdep.c (hppanbsd_supply_gregset): Likewise.
	* hppaobsd-tdep.c (hppaobsd_supply_gregset): Likewise.
	(hppaobsd_supply_fpregset): Likewise.
	* i386-cygwin-tdep.c (core_process_module_section): Likewise.
	* i386-linux-tdep.c (i386_linux_init_abi): Likewise.
	* i386-tdep.c (i386_frame_cache): Likewise.
	(i386_epilogue_frame_cache): Likewise.
	(i386_sigtramp_frame_cache): Likewise.
	(i386_supply_gregset): Likewise.
	(i386_collect_gregset): Likewise.
	(i386_gdbarch_init): Likewise.
	* i386obsd-tdep.c (i386obsd_aout_supply_regset): Likewise.
	(i386obsd_trapframe_cache): Likewise.
	* i387-tdep.c (i387_supply_fsave): Likewise.
	(i387_collect_fsave): Likewise.
	(i387_supply_fxsave): Likewise.
	(i387_collect_fxsave): Likewise.
	(i387_supply_xsave): Likewise.
	(i387_collect_xsave): Likewise.
	* ia64-tdep.c (ia64_frame_cache): Likewise.
	(ia64_sigtramp_frame_cache): Likewise.
	* infcmd.c (attach_command_continuation): Likewise.
	(attach_command_continuation_free_args): Likewise.
	* inferior.c (restore_inferior): Likewise.
	(delete_thread_of_inferior): Likewise.
	* inflow.c (inflow_inferior_data_cleanup): Likewise.
	(get_inflow_inferior_data): Likewise.
	(inflow_inferior_exit): Likewise.
	* infrun.c (displaced_step_clear_cleanup): Likewise.
	(restore_current_uiout_cleanup): Likewise.
	(release_stop_context_cleanup): Likewise.
	(do_restore_infcall_suspend_state_cleanup): Likewise.
	(do_restore_infcall_control_state_cleanup): Likewise.
	(restore_inferior_ptid): Likewise.
	* inline-frame.c (block_starting_point_at): Likewise.
	* iq2000-tdep.c (iq2000_frame_cache): Likewise.
	* jit.c (get_jit_objfile_data): Likewise.
	(get_jit_program_space_data): Likewise.
	(jit_object_close_impl): Likewise.
	(jit_find_objf_with_entry_addr): Likewise.
	(jit_breakpoint_deleted): Likewise.
	(jit_unwind_reg_set_impl): Likewise.
	(jit_unwind_reg_get_impl): Likewise.
	(jit_dealloc_cache): Likewise.
	(jit_frame_sniffer): Likewise.
	(jit_frame_prev_register): Likewise.
	(jit_prepend_unwinder): Likewise.
	(jit_inferior_exit_hook): Likewise.
	(free_objfile_data): Likewise.
	* jv-lang.c (jv_per_objfile_free): Likewise.
	(get_dynamics_objfile): Likewise.
	(get_java_class_symtab): Likewise.
	(builtin_java_type): Likewise.
	* language.c (language_string_char_type): Likewise.
	(language_bool_type): Likewise.
	(language_lookup_primitive_type): Likewise.
	(language_lookup_primitive_type_as_symbol): Likewise.
	* linespec.c (hash_address_entry): Likewise.
	(eq_address_entry): Likewise.
	(iterate_inline_only): Likewise.
	(iterate_name_matcher): Likewise.
	(decode_line_2_compare_items): Likewise.
	(collect_one_symbol): Likewise.
	(compare_symbols): Likewise.
	(compare_msymbols): Likewise.
	(add_symtabs_to_list): Likewise.
	(collect_symbols): Likewise.
	(compare_msyms): Likewise.
	(add_minsym): Likewise.
	(cleanup_linespec_result): Likewise.
	* linux-fork.c (inferior_call_waitpid_cleanup): Likewise.
	* linux-nat.c (delete_lwp_cleanup): Likewise.
	(count_events_callback): Likewise.
	(select_event_lwp_callback): Likewise.
	(resume_stopped_resumed_lwps): Likewise.
	* linux-tdep.c (get_linux_gdbarch_data): Likewise.
	(invalidate_linux_cache_inf): Likewise.
	(get_linux_inferior_data): Likewise.
	(linux_find_memory_regions_thunk): Likewise.
	(linux_make_mappings_callback): Likewise.
	(linux_corefile_thread_callback): Likewise.
	(find_mapping_size): Likewise.
	* linux-thread-db.c (find_new_threads_callback): Likewise.
	* lm32-tdep.c (lm32_frame_cache): Likewise.
	* m2-lang.c (builtin_m2_type): Likewise.
	* m32c-tdep.c (m32c_analyze_frame_prologue): Likewise.
	* m32r-linux-tdep.c (m32r_linux_sigtramp_frame_cache): Likewise.
	(m32r_linux_supply_gregset): Likewise.
	(m32r_linux_collect_gregset): Likewise.
	* m32r-tdep.c (m32r_frame_unwind_cache): Likewise.
	* m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise.
	* m68k-tdep.c (m68k_frame_cache): Likewise.
	* m68kbsd-tdep.c (m68kbsd_supply_fpregset): Likewise.
	(m68kbsd_supply_gregset): Likewise.
	* m68klinux-tdep.c (m68k_linux_sigtramp_frame_cache): Likewise.
	* m88k-tdep.c (m88k_frame_cache): Likewise.
	(m88k_supply_gregset): Likewise.

gdb/gdbserver/ChangeLog:

	* dll.c (match_dll): Add cast(s).
	(unloaded_dll): Likewise.
	* linux-low.c (second_thread_of_pid_p): Likewise.
	(delete_lwp_callback): Likewise.
	(count_events_callback): Likewise.
	(select_event_lwp_callback): Likewise.
	(linux_set_resume_request): Likewise.
	* server.c (accumulate_file_name_length): Likewise.
	(emit_dll_description): Likewise.
	(handle_qxfer_threads_worker): Likewise.
	(visit_actioned_threads): Likewise.
	* thread-db.c (any_thread_of): Likewise.
	* tracepoint.c (same_process_p): Likewise.
	(match_blocktype): Likewise.
	(build_traceframe_info_xml): Likewise.

gdb/testsuite/ChangeLog:

	* gdb.gdb/selftest.exp (do_steps_and_nexts): Adjust expected
	source line.
2015-09-25 14:08:07 -04:00
Simon Marchi 224c3ddb89 Add casts to memory allocation related calls
Most allocation functions (if not all) return a void* pointing to the
allocated memory.  In C++, we need to add an explicit cast when
assigning the result to a pointer to another type (which is the case
more often than not).

The content of this patch is taken from Pedro's branch, from commit
"(mostly) auto-generated patch to insert casts needed for C++".  I
validated that the changes make sense and manually reflowed the code to
make it respect the coding style.  I also found multiple places where I
could use XNEW/XNEWVEC/XRESIZEVEC/etc.

Thanks a lot to whoever did that automated script to insert casts, doing
it completely by hand would have taken a ridiculous amount of time.

Only files built on x86 with --enable-targets=all are modified.  This
means that all other -nat.c files are untouched and will have to be
dealt with later by using appropiate compilers.  Or maybe we can try to
build them with a regular g++ just to know where to add casts, I don't
know.

I built-tested this with --enable-targets=all and reg-tested.

Here's the changelog entry, which was not too bad to make despite the
size, thanks to David Malcom's script.  I fixed some bits by hand, but
there might be some wrong parts left (hopefully not).

gdb/ChangeLog:

	* aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast
	to allocation result assignment.
	* ada-exp.y (write_object_renaming): Likewise.
	(write_ambiguous_var): Likewise.
	(ada_nget_field_index): Likewise.
	(write_var_or_type): Likewise.
	* ada-lang.c (ada_decode_symbol): Likewise.
	(ada_value_assign): Likewise.
	(value_pointer): Likewise.
	(cache_symbol): Likewise.
	(add_nonlocal_symbols): Likewise.
	(ada_name_for_lookup): Likewise.
	(symbol_completion_add): Likewise.
	(ada_to_fixed_type_1): Likewise.
	(ada_get_next_arg): Likewise.
	(defns_collected): Likewise.
	* ada-lex.l (processId): Likewise.
	(processString): Likewise.
	* ada-tasks.c (read_known_tasks_array): Likewise.
	(read_known_tasks_list): Likewise.
	* ada-typeprint.c (decoded_type_name): Likewise.
	* addrmap.c (addrmap_mutable_create_fixed): Likewise.
	* amd64-tdep.c (amd64_push_arguments): Likewise.
	(amd64_displaced_step_copy_insn): Likewise.
	(amd64_classify_insn_at): Likewise.
	(amd64_relocate_instruction): Likewise.
	* amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise.
	* arch-utils.c (simple_displaced_step_copy_insn): Likewise.
	(initialize_current_architecture): Likewise.
	* arm-linux-tdep.c (arm_stap_parse_special_token): Likewise.
	* arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise.
	* arm-tdep.c (arm_exidx_new_objfile): Likewise.
	(arm_push_dummy_call): Likewise.
	(extend_buffer_earlier): Likewise.
	(arm_adjust_breakpoint_address): Likewise.
	(arm_skip_stub): Likewise.
	* auto-load.c (filename_is_in_pattern): Likewise.
	(maybe_add_script_file): Likewise.
	(maybe_add_script_text): Likewise.
	(auto_load_objfile_script_1): Likewise.
	* auxv.c (ld_so_xfer_auxv): Likewise.
	* ax-general.c (new_agent_expr): Likewise.
	(grow_expr): Likewise.
	(ax_reg_mask): Likewise.
	* bcache.c (bcache_full): Likewise.
	* breakpoint.c (program_breakpoint_here_p): Likewise.
	* btrace.c (parse_xml_raw): Likewise.
	* build-id.c (build_id_to_debug_bfd): Likewise.
	* buildsym.c (end_symtab_with_blockvector): Likewise.
	* c-exp.y (string_exp): Likewise.
	(qualified_name): Likewise.
	(write_destructor_name): Likewise.
	(operator_stoken): Likewise.
	(parse_number): Likewise.
	(scan_macro_expansion): Likewise.
	(yylex): Likewise.
	(c_print_token): Likewise.
	* c-lang.c (c_get_string): Likewise.
	(emit_numeric_character): Likewise.
	* charset.c (wchar_iterate): Likewise.
	* cli/cli-cmds.c (complete_command): Likewise.
	(make_command): Likewise.
	* cli/cli-dump.c (restore_section_callback): Likewise.
	(restore_binary_file): Likewise.
	* cli/cli-interp.c (cli_interpreter_exec): Likewise.
	* cli/cli-script.c (execute_control_command): Likewise.
	* cli/cli-setshow.c (do_set_command): Likewise.
	* coff-pe-read.c (add_pe_forwarded_sym): Likewise.
	(read_pe_exported_syms): Likewise.
	* coffread.c (coff_read_struct_type): Likewise.
	(coff_read_enum_type): Likewise.
	* common/btrace-common.c (btrace_data_append): Likewise.
	* common/buffer.c (buffer_grow): Likewise.
	* common/filestuff.c (gdb_fopen_cloexec): Likewise.
	* common/format.c (parse_format_string): Likewise.
	* common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise.
	* common/xml-utils.c (xml_escape_text): Likewise.
	* compile/compile-object-load.c (copy_sections): Likewise.
	(compile_object_load): Likewise.
	* compile/compile-object-run.c (compile_object_run): Likewise.
	* completer.c (filename_completer): Likewise.
	* corefile.c (read_memory_typed_address): Likewise.
	(write_memory_unsigned_integer): Likewise.
	(write_memory_signed_integer): Likewise.
	(complete_set_gnutarget): Likewise.
	* corelow.c (get_core_register_section): Likewise.
	* cp-name-parser.y (d_grab): Likewise.
	(allocate_info): Likewise.
	(cp_new_demangle_parse_info): Likewise.
	* cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise.
	(cp_lookup_symbol_in_namespace): Likewise.
	(lookup_namespace_scope): Likewise.
	(find_symbol_in_baseclass): Likewise.
	(cp_lookup_nested_symbol): Likewise.
	(cp_lookup_transparent_type_loop): Likewise.
	* cp-support.c (copy_string_to_obstack): Likewise.
	(make_symbol_overload_list): Likewise.
	(make_symbol_overload_list_namespace): Likewise.
	(make_symbol_overload_list_adl_namespace): Likewise.
	(first_component_command): Likewise.
	* cp-valprint.c (cp_print_value): Likewise.
	* ctf.c (ctf_xfer_partial): Likewise.
	* d-exp.y (StringExp): Likewise.
	* d-namespace.c (d_lookup_symbol_in_module): Likewise.
	(lookup_module_scope): Likewise.
	(find_symbol_in_baseclass): Likewise.
	(d_lookup_nested_symbol): Likewise.
	* dbxread.c (find_stab_function_addr): Likewise.
	(read_dbx_symtab): Likewise.
	(dbx_end_psymtab): Likewise.
	(cp_set_block_scope): Likewise.
	* dcache.c (dcache_alloc): Likewise.
	* demangle.c (_initialize_demangler): Likewise.
	* dicos-tdep.c (dicos_load_module_p): Likewise.
	* dictionary.c (dict_create_hashed_expandable): Likewise.
	(dict_create_linear_expandable): Likewise.
	(expand_hashtable): Likewise.
	(add_symbol_linear_expandable): Likewise.
	* dwarf2-frame.c (add_cie): Likewise.
	(add_fde): Likewise.
	(dwarf2_build_frame_info): Likewise.
	* dwarf2expr.c (dwarf_expr_grow_stack): Likewise.
	(dwarf_expr_fetch_address): Likewise.
	(add_piece): Likewise.
	(execute_stack_op): Likewise.
	* dwarf2loc.c (chain_candidate): Likewise.
	(dwarf_entry_parameter_to_value): Likewise.
	(read_pieced_value): Likewise.
	(write_pieced_value): Likewise.
	* dwarf2read.c (dwarf2_read_section): Likewise.
	(add_type_unit): Likewise.
	(read_comp_units_from_section): Likewise.
	(fixup_go_packaging): Likewise.
	(dwarf2_compute_name): Likewise.
	(dwarf2_physname): Likewise.
	(create_dwo_unit_in_dwp_v1): Likewise.
	(create_dwo_unit_in_dwp_v2): Likewise.
	(read_func_scope): Likewise.
	(read_call_site_scope): Likewise.
	(dwarf2_attach_fields_to_type): Likewise.
	(process_structure_scope): Likewise.
	(mark_common_block_symbol_computed): Likewise.
	(read_common_block): Likewise.
	(abbrev_table_read_table): Likewise.
	(guess_partial_die_structure_name): Likewise.
	(fixup_partial_die): Likewise.
	(add_file_name): Likewise.
	(dwarf2_const_value_data): Likewise.
	(dwarf2_const_value_attr): Likewise.
	(build_error_marker_type): Likewise.
	(guess_full_die_structure_name): Likewise.
	(anonymous_struct_prefix): Likewise.
	(typename_concat): Likewise.
	(dwarf2_canonicalize_name): Likewise.
	(dwarf2_name): Likewise.
	(write_constant_as_bytes): Likewise.
	(dwarf2_fetch_constant_bytes): Likewise.
	(copy_string): Likewise.
	(parse_macro_definition): Likewise.
	* elfread.c (elf_symfile_segments): Likewise.
	(elf_rel_plt_read): Likewise.
	(elf_gnu_ifunc_resolve_by_cache): Likewise.
	(elf_gnu_ifunc_resolve_by_got): Likewise.
	(elf_read_minimal_symbols): Likewise.
	(elf_gnu_ifunc_record_cache): Likewise.
	* event-top.c (top_level_prompt): Likewise.
	(command_line_handler): Likewise.
	* exec.c (resize_section_table): Likewise.
	* expprint.c (print_subexp_standard): Likewise.
	* fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise.
	* findcmd.c (parse_find_args): Likewise.
	* findvar.c (address_from_register): Likewise.
	* frame.c (get_prev_frame_always): Likewise.
	* gdb_bfd.c (gdb_bfd_ref): Likewise.
	(get_section_descriptor): Likewise.
	* gdb_obstack.c (obconcat): Likewise.
	(obstack_strdup): Likewise.
	* gdbtypes.c (lookup_function_type_with_arguments): Likewise.
	(create_set_type): Likewise.
	(lookup_unsigned_typename): Likewise.
	(lookup_signed_typename): Likewise.
	(resolve_dynamic_union): Likewise.
	(resolve_dynamic_struct): Likewise.
	(add_dyn_prop): Likewise.
	(copy_dynamic_prop_list): Likewise.
	(arch_flags_type): Likewise.
	(append_composite_type_field_raw): Likewise.
	* gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise.
	* gnu-v3-abi.c (gnuv3_rtti_type): Likewise.
	* go-exp.y (string_exp): Likewise.
	* go-lang.c (go_demangle): Likewise.
	* guile/guile.c (compute_scheme_string): Likewise.
	* guile/scm-cmd.c (gdbscm_parse_command_name): Likewise.
	(gdbscm_canonicalize_command_name): Likewise.
	* guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise.
	(ioscm_init_memory_port): Likewise.
	(ioscm_reinit_memory_port): Likewise.
	* guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise.
	(gdbscm_gc_dup_argv): Likewise.
	* h8300-tdep.c (h8300_push_dummy_call): Likewise.
	* hppa-tdep.c (internalize_unwinds): Likewise.
	(read_unwind_info): Likewise.
	* i386-cygwin-tdep.c (core_process_module_section): Likewise.
	(windows_core_xfer_shared_libraries): Likewise.
	* i386-tdep.c (i386_displaced_step_copy_insn): Likewise.
	(i386_stap_parse_special_token_triplet): Likewise.
	(i386_stap_parse_special_token_three_arg_disp): Likewise.
	* i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise.
	* inf-child.c (inf_child_fileio_readlink): Likewise.
	* inf-ptrace.c (inf_ptrace_fetch_register): Likewise.
	(inf_ptrace_store_register): Likewise.
	* infrun.c (follow_exec): Likewise.
	(displaced_step_prepare_throw): Likewise.
	(save_stop_context): Likewise.
	(save_infcall_suspend_state): Likewise.
	* jit.c (jit_read_descriptor): Likewise.
	(jit_read_code_entry): Likewise.
	(jit_symtab_line_mapping_add_impl): Likewise.
	(finalize_symtab): Likewise.
	(jit_unwind_reg_get_impl): Likewise.
	* jv-exp.y (QualifiedName): Likewise.
	* jv-lang.c (get_java_utf8_name): Likewise.
	(type_from_class): Likewise.
	(java_demangle_type_signature): Likewise.
	(java_class_name_from_physname): Likewise.
	* jv-typeprint.c (java_type_print_base): Likewise.
	* jv-valprint.c (java_value_print): Likewise.
	* language.c (add_language): Likewise.
	* linespec.c (add_sal_to_sals_basic): Likewise.
	(add_sal_to_sals): Likewise.
	(decode_objc): Likewise.
	(find_linespec_symbols): Likewise.
	* linux-fork.c (fork_save_infrun_state): Likewise.
	* linux-nat.c (linux_nat_detach): Likewise.
	(linux_nat_fileio_readlink): Likewise.
	* linux-record.c (record_linux_sockaddr): Likewise.
	(record_linux_msghdr): Likewise.
	(Do): Likewise.
	* linux-tdep.c (linux_core_info_proc_mappings): Likewise.
	(linux_collect_regset_section_cb): Likewise.
	(linux_get_siginfo_data): Likewise.
	* linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise.
	(try_thread_db_load_from_dir): Likewise.
	(thread_db_load_search): Likewise.
	(info_auto_load_libthread_db): Likewise.
	* m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise.
	(m32c_m16c_pointer_to_address): Likewise.
	* m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise.
	* m68k-tdep.c (m68k_get_longjmp_target): Likewise.
	* machoread.c (macho_check_dsym): Likewise.
	* macroexp.c (resize_buffer): Likewise.
	(gather_arguments): Likewise.
	(maybe_expand): Likewise.
	* macrotab.c (new_macro_key): Likewise.
	(new_source_file): Likewise.
	(new_macro_definition): Likewise.
	* mdebugread.c (parse_symbol): Likewise.
	(parse_type): Likewise.
	(parse_partial_symbols): Likewise.
	(psymtab_to_symtab_1): Likewise.
	* mem-break.c (default_memory_insert_breakpoint): Likewise.
	* mi/mi-cmd-break.c (mi_argv_to_format): Likewise.
	* mi/mi-main.c (mi_cmd_data_read_memory): Likewise.
	(mi_cmd_data_read_memory_bytes): Likewise.
	(mi_cmd_data_write_memory_bytes): Likewise.
	(mi_cmd_trace_frame_collected): Likewise.
	* mi/mi-parse.c (mi_parse_argv): Likewise.
	(mi_parse): Likewise.
	* minidebug.c (lzma_open): Likewise.
	(lzma_pread): Likewise.
	* mips-tdep.c (mips_read_fp_register_single): Likewise.
	(mips_print_fp_register): Likewise.
	* mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise.
	* mipsread.c (read_alphacoff_dynamic_symtab): Likewise.
	* mt-tdep.c (mt_register_name): Likewise.
	(mt_registers_info): Likewise.
	(mt_push_dummy_call): Likewise.
	* namespace.c (add_using_directive): Likewise.
	* nat/linux-btrace.c (perf_event_read): Likewise.
	(linux_enable_bts): Likewise.
	* nat/linux-osdata.c (linux_common_core_of_thread): Likewise.
	* nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise.
	* nto-tdep.c (nto_find_and_open_solib): Likewise.
	(nto_parse_redirection): Likewise.
	* objc-lang.c (objc_demangle): Likewise.
	(find_methods): Likewise.
	* objfiles.c (get_objfile_bfd_data): Likewise.
	(set_objfile_main_name): Likewise.
	(allocate_objfile): Likewise.
	(objfile_relocate): Likewise.
	(update_section_map): Likewise.
	* osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise.
	* p-exp.y (exp): Likewise.
	(yylex): Likewise.
	* p-valprint.c (pascal_object_print_value): Likewise.
	* parse.c (initialize_expout): Likewise.
	(mark_completion_tag): Likewise.
	(copy_name): Likewise.
	(parse_float): Likewise.
	(type_stack_reserve): Likewise.
	* ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise.
	(ppu2spu_prev_register): Likewise.
	* ppc-ravenscar-thread.c (supply_register_at_address): Likewise.
	* printcmd.c (printf_wide_c_string): Likewise.
	(printf_pointer): Likewise.
	* probe.c (parse_probes): Likewise.
	* python/py-cmd.c (gdbpy_parse_command_name): Likewise.
	(cmdpy_init): Likewise.
	* python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise.
	* python/py-symtab.c (set_sal): Likewise.
	* python/py-unwind.c (pyuw_sniffer): Likewise.
	* python/python.c (python_interactive_command): Likewise.
	(compute_python_string): Likewise.
	* ravenscar-thread.c (get_running_thread_id): Likewise.
	* record-full.c (record_full_exec_insn): Likewise.
	(record_full_core_open_1): Likewise.
	* regcache.c (regcache_raw_read_signed): Likewise.
	(regcache_raw_read_unsigned): Likewise.
	(regcache_cooked_read_signed): Likewise.
	(regcache_cooked_read_unsigned): Likewise.
	* remote-fileio.c (remote_fileio_func_open): Likewise.
	(remote_fileio_func_rename): Likewise.
	(remote_fileio_func_unlink): Likewise.
	(remote_fileio_func_stat): Likewise.
	(remote_fileio_func_system): Likewise.
	* remote-mips.c (mips_xfer_memory): Likewise.
	(mips_load_srec): Likewise.
	(pmon_end_download): Likewise.
	* remote.c (new_remote_state): Likewise.
	(map_regcache_remote_table): Likewise.
	(remote_register_number_and_offset): Likewise.
	(init_remote_state): Likewise.
	(get_memory_packet_size): Likewise.
	(remote_pass_signals): Likewise.
	(remote_program_signals): Likewise.
	(remote_start_remote): Likewise.
	(remote_check_symbols): Likewise.
	(remote_query_supported): Likewise.
	(extended_remote_attach): Likewise.
	(process_g_packet): Likewise.
	(store_registers_using_G): Likewise.
	(putpkt_binary): Likewise.
	(read_frame): Likewise.
	(compare_sections_command): Likewise.
	(remote_hostio_pread): Likewise.
	(remote_hostio_readlink): Likewise.
	(remote_file_put): Likewise.
	(remote_file_get): Likewise.
	(remote_pid_to_exec_file): Likewise.
	(_initialize_remote): Likewise.
	* rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise.
	(rs6000_aix_core_xfer_shared_libraries_aix): Likewise.
	* rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise.
	(bfd_uses_spe_extensions): Likewise.
	* s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise.
	* score-tdep.c (score7_malloc_and_get_memblock): Likewise.
	* solib-dsbt.c (decode_loadmap): Likewise.
	(fetch_loadmap): Likewise.
	(scan_dyntag): Likewise.
	(enable_break): Likewise.
	(dsbt_relocate_main_executable): Likewise.
	* solib-frv.c (fetch_loadmap): Likewise.
	(enable_break2): Likewise.
	(frv_relocate_main_executable): Likewise.
	* solib-spu.c (spu_relocate_main_executable): Likewise.
	(spu_bfd_open): Likewise.
	* solib-svr4.c (lm_info_read): Likewise.
	(read_program_header): Likewise.
	(find_program_interpreter): Likewise.
	(scan_dyntag): Likewise.
	(elf_locate_base): Likewise.
	(open_symbol_file_object): Likewise.
	(read_program_headers_from_bfd): Likewise.
	(svr4_relocate_main_executable): Likewise.
	* solib-target.c (solib_target_relocate_section_addresses): Likewise.
	* solib.c (solib_find_1): Likewise.
	(exec_file_find): Likewise.
	(solib_find): Likewise.
	* source.c (openp): Likewise.
	(print_source_lines_base): Likewise.
	(forward_search_command): Likewise.
	* sparc-ravenscar-thread.c (supply_register_at_address): Likewise.
	* spu-tdep.c (spu2ppu_prev_register): Likewise.
	(spu_get_overlay_table): Likewise.
	* stabsread.c (patch_block_stabs): Likewise.
	(define_symbol): Likewise.
	(again:): Likewise.
	(read_member_functions): Likewise.
	(read_one_struct_field): Likewise.
	(read_enum_type): Likewise.
	(common_block_start): Likewise.
	* stack.c (read_frame_arg): Likewise.
	(backtrace_command): Likewise.
	* stap-probe.c (stap_parse_register_operand): Likewise.
	* symfile.c (syms_from_objfile_1): Likewise.
	(find_separate_debug_file): Likewise.
	(load_command): Likewise.
	(load_progress): Likewise.
	(load_section_callback): Likewise.
	(reread_symbols): Likewise.
	(add_filename_language): Likewise.
	(allocate_compunit_symtab): Likewise.
	(read_target_long_array): Likewise.
	(simple_read_overlay_table): Likewise.
	* symtab.c (symbol_set_names): Likewise.
	(resize_symbol_cache): Likewise.
	(rbreak_command): Likewise.
	(completion_list_add_name): Likewise.
	(completion_list_objc_symbol): Likewise.
	(add_filename_to_list): Likewise.
	* target-descriptions.c (maint_print_c_tdesc_cmd): Likewise.
	* target-memory.c (target_write_memory_blocks): Likewise.
	* target.c (target_read_string): Likewise.
	(read_whatever_is_readable): Likewise.
	(target_read_alloc_1): Likewise.
	(simple_search_memory): Likewise.
	(target_fileio_read_alloc_1): Likewise.
	* tilegx-tdep.c (tilegx_push_dummy_call): Likewise.
	* top.c (command_line_input): Likewise.
	* tracefile-tfile.c (tfile_fetch_registers): Likewise.
	* tracefile.c (tracefile_fetch_registers): Likewise.
	* tracepoint.c (add_memrange): Likewise.
	(init_collection_list): Likewise.
	(add_aexpr): Likewise.
	(trace_dump_actions): Likewise.
	(parse_trace_status): Likewise.
	(parse_tracepoint_definition): Likewise.
	(parse_tsv_definition): Likewise.
	(parse_static_tracepoint_marker_definition): Likewise.
	* tui/tui-file.c (tui_sfileopen): Likewise.
	(tui_file_adjust_strbuf): Likewise.
	* tui/tui-io.c (tui_expand_tabs): Likewise.
	* tui/tui-source.c (tui_set_source_content): Likewise.
	* typeprint.c (find_global_typedef): Likewise.
	* ui-file.c (do_ui_file_xstrdup): Likewise.
	(ui_file_obsavestring): Likewise.
	(mem_file_write): Likewise.
	* utils.c (make_hex_string): Likewise.
	(get_regcomp_error): Likewise.
	(puts_filtered_tabular): Likewise.
	(gdb_realpath_keepfile): Likewise.
	(ldirname): Likewise.
	(gdb_bfd_errmsg): Likewise.
	(substitute_path_component): Likewise.
	* valops.c (search_struct_method): Likewise.
	(find_oload_champ_namespace_loop): Likewise.
	* valprint.c (print_decimal_chars): Likewise.
	(read_string): Likewise.
	(generic_emit_char): Likewise.
	* varobj.c (varobj_delete): Likewise.
	(varobj_value_get_print_value): Likewise.
	* vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise.
	* windows-tdep.c (display_one_tib): Likewise.
	* xcoffread.c (read_xcoff_symtab): Likewise.
	(process_xcoff_symbol): Likewise.
	(swap_sym): Likewise.
	(scan_xcoff_symtab): Likewise.
	(xcoff_initial_scan): Likewise.
	* xml-support.c (gdb_xml_end_element): Likewise.
	(xml_process_xincludes): Likewise.
	(xml_fetch_content_from_file): Likewise.
	* xml-syscall.c (xml_list_of_syscalls): Likewise.
	* xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise.

gdb/gdbserver/ChangeLog:

	* ax.c (gdb_parse_agent_expr): Add cast to allocation result
	assignment.
	(gdb_unparse_agent_expr): Likewise.
	* hostio.c (require_data): Likewise.
	(handle_pread): Likewise.
	* linux-low.c (disable_regset): Likewise.
	(fetch_register): Likewise.
	(store_register): Likewise.
	(get_dynamic): Likewise.
	(linux_qxfer_libraries_svr4): Likewise.
	* mem-break.c (delete_fast_tracepoint_jump): Likewise.
	(set_fast_tracepoint_jump): Likewise.
	(uninsert_fast_tracepoint_jumps_at): Likewise.
	(reinsert_fast_tracepoint_jumps_at): Likewise.
	(validate_inserted_breakpoint): Likewise.
	(clone_agent_expr): Likewise.
	* regcache.c (init_register_cache): Likewise.
	* remote-utils.c (putpkt_binary_1): Likewise.
	(decode_M_packet): Likewise.
	(decode_X_packet): Likewise.
	(look_up_one_symbol): Likewise.
	(relocate_instruction): Likewise.
	(monitor_output): Likewise.
	* server.c (handle_search_memory): Likewise.
	(handle_qxfer_exec_file): Likewise.
	(handle_qxfer_libraries): Likewise.
	(handle_qxfer): Likewise.
	(handle_query): Likewise.
	(handle_v_cont): Likewise.
	(handle_v_run): Likewise.
	(captured_main): Likewise.
	* target.c (write_inferior_memory): Likewise.
	* thread-db.c (try_thread_db_load_from_dir): Likewise.
	* tracepoint.c (init_trace_buffer): Likewise.
	(add_tracepoint_action): Likewise.
	(add_traceframe): Likewise.
	(add_traceframe_block): Likewise.
	(cmd_qtdpsrc): Likewise.
	(cmd_qtdv): Likewise.
	(cmd_qtstatus): Likewise.
	(response_source): Likewise.
	(response_tsv): Likewise.
	(cmd_qtnotes): Likewise.
	(gdb_collect): Likewise.
	(initialize_tracepoint): Likewise.
2015-09-25 14:08:06 -04:00
Pedro Alves f890475111 C++: Initialize a couple const globals
In C++ mode, we get:

 src/gdb/gdbserver/tdesc.c:43:33: error: uninitialized const ‘default_description’ [-fpermissive]
  static const struct target_desc default_description;
				  ^
 In file included from src/gdb/gdbserver/tdesc.c:19:0:
 src/gdb/gdbserver/tdesc.h:26:8: note: ‘const struct target_desc’ has no user-provided default constructor
  struct target_desc
	 ^

gdb/ChangeLog:
2015-08-21  Pedro Alves  <palves@redhat.com>

	* frame.c (null_frame_id): Explicitly zero-initialize.

gdb/gdbserver/ChangeLog:
2015-08-21  Pedro Alves  <palves@redhat.com>

	* tdesc.c (default_description): Explicitly zero-initialize.
2015-08-21 23:49:37 +01:00
Andrew Burgess 060967202b gdb: Move get_frame_language from stack.c to frame.c.
The get_frame_language feels like it would be more at home in frame.c
rather than in stack.c, while the declaration, that is currently in
language.h can be moved into frame.h to match.

A couple of new includes are added, but otherwise no substantial change
here.

gdb/ChangeLog:

	* stack.c (get_frame_language): Moved ...
	* frame.c (get_frame_language): ... to here.
	* language.h (get_frame_language): Declaration moved to frame.h.
	* frame.h: Add language.h include, for language enum.
	(get_frame_language): Declaration moved from language.h.
	* language.c: Add frame.h include.
	* top.c: Add frame.h include.
	* symtab.h (struct obj_section): Declare.
	(struct cmd_list_element): Declare.
2015-08-07 11:55:20 +02:00
Patrick Palka 0986c744df Replace TUI's select_frame hook (PR tui/13378)
The select_frame hook is used by TUI to update TUI's frame and register
information following changes to the selected frame.  The problem with
this hook is that it gets called after every single frame change, even
if the frame change is only temporary or internal.  This is the primary
cause of flickering and slowdown when running the inferior under TUI
with conditional breakpoints set.  Internal GDB events are the source of
many calls to select_frame and these internal events are triggered
frequently, especially when a few conditional breakpoints are set.

This patch removes the select_frame hook altogether and instead makes
the frame and register information get updated in two key places (using
observers): after an inferior stops, and right before displaying a
prompt.  The latter hook covers the case when frame information must be
updated following a call to "up", "down" or "frame", and the former
covers the case when frame and register information must be updated
after a call to "continue", "step", etc. or after the inferior stops in
async execution mode.  Together these hooks should cover all the cases
when frame information ought to be refreshed (and when the relevant
windows ought to be subsequently updated).

The print_frame_info_listing hook is also effectively obsolete now, but
it still must be set while the TUI is active because its caller
print_frame_info will otherwise assume that the CLI is active, and will
print the frame informaion accordingly.  So this patch also sets the
print_frame_info_listing hook to a dummy callback, in lieu of outright
removing it yet.

Effectively, with this patch, frame/PC changes that do not immediately
precede an inferior-stop event or a prompt display event no longer cause
TUI's frame and register information to be updated.

And as a result of this change and of the previous change to
tui_show_frame_info, the TUI is much more disciplined about updating the
screen, and so the flicker as described in the PR is totally gone.

gdb/ChangeLog:

	PR tui/13378
	* frame.c (select_frame): Remove reference to
	deprecated_selected_frame_level_changed_hook.
	* frame.h (deprecated_selected_frame_level_changed_hook): Remove
	declaration.
	* stack.c (deprecated_selected_frame_level_changed_hook):
	Likewise.
	* tui/tui-hooks.c (tui_selected_frame_level_changed_hook):
	Rename to ...
	(tui_refresh_frame_and_register_information): ... this.  Bail
	out if there is no stack.  Don't update register information
	unless registers_too_p is true.
	(tui_print_frame_info_listing_hook): Rename to ...
	(tui_dummy_print_frame_info_listing_hook): ... this.
	(tui_before_prompt): New function.
	(tui_normal_stop): New function.
	(tui_before_prompt_observer): New observer.
	(tui_normal_stop_observer): New observer.
	(tui_install_hooks): Set
	deprecated_print_frame_info_listing_hook to
	tui_dummy_print_frame_info_listing_hook.  Register
	tui_before_prompt_observer to call tui_before_prompt and
	tui_normal_stop_observer to call tui_normal_stop.  Remove
	reference to deprecated_selected_frame_level_changed_hook.
	(tui_remove_hooks): Detach and unset tui_before_prompt_observer
	and tui_normal_stop_observer.  Remove reference to
	deprecated_selected_frame_level_changed_hook.
2015-06-30 13:56:49 -04:00
Pedro Alves 492d29ea1c Split TRY_CATCH into TRY + CATCH
This patch splits the TRY_CATCH macro into three, so that we go from
this:

~~~
  volatile gdb_exception ex;

  TRY_CATCH (ex, RETURN_MASK_ERROR)
    {
    }
  if (ex.reason < 0)
    {
    }
~~~

to this:

~~~
  TRY
    {
    }
  CATCH (ex, RETURN_MASK_ERROR)
    {
    }
  END_CATCH
~~~

Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.

This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.

TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:

  TRY
    {
    }

  // some code here.

  CATCH (ex, RETURN_MASK_ERROR)
    {
    }
  END_CATCH

Just like it isn't valid to do that with C++'s native try/catch.

By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.

The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved.  After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch].  The result was folded into this patch so that GDB
still builds at each incremental step.

END_CATCH is necessary for two reasons:

First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:

  #define CATCH(EXCEPTION, mask) \
    for (struct gdb_exception EXCEPTION; \
         exceptions_state_mc_catch (&EXCEPTION, MASK); \
	 EXCEPTION = exception_none)

would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.

Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow.  That will
be done in END_CATCH.

After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.

IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.

gdb/ChangeLog.
2015-03-07  Pedro Alves  <palves@redhat.com>

	* common/common-exceptions.c (struct catcher) <exception>: No
	longer a pointer to volatile exception.  Now an exception value.
	<mask>: Delete field.
	(exceptions_state_mc_init): Remove all parameters.  Adjust.
	(exceptions_state_mc): No longer pop the catcher here.
	(exceptions_state_mc_catch): New function.
	(throw_exception): Adjust.
	* common/common-exceptions.h (exceptions_state_mc_init): Remove
	all parameters.
	(exceptions_state_mc_catch): Declare.
	(TRY_CATCH): Rename to ...
	(TRY): ... this.  Remove EXCEPTION and MASK parameters.
	(CATCH, END_CATCH): New.
	All callers adjusted.

gdb/gdbserver/ChangeLog:
2015-03-07  Pedro Alves  <palves@redhat.com>

	Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
	instead.
2015-03-07 15:14:14 +00:00
Pedro Alves 7556d4a4f6 Normalize TRY_CATCH exception handling block
This normalizes some exception catch blocks that check for ex.reason
to look like this:

~~~
  volatile gdb_exception ex;

  TRY_CATCH (ex, RETURN_MASK_ALL)
    {
      ...
    }
  if (ex.reason < 0)
    {
      ...
    }
~~~

This is a preparation step for running a script that converts all
TRY_CATCH uses to look like this instead:

~~~
  TRY
    {
      ...
    }
  CATCH (ex, RETURN_MASK_ALL)
    {
      ...
    }
  END_CATCH
~~~

The motivation for that change is being able to reimplent TRY/CATCH in
terms of C++ try/catch.

This commit makes it so that:

 - no condition other than ex.reason < 0 is checked in the if
   predicate

 - there's no "else" block to check whether no exception was caught

 - there's no code between the TRY_CATCH (TRY) block and the
   'if (ex.reason < 0)' block (CATCH).

 - the exception object is no longer referred to outside the if/catch
   block.  Note the local volatile exception objects that are
   currently defined inside functions that use TRY_CATCH will
   disappear.  In cases it's more convenient to still refer to the
   exception outside the catch block, a new non-volatile local is
   added and copy to that object is made within the catch block.

The following patches should make this all clearer.

gdb/ChangeLog:
2015-03-07  Pedro Alves  <palves@redhat.com>

	* amd64-tdep.c (amd64_frame_cache, amd64_sigtramp_frame_cache)
	(amd64_epilogue_frame_cache): Normal exception handling code.
	* break-catch-throw.c (check_status_exception_catchpoint)
	(re_set_exception_catchpoint): Ditto.
	* cli/cli-interp.c (safe_execute_command):
	* cli/cli-script.c (script_from_file): Ditto.
	* compile/compile-c-symbols.c (generate_c_for_for_one_variable):
	Ditto.
	* compile/compile-object-run.c (compile_object_run): Ditto.
	* cp-abi.c (baseclass_offset): Ditto.
	* cp-valprint.c (cp_print_value): Ditto.
	* exceptions.c (catch_exceptions_with_msg):
	* frame-unwind.c (frame_unwind_try_unwinder): Ditto.
	* frame.c (get_frame_address_in_block_if_available): Ditto.
	* i386-tdep.c (i386_frame_cache, i386_epilogue_frame_cache)
	(i386_sigtramp_frame_cache): Ditto.
	* infcmd.c (post_create_inferior): Ditto.
	* linespec.c (parse_linespec, find_linespec_symbols):
	* p-valprint.c (pascal_object_print_value): Ditto.
	* parse.c (parse_expression_for_completion): Ditto.
	* python/py-finishbreakpoint.c (bpfinishpy_init): Ditto.
	* remote.c (remote_get_noisy_reply): Ditto.
	* s390-linux-tdep.c (s390_frame_unwind_cache): Ditto.
	* solib-svr4.c (solib_svr4_r_map): Ditto.
2015-03-07 14:56:43 +00:00
Pedro Alves fe978cb071 C++ keyword cleanliness, mostly auto-generated
This patch renames symbols that happen to have names which are
reserved keywords in C++.

Most of this was generated with Tromey's cxx-conversion.el script.
Some places where later hand massaged a bit, to fix formatting, etc.
And this was rebased several times meanwhile, along with re-running
the script, so re-running the script from scratch probably does not
result in the exact same output.  I don't think that matters anyway.

gdb/
2015-02-27  Tom Tromey  <tromey@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	Rename symbols whose names are reserved C++ keywords throughout.

gdb/gdbserver/
2015-02-27  Tom Tromey  <tromey@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	Rename symbols whose names are reserved C++ keywords throughout.
2015-02-27 16:33:07 +00:00
Joel Brobecker 32d0add0a6 Update year range in copyright notice of all files owned by the GDB project.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2015-01-01 13:32:14 +04:00
Doug Evans 08be3fe322 Replace some symbol accessor macros with functions.
gdb/ChangeLog:

	* symtab.h (SYMBOL_SYMTAB): Delete
	(SYMBOL_OBJFILE): Delete.
	(symbol_symtab, symbol_set_symtab): Declare.
	(symbol_objfile, symbol_arch): Declare.
	* symtab.c (symbol_symtab): Replaces SYMBOL_SYMTAB.  All uses updated.
	All references to symbol->symtab redirected through here.
	(symbol_set_symtab): New function.  All assignments to SYMBOL_SYMTAB
	redirected through here.
	(symbol_arch): New function.
	(symbol_objfile): New function.  Replaces SYMBOL_OBJFILE.
	All uses updated.
	* cp-namespace.c (cp_lookup_symbol_imports_or_template): Call
	symbol_arch.
	* findvar.c (default_read_var_value): Call symbol_arch.
	* guile/scm-frame.c (gdbscm_frame_block): Call symbol_objfile.
	* jv-lang.c (add_class_symtab_symbol): Call symbol_arch.
	* printcmd.c (address_info): Call symbol_arch.
	* tracepoint.c (scope_info): Call symbol_arch.
2014-12-23 07:21:10 -08:00
Martin Galvan f0d4ba1fc4 frame.c: Fix the check for FID_STACK_INVALID in frame_id_eq()
I noticed in frame_id_eq() we were checking for the "l" frame_id being
invalid twice instead of checking both "l" and "r", so this patch
corrects it.

gdb/ChangeLog:

	* frame.c (frame_id_eq): Fix the check for FID_STACK_INVALID.
2014-11-30 19:37:31 +04:00
Doug Evans 43f3e411c4 Split struct symtab into two: struct symtab and compunit_symtab.
Currently "symtabs" in gdb are stored as a single linked list of
struct symtab that contains both symbol symtabs (the blockvectors)
and file symtabs (the linetables).

This has led to confusion, bugs, and performance issues.

This patch is conceptually very simple: split struct symtab into
two pieces: one part containing things common across the entire
compilation unit, and one part containing things specific to each
source file.

Example.
For the case of a program built out of these files:

foo.c
  foo1.h
  foo2.h
bar.c
  foo1.h
  bar.h

Today we have a single list of struct symtabs:

objfile -> foo.c -> foo1.h -> foo2.h -> bar.c -> foo1.h -> bar.h -> NULL

where "->" means the "next" pointer in struct symtab.

With this patch, that turns into:

objfile -> foo.c(cu) -> bar.c(cu) -> NULL
            |            |
            v            v
           foo.c        bar.c
            |            |
            v            v
           foo1.h       foo1.h
            |            |
            v            v
           foo2.h       bar.h
            |            |
            v            v
           NULL         NULL

where "foo.c(cu)" and "bar.c(cu)" are struct compunit_symtab objects,
and the files foo.c, etc. are struct symtab objects.

So now, for example, when we want to iterate over all blockvectors
we can now just iterate over the compunit_symtab list.

Plus a lot of the data that was either unused or replicated for each
symtab in a compilation unit now lives in struct compunit_symtab.
E.g., the objfile pointer, the producer string, etc.
I thought of moving "language" out of struct symtab but there is
logic to try to compute the language based on previously seen files,
and I think that's best left as is for now.
With my standard monster benchmark with -readnow (which I can't actually
do, but based on my calculations), whereas today the list requires
77MB to store all the struct symtabs, it now only requires 37MB.
A modest space savings given the gigabytes needed for all the debug info,
etc.  Still, it's nice.  Plus, whereas today we create a copy of dirname
for each source file symtab in a compilation unit, we now only create one
for the compunit.

So this patch is basically just a data structure reorg,
I don't expect significant performance improvements from it.

Notes:

1) A followup patch can do a similar split for struct partial_symtab.
I have left that until after I get the changes I want in to
better utilize .gdb_index (it may affect how we do partial syms).

2) Another followup patch *could* rename struct symtab.
The term "symtab" is ambiguous and has been a source of confusion.
In this patch I'm leaving it alone, calling it the "historical" name
of "filetabs", which is what they are now: just the file-name + line-table.

gdb/ChangeLog:

	Split struct symtab into two: struct symtab and compunit_symtab.
	* amd64-tdep.c (amd64_skip_xmm_prologue): Fetch producer from compunit.
	* block.c (blockvector_for_pc_sect): Change "struct symtab *" argument
	to "struct compunit_symtab *".  All callers updated.
	(set_block_compunit_symtab): Renamed from set_block_symtab.  Change
	"struct symtab *" argument to "struct compunit_symtab *".
	All callers updated.
	(get_block_compunit_symtab): Renamed from get_block_symtab.  Change
	result to "struct compunit_symtab *".  All callers updated.
	(find_iterator_compunit_symtab): Renamed from find_iterator_symtab.
	Change result to "struct compunit_symtab *".  All callers updated.
	* block.h (struct global_block) <compunit_symtab>: Renamed from symtab.
	hange type to "struct compunit_symtab *".  All uses updated.
	(struct block_iterator) <d.compunit_symtab>: Renamed from "d.symtab".
	Change type to "struct compunit_symtab *".  All uses updated.
	* buildsym.c (struct buildsym_compunit): New struct.
	(subfiles, buildsym_compdir, buildsym_objfile, main_subfile): Delete.
	(buildsym_compunit): New static global.
	(finish_block_internal): Update to fetch objfile from
	buildsym_compunit.
	(make_blockvector): Delete objfile argument.
	(start_subfile): Rewrite to use buildsym_compunit.  Don't initialize
	debugformat, producer.
	(start_buildsym_compunit): New function.
	(free_buildsym_compunit): Renamed from free_subfiles_list.
	All callers updated.
	(patch_subfile_names): Rewrite to use buildsym_compunit.
	(get_compunit_symtab): New function.
	(get_macro_table): Delete argument comp_dir.  All callers updated.
	(start_symtab): Change result to "struct compunit_symtab *".
	All callers updated.  Create the subfile of the main source file.
	(watch_main_source_file_lossage): Rewrite to use buildsym_compunit.
	(reset_symtab_globals): Update.
	(end_symtab_get_static_block): Update to use buildsym_compunit.
	(end_symtab_without_blockvector): Rewrite.
	(end_symtab_with_blockvector): Change result to
	"struct compunit_symtab *".  All callers updated.
	Update to use buildsym_compunit.  Don't set symtab->dirname,
	instead set it in the compunit.
	Explicitly make sure main symtab is first in its list.
	Set debugformat, producer, blockvector, block_line_section, and
	macrotable in the compunit.
	(end_symtab_from_static_block): Change result to
	"struct compunit_symtab *".  All callers updated.
	(end_symtab, end_expandable_symtab): Ditto.
	(set_missing_symtab): Change symtab argument to
	"struct compunit_symtab *".  All callers updated.
	(augment_type_symtab): Ditto.
	(record_debugformat): Update to use buildsym_compunit.
	(record_producer): Update to use buildsym_compunit.
	* buildsym.h (struct subfile) <dirname>: Delete.
	<producer, debugformat>: Delete.
	<buildsym_compunit>: New member.
	(get_compunit_symtab): Declare.
	* dwarf2read.c (struct type_unit_group) <compunit_symtab>: Renamed
	from primary_symtab.  Change type to "struct compunit_symtab *".
	All uses updated.
	(dwarf2_start_symtab): Change result to "struct compunit_symtab *".
	All callers updated.
	(dwarf_decode_macros): Delete comp_dir argument.  All callers updated.
	(struct dwarf2_per_cu_quick_data) <compunit_symtab>: Renamed from
	symtab.  Change type to "struct compunit_symtab *".  All uses updated.
	(dw2_instantiate_symtab): Change result to "struct compunit_symtab *".
	All callers updated.
	(dw2_find_last_source_symtab): Ditto.
	(dw2_lookup_symbol): Ditto.
	(recursively_find_pc_sect_compunit_symtab): Renamed from
	recursively_find_pc_sect_symtab.  Change result to
	"struct compunit_symtab *".  All callers updated.
	(dw2_find_pc_sect_compunit_symtab): Renamed from
	dw2_find_pc_sect_symtab.  Change result to
	"struct compunit_symtab *".  All callers updated.
	(get_compunit_symtab): Renamed from get_symtab.  Change result to
	"struct compunit_symtab *".  All callers updated.
	(recursively_compute_inclusions): Change type of immediate_parent
	argument to "struct compunit_symtab *".  All callers updated.
	(compute_compunit_symtab_includes): Renamed from
	compute_symtab_includes.  All callers updated.  Rewrite to compute
	includes of compunit_symtabs and not symtabs.
	(process_full_comp_unit): Update to work with struct compunit_symtab.
	(process_full_type_unit): Ditto.
	(dwarf_decode_lines_1): Delete argument comp_dir.  All callers updated.
	(dwarf_decode_lines): Remove special case handling of main subfile.
	(macro_start_file): Delete argument comp_dir.  All callers updated.
	(dwarf_decode_macro_bytes): Ditto.
	* guile/scm-block.c (bkscm_print_block_syms_progress_smob): Update to
	use struct compunit_symtab.
	* i386-tdep.c (i386_skip_prologue): Fetch producer from compunit.
	* jit.c (finalize_symtab): Build compunit_symtab.
	* jv-lang.c (get_java_class_symtab): Change result to
	"struct compunit_symtab *".  All callers updated.
	* macroscope.c (sal_macro_scope): Fetch macro table from compunit.
	* macrotab.c (struct macro_table) <compunit_symtab>: Renamed from
	comp_dir.  Change type to "struct compunit_symtab *".
	All uses updated.
	(new_macro_table): Change comp_dir argument to cust,
	"struct compunit_symtab *".  All callers updated.
	* maint.c (struct cmd_stats) <nr_compunit_symtabs>: Renamed from
	nr_primary_symtabs.  All uses updated.
	(count_symtabs_and_blocks): Update to handle compunits.
	(report_command_stats): Update output, "primary symtabs" renamed to
	"compunits".
	* mdebugread.c (new_symtab): Change result to
	"struct compunit_symtab *".  All callers updated.
	(parse_procedure): Change type of search_symtab argument to
	"struct compunit_symtab *".  All callers updated.
	* objfiles.c (objfile_relocate1): Loop over blockvectors in a
	separate loop.
	* objfiles.h (struct objfile) <compunit_symtabs>: Renamed from
	symtabs.  Change type to "struct compunit_symtab *".  All uses updated.
	(ALL_OBJFILE_FILETABS): Renamed from ALL_OBJFILE_SYMTABS.
	All uses updated.
	(ALL_OBJFILE_COMPUNITS): Renamed from ALL_OBJFILE_PRIMARY_SYMTABS.
	All uses updated.
	(ALL_FILETABS): Renamed from ALL_SYMTABS.  All uses updated.
	(ALL_COMPUNITS): Renamed from ALL_PRIMARY_SYMTABS.  All uses updated.
	* psympriv.h (struct partial_symtab) <compunit_symtab>: Renamed from
	symtab.  Change type to "struct compunit_symtab *".  All uses updated.
	* psymtab.c (psymtab_to_symtab): Change result type to
	"struct compunit_symtab *".  All callers updated.
	(find_pc_sect_compunit_symtab_from_partial): Renamed from
	find_pc_sect_symtab_from_partial.  Change result type to
	"struct compunit_symtab *".  All callers updated.
	(lookup_symbol_aux_psymtabs): Change result type to
	"struct compunit_symtab *".  All callers updated.
	(find_last_source_symtab_from_partial): Ditto.
	* python/py-symtab.c (stpy_get_producer): Fetch producer from compunit.
	* source.c (forget_cached_source_info_for_objfile): Fetch debugformat
	and macro_table from compunit.
	* symfile-debug.c (debug_qf_find_last_source_symtab): Change result
	type to "struct compunit_symtab *".  All callers updated.
	(debug_qf_lookup_symbol): Ditto.
	(debug_qf_find_pc_sect_compunit_symtab): Renamed from
	debug_qf_find_pc_sect_symtab, change result type to
	"struct compunit_symtab *".  All callers updated.
	* symfile.c (allocate_symtab): Delete objfile argument.
	New argument cust.
	(allocate_compunit_symtab): New function.
	(add_compunit_symtab_to_objfile): New function.
	* symfile.h (struct quick_symbol_functions) <lookup_symbol>:
	Change result type to "struct compunit_symtab *".  All uses updated.
	<find_pc_sect_compunit_symtab>: Renamed from find_pc_sect_symtab.
	Change result type to "struct compunit_symtab *".  All uses updated.
	* symmisc.c (print_objfile_statistics): Compute blockvector count in
	separate loop.
	(dump_symtab_1): Update test for primary source symtab.
	(maintenance_info_symtabs): Update to handle compunit symtabs.
	(maintenance_check_symtabs): Ditto.
	* symtab.c (set_primary_symtab): Delete.
	(compunit_primary_filetab): New function.
	(compunit_language): New function.
	(iterate_over_some_symtabs): Change type of arguments "first",
	"after_last" to "struct compunit_symtab *".  All callers updated.
	Update to loop over symtabs in each compunit.
	(error_in_psymtab_expansion): Rename symtab argument to cust,
	and change type to "struct compunit_symtab *".  All callers updated.
	(find_pc_sect_compunit_symtab): Renamed from find_pc_sect_symtab.
	Change result type to "struct compunit_symtab *".  All callers updated.
	(find_pc_compunit_symtab): Renamed from find_pc_symtab.
	Change result type to "struct compunit_symtab *".  All callers updated.
	(find_pc_sect_line): Only loop over symtabs within selected compunit
	instead of all symtabs in the objfile.
	* symtab.h (struct symtab) <blockvector>: Moved to compunit_symtab.
	<compunit_symtab> New member.
	<block_line_section>: Moved to compunit_symtab.
	<locations_valid>: Ditto.
	<epilogue_unwind_valid>: Ditto.
	<macro_table>: Ditto.
	<dirname>: Ditto.
	<debugformat>: Ditto.
	<producer>: Ditto.
	<objfile>: Ditto.
	<call_site_htab>: Ditto.
	<includes>: Ditto.
	<user>: Ditto.
	<primary>: Delete
	(SYMTAB_COMPUNIT): New macro.
	(SYMTAB_BLOCKVECTOR): Update definition.
	(SYMTAB_OBJFILE): Update definition.
	(SYMTAB_DIRNAME): Update definition.
	(struct compunit_symtab): New type.  Common members among all source
	symtabs within a compilation unit moved here.  All uses updated.
	(COMPUNIT_OBJFILE): New macro.
	(COMPUNIT_FILETABS): New macro.
	(COMPUNIT_DEBUGFORMAT): New macro.
	(COMPUNIT_PRODUCER): New macro.
	(COMPUNIT_DIRNAME): New macro.
	(COMPUNIT_BLOCKVECTOR): New macro.
	(COMPUNIT_BLOCK_LINE_SECTION): New macro.
	(COMPUNIT_LOCATIONS_VALID): New macro.
	(COMPUNIT_EPILOGUE_UNWIND_VALID): New macro.
	(COMPUNIT_CALL_SITE_HTAB): New macro.
	(COMPUNIT_MACRO_TABLE): New macro.
	(ALL_COMPUNIT_FILETABS): New macro.
	(compunit_symtab_ptr): New typedef.
	(DEF_VEC_P (compunit_symtab_ptr)): New vector type.

gdb/testsuite/ChangeLog:

	* gdb.base/maint.exp: Update expected output.
2014-11-20 07:47:44 -08:00
Gary Benson c765fdb902 Remove spurious exceptions.h inclusions
defs.h includes utils.h, and utils.h includes exceptions.h.  All GDB
.c files include defs.h as their first line, so no file other than
utils.h needs to include exceptions.h.  This commit removes all such
inclusions.

gdb/ChangeLog:

	* ada-lang.c: Do not include exceptions.h.
	* ada-valprint.c: Likewise.
	* amd64-tdep.c: Likewise.
	* auto-load.c: Likewise.
	* block.c: Likewise.
	* break-catch-throw.c: Likewise.
	* breakpoint.c: Likewise.
	* btrace.c: Likewise.
	* c-lang.c: Likewise.
	* cli/cli-cmds.c: Likewise.
	* cli/cli-interp.c: Likewise.
	* cli/cli-script.c: Likewise.
	* completer.c: Likewise.
	* corefile.c: Likewise.
	* corelow.c: Likewise.
	* cp-abi.c: Likewise.
	* cp-support.c: Likewise.
	* cp-valprint.c: Likewise.
	* darwin-nat.c: Likewise.
	* dwarf2-frame-tailcall.c: Likewise.
	* dwarf2-frame.c: Likewise.
	* dwarf2loc.c: Likewise.
	* dwarf2read.c: Likewise.
	* eval.c: Likewise.
	* event-loop.c: Likewise.
	* event-top.c: Likewise.
	* f-valprint.c: Likewise.
	* frame-unwind.c: Likewise.
	* frame.c: Likewise.
	* gdbtypes.c: Likewise.
	* gnu-v2-abi.c: Likewise.
	* gnu-v3-abi.c: Likewise.
	* guile/scm-auto-load.c: Likewise.
	* guile/scm-breakpoint.c: Likewise.
	* guile/scm-cmd.c: Likewise.
	* guile/scm-frame.c: Likewise.
	* guile/scm-lazy-string.c: Likewise.
	* guile/scm-param.c: Likewise.
	* guile/scm-symbol.c: Likewise.
	* guile/scm-type.c: Likewise.
	* hppa-hpux-tdep.c: Likewise.
	* i386-tdep.c: Likewise.
	* inf-loop.c: Likewise.
	* infcall.c: Likewise.
	* infcmd.c: Likewise.
	* infrun.c: Likewise.
	* interps.c: Likewise.
	* interps.h: Likewise.
	* jit.c: Likewise.
	* linespec.c: Likewise.
	* linux-nat.c: Likewise.
	* linux-thread-db.c: Likewise.
	* m32r-rom.c: Likewise.
	* main.c: Likewise.
	* memory-map.c: Likewise.
	* mi/mi-cmd-break.c: Likewise.
	* mi/mi-cmd-stack.c: Likewise.
	* mi/mi-interp.c: Likewise.
	* mi/mi-main.c: Likewise.
	* monitor.c: Likewise.
	* nto-procfs.c: Likewise.
	* objc-lang.c: Likewise.
	* p-valprint.c: Likewise.
	* parse.c: Likewise.
	* ppc-linux-tdep.c: Likewise.
	* printcmd.c: Likewise.
	* probe.c: Likewise.
	* python/py-auto-load.c: Likewise.
	* python/py-breakpoint.c: Likewise.
	* python/py-cmd.c: Likewise.
	* python/py-finishbreakpoint.c: Likewise.
	* python/py-frame.c: Likewise.
	* python/py-framefilter.c: Likewise.
	* python/py-function.c: Likewise.
	* python/py-gdb-readline.c: Likewise.
	* python/py-inferior.c: Likewise.
	* python/py-infthread.c: Likewise.
	* python/py-lazy-string.c: Likewise.
	* python/py-linetable.c: Likewise.
	* python/py-param.c: Likewise.
	* python/py-prettyprint.c: Likewise.
	* python/py-symbol.c: Likewise.
	* python/py-type.c: Likewise.
	* python/py-value.c: Likewise.
	* python/python-internal.h: Likewise.
	* python/python.c: Likewise.
	* record-btrace.c: Likewise.
	* record-full.c: Likewise.
	* regcache.c: Likewise.
	* remote-fileio.c: Likewise.
	* remote-mips.c: Likewise.
	* remote.c: Likewise.
	* rs6000-aix-tdep.c: Likewise.
	* rs6000-nat.c: Likewise.
	* skip.c: Likewise.
	* solib-darwin.c: Likewise.
	* solib-dsbt.c: Likewise.
	* solib-frv.c: Likewise.
	* solib-ia64-hpux.c: Likewise.
	* solib-spu.c: Likewise.
	* solib-svr4.c: Likewise.
	* solib.c: Likewise.
	* spu-tdep.c: Likewise.
	* stack.c: Likewise.
	* stap-probe.c: Likewise.
	* symfile-mem.c: Likewise.
	* symmisc.c: Likewise.
	* target.c: Likewise.
	* thread.c: Likewise.
	* top.c: Likewise.
	* tracepoint.c: Likewise.
	* tui/tui-interp.c: Likewise.
	* typeprint.c: Likewise.
	* utils.c: Likewise.
	* valarith.c: Likewise.
	* valops.c: Likewise.
	* valprint.c: Likewise.
	* value.c: Likewise.
	* varobj.c: Likewise.
	* windows-nat.c: Likewise.
	* xml-support.c: Likewise.
2014-10-08 09:33:22 +01:00
Gary Benson 6d3d12ebef Include string.h in common-defs.h
This commit includes string.h in common-defs.h and removes all other
inclusions.

gdb/
2014-08-07  Gary Benson  <gbenson@redhat.com>

	* common/common-defs.h: Include string.h.
	* aarch64-tdep.c: Do not include string.h.
	* ada-exp.y: Likewise.
	* ada-lang.c: Likewise.
	* ada-lex.l: Likewise.
	* ada-typeprint.c: Likewise.
	* ada-valprint.c: Likewise.
	* aix-thread.c: Likewise.
	* alpha-linux-tdep.c: Likewise.
	* alpha-mdebug-tdep.c: Likewise.
	* alpha-nat.c: Likewise.
	* alpha-osf1-tdep.c: Likewise.
	* alpha-tdep.c: Likewise.
	* alphanbsd-tdep.c: Likewise.
	* amd64-dicos-tdep.c: Likewise.
	* amd64-linux-tdep.c: Likewise.
	* amd64-nat.c: Likewise.
	* amd64-sol2-tdep.c: Likewise.
	* amd64fbsd-tdep.c: Likewise.
	* amd64obsd-tdep.c: Likewise.
	* arch-utils.c: Likewise.
	* arm-linux-nat.c: Likewise.
	* arm-linux-tdep.c: Likewise.
	* arm-tdep.c: Likewise.
	* arm-wince-tdep.c: Likewise.
	* armbsd-tdep.c: Likewise.
	* armnbsd-nat.c: Likewise.
	* armnbsd-tdep.c: Likewise.
	* armobsd-tdep.c: Likewise.
	* avr-tdep.c: Likewise.
	* ax-gdb.c: Likewise.
	* ax-general.c: Likewise.
	* bcache.c: Likewise.
	* bfin-tdep.c: Likewise.
	* breakpoint.c: Likewise.
	* build-id.c: Likewise.
	* buildsym.c: Likewise.
	* c-exp.y: Likewise.
	* c-lang.c: Likewise.
	* c-typeprint.c: Likewise.
	* c-valprint.c: Likewise.
	* charset.c: Likewise.
	* cli-out.c: Likewise.
	* cli/cli-cmds.c: Likewise.
	* cli/cli-decode.c: Likewise.
	* cli/cli-dump.c: Likewise.
	* cli/cli-interp.c: Likewise.
	* cli/cli-logging.c: Likewise.
	* cli/cli-script.c: Likewise.
	* cli/cli-setshow.c: Likewise.
	* cli/cli-utils.c: Likewise.
	* coffread.c: Likewise.
	* common/agent.c: Likewise.
	* common/buffer.c: Likewise.
	* common/buffer.h: Likewise.
	* common/common-utils.c: Likewise.
	* common/filestuff.c: Likewise.
	* common/filestuff.c: Likewise.
	* common/format.c: Likewise.
	* common/print-utils.c: Likewise.
	* common/rsp-low.c: Likewise.
	* common/signals.c: Likewise.
	* common/vec.h: Likewise.
	* common/xml-utils.c: Likewise.
	* core-regset.c: Likewise.
	* corefile.c: Likewise.
	* corelow.c: Likewise.
	* cp-abi.c: Likewise.
	* cp-name-parser.y: Likewise.
	* cp-support.c: Likewise.
	* cp-valprint.c: Likewise.
	* cris-tdep.c: Likewise.
	* d-exp.y: Likewise.
	* darwin-nat.c: Likewise.
	* dbxread.c: Likewise.
	* dcache.c: Likewise.
	* demangle.c: Likewise.
	* dicos-tdep.c: Likewise.
	* disasm.c: Likewise.
	* doublest.c: Likewise.
	* dsrec.c: Likewise.
	* dummy-frame.c: Likewise.
	* dwarf2-frame.c: Likewise.
	* dwarf2loc.c: Likewise.
	* dwarf2read.c: Likewise.
	* elfread.c: Likewise.
	* environ.c: Likewise.
	* eval.c: Likewise.
	* event-loop.c: Likewise.
	* exceptions.c: Likewise.
	* exec.c: Likewise.
	* expprint.c: Likewise.
	* f-exp.y: Likewise.
	* f-lang.c: Likewise.
	* f-typeprint.c: Likewise.
	* f-valprint.c: Likewise.
	* fbsd-nat.c: Likewise.
	* findcmd.c: Likewise.
	* findvar.c: Likewise.
	* fork-child.c: Likewise.
	* frame.c: Likewise.
	* frv-linux-tdep.c: Likewise.
	* frv-tdep.c: Likewise.
	* gdb.c: Likewise.
	* gdb_bfd.c: Likewise.
	* gdbarch.c: Likewise.
	* gdbarch.sh: Likewise.
	* gdbtypes.c: Likewise.
	* gnu-nat.c: Likewise.
	* gnu-v2-abi.c: Likewise.
	* gnu-v3-abi.c: Likewise.
	* go-exp.y: Likewise.
	* go-lang.c: Likewise.
	* go32-nat.c: Likewise.
	* guile/guile.c: Likewise.
	* guile/scm-auto-load.c: Likewise.
	* hppa-hpux-tdep.c: Likewise.
	* hppa-linux-nat.c: Likewise.
	* hppanbsd-tdep.c: Likewise.
	* hppaobsd-tdep.c: Likewise.
	* i386-cygwin-tdep.c: Likewise.
	* i386-dicos-tdep.c: Likewise.
	* i386-linux-tdep.c: Likewise.
	* i386-nto-tdep.c: Likewise.
	* i386-sol2-tdep.c: Likewise.
	* i386-tdep.c: Likewise.
	* i386bsd-tdep.c: Likewise.
	* i386gnu-nat.c: Likewise.
	* i386nbsd-tdep.c: Likewise.
	* i386obsd-tdep.c: Likewise.
	* i387-tdep.c: Likewise.
	* ia64-libunwind-tdep.c: Likewise.
	* ia64-linux-nat.c: Likewise.
	* inf-child.c: Likewise.
	* inf-ptrace.c: Likewise.
	* inf-ttrace.c: Likewise.
	* infcall.c: Likewise.
	* infcmd.c: Likewise.
	* inflow.c: Likewise.
	* infrun.c: Likewise.
	* interps.c: Likewise.
	* iq2000-tdep.c: Likewise.
	* irix5-nat.c: Likewise.
	* jv-exp.y: Likewise.
	* jv-lang.c: Likewise.
	* jv-typeprint.c: Likewise.
	* jv-valprint.c: Likewise.
	* language.c: Likewise.
	* linux-fork.c: Likewise.
	* linux-nat.c: Likewise.
	* lm32-tdep.c: Likewise.
	* m2-exp.y: Likewise.
	* m2-typeprint.c: Likewise.
	* m32c-tdep.c: Likewise.
	* m32r-linux-nat.c: Likewise.
	* m32r-linux-tdep.c: Likewise.
	* m32r-rom.c: Likewise.
	* m32r-tdep.c: Likewise.
	* m68hc11-tdep.c: Likewise.
	* m68k-tdep.c: Likewise.
	* m68kbsd-tdep.c: Likewise.
	* m68klinux-nat.c: Likewise.
	* m68klinux-tdep.c: Likewise.
	* m88k-tdep.c: Likewise.
	* machoread.c: Likewise.
	* macrocmd.c: Likewise.
	* main.c: Likewise.
	* mdebugread.c: Likewise.
	* mem-break.c: Likewise.
	* memattr.c: Likewise.
	* memory-map.c: Likewise.
	* mep-tdep.c: Likewise.
	* mi/mi-cmd-break.c: Likewise.
	* mi/mi-cmd-disas.c: Likewise.
	* mi/mi-cmd-env.c: Likewise.
	* mi/mi-cmd-stack.c: Likewise.
	* mi/mi-cmd-var.c: Likewise.
	* mi/mi-cmds.c: Likewise.
	* mi/mi-console.c: Likewise.
	* mi/mi-getopt.c: Likewise.
	* mi/mi-interp.c: Likewise.
	* mi/mi-main.c: Likewise.
	* mi/mi-parse.c: Likewise.
	* microblaze-rom.c: Likewise.
	* microblaze-tdep.c: Likewise.
	* mingw-hdep.c: Likewise.
	* minidebug.c: Likewise.
	* minsyms.c: Likewise.
	* mips-irix-tdep.c: Likewise.
	* mips-linux-tdep.c: Likewise.
	* mips-tdep.c: Likewise.
	* mips64obsd-tdep.c: Likewise.
	* mipsnbsd-tdep.c: Likewise.
	* mipsread.c: Likewise.
	* mn10300-linux-tdep.c: Likewise.
	* mn10300-tdep.c: Likewise.
	* monitor.c: Likewise.
	* moxie-tdep.c: Likewise.
	* mt-tdep.c: Likewise.
	* nat/linux-btrace.c: Likewise.
	* nat/linux-osdata.c: Likewise.
	* nat/linux-procfs.c: Likewise.
	* nat/linux-ptrace.c: Likewise.
	* nat/linux-waitpid.c: Likewise.
	* nbsd-tdep.c: Likewise.
	* nios2-linux-tdep.c: Likewise.
	* nto-procfs.c: Likewise.
	* nto-tdep.c: Likewise.
	* objc-lang.c: Likewise.
	* objfiles.c: Likewise.
	* opencl-lang.c: Likewise.
	* osabi.c: Likewise.
	* osdata.c: Likewise.
	* p-exp.y: Likewise.
	* p-lang.c: Likewise.
	* p-typeprint.c: Likewise.
	* parse.c: Likewise.
	* posix-hdep.c: Likewise.
	* ppc-linux-nat.c: Likewise.
	* ppc-sysv-tdep.c: Likewise.
	* ppcfbsd-tdep.c: Likewise.
	* ppcnbsd-tdep.c: Likewise.
	* ppcobsd-tdep.c: Likewise.
	* printcmd.c: Likewise.
	* procfs.c: Likewise.
	* prologue-value.c: Likewise.
	* python/py-auto-load.c: Likewise.
	* python/py-gdb-readline.c: Likewise.
	* ravenscar-thread.c: Likewise.
	* regcache.c: Likewise.
	* registry.c: Likewise.
	* remote-fileio.c: Likewise.
	* remote-m32r-sdi.c: Likewise.
	* remote-mips.c: Likewise.
	* remote-notif.c: Likewise.
	* remote-sim.c: Likewise.
	* remote.c: Likewise.
	* reverse.c: Likewise.
	* rs6000-aix-tdep.c: Likewise.
	* ser-base.c: Likewise.
	* ser-go32.c: Likewise.
	* ser-mingw.c: Likewise.
	* ser-pipe.c: Likewise.
	* ser-tcp.c: Likewise.
	* ser-unix.c: Likewise.
	* serial.c: Likewise.
	* sh-tdep.c: Likewise.
	* sh64-tdep.c: Likewise.
	* shnbsd-tdep.c: Likewise.
	* skip.c: Likewise.
	* sol-thread.c: Likewise.
	* solib-dsbt.c: Likewise.
	* solib-frv.c: Likewise.
	* solib-osf.c: Likewise.
	* solib-som.c: Likewise.
	* solib-spu.c: Likewise.
	* solib-target.c: Likewise.
	* solib.c: Likewise.
	* somread.c: Likewise.
	* source.c: Likewise.
	* sparc-nat.c: Likewise.
	* sparc-sol2-tdep.c: Likewise.
	* sparc-tdep.c: Likewise.
	* sparc64-tdep.c: Likewise.
	* sparc64fbsd-tdep.c: Likewise.
	* sparc64nbsd-tdep.c: Likewise.
	* sparcnbsd-tdep.c: Likewise.
	* spu-linux-nat.c: Likewise.
	* spu-multiarch.c: Likewise.
	* spu-tdep.c: Likewise.
	* stabsread.c: Likewise.
	* stack.c: Likewise.
	* std-regs.c: Likewise.
	* symfile.c: Likewise.
	* symmisc.c: Likewise.
	* symtab.c: Likewise.
	* target.c: Likewise.
	* thread.c: Likewise.
	* tilegx-linux-nat.c: Likewise.
	* tilegx-tdep.c: Likewise.
	* top.c: Likewise.
	* tracepoint.c: Likewise.
	* tui/tui-command.c: Likewise.
	* tui/tui-data.c: Likewise.
	* tui/tui-disasm.c: Likewise.
	* tui/tui-file.c: Likewise.
	* tui/tui-layout.c: Likewise.
	* tui/tui-out.c: Likewise.
	* tui/tui-regs.c: Likewise.
	* tui/tui-source.c: Likewise.
	* tui/tui-stack.c: Likewise.
	* tui/tui-win.c: Likewise.
	* tui/tui-windata.c: Likewise.
	* tui/tui-winsource.c: Likewise.
	* typeprint.c: Likewise.
	* ui-file.c: Likewise.
	* ui-out.c: Likewise.
	* user-regs.c: Likewise.
	* utils.c: Likewise.
	* v850-tdep.c: Likewise.
	* valarith.c: Likewise.
	* valops.c: Likewise.
	* valprint.c: Likewise.
	* value.c: Likewise.
	* varobj.c: Likewise.
	* vax-tdep.c: Likewise.
	* vaxnbsd-tdep.c: Likewise.
	* vaxobsd-tdep.c: Likewise.
	* windows-nat.c: Likewise.
	* xcoffread.c: Likewise.
	* xml-support.c: Likewise.
	* xstormy16-tdep.c: Likewise.
	* xtensa-linux-nat.c: Likewise.

gdb/gdbserver/
2014-08-07  Gary Benson  <gbenson@redhat.com>

	* server.h: Do not include string.h.
	* event-loop.c: Likewise.
	* linux-low.c: Likewise.
	* regcache.c: Likewise.
	* remote-utils.c: Likewise.
	* spu-low.c: Likewise.
	* utils.c: Likewise.
2014-08-07 09:06:47 +01:00
Gary Benson dccbb60975 Include gdb_assert.h in common-defs.h
This commit includes gdb_assert.h in common-defs.h and removes all
other inclusions.

gdb/
2014-08-07  Gary Benson  <gbenson@redhat.com>

	* common/common-defs.h: Include gdb_assert.h.
	* aarch64-tdep.c: Do not include gdb_assert.h.
	* addrmap.c: Likewise.
	* aix-thread.c: Likewise.
	* alpha-linux-tdep.c: Likewise.
	* alpha-mdebug-tdep.c: Likewise.
	* alphanbsd-tdep.c: Likewise.
	* amd64-nat.c: Likewise.
	* amd64-tdep.c: Likewise.
	* amd64bsd-nat.c: Likewise.
	* amd64fbsd-nat.c: Likewise.
	* amd64fbsd-tdep.c: Likewise.
	* amd64nbsd-nat.c: Likewise.
	* amd64nbsd-tdep.c: Likewise.
	* amd64obsd-nat.c: Likewise.
	* amd64obsd-tdep.c: Likewise.
	* arch-utils.c: Likewise.
	* arm-tdep.c: Likewise.
	* armbsd-tdep.c: Likewise.
	* auxv.c: Likewise.
	* bcache.c: Likewise.
	* bfin-tdep.c: Likewise.
	* blockframe.c: Likewise.
	* breakpoint.c: Likewise.
	* bsd-kvm.c: Likewise.
	* bsd-uthread.c: Likewise.
	* buildsym.c: Likewise.
	* c-exp.y: Likewise.
	* c-lang.c: Likewise.
	* charset.c: Likewise.
	* cleanups.c: Likewise.
	* cli-out.c: Likewise.
	* cli/cli-decode.c: Likewise.
	* cli/cli-dump.c: Likewise.
	* cli/cli-logging.c: Likewise.
	* cli/cli-script.c: Likewise.
	* cli/cli-utils.c: Likewise.
	* coffread.c: Likewise.
	* common/common-utils.c: Likewise.
	* common/queue.h: Likewise.
	* common/signals.c: Likewise.
	* common/vec.h: Likewise.
	* complaints.c: Likewise.
	* completer.c: Likewise.
	* corelow.c: Likewise.
	* cp-abi.c: Likewise.
	* cp-name-parser.y: Likewise.
	* cp-namespace.c: Likewise.
	* cp-support.c: Likewise.
	* cris-tdep.c: Likewise.
	* dbxread.c: Likewise.
	* dictionary.c: Likewise.
	* doublest.c: Likewise.
	* dsrec.c: Likewise.
	* dummy-frame.c: Likewise.
	* dwarf2-frame-tailcall.c: Likewise.
	* dwarf2-frame.c: Likewise.
	* dwarf2expr.c: Likewise.
	* dwarf2loc.c: Likewise.
	* dwarf2read.c: Likewise.
	* eval.c: Likewise.
	* event-loop.c: Likewise.
	* exceptions.c: Likewise.
	* expprint.c: Likewise.
	* f-valprint.c: Likewise.
	* fbsd-nat.c: Likewise.
	* findvar.c: Likewise.
	* frame-unwind.c: Likewise.
	* frame.c: Likewise.
	* frv-tdep.c: Likewise.
	* gcore.c: Likewise.
	* gdb-dlfcn.c: Likewise.
	* gdb_bfd.c: Likewise.
	* gdbarch.c: Likewise.
	* gdbarch.sh: Likewise.
	* gdbtypes.c: Likewise.
	* gnu-nat.c: Likewise.
	* gnu-v3-abi.c: Likewise.
	* go-lang.c: Likewise.
	* guile/scm-exception.c: Likewise.
	* guile/scm-gsmob.c: Likewise.
	* guile/scm-lazy-string.c: Likewise.
	* guile/scm-math.c: Likewise.
	* guile/scm-pretty-print.c: Likewise.
	* guile/scm-safe-call.c: Likewise.
	* guile/scm-utils.c: Likewise.
	* guile/scm-value.c: Likewise.
	* h8300-tdep.c: Likewise.
	* hppa-hpux-nat.c: Likewise.
	* hppa-tdep.c: Likewise.
	* hppanbsd-tdep.c: Likewise.
	* hppaobsd-tdep.c: Likewise.
	* i386-darwin-nat.c: Likewise.
	* i386-darwin-tdep.c: Likewise.
	* i386-nto-tdep.c: Likewise.
	* i386-tdep.c: Likewise.
	* i386bsd-nat.c: Likewise.
	* i386fbsd-tdep.c: Likewise.
	* i386gnu-nat.c: Likewise.
	* i386nbsd-tdep.c: Likewise.
	* i386obsd-tdep.c: Likewise.
	* i387-tdep.c: Likewise.
	* ia64-libunwind-tdep.c: Likewise.
	* ia64-tdep.c: Likewise.
	* inf-ptrace.c: Likewise.
	* inf-ttrace.c: Likewise.
	* infcall.c: Likewise.
	* infcmd.c: Likewise.
	* infrun.c: Likewise.
	* inline-frame.c: Likewise.
	* interps.c: Likewise.
	* jv-lang.c: Likewise.
	* jv-typeprint.c: Likewise.
	* linux-fork.c: Likewise.
	* linux-nat.c: Likewise.
	* linux-thread-db.c: Likewise.
	* m32c-tdep.c: Likewise.
	* m32r-linux-nat.c: Likewise.
	* m32r-tdep.c: Likewise.
	* m68k-tdep.c: Likewise.
	* m68kbsd-nat.c: Likewise.
	* m68kbsd-tdep.c: Likewise.
	* m88k-tdep.c: Likewise.
	* machoread.c: Likewise.
	* macroexp.c: Likewise.
	* macrotab.c: Likewise.
	* maint.c: Likewise.
	* mdebugread.c: Likewise.
	* memory-map.c: Likewise.
	* mep-tdep.c: Likewise.
	* mi/mi-common.c: Likewise.
	* microblaze-tdep.c: Likewise.
	* mingw-hdep.c: Likewise.
	* mips-linux-nat.c: Likewise.
	* mips-linux-tdep.c: Likewise.
	* mips-tdep.c: Likewise.
	* mips64obsd-tdep.c: Likewise.
	* mipsnbsd-tdep.c: Likewise.
	* mn10300-linux-tdep.c: Likewise.
	* mn10300-tdep.c: Likewise.
	* moxie-tdep.c: Likewise.
	* mt-tdep.c: Likewise.
	* nat/linux-btrace.c: Likewise.
	* nat/linux-osdata.c: Likewise.
	* nat/linux-ptrace.c: Likewise.
	* nat/mips-linux-watch.c: Likewise.
	* nios2-linux-tdep.c: Likewise.
	* nios2-tdep.c: Likewise.
	* objc-lang.c: Likewise.
	* objfiles.c: Likewise.
	* obsd-nat.c: Likewise.
	* opencl-lang.c: Likewise.
	* osabi.c: Likewise.
	* parse.c: Likewise.
	* ppc-linux-nat.c: Likewise.
	* ppc-sysv-tdep.c: Likewise.
	* ppcfbsd-nat.c: Likewise.
	* ppcfbsd-tdep.c: Likewise.
	* ppcnbsd-nat.c: Likewise.
	* ppcnbsd-tdep.c: Likewise.
	* ppcobsd-nat.c: Likewise.
	* ppcobsd-tdep.c: Likewise.
	* printcmd.c: Likewise.
	* procfs.c: Likewise.
	* prologue-value.c: Likewise.
	* psymtab.c: Likewise.
	* python/py-lazy-string.c: Likewise.
	* python/py-value.c: Likewise.
	* regcache.c: Likewise.
	* reggroups.c: Likewise.
	* registry.c: Likewise.
	* remote-sim.c: Likewise.
	* remote.c: Likewise.
	* rs6000-aix-tdep.c: Likewise.
	* rs6000-tdep.c: Likewise.
	* s390-linux-tdep.c: Likewise.
	* score-tdep.c: Likewise.
	* ser-base.c: Likewise.
	* ser-mingw.c: Likewise.
	* sh-tdep.c: Likewise.
	* sh64-tdep.c: Likewise.
	* solib-darwin.c: Likewise.
	* solib-spu.c: Likewise.
	* solib-svr4.c: Likewise.
	* source.c: Likewise.
	* sparc-nat.c: Likewise.
	* sparc-sol2-tdep.c: Likewise.
	* sparc-tdep.c: Likewise.
	* sparc64-sol2-tdep.c: Likewise.
	* sparc64-tdep.c: Likewise.
	* sparc64fbsd-tdep.c: Likewise.
	* sparc64nbsd-tdep.c: Likewise.
	* sparc64obsd-tdep.c: Likewise.
	* sparcnbsd-tdep.c: Likewise.
	* sparcobsd-tdep.c: Likewise.
	* spu-multiarch.c: Likewise.
	* spu-tdep.c: Likewise.
	* stabsread.c: Likewise.
	* stack.c: Likewise.
	* symfile.c: Likewise.
	* symtab.c: Likewise.
	* target-descriptions.c: Likewise.
	* target-memory.c: Likewise.
	* target.c: Likewise.
	* tic6x-linux-tdep.c: Likewise.
	* tic6x-tdep.c: Likewise.
	* tilegx-linux-nat.c: Likewise.
	* tilegx-tdep.c: Likewise.
	* top.c: Likewise.
	* tramp-frame.c: Likewise.
	* tui/tui-out.c: Likewise.
	* tui/tui-winsource.c: Likewise.
	* ui-out.c: Likewise.
	* user-regs.c: Likewise.
	* utils.c: Likewise.
	* v850-tdep.c: Likewise.
	* valops.c: Likewise.
	* value.c: Likewise.
	* varobj.c: Likewise.
	* vax-nat.c: Likewise.
	* xml-syscall.c: Likewise.
	* xml-tdesc.c: Likewise.
	* xstormy16-tdep.c: Likewise.
	* xtensa-linux-nat.c: Likewise.
	* xtensa-tdep.c: Likewise.

gdb/gdbserver/
2014-08-07  Gary Benson  <gbenson@redhat.com>

	* server.h: Do not include gdb_assert.h.
2014-08-07 09:06:45 +01:00
Yao Qi b67a2c6fd4 Associate dummy_frame with ptid
This patch is to add ptid into dummy_frame and extend frame_id to
dummy_frame_id (which has a ptid field).  With this change, GDB uses
dummy_frame_id (thread ptid and frame_id) to find the dummy frames.

Currently, dummy frames are looked up by frame_id, which isn't
accurate in non-stop or multi-process mode.  The test case
gdb.multi/dummy-frame-restore.exp shows the problem and this patch can
fix it.

Test dummy-frame-restore.exp makes two inferiors stop at
different functions, say, inferior 1 stops at f1 while inferior 2
stops at f2.  Set a breakpoint to a function, do the inferior call
in two inferiors, and GDB has two dummy frames of the same frame_id.
When the inferior call is finished, GDB will look up a dummy frame
from its stack/list and restore the inferior's regcache.  Two
inferiors are finished in different orders, the inferiors' states are
restored differently, which is wrong.  Running dummy-frame-restore.exp
under un-patched GDB, we'll get two fails:

FAIL: gdb.multi/dummy-frame-restore.exp: inf 2 first: after infcall: bt in inferior 2
FAIL: gdb.multi/dummy-frame-restore.exp: inf 2 first: after infcall: bt in inferior 1

With this patch applied, GDB will choose the correct dummy_frame to
restore for a given inferior, because ptid is considered when looking up
dummy frames.  Two fails above are fixed.

Regression tested on x86_64-linux, both native and gdbserver.

gdb:

2014-06-27  Yao Qi  <yao@codesourcery.com>

	* breakpoint.c (check_longjmp_breakpoint_for_call_dummy):
	Change parameter type to 'struct thread_info *'.  Caller
	updated.
	* breakpoint.h (check_longjmp_breakpoint_for_call_dummy):
	Update declaration.
	* dummy-frame.c (struct dummy_frame_id): New.
	(dummy_frame_id_eq): New function.
	(struct dummy_frame) <id>: Change its type to 'struct
	dummy_frame_id'.
	(dummy_frame_push): Add parameter ptid and save it in
	dummy_frame_id.
	(pop_dummy_frame_bpt): Use ptid of dummy_frame instead of
	inferior_ptid.
	(pop_dummy_frame): Assert that the ptid of dummy_frame equals
	to inferior_ptid.
	(lookup_dummy_frame): Change parameter type to 'struct
	dummy_frame_id *'.  Callers updated.  Call dummy_frame_id_eq
	instead of frame_id_eq.
	(dummy_frame_pop): Add parameter ptid.  Callers updated.
	Update comments.  Compose dummy_frame_id and pass it to
	lookup_dummy_frame.
	(dummy_frame_discard): Add parameter ptid.
	(dummy_frame_sniffer): Compose dummy_frame_id and call
	dummy_frame_id_eq instead of frame_id_eq.
	(fprint_dummy_frames): Print ptid.
	* dummy-frame.h: Remove comments.
	(dummy_frame_push): Add ptid in declaration.
	(dummy_frame_pop, dummy_frame_discard): Likewise.

gdb/testsuite:

2014-06-27  Yao Qi  <yao@codesourcery.com>

	* gdb.multi/dummy-frame-restore.exp: New.
	* gdb.multi/dummy-frame-restore.c: New.

gdb/doc:

2014-06-27  Yao Qi  <yao@codesourcery.com>

	* gdb.texinfo (Maintenance Commands): Update the output of
	'maint print dummy-frames' command.
2014-06-27 20:06:56 +08:00
Tom Tromey 3977b71f1d constify struct block in some places
This makes some spots in gdb, particularly general_symbol_info, use a
"const struct block", then fixes the fallout.

The justification is that, ordinarily, blocks ought to be readonly.
Note though that we can't add "const" in the blockvector due to block
relocation.  This can be done once blocks are made independent of the
program space.

2014-06-18  Tom Tromey  <tromey@redhat.com>

	* varobj.c (varobj_create): Update.
	* valops.c (value_of_this): Update.
	* tracepoint.c (add_local_symbols, scope_info): Update.
	* symtab.h (struct general_symbol_info) <block>: Now const.
	* symtab.c (skip_prologue_sal)
	(default_make_symbol_completion_list_break_on)
	(skip_prologue_using_sal): Update.
	* stack.h (iterate_over_block_locals)
	(iterate_over_block_local_vars): Update.
	* stack.c (print_frame_args): Update.
	(iterate_over_block_locals, iterate_over_block_local_vars): Make
	parameter const.
	(get_selected_block): Make return type const.
	* python/py-frame.c (frapy_block): Update.
	* python/py-block.c (gdbpy_block_for_pc): Update.
	* p-exp.y (%union) <bval>: Now const.
	* mi/mi-cmd-stack.c (list_args_or_locals): Update.
	* mdebugread.c (mylookup_symbol, parse_procedure): Update.
	* m2-exp.y (%union) <bval>: Now const.
	* linespec.c (get_current_search_block): Make return type const.
	(create_sals_line_offset, find_label_symbols): Update.
	* inline-frame.c (inline_frame_sniffer, skip_inline_frames):
	Update.
	(block_starting_point_at): Make "block" const.
	* infrun.c (insert_exception_resume_breakpoint): Make "b" const.
	(check_exception_resume): Update.
	* guile/scm-frame.c (gdbscm_frame_block): Update.
	* guile/scm-block.c (gdbscm_lookup_block): Update.
	* frame.h (get_frame_block): Update.
	(get_selected_block): Make return type const.
	* frame.c (frame_id_inner): Update.
	* f-valprint.c (info_common_command_for_block)
	(info_common_command): Update.
	* dwarf2loc.c (dwarf2_find_location_expression)
	(dwarf_expr_frame_base, dwarf2_compile_expr_to_ax)
	(locexpr_describe_location_piece): Update.
	* c-exp.y (%union) <bval>: Now const.
	* breakpoint.c (resolve_sal_pc): Update.
	* blockframe.c (get_frame_block):Make return type const.
	(get_pc_function_start, get_frame_function, find_pc_sect_function)
	(block_innermost_frame): Update.
	* block.h (blockvector_for_pc, blockvector_for_pc_sect)
	(block_for_pc, block_for_pc_sect): Update.
	* block.c (blockvector_for_pc_sect, blockvector_for_pc): Make
	'pblock' const.
	(block_for_pc_sect, block_for_pc): Make return type const.
	* ax-gdb.c (gen_expr): Update.
	* alpha-mdebug-tdep.c (find_proc_desc): Update.
	* ada-lang.c (ada_read_renaming_var_value): Make 'block' const.
	(ada_make_symbol_completion_list, ada_add_exceptions_from_frame)
	(ada_read_var_value): Update.
	* ada-exp.y (struct name_info) <block>: Now const.
	(%union): Likewise.
	(block_lookup): Constify.
2014-06-18 08:16:52 -06:00
Tom Tromey 635c7e8a05 make calls to help_list use enumerator
Currently there are many calls to help_list that pass the constant -1
as the "class" value.  However, the parameter is declared as being of
type enum command_class, and uses of the constant violate this
abstraction.

This patch fixes the error everywhere it occurs in the gdb sources.

Tested by rebuilding.

2014-06-13  Tom Tromey  <tromey@redhat.com>

	* cp-support.c (maint_cplus_command): Pass all_commands, not -1,
	to help_list.
	* guile/guile.c (info_guile_command): Pass all_commands, not -1,
	to help_list.
	* tui/tui-win.c (tui_command): Pass all_commands, not -1, to
	help_list.
	* tui/tui-regs.c (tui_reg_command): Pass all_commands, not -1, to
	help_list.Pass all_commands, not -1, to help_list.
	* cli/cli-dump.c (dump_command, append_command)
	(srec_dump_command, ihex_dump_command, tekhex_dump_command)
	(binary_dump_command, binary_append_command): Pass all_commands,
	not -1, to help_list.
	* cli/cli-cmds.c (info_command, set_debug): Pass all_commands, not
	-1, to help_list.
	* valprint.c (set_print, set_print_raw): Pass all_commands, not
	-1, to help_list.
	* typeprint.c (set_print_type): Pass all_commands, not -1, to
	help_list.
	* top.c (set_history): Pass all_commands, not -1, to help_list.
	* target-descriptions.c (set_tdesc_cmd, unset_tdesc_cmd): Pass
	all_commands, not -1, to help_list.
	* symfile.c (overlay_command): Pass all_commands, not -1, to
	help_list.
	* spu-tdep.c (info_spu_command): Pass all_commands, not -1, to
	help_list.
	* serial.c (serial_set_cmd): Pass all_commands, not -1, to
	help_list.
	* ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Pass all_commands, not
	-1, to help_list.
	* remote.c (remote_command, set_remote_cmd): Pass all_commands,
	not -1, to help_list.
	* ravenscar-thread.c (set_ravenscar_command): Pass all_commands,
	not -1, to help_list.
	* maint.c (maintenance_command, maintenance_info_command)
	(maintenance_print_command, maintenance_set_cmd): Pass
	all_commands, not -1, to help_list.
	* macrocmd.c (macro_command): Pass all_commands, not -1, to
	help_list.
	* language.c (set_check): Pass all_commands, not -1, to help_list.
	* infcmd.c (unset_command): Pass all_commands, not -1, to
	help_list.
	* frame.c (set_backtrace_cmd): Pass all_commands, not -1, to
	help_list.
	* dwarf2read.c (set_dwarf2_cmd): Pass all_commands, not -1, to
	help_list.
	* dcache.c (set_dcache_command): Pass all_commands, not -1, to
	help_list.
	* breakpoint.c (save_command): Pass all_commands, not -1, to
	help_list.
	* ada-lang.c (maint_set_ada_cmd, set_ada_command): Pass
	all_commands, not -1, to help_list.
2014-06-13 09:29:19 -06:00
Andrew Burgess 53e8a631a0 Add a TRY_CATCH to get_prev_frame_always to better manage errors during unwind.
https://sourceware.org/ml/gdb-patches/2014-05/msg00737.html

Currently a MEMORY_ERROR raised during unwinding a frame will cause the
unwind to stop with an error message, for example:

  (gdb) bt
  #0  breakpt () at amd64-invalid-stack-middle.c:27
  #1  0x00000000004008f0 in func5 () at amd64-invalid-stack-middle.c:32
  #2  0x0000000000400900 in func4 () at amd64-invalid-stack-middle.c:38
  #3  0x0000000000400910 in func3 () at amd64-invalid-stack-middle.c:44
  #4  0x0000000000400928 in func2 () at amd64-invalid-stack-middle.c:50
  Cannot access memory at address 0x2aaaaaab0000

However, frame #4 is marked as being the end of the stack unwind, so a
subsequent request for the backtrace looses the error message, such as:

  (gdb) bt
  #0  breakpt () at amd64-invalid-stack-middle.c:27
  #1  0x00000000004008f0 in func5 () at amd64-invalid-stack-middle.c:32
  #2  0x0000000000400900 in func4 () at amd64-invalid-stack-middle.c:38
  #3  0x0000000000400910 in func3 () at amd64-invalid-stack-middle.c:44
  #4  0x0000000000400928 in func2 () at amd64-invalid-stack-middle.c:50

When fetching the backtrace, or requesting the stack depth using the MI
interface the situation is even worse, the first time a request is made
we encounter the memory error and so the MI returns an error instead of
the correct result, for example:

  (gdb) -stack-info-depth
  ^error,msg="Cannot access memory at address 0x2aaaaaab0000"

Or,

  (gdb) -stack-list-frames
  ^error,msg="Cannot access memory at address 0x2aaaaaab0000"

However, once one of these commands has been used gdb has, internally,
walked the stack and figured that out that frame #4 is the bottom of the
stack, so the second time an MI command is tried you'll get the "expected"
result:

  (gdb) -stack-info-depth
  ^done,depth="5"

Or,

  (gdb) -stack-list-frames
  ^done,stack=[frame={level="0", .. snip lots .. }]

After this patch the MEMORY_ERROR encountered during the frame unwind is
attached to frame #4 as the stop reason, and is displayed in the CLI each
time the backtrace is requested.  In the MI, catching the error means that
the "expected" result is returned the first time the MI command is issued.
So, from the CLI the results of the backtrace will be:

  (gdb) bt
  #0  breakpt () at amd64-invalid-stack-middle.c:27
  #1  0x00000000004008f0 in func5 () at amd64-invalid-stack-middle.c:32
  #2  0x0000000000400900 in func4 () at amd64-invalid-stack-middle.c:38
  #3  0x0000000000400910 in func3 () at amd64-invalid-stack-middle.c:44
  #4  0x0000000000400928 in func2 () at amd64-invalid-stack-middle.c:50
  Backtrace stopped: Cannot access memory at address 0x2aaaaaab0000

Each and every time that the backtrace is requested, while the MI output
will similarly be consistently:

  (gdb) -stack-info-depth
  ^done,depth="5"

Or,

  (gdb) -stack-list-frames
  ^done,stack=[frame={level="0", .. snip lots .. }]

gdb/ChangeLog:

	* frame.c (struct frame_info): Add stop_string field.
	(get_prev_frame_always_1): Renamed from get_prev_frame_always.
	(get_prev_frame_always): Old content moved into
	get_prev_frame_always_1.  Call get_prev_frame_always_1 inside
	TRY_CATCH, handle MEMORY_ERROR exceptions.
	(frame_stop_reason_string): New function definition.
	* frame.h (unwind_stop_reason_to_string): Extend comment to
	mention frame_stop_reason_string.
	(frame_stop_reason_string): New function declaration.
	* stack.c (frame_info): Switch to frame_stop_reason_string.
	(backtrace_command_1): Switch to frame_stop_reason_string.
	* unwind_stop_reason.def: Add UNWIND_MEMORY_ERROR.
	(LAST_ENTRY): Changed to UNWIND_MEMORY_ERROR.
	* guile/lib/gdb.scm: Add FRAME_UNWIND_MEMORY_ERROR to export list.

gdb/doc/ChangeLog:

	* guile.texi (Frames In Guile): Mention FRAME_UNWIND_MEMORY_ERROR.
	* python.texi (Frames In Python): Mention
	gdb.FRAME_UNWIND_MEMORY_ERROR.

gdb/testsuite/ChangeLog:

	* gdb.arch/amd64-invalid-stack-middle.exp: Update expected results.
	* gdb.arch/amd64-invalid-stack-top.exp: Likewise.
2014-05-30 22:44:36 +01:00
Andrew Burgess 70e38b8e98 Rename frame_stop_reason_string to unwind_stop_reason_to_string.
https://sourceware.org/ml/gdb-patches/2014-05/msg00721.html

This function is confusingly named, the "frame_" in the name implies it
somehow is frame dependent, when in reality the function just converts an
'enum unwind_stop_reason' value to a string.

gdb/ChangeLog:

	* frame.c (frame_stop_reason_string): Rename to ...
	(unwind_stop_reason_to_string): this.
	* frame.h (frame_stop_reason_string): Rename to ...
	(unwind_stop_reason_to_string): this.
	* stack.c (frame_info): Update call to frame_stop_reason_string.
	(backtrace_command_1): Likewise.
	* guile/scm-frame.c (gdbscm_unwind_stop_reason_string): Likewise.
	* python/py-frame.c (gdbpy_frame_stop_reason_string): Likewise.
2014-05-30 22:40:29 +01:00
Andrew Burgess 938f0e2f67 Remove previous frame if an error occurs when computing frame id during unwind.
https://sourceware.org/ml/gdb-patches/2014-05/msg00712.html

If an error is thrown during computing a frame id then the frame is left
in existence but without a valid frame id, this will trigger internal
errors if/when the frame is later visited (for example in a backtrace).

This patch catches errors raised while computing the frame id, and
arranges for the new frame, the one without a frame id, to be removed
from the linked list of frames.

gdb/ChangeLog:

	* frame.c (remove_prev_frame): New function.
	(get_prev_frame_if_no_cycle): Create / discard cleanup using
	remove_prev_frame.

gdb/testsuite/ChangeLog:

	* gdb.arch/amd64-invalid-stack-middle.S: New file.
	* gdb.arch/amd64-invalid-stack-middle.c: New file.
	* gdb.arch/amd64-invalid-stack-middle.exp: New file.
	* gdb.arch/amd64-invalid-stack-top.c: New file.
	* gdb.arch/amd64-invalid-stack-top.exp: New file.
2014-05-30 22:36:14 +01:00
Pedro Alves 51d481464e Fix PR backtrace/15558
This PR is about an assertion failure in GDB that can be triggered by
setting "backtrace limit" to a value that causes GDB to stop unwinding
after an inline frame.  In this case, an assertion in
inline_frame_this_id will trigger:

  /* We need a valid frame ID, so we need to be based on a valid
     frame.  (...).  */
  gdb_assert (frame_id_p (*this_id));

Looking at the function:

 static void
 inline_frame_this_id (struct frame_info *this_frame,
		       void **this_cache,
		       struct frame_id *this_id)
 {
   struct symbol *func;

   /* In order to have a stable frame ID for a given inline function,
      we must get the stack / special addresses from the underlying
      real frame's this_id method.  So we must call get_prev_frame.
      Because we are inlined into some function, there must be previous
      frames, so this is safe - as long as we're careful not to
      create any cycles.  */
   *this_id = get_frame_id (get_prev_frame (this_frame));

we see we're computing the frame id for the inline frame.  If this is
an inline frame, which is a virtual frame constructed based on debug
info, on top of a real stack frame, we should _always_ be able to find
where the frame was inlined into, as that ultimately just means
peeling off the virtual frames on top of the real stack frame.  If
there ultimately was no prev (real) stack frame, then we wouldn't have
been able to construct the inline frame either, by design.  That's
what the assertion catches.

So we have an inline frame, we should _always_ be able to compute its
ID, even if that means bypassing the user backtrace limits to get at
the real stack frame's info.  The problem is that inline_frame_id
calls get_prev_frame, and that takes user backtrace limits into
account.  Code that wants to bypass the limits calls get_prev_frame_1
instead.

Note how get_prev_frame_1 already skips all checks for inline frames:

   /* If we are unwinding from an inline frame, all of the below tests
      were already performed when we unwound from the next non-inline
      frame.  We must skip them, since we can not get THIS_FRAME's ID
      until we have unwound all the way down to the previous non-inline
      frame.  */
   if (get_frame_type (this_frame) == INLINE_FRAME)
     return get_prev_frame_if_no_cycle (this_frame);

And note how the related frame_unwind_caller_id function also uses
get_prev_frame_1:

 struct frame_id
 frame_unwind_caller_id (struct frame_info *next_frame)
 {
   struct frame_info *this_frame;

   /* Use get_prev_frame_1, and not get_prev_frame.  The latter will truncate
      the frame chain, leading to this function unintentionally
      returning a null_frame_id (e.g., when a caller requests the frame
      ID of "main()"s caller.  */

   next_frame = skip_artificial_frames (next_frame);
   this_frame = get_prev_frame_1 (next_frame);
   if (this_frame)
     return get_frame_id (skip_artificial_frames (this_frame));
   else
     return null_frame_id;
 }

get_prev_frame_1 is currently static in frame.c.  As a _1 suffix is
not a good name for an extern function, I've renamed it.

Tested on x86-64 Fedora 17.

gdb/
2014-04-18  Pedro alves  <palves@redhat.com>
	    Tom Tromey  <tromey@redhat.com>

	PR backtrace/15558
	* frame.c (get_prev_frame_1): Rename to ...
	(get_prev_frame_always): ... this, and make extern.  Adjust.
	(skip_artificial_frames): Use get_prev_frame_always.
	(frame_unwind_caller_id, frame_pop, get_prev_frame)
	(get_frame_unwind_stop_reason): Adjust to rename.
	* frame.h (get_prev_frame_always): Declare.
	* inline-frame.c: Include frame.h.
	(inline_frame_this_id): Use get_prev_frame_always.

gdb/testsuite/
2014-04-18  Tom Tromey  <palves@redhat.com>
	    Pedro alves  <tromey@redhat.com>

	PR backtrace/15558
	* gdb.opt/inline-bt.exp: Test backtracing from an inline function
	with a backtrace limit.
	* gdb.python/py-frame-inline.exp: Test running to an inline
	function with a backtrace limit, and printing the newest frame.
	* gdb.python/py-frame-inline.c (main): Call f.
2014-04-18 10:34:09 +01:00
Tom Tromey 77e371c079 start change to progspace independence
This patch starts changing minimal symbols to be independent of the
program space.

Specifically, it adds a new objfile parameter to MSYMBOL_VALUE_ADDRESS
and changes all the code to use it.  This is needed so we can change
gdb to apply the section offset when a minsym's address is computed,
as opposed to baking the offsets into the symbol itself.

A few spots still need the unrelocated address.  For these, we
introduce MSYMBOL_VALUE_RAW_ADDRESS.

As a convenience, we also add the new macro BMSYMBOL_VALUE_ADDRESS,
which computes the address of a bound minimal symbol.  This just does
the obvious thing with the fields.

Note that this change does not actually enable program space
independence.  That requires more changes to gdb.  However, to ensure
that these changes compile properly, this patch does add the needed
section lookup code to MSYMBOL_VALUE_ADDRESS -- it just ensures it has
no effect at runtime by multiplying the offset by 0.

2014-02-26  Tom Tromey  <tromey@redhat.com>

	* ada-lang.c (ada_main_name): Update.
	(ada_add_standard_exceptions): Update.
	* ada-tasks.c (ada_tasks_inferior_data_sniffer): Update.
	* aix-thread.c (pdc_symbol_addrs, pd_enable): Update.
	* arm-tdep.c (skip_prologue_function, arm_skip_stub): Update.
	* auxv.c (ld_so_xfer_auxv): Update.
	* avr-tdep.c (avr_scan_prologue): Update.
	* ax-gdb.c (gen_var_ref): Update.
	* blockframe.c (get_pc_function_start)
	(find_pc_partial_function_gnu_ifunc): Update.
	* breakpoint.c (create_overlay_event_breakpoint)
	(create_longjmp_master_breakpoint)
	(create_std_terminate_master_breakpoint)
	(create_exception_master_breakpoint): Update.
	* bsd-uthread.c (bsd_uthread_lookup_address): Update.
	* c-valprint.c (c_val_print): Update.
	* coff-pe-read.c (add_pe_forwarded_sym): Update.
	* common/agent.c (agent_look_up_symbols): Update.
	* dbxread.c (find_stab_function_addr, end_psymtab): Update.
	* dwarf2loc.c (call_site_to_target_addr): Update.
	* dwarf2read.c (dw2_find_pc_sect_symtab): Update.
	* elfread.c (elf_gnu_ifunc_record_cache)
	(elf_gnu_ifunc_resolve_by_got): Update.
	* findvar.c (default_read_var_value): Update.
	* frame.c (inside_main_func): Update.
	* frv-tdep.c (frv_frame_this_id): Update.
	* glibc-tdep.c (glibc_skip_solib_resolver): Update.
	* gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline):
	Update.
	* hppa-hpux-tdep.c (hppa64_hpux_search_dummy_call_sequence)
	(hppa_hpux_find_dummy_bpaddr): Update.
	* hppa-tdep.c (hppa_symbol_address): Update.
	* infcmd.c (until_next_command): Update.
	* jit.c (jit_read_descriptor, jit_breakpoint_re_set_internal):
	Update.
	* linespec.c (minsym_found, add_minsym): Update.
	* linux-nat.c (get_signo): Update.
	* linux-thread-db.c (inferior_has_bug): Update.
	* m32c-tdep.c (m32c_return_value)
	(m32c_m16c_address_to_pointer): Update.
	* m32r-tdep.c (m32r_frame_this_id): Update.
	* m68hc11-tdep.c (m68hc11_get_register_info): Update.
	* machoread.c (macho_resolve_oso_sym_with_minsym): Update.
	* maint.c (maintenance_translate_address): Update.
	* minsyms.c (lookup_minimal_symbol_by_pc_name): Update.
	(frob_address): New function.
	(lookup_minimal_symbol_by_pc_section_1): Use raw addresses,
	frob_address.  Rename parameter to "pc_in".
	(compare_minimal_symbols, compact_minimal_symbols): Use raw
	addresses.
	(find_solib_trampoline_target, minimal_symbol_upper_bound):
	Update.
	* mips-linux-tdep.c (mips_linux_skip_resolver): Update.
	* mips-tdep.c (mips_skip_pic_trampoline_code): Update.
	* objc-lang.c (find_objc_msgsend): Update.
	* objfiles.c (objfile_relocate1): Update.
	* obsd-tdep.c (obsd_skip_solib_resolver): Update.
	* p-valprint.c (pascal_val_print): Update.
	* parse.c (write_exp_msymbol): Update.
	* ppc-linux-tdep.c (ppc_linux_spe_context_lookup)
	(ppc_elfv2_skip_entrypoint): Update.
	* ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update.
	* printcmd.c (build_address_symbolic, msym_info)
	(address_info): Update.
	* proc-service.c (ps_pglobal_lookup): Update.
	* psymtab.c (find_pc_sect_psymtab_closer)
	(find_pc_sect_psymtab, find_pc_sect_symtab_from_partial):
	Change msymbol parameter to bound_minimal_symbol.
	* ravenscar-thread.c (get_running_thread_id): Update.
	* remote.c (remote_check_symbols): Update.
	* sh64-tdep.c (sh64_elf_make_msymbol_special): Use raw
	address.
	* sol2-tdep.c (sol2_skip_solib_resolver): Update.
	* solib-dsbt.c (lm_base): Update.
	* solib-frv.c (lm_base, main_got): Update.
	* solib-irix.c (locate_base): Update.
	* solib-som.c (som_solib_create_inferior_hook)
	(link_map_start): Update.
	* solib-spu.c (spu_enable_break, ocl_enable_break): Update.
	* solib-svr4.c (elf_locate_base, enable_break): Update.
	* spu-tdep.c (spu_get_overlay_table, spu_catch_start)
	(flush_ea_cache): Update.
	* stabsread.c (define_symbol, scan_file_globals): Update.
	* stack.c (find_frame_funname): Update.
	* symfile-debug.c (debug_qf_expand_symtabs_matching)
	(debug_qf_find_pc_sect_symtab): Update.
	* symfile.c (simple_read_overlay_table)
	(simple_overlay_update): Update.
	* symfile.h (struct quick_symbol_functions)
	<find_pc_sect_symtab>: Change type of msymbol to
	bound_minimal_symbol.
	* symmisc.c (dump_msymbols): Update.
	* symtab.c (find_pc_sect_symtab_via_partial)
	(find_pc_sect_psymtab, find_pc_sect_line, skip_prologue_sal)
	(search_symbols, print_msymbol_info): Update.
	* symtab.h (MSYMBOL_VALUE_RAW_ADDRESS): New macro.
	(MSYMBOL_VALUE_ADDRESS): Redefine.
	(BMSYMBOL_VALUE_ADDRESS): New macro.
	* tracepoint.c (scope_info): Update.
	* tui/tui-disasm.c (tui_find_disassembly_address)
	(tui_get_begin_asm_address): Update.
	* valops.c (find_function_in_inferior): Update.
	* value.c (value_static_field, value_fn_field): Update.
2014-02-26 12:11:17 -07:00
Tom Tromey 3b7344d5ab use bound_minsym as result for lookup_minimal_symbol et al
This patch changes a few minimal symbol lookup functions to return a
bound_minimal_symbol rather than a pointer to the minsym.  This change
helps prepare gdb for computing a minimal symbol's address at the
point of use.

Note that this changes even those functions that ostensibly search a
single objfile.  That was necessary because, in fact, those functions
can search an objfile and its separate debug objfiles; and it is
important for the caller to know in which objfile the minimal symbol
was actually found.

The bulk of this patch is mechanical.

2014-02-26  Tom Tromey  <tromey@redhat.com>

	* ada-lang.c (ada_update_initial_language): Update.
	(ada_main_name, ada_has_this_exception_support): Update.
	* ada-tasks.c (ada_tasks_inferior_data_sniffer): Update.
	* aix-thread.c (pdc_symbol_addrs, pd_enable): Update.
	* arm-tdep.c (arm_skip_stub): Update.
	* auxv.c (ld_so_xfer_auxv): Update.
	* avr-tdep.c (avr_scan_prologue): Update.
	* ax-gdb.c (gen_var_ref): Update.
	* breakpoint.c (struct breakpoint_objfile_data)
	<overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change
	type to bound_minimal_symbol.
	(create_overlay_event_breakpoint)
	(create_longjmp_master_breakpoint)
	(create_std_terminate_master_breakpoint)
	(create_exception_master_breakpoint): Update.
	* bsd-uthread.c (bsd_uthread_lookup_address): Update.
	* c-exp.y (classify_name): Update.
	* coffread.c (coff_symfile_read): Update.
	* common/agent.c (agent_look_up_symbols): Update.
	* d-lang.c (d_main_name): Update.
	* dbxread.c (find_stab_function_addr, end_psymtab): Update.
	* dec-thread.c (enable_dec_thread): Update.
	* dwarf2loc.c (call_site_to_target_addr): Update.
	* elfread.c (elf_gnu_ifunc_resolve_by_got): Update.
	* eval.c (evaluate_subexp_standard): Update.
	* findvar.c (struct minsym_lookup_data) <result>: Change type
	to bound_minimal_symbol.
	<objfile>: Remove.
	(minsym_lookup_iterator_cb, default_read_var_value): Update.
	* frame.c (inside_main_func): Update.
	* frv-tdep.c (frv_frame_this_id): Update.
	* gcore.c (call_target_sbrk): Update.
	* glibc-tdep.c (glibc_skip_solib_resolver): Update.
	* gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline):
	Update.
	* go-lang.c (go_main_name): Update.
	* hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code)
	(hppa_hpux_find_import_stub_for_addr): Update.
	* hppa-tdep.c (hppa_extract_17,	hppa_lookup_stub_minimal_symbol):
	Update.  Change return type.
	* hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return
	type.
	* jit.c (jit_breakpoint_re_set_internal): Update.
	* linux-fork.c (inferior_call_waitpid, checkpoint_command):
	Update.
	* linux-nat.c (get_signo): Update.
	* linux-thread-db.c (inferior_has_bug): Update
	* m32c-tdep.c (m32c_return_value)
	(m32c_m16c_address_to_pointer): Update.
	* m32r-tdep.c (m32r_frame_this_id): Update.
	* m68hc11-tdep.c (m68hc11_get_register_info): Update.
	* machoread.c (macho_resolve_oso_sym_with_minsym): Update.
	* minsyms.c (lookup_minimal_symbol_internal): Rename to
	lookup_minimal_symbol.  Change return type.
	(lookup_minimal_symbol): Remove.
	(lookup_bound_minimal_symbol): Update.
	(lookup_minimal_symbol_text): Change return type.
	(lookup_minimal_symbol_solib_trampoline): Change return type.
	* minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text)
	(lookup_minimal_symbol_solib_trampoline): Change return type.
	* mips-linux-tdep.c (mips_linux_skip_resolver): Update.
	* objc-lang.c (lookup_objc_class, lookup_child_selector)
	(value_nsstring, find_imps): Update.
	* obsd-tdep.c (obsd_skip_solib_resolver): Update.
	* p-lang.c (pascal_main_name): Update.
	* ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update.
	* ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update.
	* proc-service.c (ps_pglobal_lookup): Update.
	* ravenscar-thread.c (get_running_thread_msymbol): Change
	return type.
	(has_ravenscar_runtime, get_running_thread_id): Update.
	* remote.c (remote_check_symbols): Update.
	* sol-thread.c (ps_pglobal_lookup): Update.
	* sol2-tdep.c (sol2_skip_solib_resolver): Update.
	* solib-dsbt.c (lm_base): Update.
	* solib-frv.c (lm_base, frv_relocate_section_addresses):
	Update.
	* solib-irix.c (locate_base): Update.
	* solib-som.c (som_solib_create_inferior_hook)
	(som_solib_desire_dynamic_linker_symbols, link_map_start):
	Update.
	* solib-spu.c (spu_enable_break): Update.
	* solib-svr4.c (elf_locate_base, enable_break): Update.
	* spu-tdep.c (spu_get_overlay_table, spu_catch_start)
	(flush_ea_cache): Update.
	* stabsread.c (define_symbol): Update.
	* symfile.c (simple_read_overlay_table): Update.
	* symtab.c (find_pc_sect_line): Update.
	* tracepoint.c (scope_info): Update.
	* tui-disasm.c (tui_get_begin_asm_address): Update.
	* value.c (value_static_field): Update.
2014-02-26 12:11:17 -07:00
Tom Tromey efd66ac669 change minsym representation
In a later patch we're going to change the minimal symbol address
calculation to apply section offsets at the point of use.  To make it
simpler to catch potential problem spots, this patch changes the
representation of minimal symbols and introduces new
minimal-symbol-specific variants of the various accessors.  This is
necessary because it would be excessively ambitious to try to convert
all the symbol types at once.

The core of this change is just renaming a field in minimal_symbol;
the rest is just a fairly mechanical rewording.

2014-02-26  Tom Tromey  <tromey@redhat.com>

	* symtab.h (struct minimal_symbol) <mginfo>: Rename from ginfo.
	(MSYMBOL_VALUE, MSYMBOL_VALUE_ADDRESS, MSYMBOL_VALUE_BYTES)
	(MSYMBOL_BLOCK_VALUE, MSYMBOL_VALUE_CHAIN, MSYMBOL_LANGUAGE)
	(MSYMBOL_SECTION, MSYMBOL_OBJ_SECTION, MSYMBOL_NATURAL_NAME)
	(MSYMBOL_LINKAGE_NAME, MSYMBOL_PRINT_NAME, MSYMBOL_DEMANGLED_NAME)
	(MSYMBOL_SET_LANGUAGE, MSYMBOL_SEARCH_NAME)
	(MSYMBOL_MATCHES_SEARCH_NAME, MSYMBOL_SET_NAMES): New macros.
	* ada-lang.c (ada_main_name): Update.
	(ada_lookup_simple_minsym): Update.
	(ada_make_symbol_completion_list): Update.
	(ada_add_standard_exceptions): Update.
	* ada-tasks.c (read_atcb, ada_tasks_inferior_data_sniffer): Update.
	* aix-thread.c (pdc_symbol_addrs, pd_enable): Update.
	* amd64-windows-tdep.c (amd64_skip_main_prologue): Update.
	* arm-tdep.c (skip_prologue_function): Update.
	(arm_skip_stack_protector, arm_skip_stub): Update.
	* arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update.
	(arm_wince_skip_main_prologue): Update.
	* auxv.c (ld_so_xfer_auxv): Update.
	* avr-tdep.c (avr_scan_prologue): Update.
	* ax-gdb.c (gen_var_ref): Update.
	* block.c (call_site_for_pc): Update.
	* blockframe.c (get_pc_function_start): Update.
	(find_pc_partial_function_gnu_ifunc): Update.
	* breakpoint.c (create_overlay_event_breakpoint): Update.
	(create_longjmp_master_breakpoint): Update.
	(create_std_terminate_master_breakpoint): Update.
	(create_exception_master_breakpoint): Update.
	(resolve_sal_pc): Update.
	* bsd-uthread.c (bsd_uthread_lookup_address): Update.
	* btrace.c (ftrace_print_function_name, ftrace_function_switched):
	Update.
	* c-valprint.c (c_val_print): Update.
	* coff-pe-read.c (add_pe_forwarded_sym): Update.
	* coffread.c (coff_symfile_read): Update.
	* common/agent.c (agent_look_up_symbols): Update.
	* dbxread.c (find_stab_function_addr): Update.
	(end_psymtab): Update.
	* dwarf2loc.c (call_site_to_target_addr): Update.
	(func_verify_no_selftailcall): Update.
	(tailcall_dump): Update.
	(call_site_find_chain_1): Update.
	(dwarf_expr_reg_to_entry_parameter): Update.
	* elfread.c (elf_gnu_ifunc_record_cache): Update.
	(elf_gnu_ifunc_resolve_by_got): Update.
	* f-valprint.c (info_common_command): Update.
	* findvar.c (read_var_value): Update.
	* frame.c (get_prev_frame_1): Update.
	(inside_main_func): Update.
	* frv-tdep.c (frv_skip_main_prologue): Update.
	(frv_frame_this_id): Update.
	* glibc-tdep.c (glibc_skip_solib_resolver): Update.
	* gnu-v2-abi.c (gnuv2_value_rtti_type): Update.
	* gnu-v3-abi.c (gnuv3_rtti_type): Update.
	(gnuv3_skip_trampoline): Update.
	* hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline): Update.
	(hppa64_hpux_in_solib_call_trampoline): Update.
	(hppa_hpux_skip_trampoline_code): Update.
	(hppa64_hpux_search_dummy_call_sequence): Update.
	(hppa_hpux_find_import_stub_for_addr): Update.
	(hppa_hpux_find_dummy_bpaddr): Update.
	* hppa-tdep.c (hppa_symbol_address)
	(hppa_lookup_stub_minimal_symbol): Update.
	* i386-tdep.c (i386_skip_main_prologue): Update.
	(i386_pe_skip_trampoline_code): Update.
	* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Update.
	* infcall.c (get_function_name): Update.
	* infcmd.c (until_next_command): Update.
	* jit.c (jit_breakpoint_re_set_internal): Update.
	(jit_inferior_init): Update.
	* linespec.c (minsym_found): Update.
	(add_minsym): Update.
	* linux-fork.c (info_checkpoints_command): Update.
	* linux-nat.c (get_signo): Update.
	* linux-thread-db.c (inferior_has_bug): Update.
	* m32c-tdep.c (m32c_return_value): Update.
	(m32c_m16c_address_to_pointer): Update.
	(m32c_m16c_pointer_to_address): Update.
	* m32r-tdep.c (m32r_frame_this_id): Update.
	* m68hc11-tdep.c (m68hc11_get_register_info): Update.
	* machoread.c (macho_resolve_oso_sym_with_minsym): Update.
	* maint.c (maintenance_translate_address): Update.
	* minsyms.c (add_minsym_to_hash_table): Update.
	(add_minsym_to_demangled_hash_table): Update.
	(msymbol_objfile): Update.
	(lookup_minimal_symbol): Update.
	(iterate_over_minimal_symbols): Update.
	(lookup_minimal_symbol_text): Update.
	(lookup_minimal_symbol_by_pc_name): Update.
	(lookup_minimal_symbol_solib_trampoline): Update.
	(lookup_minimal_symbol_by_pc_section_1): Update.
	(lookup_minimal_symbol_and_objfile): Update.
	(prim_record_minimal_symbol_full): Update.
	(compare_minimal_symbols): Update.
	(compact_minimal_symbols): Update.
	(build_minimal_symbol_hash_tables): Update.
	(install_minimal_symbols): Update.
	(terminate_minimal_symbol_table): Update.
	(find_solib_trampoline_target): Update.
	(minimal_symbol_upper_bound): Update.
	* mips-linux-tdep.c (mips_linux_skip_resolver): Update.
	* mips-tdep.c (mips_stub_frame_sniffer): Update.
	(mips_skip_pic_trampoline_code): Update.
	* msp430-tdep.c (msp430_skip_trampoline_code): Update.
	* objc-lang.c (selectors_info): Update.
	(classes_info): Update.
	(find_methods): Update.
	(find_imps): Update.
	(find_objc_msgsend): Update.
	* objfiles.c (objfile_relocate1): Update.
	* objfiles.h (ALL_OBJFILE_MSYMBOLS): Update.
	* obsd-tdep.c (obsd_skip_solib_resolver): Update.
	* p-valprint.c (pascal_val_print): Update.
	* parse.c (write_exp_msymbol): Update.
	* ppc-linux-tdep.c (powerpc_linux_in_dynsym_resolve_code)
	(ppc_linux_spe_context_lookup, ppc_elfv2_skip_entrypoint): Update.
	* ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update.
	* printcmd.c (build_address_symbolic): Update.
	(sym_info): Update.
	(address_info): Update.
	* proc-service.c (ps_pglobal_lookup): Update.
	* psymtab.c (find_pc_sect_psymtab_closer): Update.
	(find_pc_sect_psymtab): Update.
	* python/py-framefilter.c (py_print_frame): Update.
	* ravenscar-thread.c (get_running_thread_id): Update.
	* record-btrace.c (btrace_call_history, btrace_get_bfun_name):
	Update.
	* remote.c (remote_check_symbols): Update.
	* rs6000-tdep.c (rs6000_skip_main_prologue): Update.
	(rs6000_skip_trampoline_code): Update.
	* sh64-tdep.c (sh64_elf_make_msymbol_special): Update.
	* sol2-tdep.c (sol2_skip_solib_resolver): Update.
	* solib-dsbt.c (lm_base): Update.
	* solib-frv.c (lm_base): Update.
	(main_got): Update.
	* solib-irix.c (locate_base): Update.
	* solib-som.c (som_solib_create_inferior_hook): Update.
	(som_solib_desire_dynamic_linker_symbols): Update.
	(link_map_start): Update.
	* solib-spu.c (spu_enable_break): Update.
	(ocl_enable_break): Update.
	* solib-svr4.c (elf_locate_base): Update.
	(enable_break): Update.
	* spu-tdep.c (spu_get_overlay_table): Update.
	(spu_catch_start): Update.
	(flush_ea_cache): Update.
	* stabsread.c (define_symbol): Update.
	(scan_file_globals): Update.
	* stack.c (find_frame_funname): Update.
	(frame_info): Update.
	* symfile.c (simple_read_overlay_table): Update.
	(simple_overlay_update): Update.
	* symmisc.c (dump_msymbols): Update.
	* symtab.c (fixup_section): Update.
	(find_pc_sect_line): Update.
	(skip_prologue_sal): Update.
	(search_symbols): Update.
	(print_msymbol_info): Update.
	(rbreak_command): Update.
	(MCOMPLETION_LIST_ADD_SYMBOL): New macro.
	(completion_list_objc_symbol): Update.
	(default_make_symbol_completion_list_break_on): Update.
	* tracepoint.c (scope_info): Update.
	* tui/tui-disasm.c (tui_find_disassembly_address): Update.
	(tui_get_begin_asm_address): Update.
	* valops.c (find_function_in_inferior): Update.
	* value.c (value_static_field): Update.
	(value_fn_field): Update.
2014-02-26 12:11:16 -07:00
Markus Metzger 824344ca4f frame: do not assume unwinding will succeed
In get_frame_unwind_stop_reason, remove the assumption that further frame
unwinding will succeed.

gdb/
2013-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* frame.c (get_frame_unwind_stop_reason): Unconditionally call
	get_prev_frame_1.
2014-01-16 13:06:12 +01:00
Markus Metzger 8372a7cb96 frame: add frame_id_build_unavailable_stack_special
Add a function to build a frame_id for a frame with unavailable stack
and with a special identifier address.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* frame.h (frame_id_build_unavailable_stack_special): New.
	* frame.c (frame_id_build_unavailable_stack_special): New.
2014-01-16 12:45:11 +01:00
Joel Brobecker ecd75fc8ee Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
Pedro Alves 5ce0145de7 "tfind" across unavailable-stack frames.
Like when stepping, the current stack frame location is expected to be
printed as result of tfind command, if that results in moving to a
different function.  In tfind_1 we see:

  if (from_tty
      && (has_stack_frames () || traceframe_number >= 0))
    {
      enum print_what print_what;

      /* NOTE: in imitation of the step command, try to determine
         whether we have made a transition from one function to
         another.  If so, we'll print the "stack frame" (ie. the new
         function and it's arguments) -- otherwise we'll just show the
         new source line.  */

      if (frame_id_eq (old_frame_id,
                       get_frame_id (get_current_frame ())))
        print_what = SRC_LINE;
      else
        print_what = SRC_AND_LOC;

      print_stack_frame (get_selected_frame (NULL), 1, print_what, 1);
      do_displays ();
    }

However, when we haven't collected any registers in the tracepoint
(collect $regs), that doesn't actually work:

 (gdb) tstart
 (gdb) info tracepoints
 Num     Type           Disp Enb Address    What
 1       tracepoint     keep y   0x080483b7 in func0
                                            at ../.././../git/gdb/testsuite/gdb.trace/circ.c:28
         collect testload
     installed on target
 2       tracepoint     keep y   0x080483bc in func1
                                            at ../.././../git/gdb/testsuite/gdb.trace/circ.c:32
         collect testload
     installed on target
 (gdb) c
 Continuing.

 Breakpoint 3, end () at ../.././../git/gdb/testsuite/gdb.trace/circ.c:72
 72    }
 (gdb) tstop
 (gdb) tfind start
 Found trace frame 0, tracepoint 1
 #0  func0 () at ../.././../git/gdb/testsuite/gdb.trace/circ.c:28
 28    }
 (gdb) tfind
 Found trace frame 1, tracepoint 2
 32    }
 (gdb)

When we don't have info about the stack available
(UNWIND_UNAVAILABLE), frames end up with outer_frame_id as frame ID.
And in the scenario above, the issue is that both frames before and
after the second tfind (the frames for func0 an func1) have the same
id (outer_frame_id), so the frame_id_eq check returns false, even
though the frames were of different functions.  GDB knows that,
because the PC is inferred from the tracepoint's address, even if no
registers were collected.

To fix this, this patch adds support for frame ids with a valid code
address, but <unavailable> stack address, and then makes the unwinders
use that instead of the catch-all outer_frame_id for such frames.  The
frame_id_eq check in tfind_1 then automatically does the right thing
as expected.

I tested with --directory=gdb.trace/ , before/after the patch, and
compared the resulting gdb.logs, then adjusted the tests to expect the
extra output that came out.  Turns out that was only circ.exp, the
original test that actually brought this issue to light.

Tested on x86_64 Fedora 17, native and gdbserver.

gdb/
2013-12-17  Pedro Alves  <palves@redhat.com>

	* frame.h (enum frame_id_stack_status): New enum.
	(struct frame_id) <stack_addr>: Adjust comment.
	<stack_addr_p>: Delete field, replaced with ...
	<stack_status>: ... this new field.
	(frame_id_build_unavailable_stack): Declare.
	* frame.c (frame_addr_hash, fprint_field, outer_frame_id)
	(frame_id_build_special): Adjust.
	(frame_id_build_unavailable_stack): New function.
	(frame_id_build, frame_id_build_wild): Adjust.
	(frame_id_p, frame_id_eq, frame_id_inner): Adjust to take into
	account frames with unavailable stack.

	* amd64-tdep.c (amd64_frame_this_id)
	(amd64_sigtramp_frame_this_id, amd64_epilogue_frame_this_id): Use
	frame_id_build_unavailable_stack.
	* dwarf2-frame.c (dwarf2_frame_this_id): Likewise.
	* i386-tdep.c (i386_frame_this_id, i386_epilogue_frame_this_id)
	(i386_sigtramp_frame_this_id):  Likewise.

gdb/testsuite/
2013-12-17  Pedro Alves  <palves@redhat.com>

	* gdb.trace/circ.exp: Expect frame info to be printed when
	switching between frames with unavailable stack, but different
	functions.
2013-12-17 20:47:36 +00:00
Pedro Alves 782d47dfbd Fix "info frame" in the outermost frame.
Doing "info frame" in the outermost frame, when that was indicated by
the next frame saying the unwound PC is undefined/not saved, results
in error and incomplete output:

 (gdb) bt
 #0  thread_function0 (arg=0x0) at threads.c:63
 #1  0x00000034cf407d14 in start_thread (arg=0x7ffff7fcb700) at pthread_create.c:309
 #2  0x000000323d4f168d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115

 (gdb) frame 2
 #2  0x000000323d4f168d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115
 115             call    *%rax

 (gdb) info frame
 Stack level 2, frame at 0x0:
  rip = 0x323d4f168d in clone (../sysdeps/unix/sysv/linux/x86_64/clone.S:115); saved rip Register 16 was not saved
 (gdb)

Not saved register values are treated as optimized out values
internally throughout.  stack.c:frame_info is handing unvailable
values, but not optimized out ones.  The patch deletes the
frame_unwind_caller_pc_if_available wrapper function and instead lets
errors propagate to frame_info (it's only user).

As frame_unwind_pc now needs to be able to handle and cache two
different error scenarios, the prev_pc.p variable is replaced with an
enumeration.

(FWIW, I looked into making gdbarch_unwind_pc or a variant return
struct value's instead, but it results in lots of boxing and unboxing
for no real gain -- e.g., the mips and arm implementations need to do
computation on the unboxed PC value.  Might as well throw an error on
first attempt to get at invalid contents.)

After the patch, we get:

 (gdb) info frame
 Stack level 2, frame at 0x0:
  rip = 0x323d4f168d in clone (../sysdeps/unix/sysv/linux/x86_64/clone.S:115); saved rip = <not saved>
  Outermost frame: outermost
  caller of frame at 0x7ffff7fcafc0
  source language asm.
  Arglist at 0x7ffff7fcafb8, args:
  Locals at 0x7ffff7fcafb8, Previous frame's sp is 0x7ffff7fcafc8
 (gdb)

A new test is added.  It's based off dw2-reg-undefined.exp, and tweaked to
mark the return address (rip) of "stop_frame" as undefined.

Tested on x86_64 Fedora 17.

gdb/
2013-12-06  Pedro Alves  <palves@redhat.com>

	* frame.c (enum cached_copy_status): New enum.
	(struct frame_info) <prev_pc.p>: Change type to enum
	cached_copy_status.
	(fprint_frame): Handle not saved and unavailable prev_pc values.
	(frame_unwind_pc_if_available): Delete and merge contents into ...
	(frame_unwind_pc): ... here.  Handle OPTIMIZED_OUT_ERROR.  Adjust
	to use enum cached_copy_status.
	(frame_unwind_caller_pc_if_available): Delete.
	(create_new_frame): Adjust.
	* frame.h (frame_unwind_caller_pc_if_available): Delete
	declaration.
	* stack.c (frame_info): Use frame_unwind_caller_pc instead of
	frame_unwind_caller_pc_if_available, and handle
	NOT_AVAILABLE_ERROR and OPTIMIZED_OUT_ERROR errors.
	* valprint.c (val_print_optimized_out): Use val_print_not_saved.
	(val_print_not_saved): New function.
	* valprint.h (val_print_not_saved): Declare.

gdb/testsuite/
2013-12-06  Pedro Alves  <palves@redhat.com>

	* gdb.dwarf2/dw2-undefined-ret-addr.S: New file.
	* gdb.dwarf2/dw2-undefined-ret-addr.c: New file.
	* gdb.dwarf2/dw2-undefined-ret-addr.exp: New file.
2013-12-06 19:50:10 +00:00
Pedro Alves 710409a221 New OPTIMIZED_OUT_ERROR error code.
In order to catch <optimized out> errors like we catch <unavailable>
errors, this adds a new OPTIMIZED_OUT_ERROR error code, and throws it
in various places.

gdb/ChangeLog
2013-12-06  Andrew Burgess  <aburgess@broadcom.com>
	    Pedro Alves  <palves@redhat.com>

	* exceptions.h (errors): Add OPTIMIZED_OUT_ERROR.
	* dwarf2loc.c (write_pieced_value): Throw OPTIMIZED_OUT_ERROR.
	* frame.c (frame_unwind_register): Throw OPTIMIZED_OUT_ERROR.
	* spu-tdep.c (spu_software_single_step): Throw
	OPTIMIZED_OUT_ERROR.
	* valops.c (value_assign): Throw OPTIMIZED_OUT_ERROR.
2013-12-06 19:48:54 +00:00
Joel Brobecker da361ebd2d Uninitialized variable "this_id" in frame.c:get_prev_frame_1.
With a simple Ada program where I have 3 functions, one just calling
the next, the backtrace is currently broken when GDB is compiled
at -O2:

   #0  hello.first () at hello.adb:5
   #1  0x0000000100001475 in hello.second () at hello.adb:10
   Backtrace stopped: previous frame inner to this frame (corrupt stack?)

It turns out that a recent patch deleted the assignment of variable
this_id, making it an unitialized variable:

        * frame-unwind.c (default_frame_unwind_stop_reason): Return
        UNWIND_OUTERMOST if the frame's ID is outer_frame_id.
        * frame.c (get_prev_frame_1): Remove outer_frame_id check.

The hunk in question starts with:

-  /* Check that this frame is not the outermost.  If it is, don't try
-     to unwind to the prev frame.  */
-  this_id = get_frame_id (this_frame);
-  if (frame_id_eq (this_id, outer_frame_id))

(the code was removed as redundant - but removing the assignment
was in fact not intentional).

There is no other code in this function that sets the variable.
Instead of re-adding the statement in the lone section where it is
actually used, I inlined it, and then got rid of the variable
altogether.  This way, and until we start needing this frame ID
in another location within that function, we dont' have to worry
about the variable's validity/lifetime.

gdb/ChangeLog:

        * frame.c (get_prev_frame_1): Delete variable "this_id".
        Replace its use by a call to get_frame_id.
2013-12-06 08:51:15 +04:00
Pedro Alves a730086980 get_prev_frame, stop_reason != UNWIND_NO_REASON, add frame debug output.
The stop_reason != UNWIND_NO_REASON doesn't currently have "set debug
frame" output.  This patch makes it print the stop_reason enum value
as a string.

gdb/
2013-11-28  Pedro Alves  <palves@redhat.com>

	* frame.c (get_prev_frame_1) <stop_reason != UNWIND_NO_REASON>:
	Add "set debug frame" output.
	(frame_stop_reason_symbol_string): New function.
2013-11-28 18:09:41 +00:00
Pedro Alves 50fd528a13 get_prev_frame, outer_frame_id and unwind->stop_reason checks are redundant.
After the previous patch, it should be clear that the
this_frame->unwind->stop_reason check is redundant with the
outer_frame_id check just below.  We can now move the frame_id_eq
comparison to the default this_frame->unwind->stop_reason callback.

Tested on x86_64 Fedora 17.

gdb/
2013-11-28  Pedro Alves  <palves@redhat.com>

	* frame-unwind.c (default_frame_unwind_stop_reason): Return
	UNWIND_OUTERMOST if the frame's ID is outer_frame_id.
	* frame.c (get_prev_frame_1): Remove outer_frame_id check.
2013-11-28 17:37:47 +00:00
Pedro Alves 5de5158168 get_prev_frame, UNWIND_NULL_ID -> UNWIND_OUTERMOST
- The UNWIND_NULL_ID check in get_prev_frame_1 used to really be
  against null_frame_id, back before we had outer_frame_id.  We didn't
  have UNWIND_OUTERMOST when outer_frame_id was added, but we do now,
  and it's more accurate.

- It used to be necessary to check for the sentinel frame explicitly
  because that uses null_frame_id for frame id.  Since no other frame
  can have that id nowadays (it's asserted by compute_frame_id), we
  don't need that explicit check.

Tested on x86_64 Fedora 17.

gdb/
2013-11-28  Pedro Alves  <palves@redhat.com>

	* frame.c (get_prev_frame_1): If the frame id is outer_frame_id,
	set the unwind stop reason to UNWIND_OUTERMOST, not
	UNWIND_NULL_ID.  Remove explicit check for sentinel frame.
2013-11-28 17:35:28 +00:00
Pedro Alves 739cb10c0e register: "optimized out" -> "not saved".
Another spot that missed the previous related text adjustments.

Tested on x86_64 Fedora 17.

gdb/
2013-11-28  Pedro Alves  <palves@redhat.com>

	* frame.c (frame_unwind_register): Say the register was "not
	saved" instead of "optimized out".
2013-11-28 17:32:26 +00:00
Andrew Burgess f6c01fc515 Make "set debug frame 1" use the standard print routine for optimized out values.
...
 - { frame_unwind_register_value (frame=0,regnum=7(rsp),...) -> optimized out }
 + { frame_unwind_register_value (frame=0,regnum=7(rsp),...) -> <optimized out> }
 ...

Tested on x86_64 Fedora 17.

2013-11-27  Andrew Burgess  <aburgess@broadcom.com>

	* frame.c: Include "valprint.h".
	(frame_unwind_register_value): Use value_optimized_out.
	* value.c (value_fetch_lazy): Likewise.
2013-11-27 17:49:59 +00:00
Pedro Alves 194cca4119 Make use of the frame stash to detect wider stack cycles.
Given we already have the frame id stash, which holds the ids of all
frames in the chain, detecting corrupted stacks with wide stack cycles
with non-consecutive dup frame ids is just as cheap as just detecting
cycles in consecutive frames:

 #0 frame_id1
 #1 frame_id2
 #2 frame_id3
 #3 frame_id1
 #4 frame_id2
 #5 frame_id3
 #6 frame_id1
 ... forever ...

We just need to check whether the stash already knows about a given
frame id instead of comparing the ids of the previous/this frames.

Tested on x86_64 Fedora 17.

gdb/
2013-11-22  Pedro Alves  <palves@redhat.com>
	    Tom Tromey  <tromey@redhat.com>

	* frame.c (frame_stash_add): Now returns whether a frame with the
	same ID was already known.
	(compute_frame_id): New function, factored out from get_frame_id.
	(get_frame_id): No longer lazilly compute the frame id here.
	(get_prev_frame_if_no_cycle): New function.  Detects wider stack
	cycles.
	(get_prev_frame_1): Use it instead of get_prev_frame_raw directly,
	and checking for stack cycles here.
2013-11-22 13:53:39 +00:00
Pedro Alves 33f8fe58b9 Don't let two frames with the same id end up in the frame chain.
The UNWIND_SAME_ID check is done between THIS_FRAME and the next frame
when we go try to unwind the previous frame.  But at this point, it's
already too late -- we ended up with two frames with the same ID in
the frame chain.  Each frame having its own ID is an invariant assumed
throughout GDB.  This patch applies the UNWIND_SAME_ID detection
earlier, right after the previous frame is unwound, discarding the dup
frame if a cycle is detected.

The patch includes a new test that fails before the change.  Before
the patch, the test causes an infinite loop in GDB, after the patch,
the UNWIND_SAME_ID logic kicks in and makes the backtrace stop with:

  Backtrace stopped: previous frame identical to this frame (corrupt stack?)

The test uses dwarf CFI to emulate a corrupted stack with a cycle.  It
has a function with registers marked DW_CFA_same_value (most
importantly RSP/RIP), so that GDB computes the same ID for that frame
and its caller.  IOW, something like this:

 #0 - frame_id_1
 #1 - frame_id_2
 #2 - frame_id_3
 #3 - frame_id_4
 #4 - frame_id_4  <<<< outermost (UNWIND_SAME_ID).

(The test's code is just a copy of dw2-reg-undefined.S /
dw2-reg-undefined.c, adjusted to use DW_CFA_same_value instead of
DW_CFA_undefined, and to mark a different set of registers.)

The infinite loop is here, in value_fetch_lazy:

      while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val))
	{
	  frame = frame_find_by_id (VALUE_FRAME_ID (new_val));
...
	  new_val = get_frame_register_value (frame, regnum);
	}

get_frame_register_value can return a lazy register value pointing to
the next frame.  This means that the register wasn't clobbered by
FRAME; the debugger should therefore retrieve its value from the next
frame.

To be clear, get_frame_register_value unwinds the value in question
from the next frame:

 struct value *
 get_frame_register_value (struct frame_info *frame, int regnum)
 {
   return frame_unwind_register_value (frame->next, regnum);
                                       ^^^^^^^^^^^
 }

In other words, if we get a lazy lval_register, it should have the
frame ID of the _next_ frame, never of FRAME.

At this point in value_fetch_lazy, the whole relevant chunk of the
stack up to frame #4 has already been unwound.  The loop always
"unlazies" lval_registers in the "next/innermost" direction, not in
the "prev/unwind further/outermost" direction.

So say we're looking at frame #4.  get_frame_register_value in frame
#4 can return a lazy register value of frame #3.  So the next
iteration, frame_find_by_id tries to read the register from frame #3.
But, since frame #4 happens to have same id as frame #3,
frame_find_by_id returns frame #4 instead.  Rinse, repeat, and we have
an infinite loop.

This is an old latent problem, exposed by the recent addition of the
frame stash.  Before we had a stash, frame_find_by_id(frame_id_4)
would walk over all frames starting at the current frame, and would
always find #3 first.  The stash happens to return #4 instead:

struct frame_info *
frame_find_by_id (struct frame_id id)
{
  struct frame_info *frame, *prev_frame;

...
  /* Try using the frame stash first.  Finding it there removes the need
     to perform the search by looping over all frames, which can be very
     CPU-intensive if the number of frames is very high (the loop is O(n)
     and get_prev_frame performs a series of checks that are relatively
     expensive).  This optimization is particularly useful when this function
     is called from another function (such as value_fetch_lazy, case
     VALUE_LVAL (val) == lval_register) which already loops over all frames,
     making the overall behavior O(n^2).  */
  frame = frame_stash_find (id);
  if (frame)
    return frame;

  for (frame = get_current_frame (); ; frame = prev_frame)
    {

gdb/
2013-11-22  Pedro Alves  <palves@redhat.com>

	PR 16155
	* frame.c (get_prev_frame_1): Do the UNWIND_SAME_ID check between
	this frame and the new previous frame, not between this frame and
	the next frame.

gdb/testsuite/
2013-11-22  Pedro Alves  <palves@redhat.com>

	PR 16155
	* gdb.dwarf2/dw2-dup-frame.S: New file.
	* gdb.dwarf2/dw2-dup-frame.c: New file.
	* gdb.dwarf2/dw2-dup-frame.exp: New file.
2013-11-22 13:50:48 +00:00
Pedro Alves 8ad6489081 Revert "Don't let two frames with the same id end up in the frame chain."
This reverts commit be2c48b4d5.
2013-11-22 13:46:51 +00:00
Pedro Alves c8381c86b4 Revert "Make use of the frame stash to detect wider stack cycles."
This reverts commit f5b0ed3c8c.
2013-11-22 13:46:43 +00:00
Pedro Alves f5b0ed3c8c Make use of the frame stash to detect wider stack cycles.
Tested on x86_64 Fedora 17.

gdb/
2013-11-22  Pedro Alves  <palves@redhat.com>
	    Tom Tromey  <tromey@redhat.com>

	* frame.c (frame_stash_add): Now returns whether a frame with the
	same ID was already known.
	(compute_frame_id): New function, factored out from get_frame_id.
	(get_frame_id): No longer lazilly compute the frame id here.
	(get_prev_frame_if_no_cycle): New function.  Detects wider stack
	cycles.
	(get_prev_frame_1): Use it instead of get_prev_frame_raw directly,
	and checking for stack cycles here.
2013-11-22 13:41:43 +00:00
Pedro Alves be2c48b4d5 Don't let two frames with the same id end up in the frame chain.
The UNWIND_SAME_ID check is done between THIS_FRAME and the next frame
when we go try to unwind the previous frame.  But at this point, it's
already too late -- we ended up with two frames with the same ID in
the frame chain.  Each frame having its own ID is an invariant assumed
throughout GDB.  This patch applies the UNWIND_SAME_ID detection
earlier, right after the previous frame is unwound, discarding the dup
frame if a cycle is detected.

The patch includes a new test that fails before the change.  Before
the patch, the test causes an infinite loop in GDB, after the patch,
the UNWIND_SAME_ID logic kicks in and makes the backtrace stop with:

  Backtrace stopped: previous frame identical to this frame (corrupt stack?)

The test uses dwarf CFI to emulate a corrupted stack with a cycle.  It
has a function with registers marked DW_CFA_same_value (most
importantly RSP/RIP), so that GDB computes the same ID for that frame
and its caller.  IOW, something like this:

 #0 - frame_id_1
 #1 - frame_id_2
 #2 - frame_id_3
 #3 - frame_id_4
 #4 - frame_id_4  <<<< outermost (UNWIND_SAME_ID).

(The test's code is just a copy of dw2-reg-undefined.S /
dw2-reg-undefined.c, adjusted to use DW_CFA_same_value instead of
DW_CFA_undefined, and to mark a different set of registers.)

The infinite loop is here, in value_fetch_lazy:

      while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val))
	{
	  frame = frame_find_by_id (VALUE_FRAME_ID (new_val));
...
	  new_val = get_frame_register_value (frame, regnum);
	}

get_frame_register_value can return a lazy register value pointing to
the next frame.  This means that the register wasn't clobbered by
FRAME; the debugger should therefore retrieve its value from the next
frame.

To be clear, get_frame_register_value unwinds the value in question
from the next frame:

 struct value *
 get_frame_register_value (struct frame_info *frame, int regnum)
 {
   return frame_unwind_register_value (frame->next, regnum);
                                       ^^^^^^^^^^^
 }

In other words, if we get a lazy lval_register, it should have the
frame ID of the _next_ frame, never of FRAME.

At this point in value_fetch_lazy, the whole relevant chunk of the
stack up to frame #4 has already been unwound.  The loop always
"unlazies" lval_registers in the "next/innermost" direction, not in
the "prev/unwind further/outermost" direction.

So say we're looking at frame #4.  get_frame_register_value in frame
#4 can return a lazy register value of frame #3.  So the next
iteration, frame_find_by_id tries to read the register from frame #3.
But, since frame #4 happens to have same id as frame #3,
frame_find_by_id returns frame #4 instead.  Rinse, repeat, and we have
an infinite loop.

This is an old latent problem, exposed by the recent addition of the
frame stash.  Before we had a stash, frame_find_by_id(frame_id_4)
would walk over all frames starting at the current frame, and would
always find #3 first.  The stash happens to return #4 instead:

struct frame_info *
frame_find_by_id (struct frame_id id)
{
  struct frame_info *frame, *prev_frame;

...
  /* Try using the frame stash first.  Finding it there removes the need
     to perform the search by looping over all frames, which can be very
     CPU-intensive if the number of frames is very high (the loop is O(n)
     and get_prev_frame performs a series of checks that are relatively
     expensive).  This optimization is particularly useful when this function
     is called from another function (such as value_fetch_lazy, case
     VALUE_LVAL (val) == lval_register) which already loops over all frames,
     making the overall behavior O(n^2).  */
  frame = frame_stash_find (id);
  if (frame)
    return frame;

  for (frame = get_current_frame (); ; frame = prev_frame)
    {

gdb/
2013-11-22  Pedro Alves  <palves@redhat.com>

	PR 16155
	* frame.c (get_prev_frame_1): Do the UNWIND_SAME_ID check between
	this frame and the new previous frame, not between this frame and
	the next frame.

gdb/testsuite/
2013-11-22  Pedro Alves  <palves@redhat.com>

	PR 16155
	* gdb.dwarf2/dw2-dup-frame.S: New file.
 	* gdb.dwarf2/dw2-dup-frame.c: New file.
 	* gdb.dwarf2/dw2-dup-frame.exp: New file.
2013-11-22 13:41:43 +00:00
Tom Tromey 0e9f083f4c remove gdb_string.h
This removes gdb_string.h.  This patch is purely mechanical.  I
created it by running the two commands:

    git rm common/gdb_string.h
    perl -pi -e's/"gdb_string.h"/<string.h>/;'  *.[chyl] */*.[chyl]

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* common/gdb_string.h: Remove.
	* aarch64-tdep.c: Use string.h, not gdb_string.h.
	* ada-exp.y: Use string.h, not gdb_string.h.
	* ada-lang.c: Use string.h, not gdb_string.h.
	* ada-lex.l: Use string.h, not gdb_string.h.
	* ada-typeprint.c: Use string.h, not gdb_string.h.
	* ada-valprint.c: Use string.h, not gdb_string.h.
	* aix-thread.c: Use string.h, not gdb_string.h.
	* alpha-linux-tdep.c: Use string.h, not gdb_string.h.
	* alpha-mdebug-tdep.c: Use string.h, not gdb_string.h.
	* alpha-nat.c: Use string.h, not gdb_string.h.
	* alpha-osf1-tdep.c: Use string.h, not gdb_string.h.
	* alpha-tdep.c: Use string.h, not gdb_string.h.
	* alphanbsd-tdep.c: Use string.h, not gdb_string.h.
	* amd64-dicos-tdep.c: Use string.h, not gdb_string.h.
	* amd64-linux-nat.c: Use string.h, not gdb_string.h.
	* amd64-linux-tdep.c: Use string.h, not gdb_string.h.
	* amd64-nat.c: Use string.h, not gdb_string.h.
	* amd64-sol2-tdep.c: Use string.h, not gdb_string.h.
	* amd64fbsd-tdep.c: Use string.h, not gdb_string.h.
	* amd64obsd-tdep.c: Use string.h, not gdb_string.h.
	* arch-utils.c: Use string.h, not gdb_string.h.
	* arm-linux-nat.c: Use string.h, not gdb_string.h.
	* arm-linux-tdep.c: Use string.h, not gdb_string.h.
	* arm-tdep.c: Use string.h, not gdb_string.h.
	* arm-wince-tdep.c: Use string.h, not gdb_string.h.
	* armbsd-tdep.c: Use string.h, not gdb_string.h.
	* armnbsd-nat.c: Use string.h, not gdb_string.h.
	* armnbsd-tdep.c: Use string.h, not gdb_string.h.
	* armobsd-tdep.c: Use string.h, not gdb_string.h.
	* avr-tdep.c: Use string.h, not gdb_string.h.
	* ax-gdb.c: Use string.h, not gdb_string.h.
	* ax-general.c: Use string.h, not gdb_string.h.
	* bcache.c: Use string.h, not gdb_string.h.
	* bfin-tdep.c: Use string.h, not gdb_string.h.
	* breakpoint.c: Use string.h, not gdb_string.h.
	* build-id.c: Use string.h, not gdb_string.h.
	* buildsym.c: Use string.h, not gdb_string.h.
	* c-exp.y: Use string.h, not gdb_string.h.
	* c-lang.c: Use string.h, not gdb_string.h.
	* c-typeprint.c: Use string.h, not gdb_string.h.
	* c-valprint.c: Use string.h, not gdb_string.h.
	* charset.c: Use string.h, not gdb_string.h.
	* cli-out.c: Use string.h, not gdb_string.h.
	* cli/cli-cmds.c: Use string.h, not gdb_string.h.
	* cli/cli-decode.c: Use string.h, not gdb_string.h.
	* cli/cli-dump.c: Use string.h, not gdb_string.h.
	* cli/cli-interp.c: Use string.h, not gdb_string.h.
	* cli/cli-logging.c: Use string.h, not gdb_string.h.
	* cli/cli-script.c: Use string.h, not gdb_string.h.
	* cli/cli-setshow.c: Use string.h, not gdb_string.h.
	* cli/cli-utils.c: Use string.h, not gdb_string.h.
	* coffread.c: Use string.h, not gdb_string.h.
	* common/common-utils.c: Use string.h, not gdb_string.h.
	* common/filestuff.c: Use string.h, not gdb_string.h.
	* common/linux-procfs.c: Use string.h, not gdb_string.h.
	* common/linux-ptrace.c: Use string.h, not gdb_string.h.
	* common/signals.c: Use string.h, not gdb_string.h.
	* common/vec.h: Use string.h, not gdb_string.h.
	* core-regset.c: Use string.h, not gdb_string.h.
	* corefile.c: Use string.h, not gdb_string.h.
	* corelow.c: Use string.h, not gdb_string.h.
	* cp-abi.c: Use string.h, not gdb_string.h.
	* cp-support.c: Use string.h, not gdb_string.h.
	* cp-valprint.c: Use string.h, not gdb_string.h.
	* cris-tdep.c: Use string.h, not gdb_string.h.
	* d-lang.c: Use string.h, not gdb_string.h.
	* dbxread.c: Use string.h, not gdb_string.h.
	* dcache.c: Use string.h, not gdb_string.h.
	* demangle.c: Use string.h, not gdb_string.h.
	* dicos-tdep.c: Use string.h, not gdb_string.h.
	* disasm.c: Use string.h, not gdb_string.h.
	* doublest.c: Use string.h, not gdb_string.h.
	* dsrec.c: Use string.h, not gdb_string.h.
	* dummy-frame.c: Use string.h, not gdb_string.h.
	* dwarf2-frame.c: Use string.h, not gdb_string.h.
	* dwarf2loc.c: Use string.h, not gdb_string.h.
	* dwarf2read.c: Use string.h, not gdb_string.h.
	* elfread.c: Use string.h, not gdb_string.h.
	* environ.c: Use string.h, not gdb_string.h.
	* eval.c: Use string.h, not gdb_string.h.
	* event-loop.c: Use string.h, not gdb_string.h.
	* exceptions.c: Use string.h, not gdb_string.h.
	* exec.c: Use string.h, not gdb_string.h.
	* expprint.c: Use string.h, not gdb_string.h.
	* f-exp.y: Use string.h, not gdb_string.h.
	* f-lang.c: Use string.h, not gdb_string.h.
	* f-typeprint.c: Use string.h, not gdb_string.h.
	* f-valprint.c: Use string.h, not gdb_string.h.
	* fbsd-nat.c: Use string.h, not gdb_string.h.
	* findcmd.c: Use string.h, not gdb_string.h.
	* findvar.c: Use string.h, not gdb_string.h.
	* fork-child.c: Use string.h, not gdb_string.h.
	* frame.c: Use string.h, not gdb_string.h.
	* frv-linux-tdep.c: Use string.h, not gdb_string.h.
	* frv-tdep.c: Use string.h, not gdb_string.h.
	* gdb.c: Use string.h, not gdb_string.h.
	* gdb_bfd.c: Use string.h, not gdb_string.h.
	* gdbarch.c: Use string.h, not gdb_string.h.
	* gdbtypes.c: Use string.h, not gdb_string.h.
	* gnu-nat.c: Use string.h, not gdb_string.h.
	* gnu-v2-abi.c: Use string.h, not gdb_string.h.
	* gnu-v3-abi.c: Use string.h, not gdb_string.h.
	* go-exp.y: Use string.h, not gdb_string.h.
	* go-lang.c: Use string.h, not gdb_string.h.
	* go32-nat.c: Use string.h, not gdb_string.h.
	* hppa-hpux-tdep.c: Use string.h, not gdb_string.h.
	* hppa-linux-nat.c: Use string.h, not gdb_string.h.
	* hppanbsd-tdep.c: Use string.h, not gdb_string.h.
	* hppaobsd-tdep.c: Use string.h, not gdb_string.h.
	* i386-cygwin-tdep.c: Use string.h, not gdb_string.h.
	* i386-dicos-tdep.c: Use string.h, not gdb_string.h.
	* i386-linux-nat.c: Use string.h, not gdb_string.h.
	* i386-linux-tdep.c: Use string.h, not gdb_string.h.
	* i386-nto-tdep.c: Use string.h, not gdb_string.h.
	* i386-sol2-tdep.c: Use string.h, not gdb_string.h.
	* i386-tdep.c: Use string.h, not gdb_string.h.
	* i386bsd-tdep.c: Use string.h, not gdb_string.h.
	* i386gnu-nat.c: Use string.h, not gdb_string.h.
	* i386nbsd-tdep.c: Use string.h, not gdb_string.h.
	* i386obsd-tdep.c: Use string.h, not gdb_string.h.
	* i387-tdep.c: Use string.h, not gdb_string.h.
	* ia64-libunwind-tdep.c: Use string.h, not gdb_string.h.
	* ia64-linux-nat.c: Use string.h, not gdb_string.h.
	* inf-child.c: Use string.h, not gdb_string.h.
	* inf-ptrace.c: Use string.h, not gdb_string.h.
	* inf-ttrace.c: Use string.h, not gdb_string.h.
	* infcall.c: Use string.h, not gdb_string.h.
	* infcmd.c: Use string.h, not gdb_string.h.
	* inflow.c: Use string.h, not gdb_string.h.
	* infrun.c: Use string.h, not gdb_string.h.
	* interps.c: Use string.h, not gdb_string.h.
	* iq2000-tdep.c: Use string.h, not gdb_string.h.
	* irix5-nat.c: Use string.h, not gdb_string.h.
	* jv-exp.y: Use string.h, not gdb_string.h.
	* jv-lang.c: Use string.h, not gdb_string.h.
	* jv-typeprint.c: Use string.h, not gdb_string.h.
	* jv-valprint.c: Use string.h, not gdb_string.h.
	* language.c: Use string.h, not gdb_string.h.
	* linux-fork.c: Use string.h, not gdb_string.h.
	* linux-nat.c: Use string.h, not gdb_string.h.
	* lm32-tdep.c: Use string.h, not gdb_string.h.
	* m2-exp.y: Use string.h, not gdb_string.h.
	* m2-typeprint.c: Use string.h, not gdb_string.h.
	* m32c-tdep.c: Use string.h, not gdb_string.h.
	* m32r-linux-nat.c: Use string.h, not gdb_string.h.
	* m32r-linux-tdep.c: Use string.h, not gdb_string.h.
	* m32r-rom.c: Use string.h, not gdb_string.h.
	* m32r-tdep.c: Use string.h, not gdb_string.h.
	* m68hc11-tdep.c: Use string.h, not gdb_string.h.
	* m68k-tdep.c: Use string.h, not gdb_string.h.
	* m68kbsd-tdep.c: Use string.h, not gdb_string.h.
	* m68klinux-nat.c: Use string.h, not gdb_string.h.
	* m68klinux-tdep.c: Use string.h, not gdb_string.h.
	* m88k-tdep.c: Use string.h, not gdb_string.h.
	* macrocmd.c: Use string.h, not gdb_string.h.
	* main.c: Use string.h, not gdb_string.h.
	* mdebugread.c: Use string.h, not gdb_string.h.
	* mem-break.c: Use string.h, not gdb_string.h.
	* memattr.c: Use string.h, not gdb_string.h.
	* memory-map.c: Use string.h, not gdb_string.h.
	* mep-tdep.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-break.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-disas.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-env.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-stack.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-var.c: Use string.h, not gdb_string.h.
	* mi/mi-cmds.c: Use string.h, not gdb_string.h.
	* mi/mi-console.c: Use string.h, not gdb_string.h.
	* mi/mi-getopt.c: Use string.h, not gdb_string.h.
	* mi/mi-interp.c: Use string.h, not gdb_string.h.
	* mi/mi-main.c: Use string.h, not gdb_string.h.
	* mi/mi-parse.c: Use string.h, not gdb_string.h.
	* microblaze-rom.c: Use string.h, not gdb_string.h.
	* microblaze-tdep.c: Use string.h, not gdb_string.h.
	* mingw-hdep.c: Use string.h, not gdb_string.h.
	* minidebug.c: Use string.h, not gdb_string.h.
	* minsyms.c: Use string.h, not gdb_string.h.
	* mips-irix-tdep.c: Use string.h, not gdb_string.h.
	* mips-linux-tdep.c: Use string.h, not gdb_string.h.
	* mips-tdep.c: Use string.h, not gdb_string.h.
	* mips64obsd-tdep.c: Use string.h, not gdb_string.h.
	* mipsnbsd-tdep.c: Use string.h, not gdb_string.h.
	* mipsread.c: Use string.h, not gdb_string.h.
	* mn10300-linux-tdep.c: Use string.h, not gdb_string.h.
	* mn10300-tdep.c: Use string.h, not gdb_string.h.
	* monitor.c: Use string.h, not gdb_string.h.
	* moxie-tdep.c: Use string.h, not gdb_string.h.
	* mt-tdep.c: Use string.h, not gdb_string.h.
	* nbsd-tdep.c: Use string.h, not gdb_string.h.
	* nios2-linux-tdep.c: Use string.h, not gdb_string.h.
	* nto-procfs.c: Use string.h, not gdb_string.h.
	* nto-tdep.c: Use string.h, not gdb_string.h.
	* objc-lang.c: Use string.h, not gdb_string.h.
	* objfiles.c: Use string.h, not gdb_string.h.
	* opencl-lang.c: Use string.h, not gdb_string.h.
	* osabi.c: Use string.h, not gdb_string.h.
	* osdata.c: Use string.h, not gdb_string.h.
	* p-exp.y: Use string.h, not gdb_string.h.
	* p-lang.c: Use string.h, not gdb_string.h.
	* p-typeprint.c: Use string.h, not gdb_string.h.
	* parse.c: Use string.h, not gdb_string.h.
	* posix-hdep.c: Use string.h, not gdb_string.h.
	* ppc-linux-nat.c: Use string.h, not gdb_string.h.
	* ppc-sysv-tdep.c: Use string.h, not gdb_string.h.
	* ppcfbsd-tdep.c: Use string.h, not gdb_string.h.
	* ppcnbsd-tdep.c: Use string.h, not gdb_string.h.
	* ppcobsd-tdep.c: Use string.h, not gdb_string.h.
	* printcmd.c: Use string.h, not gdb_string.h.
	* procfs.c: Use string.h, not gdb_string.h.
	* prologue-value.c: Use string.h, not gdb_string.h.
	* python/py-auto-load.c: Use string.h, not gdb_string.h.
	* python/py-gdb-readline.c: Use string.h, not gdb_string.h.
	* ravenscar-thread.c: Use string.h, not gdb_string.h.
	* regcache.c: Use string.h, not gdb_string.h.
	* registry.c: Use string.h, not gdb_string.h.
	* remote-fileio.c: Use string.h, not gdb_string.h.
	* remote-m32r-sdi.c: Use string.h, not gdb_string.h.
	* remote-mips.c: Use string.h, not gdb_string.h.
	* remote-sim.c: Use string.h, not gdb_string.h.
	* remote.c: Use string.h, not gdb_string.h.
	* reverse.c: Use string.h, not gdb_string.h.
	* rs6000-aix-tdep.c: Use string.h, not gdb_string.h.
	* ser-base.c: Use string.h, not gdb_string.h.
	* ser-go32.c: Use string.h, not gdb_string.h.
	* ser-mingw.c: Use string.h, not gdb_string.h.
	* ser-pipe.c: Use string.h, not gdb_string.h.
	* ser-tcp.c: Use string.h, not gdb_string.h.
	* ser-unix.c: Use string.h, not gdb_string.h.
	* serial.c: Use string.h, not gdb_string.h.
	* sh-tdep.c: Use string.h, not gdb_string.h.
	* sh64-tdep.c: Use string.h, not gdb_string.h.
	* shnbsd-tdep.c: Use string.h, not gdb_string.h.
	* skip.c: Use string.h, not gdb_string.h.
	* sol-thread.c: Use string.h, not gdb_string.h.
	* solib-dsbt.c: Use string.h, not gdb_string.h.
	* solib-frv.c: Use string.h, not gdb_string.h.
	* solib-osf.c: Use string.h, not gdb_string.h.
	* solib-spu.c: Use string.h, not gdb_string.h.
	* solib-target.c: Use string.h, not gdb_string.h.
	* solib.c: Use string.h, not gdb_string.h.
	* somread.c: Use string.h, not gdb_string.h.
	* source.c: Use string.h, not gdb_string.h.
	* sparc-nat.c: Use string.h, not gdb_string.h.
	* sparc-sol2-tdep.c: Use string.h, not gdb_string.h.
	* sparc-tdep.c: Use string.h, not gdb_string.h.
	* sparc64-tdep.c: Use string.h, not gdb_string.h.
	* sparc64fbsd-tdep.c: Use string.h, not gdb_string.h.
	* sparc64nbsd-tdep.c: Use string.h, not gdb_string.h.
	* sparcnbsd-tdep.c: Use string.h, not gdb_string.h.
	* spu-linux-nat.c: Use string.h, not gdb_string.h.
	* spu-multiarch.c: Use string.h, not gdb_string.h.
	* spu-tdep.c: Use string.h, not gdb_string.h.
	* stabsread.c: Use string.h, not gdb_string.h.
	* stack.c: Use string.h, not gdb_string.h.
	* std-regs.c: Use string.h, not gdb_string.h.
	* symfile.c: Use string.h, not gdb_string.h.
	* symmisc.c: Use string.h, not gdb_string.h.
	* symtab.c: Use string.h, not gdb_string.h.
	* target.c: Use string.h, not gdb_string.h.
	* thread.c: Use string.h, not gdb_string.h.
	* tilegx-linux-nat.c: Use string.h, not gdb_string.h.
	* tilegx-tdep.c: Use string.h, not gdb_string.h.
	* top.c: Use string.h, not gdb_string.h.
	* tracepoint.c: Use string.h, not gdb_string.h.
	* tui/tui-command.c: Use string.h, not gdb_string.h.
	* tui/tui-data.c: Use string.h, not gdb_string.h.
	* tui/tui-disasm.c: Use string.h, not gdb_string.h.
	* tui/tui-file.c: Use string.h, not gdb_string.h.
	* tui/tui-layout.c: Use string.h, not gdb_string.h.
	* tui/tui-out.c: Use string.h, not gdb_string.h.
	* tui/tui-regs.c: Use string.h, not gdb_string.h.
	* tui/tui-source.c: Use string.h, not gdb_string.h.
	* tui/tui-stack.c: Use string.h, not gdb_string.h.
	* tui/tui-win.c: Use string.h, not gdb_string.h.
	* tui/tui-windata.c: Use string.h, not gdb_string.h.
	* tui/tui-winsource.c: Use string.h, not gdb_string.h.
	* typeprint.c: Use string.h, not gdb_string.h.
	* ui-file.c: Use string.h, not gdb_string.h.
	* ui-out.c: Use string.h, not gdb_string.h.
	* user-regs.c: Use string.h, not gdb_string.h.
	* utils.c: Use string.h, not gdb_string.h.
	* v850-tdep.c: Use string.h, not gdb_string.h.
	* valarith.c: Use string.h, not gdb_string.h.
	* valops.c: Use string.h, not gdb_string.h.
	* valprint.c: Use string.h, not gdb_string.h.
	* value.c: Use string.h, not gdb_string.h.
	* varobj.c: Use string.h, not gdb_string.h.
	* vax-tdep.c: Use string.h, not gdb_string.h.
	* vaxnbsd-tdep.c: Use string.h, not gdb_string.h.
	* vaxobsd-tdep.c: Use string.h, not gdb_string.h.
	* windows-nat.c: Use string.h, not gdb_string.h.
	* xcoffread.c: Use string.h, not gdb_string.h.
	* xml-support.c: Use string.h, not gdb_string.h.
	* xstormy16-tdep.c: Use string.h, not gdb_string.h.
	* xtensa-linux-nat.c: Use string.h, not gdb_string.h.
2013-11-18 13:29:00 -07:00
Pedro Alves 901461f8eb Print registers not saved in the frame as "<not saved>" instead of "<optimized out>".
Currently, in some scenarios, GDB prints <optimized out> when printing
outer frame registers.  An <optimized out> register is a confusing
concept.  What this really means is that the register is
call-clobbered, or IOW, not saved by the callee.  This patch makes GDB
say that instead.

Before patch:

 (gdb) p/x $rax $1 = <optimized out>
 (gdb) info registers rax
 rax            <optimized out>

After patch:

 (gdb) p/x $rax
 $1 = <not saved>
 (gdb) info registers rax
 rax            <not saved>

However, if for some reason the debug info describes a variable as
being in such a register (**), we still want to print <optimized out>
when printing the variable.  IOW, <not saved> is reserved for
inspecting registers at the machine level.  The patch uses
lval_register+optimized_out to encode the not saved registers, and
makes it so that optimized out variables always end up in
!lval_register values.

** See <https://sourceware.org/ml/gdb-patches/2012-08/msg00787.html>.
Current/recent enough GCC doesn't mark variables/arguments as being in
call-clobbered registers in the ranges corresponding to function
calls, while older GCCs did.  Newer GCCs will just not say where the
variable is, so GDB will end up realizing the variable is optimized
out.

frame_unwind_got_optimized creates not_lval optimized out registers,
so by default, in most cases, we'll see <optimized out>.

value_of_register is the function eval.c uses for evaluating
OP_REGISTER (again, $pc, etc.), and related bits.  It isn't used for
anything else.  This function makes sure to return lval_register
values.  The patch makes "info registers" and the MI equivalent use it
too.  I think it just makes a lot of sense, as this makes it so that
when printing machine registers ($pc, etc.), we go through a central
function.

We're likely to need a different encoding at some point, if/when we
support partially saved registers.  Even then, I think
value_of_register will still be the spot to tag the intention to print
machine register values differently.

value_from_register however may also return optimized out
lval_register values, so at a couple places where we're computing a
variable's location from a dwarf expression, we convert the resulting
value away from lval_register to a regular optimized out value.

Tested on x86_64 Fedora 17

gdb/
2013-10-02  Pedro Alves  <palves@redhat.com>

	* cp-valprint.c (cp_print_value_fields): Adjust calls to
	val_print_optimized_out.
	* jv-valprint.c (java_print_value_fields): Likewise.
	* p-valprint.c (pascal_object_print_value_fields): Likewise.
	* dwarf2loc.c (dwarf2_evaluate_loc_desc_full)
	<DWARF_VALUE_REGISTER>: If the register was not saved, return a
	new optimized out value.
	* findvar.c (address_from_register): Likewise.
	* frame.c (put_frame_register): Tweak error string to say the
	register was not saved, rather than optimized out.
	* infcmd.c (default_print_one_register_info): Adjust call to
	val_print_optimized_out.  Use value_of_register instead of
	get_frame_register_value.
	* mi/mi-main.c (output_register): Use value_of_register instead of
	get_frame_register_value.
	* valprint.c (valprint_check_validity): Likewise.
	(val_print_optimized_out): New value parameter.  If the value is
	lval_register, print <not saved> instead.
	(value_check_printable, val_print_scalar_formatted): Adjust calls
	to val_print_optimized_out.
	* valprint.h (val_print_optimized_out): New value parameter.
	* value.c (struct value) <optimized_out>: Extend comment.
	(error_value_optimized_out): New function.
	(require_not_optimized_out): Use it.  Use a different string for
	lval_register values.
	* value.h (error_value_optimized_out): New declaration.
	* NEWS: Mention <not saved>.

gdb/testsuite/
2013-10-02  Pedro Alves  <palves@redhat.com>

	* gdb.dwarf2/dw2-reg-undefined.exp <pattern_rax_rbx_rcx_print,
	pattern_rax_rbx_rcx_info>: Set to "<not saved>".
	* gdb.mi/mi-reg-undefined.exp (opt_out_pattern): Delete.
	(not_saved_pattern): New.
	Replace use of the former with the latter.

gdb/doc/
2013-10-02  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Registers): Expand description of saved registers
	in frames.  Explain <not saved>.
2013-10-02 16:15:46 +00:00
Jan Kratochvil b5eef7aadc Fix set debug frame output
gdb/
2013-09-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix set debug frame output.
	* frame.c (fprint_frame_type): Add TAILCALL_FRAME entry.  Move
	SENTINEL_FRAME entry lower to match enum frame_type order.
2013-09-26 20:01:25 +00:00