deliverable/binutils-gdb.git
8 years agoAdd casts to memory allocation related calls
Simon Marchi [Fri, 25 Sep 2015 18:08:06 +0000 (14:08 -0400)] 
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.

8 years ago[PATCH] Add micromips support to the MIPS simulator
Andrew Bennett [Fri, 25 Sep 2015 14:52:18 +0000 (15:52 +0100)] 
[PATCH] Add micromips support to the MIPS simulator

2015-09-25  Andrew Bennett  <andrew.bennett@imgtec.com>
        Ali Lown  <ali.lown@imgtec.com>

sim/common/
* sim-bits.h (EXTEND6): New macro.
(EXTEND12): New macro.
(EXTEND25): New macro.

sim/mips/
* Makefile.in (tmp-micromips): New rule.
(tmp-mach-multi): Add support for micromips.
* configure.ac (mips*-sde-elf* | mips*-mti-elf*): Made a multi sim
that works for both mips64 and micromips64.
(mipsisa32r2*-*-*): Made a multi sim that works for mips32 and
micromips32.
Add build support for micromips.
* dsp.igen (do_ph_s_absq, do_w_s_absq, do_qb_s_absq, do_addsc,
do_addwc, do_bitrev, do_extpv, do_extrv, do_extrv_s_h, do_insv,
do_lxx do_modsub, do_mthlip, do_mulsaq_s_w_ph, do_ph_packrl, do_qb_pick
do_ph_pick, do_qb_ph_precequ, do_qb_ph_preceu, do_w_preceq
do_w_ph_precrq, do_ph_qb_precrq, do_w_ph_rs_precrq do_qb_w_raddu,
do_rddsp, do_repl, do_shilov, do_ph_shl, do_qb_shl do_w_s_shllv,
do_ph_shrlv, do_w_r_shrav, do_wrdsp, do_qb_shrav, do_append,
do_balign, do_ph_w_mulsa, do_ph_qb_precr, do_prepend): New functions.
Refactored instruction code to use these functions.
* dsp2.igen: Refactored instruction code to use the new functions.
* interp.c (decode_coproc): Refactored to work with any instruction
encoding.
(isa_mode): New variable
(RSVD_INSTRUCTION): Changed to 0x00000039.
* m16.igen (BREAK16): Refactored instruction to use do_break16.
(JALX32): Add mips32, mips64, mips32r2 and mips64r2 models.
* micromips.dc: New file.
* micromips.igen: New file.
* micromips16.dc: New file.
* micromipsdsp.igen: New file.
* micromipsrun.c: New file.
* mips.igen (do_swc1): Changed to work with any instruction encoding.
(do_add do_addi do_andi do_dadd do_daddi do_dsll32 do_dsra32
do_dsrl32, do_dsub, do_break, do_break16, do_clo, do_clz, do_dclo
do_dclz, do_lb, do_lh, do_lwr, do_lwl, do_lwc, do_lw, do_lwu, do_lhu
do_ldc, do_lbu, do_ll, do_lld, do_lui, do_madd, do_dsp_madd, do_maddu
do_dsp_maddu, do_dsp_mfhi, do_dsp_mflo, do_movn, do_movz, do_msub
do_dsp_msub, do_msubu, do_dsp_msubu, do_mthi, do_dsp_mthi, do_mtlo
do_dsp_mtlo, do_mul, do_dsp_mult, do_dsp_multu, do_pref, do_sc, do_scd
do_sub, do_sw, do_teq, do_teqi, do_tge, do_tgei, do_tgeiu, do_tgeu, do_tlt
do_tlti, do_tltiu, do_tltu, do_tne, do_tnei, do_abs_fmt, do_add_fmt
do_alnv_ps, do_c_cond_fmt, do_ceil_fmt, do_cfc1, do_ctc1, do_cvt_d_fmt
do_cvt_l_fmt, do_cvt_ps_s, do_cvt_s_fmt, do_cvt_s_pl, do_cvt_s_pu
do_cvt_w_fmt, do_div_fmt, do_dmfc1b, do_dmtc1b, do_floor_fmt, do_luxc1_32
do_luxc1_64, do_lwc1, do_lwxc1, do_madd_fmt, do_mfc1b, do_mov_fmt, do_movtf
do_movtf_fmt, do_movn_fmt, do_movz_fmt, do_msub_fmt, do_mtc1b, do_mul_fmt
do_neg_fmt, do_nmadd_fmt, do_nmsub_fmt, do_pll_ps, do_plu_ps, do_pul_ps
do_puu_ps, do_recip_fmt, do_round_fmt, do_rsqrt_fmt, do_prefx, do_sdc1
do_suxc1_32, do_suxc1_64, do_sqrt_fmt, do_sub_fmt, do_swc1, do_swxc1
do_trunc_fmt): New functions, refactored from existing instructions.
Refactored instruction code to use these functions.
(RSVD): Changed to use new reserved instruction.
(loadstore_ea, not_word_value, unpredictable, check_mt_hilo, check_mf_hilo,
check_mult_hilo, check_div_hilo, check_u64, do_luxc1_32, do_sdc1, do_suxc1_32,
check_fmt_p, check_fpu, do_load_double, do_store_double):  Added micromips32
and micromips64 models.
Added include for micromips.igen and micromipsdsp.igen
Add micromips32 and micromips64 models.
(DecodeCoproc): Updated to use new macro definition.
* mips3264r2.igen (do_dsbh, do_dshd, do_dext, do_dextm, do_dextu, do_di,
do_dins, do_dinsm, do_ei, do_ext, do_mfhc1, do_mthc1, do_ins, do_dinsu,
do_seb, do_seh do_rdhwr, do_wsbh): New functions.
Refactored instruction code to use these functions.
* sim-main.h (CP0_operation): New enum.
(DecodeCoproc): Updated macro.
(IMEM32_MICROMIPS, IMEM16_MICROMIPS, MICROMIPS_MINOR_OPCODE,
MICROMIPS_DELAYSLOT_SIZE_ANY, MICROMIPS_DELAYSLOT_SIZE_16, MICROMIPS_DELAYSLOT_SIZE_32,
ISA_MODE_MIPS32 and ISA_MODE_MICROMIPS): New defines.
(sim_state): Add isa_mode field.

sim/testsuite/sim/mips/
       * basic.exp (run_micromips_test, run_sim_tests): New functions
Add support for micromips tests.
* hilo-hazard-4.s: New file.
* testutils.inc (_dowrite): Changed reserved instruction encoding.
(writemsg): Moved the la and li instructions before the data they are
assigned to, which prevents a bug where MIPS32 relocations are used instead
of micromips relocations when building for micromips.

8 years agoCorrect the generation of OR1K pc-relative relocations.
Peter Zotov [Fri, 25 Sep 2015 14:21:14 +0000 (15:21 +0100)] 
Correct the generation of OR1K pc-relative relocations.

gas PR ld/18759
* config/tc-or1k.c (tc_gen_reloc): Correct computation of PC
relative relocs.
* config/tc-or1k.h (GAS_CGEN_PRCEL_R_TYPE): Delete.

bfd * elf32-or1k.c (R_OR1K_32_PCREL): Set pcrel_offset to TRUE.
(R_OR1K_16_PCREL): Likewise.
(R_OR1K_8_PCREL): Likewise.

ld/tests * ld-elf/eh-frame-hdr: Expect to pass on the or1k-linux target.

8 years agoPOSIX shell compatibility of gas/configure.ac
Ryo ONODERA [Fri, 25 Sep 2015 02:03:17 +0000 (11:33 +0930)] 
POSIX shell compatibility of gas/configure.ac

* configure.ac (nds32): Don't use bash == in tests.
* configure: Regenerate.

8 years agoGeneralize enum regexp in gdb.cp/classes.exp.
Sandra Loosemore [Fri, 25 Sep 2015 01:22:57 +0000 (18:22 -0700)] 
Generalize enum regexp in gdb.cp/classes.exp.

2015-09-24 Sandra Loosemore <sandra@codesourcery.com>

gdb/testsuite/
* gdb.cp/classes.exp (test_enums): Generalize regexp to allow
short or char as base type.

8 years agoAutomatic date update in version.in
GDB Administrator [Fri, 25 Sep 2015 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoAccidentally added file. Removed it.
jamesbowman [Thu, 24 Sep 2015 23:40:41 +0000 (16:40 -0700)] 
Accidentally added file. Removed it.

8 years agoTest case, disassembler not showing RIMM literals correctly #14
jamesbowman [Thu, 24 Sep 2015 23:31:00 +0000 (16:31 -0700)] 
Test case, disassembler not showing RIMM literals correctly #14

8 years ago[FT32] Implement pointer to address conversion method.
jamesbowman [Thu, 24 Sep 2015 23:07:35 +0000 (16:07 -0700)] 
[FT32] Implement pointer to address conversion method.

FT32 is a Harvard architecture with two address spaces -- RAM and flash.
The patch properly implements the pointer to address conversion method.
There are some other small fixes to handle address spaces.

gdb/
* ft32-tdep.c (ft32_register_type): Return gdbarch_tdep
(gdbarch)->pc_type instead of builtin_func_ptr.
(ft32_pointer_to_address): New function.
(ft32_address_class_type_flags): New function.
(ft32_address_class_type_flags_to_name): New function.
(ft32_address_class_name_to_type_flags): New function.
(ft32_gdbarch_init): Set tdep->pc_type.  Call
set_gdbarch_pointer_to_address,
set_gdbarch_address_class_type_flags
set_gdbarch_address_class_name_to_type_flags,
and set_gdbarch_address_class_type_flags_to_name.
* ft32-tdep.h (struct gdbarch_tdep) <pc_type>: New field.

8 years agoRelative DT_RPATH/DT_RUNPATH vs. sysroot capable ld.
Alan Modra [Thu, 24 Sep 2015 03:43:57 +0000 (13:13 +0930)] 
Relative DT_RPATH/DT_RUNPATH vs. sysroot capable ld.

This fixes two problems.  First, the --sysroot option wasn't available
with a ld configured without --with-sysroot, a historical accident.
This led to people configuring binutils with --with-sysroot=/ in order
to enable sysroot support, which exposes a case where ld wrongly
prepends the sysroot to a relative path.

PR ld/18992
* ldmain.c (main): Always enable --sysroot.
* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Don't
prepend sysroot to relative rpath/runpath.

8 years agoAllow any size enum in gdb.cp/var-tag.exp.
Sandra Loosemore [Thu, 24 Sep 2015 00:12:07 +0000 (17:12 -0700)] 
Allow any size enum in gdb.cp/var-tag.exp.

2015-09-23 Sandra Loosemore <sandra@codesourcery.com>

gdb/testsuite/
* gdb.cp/var-tag.exp (do_global_tests): Generalize opt_underlying
to allow any size enum.

8 years agoAutomatic date update in version.in
GDB Administrator [Thu, 24 Sep 2015 00:00:10 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years ago[Ada] Fix handling of array renamings
Pierre-Marie de Rodat [Tue, 1 Sep 2015 14:18:40 +0000 (16:18 +0200)] 
[Ada] Fix handling of array renamings

Compilers can materialize renamings of arrays (or of accesses to arrays)
in Ada into variables whose types are references to the actual array
types.  Before this change, trying to use such an array renaming yielded
an error in GDB:

    (gdb) print my_array(1)
    cannot subscript or call a record
    (gdb) print my_array_ptr(1)
    cannot subscript or call something of type `(null)'

This behavior comes from bad handling for array renamings, in particular
the OP_FUNCALL expression operator handling from ada-lang.c
(ada_evaluate_subexp): in one place we turn the reference into a
pointer, but the code that follows expect the value to be an array.

This patch fixes how we handle references in call/subscript evaluation
so that we turn these references into the actual array values instead of
pointers to them.

gdb/ChangeLog:

* ada-lang.c (ada_evaluate_subexp) <OP_FUNCALL>: When the input
value is a reference, actually dereference it in order to get
the underlying value.

gdb/testsuite/ChangeLog:

* gdb.ada/array_ptr_renaming.exp: New testcase.
* gdb.ada/array_ptr_renaming/foo.adb: New file.
* gdb.ada/array_ptr_renaming/pack.ads: New file.

Tested on x86_64-linux, no regression.

8 years agoFix compile time warnings generated when compiling with clang.
Nick Clifton [Wed, 23 Sep 2015 17:05:16 +0000 (18:05 +0100)] 
Fix compile time warnings generated when compiling with clang.

bfd * bout.c (b_out_slurp_reloc_table): Cast constant to unsigned in
order to avoid problems with left shifting negative values.
(abs32code): Likewise.
* mach-o.c (FILE_ALIGN): Likewise.
* coff-rs6000.c (xcoff_debug_sections): Delete unused static
array.
* elf32-visium.c (visium_reloc_map): Likewise.
* elf32-arm.c (elf32_arm_final_link_relocate): Remove useless
calls to abs function.
* elf32-frv.c (_frvfdpic_relax_tls_entries): Likewise.
* elf32-score.c (score_elf_final_link_relocate): Likewise.
* elf32-score7.c (score_elf_final_link_relocate): Likewise.
* elf32-i860.c (i860_howto_pc26_reloc): Use multiplication instead
of shifting to create a negative mask.
* elf32-msp430.c (elf_backend_special_sections): Define.
* elfxx-mips.c (got_ofst_reloc_p): Delete unused function.
(got_hi16_reloc_p): Delete unused function.
* ppcboot.c (ppcboot_bfd_print_private_bfd_data): Fix test of
partition name.

gas * config/tc-ppc.c (insn_validate): Cast PPC_OPSHIFT_INV to an int.

opcode * ppc.h (PPC_OPSHIFT_INV): Use an unsigned constant when left
shifting.

ld * emultempl/elf32.em (ehdr_start_empty): New static variable.
(before_allocation): Use it to initialise ehdr_start_save.
* emultempl/pe.em (write_build_id): Remove useless double
parenthesis.
* emultempl/pep.em (write_build_id): Likewise.

opcodes * bfin-dis.c (fmtconst): Remove unnecessary call to the abs
function.
* tic30-dis.c (print_branch): Likewise.
* cgen-asm.c (cgen_parse_signed_integer): Cast integer to signed
value before left shifting.
* fr30-ibld.c (fr30_cgen_extract_operand): Likewise.
* hppa-dis.c (print_insn_hppa): Likewise.
* mips-dis.c (mips_cp0sel_names_mipsr5900): Delete unused static
array.
* msp430-dis.c (msp430_singleoperand): Likewise.
(msp430_doubleoperand): Likewise.
(print_insn_msp430): Likewise.
* nds32-asm.c (parse_operand): Likewise.
* sh-opc.h (MASK): Likewise.
* v850-dis.c (get_operand_value): Likewise.

8 years agoAdd support for files that contain multiple symbol index tables. Fixes PR 15835
Nick Clifton [Wed, 23 Sep 2015 16:23:58 +0000 (17:23 +0100)] 
Add support for files that contain multiple symbol index tables.  Fixes PR 15835

binutils PR binutils/15835
* readelf.c (struct elf_section_list): New structure.
(symtab_shndx_hdr): Replace with symtab_shndx_list.
(get_32bit_elf_symbols): Scan for a symbol index table matching
the symbol table in use.
(get_64bit_elf_symbols): Likewise.
(process_section_headers): Handle multiple symbol index sections.

bfd * elf-bfd.h (struct elf_section_list): New structure.
(struct elf_obj_tdata): Replace symtab_shndx_hdr with
symtab_shndx_list.  Delete symtab_shndx_section.
(elf_symtab_shndx): Replace macro with elf_symtab_shndx_list.
* elf.c (bfd_elf_get_syms): If symtab index sections are present,
scan them for the section that matches the provided symbol table.
(bfd_section_from_shdr): Record all SHT_SYMTAB_SHNDX sections.
(assign_section_numbers): Use the first symtab index table in the
list.
(_bfd_elf_compute_section_file_positions): Replace use of
symtab_shndx_hdr with use of symtab_shndx_list.
(find_section_in_list): New function.
(assign_file_postions_except_relocs): Use new function.
(_bfd_elf_copy_private_symbol_data): Likewise.
(swap_out_syms): Handle multiple symbol table index sections.
* elf32-m32c.c (m32c_elf_relax_section): Replace use of
symtab_shndx_hdr with use of symtab_shndx_list.
* elf32-rl78.c (rl78_elf_relax_section): Likewise.
* elf32-rx.c (rx_relax_section): Likewise.
* elf32-v850.c (v850_elf_relax_delete_bytes): Likewise.
* elflink.c (bfd_elf_final_link): Likewise.

8 years agosim: ft32: add character input port
James Bowman [Wed, 23 Sep 2015 02:43:56 +0000 (22:43 -0400)] 
sim: ft32: add character input port

The FT32 simulator has character output, of course. This patch
adds character input, which lets the simulator run interactive
FT32 applications, e.g. language interpreters.

8 years agoAutomatic date update in version.in
GDB Administrator [Wed, 23 Sep 2015 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agodoc: Fix substitute-path example
Simon Marchi [Tue, 22 Sep 2015 20:41:08 +0000 (16:41 -0400)] 
doc: Fix substitute-path example

Found by Marc Khouzam.

gdb/doc/ChangeLog:

* gdb.texinfo (Specifying Source Directories): Fix
substitute-path example.

8 years agoUpdate MIPS PIE tests for DF_1_PIE change
H.J. Lu [Tue, 22 Sep 2015 18:12:01 +0000 (11:12 -0700)] 
Update MIPS PIE tests for DF_1_PIE change

Since linker now sets the DF_1_PIE bit in the DT_FLAGS_1 tag for PIE,
we need to update MIPS PIE tests for it.

* ld-mips-elf/pie-n32.d: Updated.
* ld-mips-elf/pie-n64.d: Likewise.
* ld-mips-elf/pie-o32.d: Likewise.

8 years agoChange 7-byte NOP instruction for RX target, so that it only takes 1 cycle to excute.
Nick Clifton [Tue, 22 Sep 2015 16:32:28 +0000 (17:32 +0100)] 
Change 7-byte NOP instruction for RX target, so that it only takes 1 cycle to excute.

* config/tc-rx.c (nop_7): Recode using MAX.

8 years agoEnhance the RX disassembler to detect and report bad instructions.
Nick Clifton [Tue, 22 Sep 2015 16:21:13 +0000 (17:21 +0100)] 
Enhance the RX disassembler to detect and report bad instructions.

opcode * rx.h (enum RX_Size): Add RX_Bad_Size entry.

opcodes * rx-decode.opc (bwl): Use RX_Bad_Size.
(sbwl): Likewise.
(ubwl): Likewise.  Rename to ubw.
(uBWL): Rename to uBW.
Replace all references to uBWL with uBW.
* rx-decode.c: Regenerate.
* rx-dis.c (size_names): Add entry for RX_Bad_Size.
(opsize_names): Likewise.
(print_insn_rx): Detect and report RX_Bad_Size.

8 years agostap-probe: Remove unnecessary cast
Simon Marchi [Tue, 22 Sep 2015 15:17:52 +0000 (11:17 -0400)] 
stap-probe: Remove unnecessary cast

ret->args_u.text is const char *, probe_args is const char *, so no cast
is needed.  Found while doing cxx-conversion stuff, since it wouldn't
build in C++.

gdb/ChangeLog:

* stap-probe.c (handle_stap_probe): Remove unnecessary cast.

8 years agoSet DF_1_PIE in gld${EMULATION_NAME}_after_parse
H.J. Lu [Tue, 22 Sep 2015 13:08:55 +0000 (06:08 -0700)] 
Set DF_1_PIE in gld${EMULATION_NAME}_after_parse

We can't add OPTION_PIE to gld${EMULATION_NAME}_handle_option since
it has been handled in parse_args in lexsup.c.  This patch moves
setting DF_1_PIE to gld${EMULATION_NAME}_after_parse.

ld/

* emultempl/alphaelf.em (alpha_after_parse): Call
gld${EMULATION_NAME}_after_parse instead of
after_parse_default.
* emultempl/cr16elf.em (cr16elf_after_parse): Likewise.
* emultempl/crxelf.em (crxelf_after_parse); Likewise.
* emultempl/hppaelf.em (hppaelf_after_parse): Likewise.
* emultempl/mipself.em (mips_after_parse): Likewise.
* emultempl/nds32elf.em (nds32_elf_after_parse): Likewise.
* emultempl/elf32.em: Don't include ldlex.h.
(gld${EMULATION_NAME}_after_parse): New function.
(gld${EMULATION_NAME}_handle_option) [GENERATE_PIE_SCRIPT]
<OPTION_PIE>: Removed.
(ld_${EMULATION_NAME}_emulation): Replace after_parse_default
with gld${EMULATION_NAME}_after_parse.
* emultempl/ia64elf.em (gld${EMULATION_NAME}_after_parse):
Renamed to ...
(ia64elf_after_parse): This.  Call
gld${EMULATION_NAME}_after_parse instead of after_parse_default.
(LDEMUL_AFTER_PARSE): Replace gld${EMULATION_NAME}_after_parse
with ia64elf_after_parse.

ld/testsuite/

* ld-elf/pie.d: New test.

8 years agoSolaris PIE support
Rainer Orth [Tue, 22 Sep 2015 09:12:51 +0000 (11:12 +0200)] 
Solaris PIE support

include/elf:
* common.h (DF_1_STUB, DF_1_PIE): Define.

ld:
* emulparams/solaris2.sh (GENERATE_PIE_SCRIPT): Set to yes.

* emultempl/elf32.em: Include ldlex.h.
(gld${EMULATION_NAME}_handle_option) [GENERATE_PIE_SCRIPT]
<OPTION_PIE>: Set DF_1_PIE.

binutils:
* readelf.c (process_dynamic_section): Handle DF_1_STUB, DF_1_PIE.

8 years agoopcodes/ppc-opc.c: Add dscr and ctrl SPR mnemonics
Anton Blanchard [Tue, 22 Sep 2015 05:39:24 +0000 (15:39 +1000)] 
opcodes/ppc-opc.c: Add dscr and ctrl SPR mnemonics

opcodes/
* ppc-opc.c (powerpc_opcodes): Add mfdscr, mfctrl, mtdscr and mtctrl.

8 years agoUse bfd_get_32 and bfd_put_32 to access ch_type
H.J. Lu [Tue, 22 Sep 2015 02:38:40 +0000 (19:38 -0700)] 
Use bfd_get_32 and bfd_put_32 to access ch_type

The ch_type field in Elf64_External_Chdr is 4 bytes.  We should use
bfd_get_32 and bfd_put_32 to access it.

* bfd.c (bfd_update_compression_header): Use bfd_put_32 on
ch_type.
(bfd_check_compression_header): Use bfd_get_32 on ch_type.
(bfd_convert_section_contents): Use bfd_get_32 and bfd_put_32
on ch_type.

8 years agoAutomatic date update in version.in
GDB Administrator [Tue, 22 Sep 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoFormat ld option items
Alan Modra [Mon, 21 Sep 2015 23:40:44 +0000 (09:10 +0930)] 
Format ld option items

* ld.texinfo: Put --dotsyms/--no-dotsyms on separate lines.
Ditto for --save-restore-funcs and --tls-get-addr-optimize.

8 years agoAdd two missing consts
Simon Marchi [Mon, 21 Sep 2015 22:47:33 +0000 (18:47 -0400)] 
Add two missing consts

Two missing consts, found while doing cxx-conversion work.  We end up
with a char*, even though we pass a const char* to strstr.  I am pushing
this as obvious.

gdb/ChangeLog:

* cli/cli-setshow.c (cmd_show_list): Constify a variable.
* linespec.c (linespec_lexer_lex_string): Same.

8 years agoChange ch_type in Elf64_External_Chdr to 4 bytes
H.J. Lu [Mon, 21 Sep 2015 17:19:25 +0000 (10:19 -0700)] 
Change ch_type in Elf64_External_Chdr to 4 bytes

The ch_type field in Elf64_External_Chdr is 4 bytes, followed by a
4-byte padding.  This change doesn't introduce any functional change
since only the lower 32 bits of the ch_type field are used.

* external.h (Elf64_External_Chdr): Change ch_type to 4 bytes
and add ch_reserved.

8 years agoAdd NEWS entry for fast tracepoint support on aarch64-linux
Pierre Langlois [Mon, 21 Sep 2015 14:01:05 +0000 (15:01 +0100)] 
Add NEWS entry for fast tracepoint support on aarch64-linux

Here is a NEWS entry for this series:

gdb/ChangeLog:

* NEWS: Mention support for fast tracepoints on aarch64-linux.

8 years agoAdd a test case for fast tracepoints' locking mechanism
Pierre Langlois [Mon, 21 Sep 2015 14:01:05 +0000 (15:01 +0100)] 
Add a test case for fast tracepoints' locking mechanism

When installing a fast tracepoint, we create a jump pad with a
spin-lock.  This way, only one thread can collect a given tracepoint at
any time.  This test case checks that this lock actually works as
expected.

This test works by creating a function which overrides the in-process
agent library's gdb_collect function.  On start up, GDBserver will ask
GDB with the 'qSymbol' packet about symbols present in the inferior.
GDB will reply with the gdb_agent_gdb_collect function from the test
case instead of the one from the agent.

gdb/testsuite/ChangeLog:

* gdb.trace/ftrace-lock.c: New file.
* gdb.trace/ftrace-lock.exp: New file.

8 years agoAdd a gdb.trace test for instruction relocation
Pierre Langlois [Mon, 21 Sep 2015 14:01:05 +0000 (15:01 +0100)] 
Add a gdb.trace test for instruction relocation

This test case makes sure that relocating PC relative instructions does
not change their behaviors.  All PC relative AArch64 instructions are
covered.  While call and jump (32 bit relative) instructions are covered
on x86.

The test case creates a static array of function pointers for each
supported architecture.  Each function in this array tests a specific
instruction using inline assembly.  They all need to contain a symbol in
the form of 'set_point\[0-9\]+' and finish by either calling pass or
fail.  The number of 'set_pointN' needs to go from 0 to
(ARRAY_SIZE - 1).

The test will:
- look up the number of function pointers in the static array.
- set fast tracepoints on each 'set_point\[0-9\]+' symbol, one in each
  functions from 0 to (ARRAY_SIZE - 1).
- run the trace experiment and make sure the pass function is called for
  every function.

gdb/testsuite/ChangeLog:

* gdb.arch/insn-reloc.c: New file.
* gdb.arch/ftrace-insn-reloc.exp: New file.

8 years agoEnable fast tracepoint tests
Pierre Langlois [Mon, 21 Sep 2015 14:01:05 +0000 (15:01 +0100)] 
Enable fast tracepoint tests

gdb/testsuite/ChangeLog:

* gdb.trace/change-loc.h (func4) [__aarch64__]: Add a nop
instruction.
* gdb.trace/pendshr1.c (pendfunc): Likewise.
* gdb.trace/pendshr2.c (pendfunc2): Likewise.
* gdb.trace/range-stepping.c: Likewise.
* gdb.trace/trace-break.c: Likewise.
* gdb.trace/trace-mt.c (thread_function): Likewise.
* gdb.trace/ftrace.c (marker): Likewise.
* gdb.trace/trace-condition.c (marker): Likewise.
* gdb.trace/ftrace.exp: Enable ftrace test if is_aarch64_target.
* gdb.trace/trace-condition.exp: Set pcreg to "\$pc" if
is_aarch64_target.

8 years agoImplement target_emit_ops
Pierre Langlois [Mon, 21 Sep 2015 14:01:04 +0000 (15:01 +0100)] 
Implement target_emit_ops

This patch implements compiling agent expressions to native code for
AArch64.  This allows us to compile conditions set on fast tracepoints.

The compiled function has the following prologue:

High *------------------------------------------------------*
     | LR                                                   |
     | FP                                                   | <- FP
     | x1  (ULONGEST *value)                                |
     | x0  (unsigned char *regs)                            |
Low  *------------------------------------------------------*

We save the function's argument on the stack as well as the return
address and the frame pointer.  We then set the current frame pointer to
point to the previous one.

The generated code for the expression will freely update the stack
pointer so we use the frame pointer to refer to `*value' and `*regs'.
`*value' needs to be accessed in the epilogue of the function, in order
to set it to whatever is on top of the stack.  `*regs' needs to be passed
down to the `gdb_agent_get_raw_reg' function with the `reg' operation.

gdb/gdbserver/ChangeLog:

* linux-aarch64-low-.c: Include ax.h and tracepoint.h.
(enum aarch64_opcodes) <RET>, <SUBS>, <AND>, <ORR>, <ORN>,
<EOR>, <LSLV>, <LSRV>, <ASRV>, <SBFM>, <UBFM>, <CSINC>, <MUL>,
<NOP>: New.
(enum aarch64_condition_codes): New enum.
(w0): New static global.
(fp): Likewise.
(lr): Likewise.
(struct aarch64_memory_operand) <type>: New
MEMORY_OPERAND_POSTINDEX type.
(postindex_memory_operand): New helper function.
(emit_ret): New function.
(emit_load_store_pair): New function, factored out of emit_stp
with support for MEMORY_OPERAND_POSTINDEX.
(emit_stp): Rewrite using emit_load_store_pair.
(emit_ldp): New function.
(emit_load_store): Likewise.
(emit_ldr): Mention post-index instruction in comment.
(emit_ldrh): New function.
(emit_ldrb): New function.
(emit_ldrsw): Mention post-index instruction in comment.
(emit_str): Likewise.
(emit_subs): New function.
(emit_cmp): Likewise.
(emit_and): Likewise.
(emit_orr): Likewise.
(emit_orn): Likewise.
(emit_eor): Likewise.
(emit_mvn): Likewise.
(emit_lslv): Likewise.
(emit_lsrv): Likewise.
(emit_asrv): Likewise.
(emit_mul): Likewise.
(emit_sbfm): Likewise.
(emit_sbfx): Likewise.
(emit_ubfm): Likewise.
(emit_ubfx): Likewise.
(emit_csinc): Likewise.
(emit_cset): Likewise.
(emit_nop): Likewise.
(emit_ops_insns): New helper function.
(emit_pop): Likewise.
(emit_push): Likewise.
(aarch64_emit_prologue): New function.
(aarch64_emit_epilogue): Likewise.
(aarch64_emit_add): Likewise.
(aarch64_emit_sub): Likewise.
(aarch64_emit_mul): Likewise.
(aarch64_emit_lsh): Likewise.
(aarch64_emit_rsh_signed): Likewise.
(aarch64_emit_rsh_unsigned): Likewise.
(aarch64_emit_ext): Likewise.
(aarch64_emit_log_not): Likewise.
(aarch64_emit_bit_and): Likewise.
(aarch64_emit_bit_or): Likewise.
(aarch64_emit_bit_xor): Likewise.
(aarch64_emit_bit_not): Likewise.
(aarch64_emit_equal): Likewise.
(aarch64_emit_less_signed): Likewise.
(aarch64_emit_less_unsigned): Likewise.
(aarch64_emit_ref): Likewise.
(aarch64_emit_if_goto): Likewise.
(aarch64_emit_goto): Likewise.
(aarch64_write_goto_address): Likewise.
(aarch64_emit_const): Likewise.
(aarch64_emit_call): Likewise.
(aarch64_emit_reg): Likewise.
(aarch64_emit_pop): Likewise.
(aarch64_emit_stack_flush): Likewise.
(aarch64_emit_zero_ext): Likewise.
(aarch64_emit_swap): Likewise.
(aarch64_emit_stack_adjust): Likewise.
(aarch64_emit_int_call_1): Likewise.
(aarch64_emit_void_call_2): Likewise.
(aarch64_emit_eq_goto): Likewise.
(aarch64_emit_ne_goto): Likewise.
(aarch64_emit_lt_goto): Likewise.
(aarch64_emit_le_goto): Likewise.
(aarch64_emit_gt_goto): Likewise.
(aarch64_emit_ge_got): Likewise.
(aarch64_emit_ops_impl): New static global variable.
(aarch64_emit_ops): New target function, return
&aarch64_emit_ops_impl.
(struct linux_target_ops): Install it.

8 years agoAdd support for fast tracepoints
Pierre Langlois [Mon, 21 Sep 2015 14:01:04 +0000 (15:01 +0100)] 
Add support for fast tracepoints

This patch adds support for fast tracepoints for aarch64-linux.  With this
implementation, a tracepoint can only be placed in a +/- 128MB range of
the jump pad.  This is due to the unconditional branch instruction
being limited to a (26 bit << 2) offset from the current PC.

Three target operations are implemented:

- target_install_fast_tracepoint_jump_pad

Building the jump pad the biggest change of this patch.  We need to add
functions to emit all instructions needed to save and restore the
current state when the tracepoint is hit.  As well as implementing a
lock and creating a collecting_t object identifying the current thread.

Steps performed by the jump pad:

  * Save the current state on the stack.
  * Push a collecting_t object on the stack.  We read the special
  tpidr_el0 system register to get the thread ID.
  * Spin-lock on the shared memory location of all tracing threads.  We
  write the address of our collecting_t object there once we have the
  lock.
  * Call gdb_collect.
  * Release the lock.
  * Restore the state.

  * Execute the replaced instruction which will have been relocated.
  * Jump back to the program.

- target_get_thread_area

As implemented in ps_get_thread_area, target_get_thread_area uses ptrace
to fetch the NT_ARM_TLS register.  At the architecture level, NT_ARM_TLS
represents the tpidr_el0 system register.

So this ptrace call (if lwpid is the current thread):
~~~
ptrace (PTRACE_GETREGSET, lwpid, NT_ARM_TLS, &iovec);
~~~

Is equivalent to the following instruction:
~~~
msr x0, tpidr_el0
~~~

This instruction is used when creating the collecting_t object that
GDBserver can read to know if a given thread is currently tracing.

So target_get_thread_area must get the same thread IDs as what the jump
pad writes into its collecting_t object.

- target_get_min_fast_tracepoint_insn_len

This just returns 4.

gdb/gdbserver/ChangeLog:

* Makefile.in (linux-aarch64-ipa.o, aarch64-ipa.o): New rules.
* configure.srv (aarch64*-*-linux*): Add linux-aarch64-ipa.o and
aarch64-ipa.o.
* linux-aarch64-ipa.c: New file.
* linux-aarch64-low.c: Include arch/aarch64-insn.h, inttypes.h
and endian.h.
(aarch64_get_thread_area): New target method.
(extract_signed_bitfield): New helper function.
(aarch64_decode_ldr_literal): New function.
(enum aarch64_opcodes): New enum.
(struct aarch64_register): New struct.
(struct aarch64_operand): New struct.
(x0): New static global.
(x1): Likewise.
(x2): Likewise.
(x3): Likewise.
(x4): Likewise.
(w2): Likewise.
(ip0): Likewise.
(sp): Likewise.
(xzr): Likewise.
(aarch64_register): New helper function.
(register_operand): Likewise.
(immediate_operand): Likewise.
(struct aarch64_memory_operand): New struct.
(offset_memory_operand): New helper function.
(preindex_memory_operand): Likewise.
(enum aarch64_system_control_registers): New enum.
(ENCODE): New macro.
(emit_insn): New helper function.
(emit_b): New function.
(emit_bcond): Likewise.
(emit_cb): Likewise.
(emit_tb): Likewise.
(emit_blr): Likewise.
(emit_stp): Likewise.
(emit_ldp_q_offset): Likewise.
(emit_stp_q_offset): Likewise.
(emit_load_store): Likewise.
(emit_ldr): Likewise.
(emit_ldrsw): Likewise.
(emit_str): Likewise.
(emit_ldaxr): Likewise.
(emit_stxr): Likewise.
(emit_stlr): Likewise.
(emit_data_processing_reg): Likewise.
(emit_data_processing): Likewise.
(emit_add): Likewise.
(emit_sub): Likewise.
(emit_mov): Likewise.
(emit_movk): Likewise.
(emit_mov_addr): Likewise.
(emit_mrs): Likewise.
(emit_msr): Likewise.
(emit_sevl): Likewise.
(emit_wfe): Likewise.
(append_insns): Likewise.
(can_encode_int32_in): New helper function.
(aarch64_relocate_instruction): New function.
(aarch64_install_fast_tracepoint_jump_pad): Likewise.
(aarch64_get_min_fast_tracepoint_insn_len): Likewise.
(struct linux_target_ops): Install aarch64_get_thread_area,
aarch64_install_fast_tracepoint_jump_pad and
aarch64_get_min_fast_tracepoint_insn_len.

8 years agoMake aarch64_decode_adrp handle both ADR and ADRP instructions
Pierre Langlois [Mon, 21 Sep 2015 14:01:04 +0000 (15:01 +0100)] 
Make aarch64_decode_adrp handle both ADR and ADRP instructions

We will need to decode both ADR and ADRP instructions in GDBserver.
This patch makes common code handle both cases, even if GDB only needs
to decode the ADRP instruction.

gdb/ChangeLog:

* aarch64-tdep.c (aarch64_analyze_prologue): New is_adrp
variable.  Call aarch64_decode_adr instead of
aarch64_decode_adrp.
* arch/aarch64-insn.h (aarch64_decode_adrp): Delete.
(aarch64_decode_adr): New function declaration.
* arch/aarch64-insn.c (aarch64_decode_adrp): Delete.
(aarch64_decode_adr): New function, factored out from
aarch64_decode_adrp to decode both adr and adrp instructions.

8 years agoMove instruction decoding into new arch/ directory
Pierre Langlois [Mon, 21 Sep 2015 14:01:04 +0000 (15:01 +0100)] 
Move instruction decoding into new arch/ directory

This patch moves the following functions into the arch/ common
directory, in new files arch/aarch64-insn.{h,c}.  They are prefixed with
'aarch64_':

 - aarch64_decode_adrp
 - aarch64_decode_b
 - aarch64_decode_cb
 - aarch64_decode_tb

We will need them to implement fast tracepoints in GDBserver.

For consistency, this patch also adds the 'aarch64_' prefix to static
decoding functions that do not need to be shared right now.

V2:
 make sure the formatting issues propagated
 fix `gdbserver/configure.srv'.

gdb/ChangeLog:

* Makefile.in (ALL_64_TARGET_OBS): Add aarch64-insn.o.
(HFILES_NO_SRCDIR): Add arch/aarch64-insn.h.
(aarch64-insn.o): New rule.
* configure.tgt (aarch64*-*-elf): Add aarch64-insn.o.
(aarch64*-*-linux*): Likewise.
* arch/aarch64-insn.c: New file.
* arch/aarch64-insn.h: New file.
* aarch64-tdep.c: Include arch/aarch64-insn.h.
(aarch64_debug): Move to arch/aarch64-insn.c.  Declare in
arch/aarch64-insn.h.
(decode_add_sub_imm): Rename to ...
(aarch64_decode_add_sub_imm): ... this.
(decode_adrp): Rename to ...
(aarch64_decode_adrp): ... this.  Move to arch/aarch64-insn.c.
Declare in arch/aarch64-insn.h.
(decode_b): Rename to ...
(aarch64_decode_b): ... this.  Move to arch/aarch64-insn.c.
Declare in arch/aarch64-insn.h.
(decode_bcond): Rename to ...
(aarch64_decode_bcond): ... this.  Move to arch/aarch64-insn.c.
Declare in arch/aarch64-insn.h.
(decode_br): Rename to ...
(aarch64_decode_br): ... this.
(decode_cb): Rename to ...
(aarch64_decode_cb): ... this.  Move to arch/aarch64-insn.c.
Declare in arch/aarch64-insn.h.
(decode_eret): Rename to ...
(aarch64_decode_eret): ... this.
(decode_movz): Rename to ...
(aarch64_decode_movz): ... this.
(decode_orr_shifted_register_x): Rename to ...
(aarch64_decode_orr_shifted_register_x): ... this.
(decode_ret): Rename to ...
(aarch64_decode_ret): ... this.
(decode_stp_offset): Rename to ...
(aarch64_decode_stp_offset): ... this.
(decode_stp_offset_wb): Rename to ...
(aarch64_decode_stp_offset_wb): ... this.
(decode_stur): Rename to ...
(aarch64_decode_stur): ... this.
(decode_tb): Rename to ...
(aarch64_decode_tb): ... this.  Move to arch/aarch64-insn.c.
Declare in arch/aarch64-insn.h.
(aarch64_analyze_prologue): Adjust calls to renamed functions.

gdb/gdbserver/ChangeLog:

* Makefile.in (aarch64-insn.o): New rule.
* configure.srv (aarch64*-*-linux*): Add aarch64-insn.o.

8 years agoWrap gdb_agent_op_sizes by #ifndef IN_PROCESS_AGENT
Yao Qi [Mon, 21 Sep 2015 11:31:51 +0000 (12:31 +0100)] 
Wrap gdb_agent_op_sizes by #ifndef IN_PROCESS_AGENT

Hi,
I see the following build warning with recent GCC built from mainline,

aarch64-none-linux-gnu-gcc -g -O2    -I. -I/home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver -I/home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/../common -I/home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/../regformats -I/home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/.. -I/home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/../../include -I/home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/../gnulib/import -Ibuild-gnulib-gdbserver/import  -Wall -Wpointer-arith -Wformat-nonliteral -Wno-char-subscripts -Wempty-body -Wdeclaration-after-statement -Werror -DGDBSERVER  -DCONFIG_UST_GDB_INTEGRATION -fPIC -DIN_PROCESS_AGENT -fvisibility=hidden -c -o ax-ipa.o -MT ax-ipa.o -MMD -MP -MF .deps/ax-ipa.Tpo `echo " -Wall -Wpointer-arith -Wformat-nonliteral -Wno-char-subscripts -Wempty-body -Wdeclaration-after-statement " | sed "s/ -Wformat-nonliteral / -Wno-format-nonliteral /g"` /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/ax.c
/home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/ax.c:73:28: error: 'gdb_agent_op_sizes' defined but not used [-Werror=unused-const-variable]
 static const unsigned char gdb_agent_op_sizes [gdb_agent_op_last] =
                            ^
cc1: all warnings being treated as errors

gdb_agent_op_sizes is only used in function is_goto_target, which is
defined inside #ifndef IN_PROCESS_AGENT.  This warning is not arch
specific, so GCC mainline for other targets should produce this warning
too, although this warning is triggered by enabling aarch64 fast
tracepoint.  The fix is to move gdb_agent_op_sizes to

gdb/gdbserver:

2015-09-21  Yao Qi  <yao.qi@linaro.org>

* ax.c [!IN_PROCESS_AGENT] (gdb_agent_op_sizes): Define it.

8 years ago[gdbserver] Remove unused max_jump_pad_size
Yao Qi [Mon, 21 Sep 2015 10:49:22 +0000 (11:49 +0100)] 
[gdbserver] Remove unused max_jump_pad_size

This patch is to remove max_jump_pad_size which isn't used else where,
and it causes a recent gcc warning like this,

gdb/gdbserver/tracepoint.c:2920:18: error: 'max_jump_pad_size' defined but not used [-Werror=unused-const-variable]
 static const int max_jump_pad_size = 0x100;
                  ^
cc1: all warnings being treated as errors

This variable max_jump_pad_size wasn't used since it was added in 2010
by https://sourceware.org/ml/gdb-patches/2010-06/msg00002.html

gdb/gdbserver:

2015-09-21  Yao Qi  <yao.qi@linaro.org>

* tracepoint.c (max_jump_pad_size): Remove.

8 years agodwarf2read.c (add_partial_symbol): Remove outdated comments.
Doug Evans [Mon, 21 Sep 2015 04:48:31 +0000 (21:48 -0700)] 
dwarf2read.c (add_partial_symbol): Remove outdated comments.

gdb/ChangeLog:

* dwarf2read.c (add_partial_symbol): Remove outdated comments.

8 years agoAutomatic date update in version.in
GDB Administrator [Mon, 21 Sep 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agodwarf2_compute_name: add fixme, don't use same name as parameter for local
Doug Evans [Sun, 20 Sep 2015 21:13:54 +0000 (14:13 -0700)] 
dwarf2_compute_name: add fixme, don't use same name as parameter for local

gdb/ChangeLog:

* dwarf2read.c (dwarf2_compute_name): Add FIXME.  Don't use a local
variable name that collides with a parameter.

8 years agocrash printing non-local variable from nested subprogram
Joel Brobecker [Tue, 1 Sep 2015 20:20:32 +0000 (22:20 +0200)] 
crash printing non-local variable from nested subprogram

We have noticed that GDB would sometimes crash trying to print
from a nested function the value of a variable declared in an
enclosing scope. This appears to be target dependent, although
that correlation might only be fortuitious.  We noticed the issue
on x86_64-darwin, x86-vxworks6 and x86-solaris.  The investigation
was done on Darwin.

This is a new feature that was introduced by:

    commit 63e43d3aedb8b1112899c2d0ad74cbbee687e5d6
    Date:   Thu Feb 5 17:00:06 2015 +0100
    DWARF: handle non-local references in nested functions

We can reproduce the problem with one of the testcases that was
added with the patch (gdb.base/nested-subp1.exp), where we have...

    18 int
    19 foo (int i1)
    20 {
    21   int
    22   nested (int i2)
    23   {
    [...]
    27     return i1 * i2; /* STOP */
    28   }

...  After building the example program, and running until line 27,
try printing the value of "i1":

    % gdb gdb.base/nested-subp1
    (gdb) break foo.c:27
    (gdb) run
    Breakpoint 1, nested (i2=2) at /[...]/nested-subp1.c:27
    27          return i1 * i2; /* STOP */
    (gdb) p i1
    [1]    73090 segmentation fault  ../gdb -q gdb.base/nested-subp1

Ooops!

What happens is that, because the reference is non-local, we are trying
to follow the function's static link, which does...

    /* If we don't know how to compute FRAME's base address, don't give up:
       maybe the frame we are looking for is upper in the stace frame.  */
    if (framefunc != NULL
        && SYMBOL_BLOCK_OPS (framefunc)->get_frame_base != NULL
        && (SYMBOL_BLOCK_OPS (framefunc)->get_frame_base (framefunc, frame)
            == upper_frame_base))

... or, in other words, calls the get_frame_base "method" of
framefunc's struct symbol_block_ops data. This resolves to
the block_op_get_frame_base function.

Looking at the function's implementation, we see:

  struct dwarf2_locexpr_baton *dlbaton;
  [...]
  dlbaton = SYMBOL_LOCATION_BATON (framefunc);
  [...]
  result = dwarf2_evaluate_loc_desc (type, frame, start, length,
                                     dlbaton->per_cu);
                                     ^^^^^^^^^^^^^^^

Printing dlbaton->per_cu gives a value that seems fairly bogus for
a memory address (0x60). Because of it, dwarf2_evaluate_loc_desc
then crashes trying to dereference it.

What's different on Darwin compared to Linux is that the function's
frame base is encoded using the following form:

        .byte   0x40    # uleb128 0x40; (DW_AT_frame_base)
        .byte   0x6     # uleb128 0x6; (DW_FORM_data4)

... and so dwarf2_symbol_mark_computed ends up creating
a SYMBOL_LOCATION_BATON as a struct dwarf2_loclist_baton:

  if (attr_form_is_section_offset (attr)
      /* .debug_loc{,.dwo} may not exist at all, or the offset may be outside
         the section.  If so, fall through to the complaint in the
         other branch.  */
      && DW_UNSND (attr) < dwarf2_section_size (objfile, section))
    {
      struct dwarf2_loclist_baton *baton;
      [...]
      SYMBOL_LOCATION_BATON (sym) = baton;

However, if you look more closely at block_op_get_frame_base's
implementation, you'll notice that the function extracts the
symbol's SYMBOL_LOCATION_BATON as a dwarf2_locexpr_baton
(a DWARF _expression_ rather than a _location list_).
That's why we end up decoding the DLBATON improperly, and thus
pass a random dlbaton->per_cu when calling dwarf2_evaluate_loc_desc.

This works on x86_64-linux, because we indeed have the frame base
described using a different form:

        .uleb128 0x40   # (DW_AT_frame_base)
        .uleb128 0x18   # (DW_FORM_exprloc)

This patch fixes the issue by doing what we do for most (if not all)
other such methods: providing one implementation each for loc-list,
and loc-expr. Both implementations are nearly identical, so perhaps
we might later want to improve this. But this patch first tries to
fix the crash first, leaving the design issue for later.

gdb/ChangeLog:

        * dwarf2loc.c (locexpr_get_frame_base): Renames
        block_op_get_frame_base.
        (dwarf2_block_frame_base_locexpr_funcs): Replace reference to
        block_op_get_frame_base by reference to locexpr_get_frame_base.
        (loclist_get_frame_base): New function, near identical copy of
        locexpr_get_frame_base.
        (dwarf2_block_frame_base_loclist_funcs): Replace reference to
        block_op_get_frame_base by reference to loclist_get_frame_base.

Tested on x86_64-darwin (AdaCore testsuite), and x86_64-linux
(official testsuite).

8 years agoAdd --no-dynamic-linker option to ld, for static PIE use
Rich Felker [Sun, 20 Sep 2015 02:50:19 +0000 (12:20 +0930)] 
Add --no-dynamic-linker option to ld, for static PIE use

Inhibits output of .interp section in ELF executables.

include/
* bfdlink.h (struct bfd_link_info): Add "nointerp" field.
bfd/
* elflink.c (_bfd_elf_link_create_dynamic_sections): Don't create
.interp when info->nointerp.
(bfd_elf_size_dynamic_sections): Adjust assert.
* elf32-arm.c (elf32_arm_size_dynamic_sections): Don't size .interp
when info->nointerp.
* elf32-bfin.c (elf32_bfinfdpic_size_dynamic_sections): Likewise.
* elf32-cr16.c (_bfd_cr16_elf_size_dynamic_sections): Likewise.
* elf32-cris.c (elf_cris_size_dynamic_sections): Likewise.
* elf32-frv.c (elf32_frvfdpic_size_dynamic_sections): Likewise.
* elf32-hppa.c (elf32_hppa_size_dynamic_sections): Likewise.
* elf32-i370.c (i370_elf_size_dynamic_sections): Likewise.
* elf32-i386.c (elf_i386_size_dynamic_sections): Likewise.
* elf32-lm32.c (lm32_elf_size_dynamic_sections): Likewise.
* elf32-m32r.c (m32r_elf_size_dynamic_sections): Likewise.
* elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise.
* elf32-metag.c (elf_metag_size_dynamic_sections): Likewise.
* elf32-nds32.c (nds32_elf_size_dynamic_sections): Likewise.
* elf32-nios2.c (nios2_elf32_size_dynamic_sections): Likewise.
* elf32-or1k.c (or1k_elf_size_dynamic_sections): Likewise.
* elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise.
* elf32-s390.c (elf_s390_size_dynamic_sections): Likewise.
* elf32-score.c (s3_bfd_score_elf_size_dynamic_sections): Likewise.
* elf32-score7.c (s7_bfd_score_elf_size_dynamic_sections): Likewise.
* elf32-sh.c (sh_elf_size_dynamic_sections): Likewise.
* elf32-tic6x.c (elf32_tic6x_size_dynamic_sections): Likewise.
* elf32-tilepro.c (tilepro_elf_size_dynamic_sections): Likewise.
* elf32-vax.c (elf_vax_size_dynamic_sections): Likewise.
* elf32-xtensa.c (elf_xtensa_size_dynamic_sections): Likewise.
* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise.
* elf64-hppa.c (elf64_hppa_size_dynamic_sections): Likewise.
* elf64-ppc.c (ppc64_elf_size_dynamic_sections): Likewise.
* elf64-s390.c (elf_s390_size_dynamic_sections): Likewise.
* elf64-sh64.c (sh64_elf64_size_dynamic_sections): Likewise.
* elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections): Likewise.
* elfnn-ia64.c (elfNN_ia64_size_dynamic_sections): Likewise.
* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Likewise.
* elfxx-tilegx.c (tilegx_elf_size_dynamic_sections): Likewise.
ld/
* ld.texinfo (--no-dynamic-linker): Document.
* ldlex.h (enum option_values): Add OPTION_NO_DYNAMIC_LINKER.
* lexsup.c (ld_options, parse_args): Handle --no-dynamic-linker.

8 years agoAutomatic date update in version.in
GDB Administrator [Sun, 20 Sep 2015 00:00:10 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoReplace current_inferior ()->gdbarch with its wrapper target_gdbarch.
Doug Evans [Sat, 19 Sep 2015 15:29:58 +0000 (08:29 -0700)] 
Replace current_inferior ()->gdbarch with its wrapper target_gdbarch.

gdb/ChangeLog:

* ravenscar-thread.c (ravenscar_inferior_created): Replace
current_inferior ()->gdbarch with its wrapper target_gdbarch.

8 years agolinux-thread-db.c (record_thread): Return the created thread.
Doug Evans [Sat, 19 Sep 2015 06:21:04 +0000 (23:21 -0700)] 
linux-thread-db.c (record_thread): Return the created thread.

gdb/ChangeLog:

* linux-thread-db.c (record_thread): Return the created thread.
(thread_from_lwp): Likewise.
(thread_db_get_thread_local_address): Update.

8 years agosymtab.h (general_symbol_info) <mangled_lang>: delete and move up only member.
Doug Evans [Sat, 19 Sep 2015 05:30:22 +0000 (22:30 -0700)] 
symtab.h (general_symbol_info) <mangled_lang>: delete and move up only member.

gdb/ChangeLog:

* symtab.h (general_symbol_info) <mangled_lang>: Delete struct,
move only member demangled_name up.  All uses updated.

8 years agodefault_read_var_value <LOC_UNRESOLVED>: Include minsym kind in error message.
Doug Evans [Sat, 19 Sep 2015 04:43:38 +0000 (21:43 -0700)] 
default_read_var_value <LOC_UNRESOLVED>: Include minsym kind in error message.

bfd/ChangeLog:

* targets.c (enum bfd_flavour): Add comment.
(bfd_flavour_name): New function.
* bfd-in2.h: Regenerate.

gdb/ChangeLog:

* findvar.c (default_read_var_value) <LOC_UNRESOLVED>: Include the
kind of minimal symbol in the error message.
* objfiles.c (objfile_flavour_name): New function.
* objfiles.h (objfile_flavour_name): Declare.

gdb/testsuite/ChangeLog:

* gdb.dwarf2/dw2-bad-unresolved.c: New file.
* gdb.dwarf2/dw2-bad-unresolved.exp: New file.

8 years agoAutomatic date update in version.in
GDB Administrator [Sat, 19 Sep 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoFix directory prefix in gdb.base/dso2dso.exp.
Sandra Loosemore [Fri, 18 Sep 2015 19:21:06 +0000 (12:21 -0700)] 
Fix directory prefix in gdb.base/dso2dso.exp.

2015-09-18  Sandra Loosemore  <sandra@codesourcery.com>

gdb/testsuite/
* gdb.base/dso2dso.exp: Don't use directory prefix when setting
the breakpoint.

8 years agoFix pathname prefix and timeout issues in gdb.mi/mi-pending.exp.
Sandra Loosemore [Fri, 18 Sep 2015 18:52:26 +0000 (11:52 -0700)] 
Fix pathname prefix and timeout issues in gdb.mi/mi-pending.exp.

2015-09-18  Sandra Loosemore  <sandra@codesourcery.com>

gdb/testsuite/
* gdb.mi/mi-pending.exp: Don't use directory prefix when setting
the pending breakpoint.  Remove timeout override for "Run till
MI pending breakpoint on pendfunc3 on thread 2" test.

8 years agoGeneralize breakpoint pattern in gdb.mi/mi-cli.exp.
Sandra Loosemore [Fri, 18 Sep 2015 16:39:31 +0000 (09:39 -0700)] 
Generalize breakpoint pattern in gdb.mi/mi-cli.exp.

2015-09-18  Sandra Loosemore  <sandra@codesourcery.com>

gdb/testsuite/
* gdb.mi/mi-cli.exp: Don't require directory prefix in breakpoint
filename pattern.

8 years agoGeneralize filename pattern in gdb.mi/mi-dprintf-pending.exp.
Sandra Loosemore [Fri, 18 Sep 2015 16:22:02 +0000 (09:22 -0700)] 
Generalize filename pattern in gdb.mi/mi-dprintf-pending.exp.

2015-09-18  Sandra Loosemore  <sandra@codesourcery.com>

gdb/testsuite/
* gdb.mi/mi-dprintf-pending.exp: Don't require directory prefix
in breakpoint filename pattern.

8 years agoFix shared library load in gdb.base/global-var-nested-by-dso.exp.
Sandra Loosemore [Fri, 18 Sep 2015 16:05:37 +0000 (09:05 -0700)] 
Fix shared library load in gdb.base/global-var-nested-by-dso.exp.

2015-09-18  Sandra Loosemore  <sandra@codesourcery.com>

gdb/testsuite/
* gdb.base/global-var-nested-by-dso.exp: Call gdb_load_shlibs.

8 years agoRequire readline for gdb.linespec/explicit.exp tab-completion tests.
Sandra Loosemore [Fri, 18 Sep 2015 15:54:20 +0000 (08:54 -0700)] 
Require readline for gdb.linespec/explicit.exp tab-completion tests.

2015-09-18  Sandra Loosemore  <sandra@codesourcery.com>

gdb/testsuite/
* gdb.linespec/explicit.exp: Check for readline support for
tab-completion tests.  Fix obvious typo.

8 years agoaarch64 multi-arch (part 3): get thread area
Yao Qi [Fri, 18 Sep 2015 12:59:42 +0000 (13:59 +0100)] 
aarch64 multi-arch (part 3): get thread area

With the kernle fix <http://lists.infradead.org/pipermail/linux-arm-kernel/2015-July/356511.html>,
aarch64 GDB is able to read the base of thread area of 32-bit arm
program through NT_ARM_TLS.

This patch is to teach both GDB and GDBserver to read the base of
thread area correctly in the multi-arch case.  A new function
aarch64_ps_get_thread_area is added, and is shared between GDB and
GDBserver.

With this patch applied, the following fails in multi-arch testing
(GDB is aarch64 but the test cases are arm) are fixed,

 -FAIL: gdb.threads/tls-nodebug.exp: thread local storage
 -FAIL: gdb.threads/tls-shared.exp: print thread local storage variable
 -FAIL: gdb.threads/tls-so_extern.exp: print thread local storage variable
 -FAIL: gdb.threads/tls-var.exp: print tls_var
 -FAIL: gdb.threads/tls.exp: first thread local storage
 -FAIL: gdb.threads/tls.exp: first another thread local storage
 -FAIL: gdb.threads/tls.exp: p a_thread_local
 -FAIL: gdb.threads/tls.exp: p file2_thread_local
 -FAIL: gdb.threads/tls.exp: p a_thread_local second time

gdb:

2015-09-18  Yao Qi  <yao.qi@linaro.org>

* nat/aarch64-linux.c: Include elf/common.h,
nat/gdb_ptrace.h, asm/ptrace.h and sys/uio.h.
(aarch64_ps_get_thread_area): New function.
* nat/aarch64-linux.h: Include gdb_proc_service.h.
(aarch64_ps_get_thread_area): Declare.
* aarch64-linux-nat.c (ps_get_thread_area): Call
aarch64_ps_get_thread_area.

gdb/gdbserver:

2015-09-18  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c: Don't include sys/uio.h.
(ps_get_thread_area): Call aarch64_ps_get_thread_area.

8 years agobtrace: honour scheduler-locking for all-stop targets
Markus Metzger [Wed, 16 Sep 2015 07:05:22 +0000 (09:05 +0200)] 
btrace: honour scheduler-locking for all-stop targets

In all-stop mode, record btrace maintains the old behaviour of an implicit
scheduler-locking on.

Now that we added a scheduler-locking mode to model this old behaviour, we
don't need the respective code in record btrace anymore.  Remove it.

For all-stop targets, step inferior_ptid and continue other threads matching
the argument ptid.  Assert that inferior_ptid matches the argument ptid.

This should make record btrace honour scheduler-locking.

gdb/
* record-btrace.c (record_btrace_resume): Honour scheduler-locking.

testsuite/
* gdb.btrace/multi-thread-step.exp: Test scheduler-locking on, step,
and replay.

8 years agoinfrun: scheduler-locking replay
Markus Metzger [Mon, 7 Sep 2015 13:41:00 +0000 (15:41 +0200)] 
infrun: scheduler-locking replay

Record targets behave as if scheduler-locking were on in replay mode.  Add a
new scheduler-locking option "replay" to make this implicit behaviour explicit.
It behaves like "on" in replay mode and like "off" in record mode.

By making the current behaviour a scheduler-locking option, we allow the user
to change it.  Since it is the current behaviour, this new option is also
the new default.

One caveat is that when resuming a thread that is at the end of its execution
history, record btrace implicitly stops replaying other threads and resumes
the entire process.  This is a convenience feature to not require the user
to explicitly move all other threads to the end of their execution histories
before being able to resume the process.

We mimick this behaviour with scheduler-locking replay and move it from
record-btrace into infrun.  With all-stop on top of non-stop, we can't do
this in record-btrace anymore.

Record full does not really support multi-threading and is therefore not
impacted.  If it were extended to support multi-threading, it would 'benefit'
from this change.  The good thing is that all record targets will behave the
same with respect to scheduler-locking.

I put the code for this into clear_proceed_status.  It also sends the
about_to_proceed notification.

gdb/
* NEWS: Announce new scheduler-locking mode.
* infrun.c (schedlock_replay): New.
(scheduler_enums): Add schedlock_replay.
(scheduler_mode): Change default to schedlock_replay.
(user_visible_resume_ptid): Handle schedlock_replay.
(clear_proceed_status_thread): Stop replaying if resumed thread is
not replaying.
(schedlock_applies): Handle schedlock_replay.
(_initialize_infrun): Document new scheduler-locking mode.
* record-btrace.c (record_btrace_resume): Remove code to stop other
threads when not replaying the resumed thread.

doc/
* gdb.texinfo (All-Stop Mode): Describe new scheduler-locking mode.

8 years agotarget: add to_record_will_replay target method
Markus Metzger [Thu, 17 Sep 2015 09:14:55 +0000 (11:14 +0200)] 
target: add to_record_will_replay target method

Add a new target method to_record_will_replay to query if there is a record
target that will replay at least one thread matching the argument PTID if it
were executed in the argument execution direction.

gdb/
* record-btrace.c ((record_btrace_will_replay): New.
(init_record_btrace_ops): Initialize to_record_will_replay.
* record-full.c ((record_full_will_replay): New.
(init_record_full_ops): Initialize to_record_will_replay.
* target-delegates.c: Regenerated.
* target.c (target_record_will_replay): New.
* target.h (struct target_ops) <to_record_will_replay>: New.
(target_record_will_replay): New.

Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
8 years agotarget: add to_record_stop_replaying target method
Markus Metzger [Tue, 8 Sep 2015 07:42:20 +0000 (09:42 +0200)] 
target: add to_record_stop_replaying target method

Add a new target method to_record_stop_replaying to stop replaying.

gdb/
* record-btrace.c (record_btrace_resume): Call
target_record_stop_replaying.
(record_btrace_stop_replaying_all): New.
(init_record_btrace_ops): Initialize to_record_stop_replaying.
* record-full.c (record_full_stop_replaying): New.
(init_record_full_ops ): Initialize to_record_stop_replaying.
* target-delegates.c: Regenerated.
* target.c (target_record_stop_replaying): New.
* target.h (struct target_ops) <to_record_stop_replaying>: New.
(target_record_stop_replaying): New.

8 years agobtrace: allow full memory and register access for non-replaying threads
Markus Metzger [Tue, 8 Sep 2015 07:05:38 +0000 (09:05 +0200)] 
btrace: allow full memory and register access for non-replaying threads

The record btrace target does not allow accessing memory and storing registers
while replaying.  For multi-threaded applications, this prevents those
accesses also for threads that are at the end of their execution history as
long as at least one thread is replaying.

Change this to only check if the selected thread is replaying.  This allows
threads that are at the end of their execution history to read and write
memory and to store registers.

Also change the error message to reflect this change.

gdb/
* record-btrace.c (record_btrace_xfer_partial)
(record_btrace_store_registers, record_btrace_prepare_to_store):
Call record_btrace_is_replaying with inferior_ptid instead of
minus_one_ptid.
(record_btrace_store_registers): Change error message.

8 years agotarget, record: add PTID argument to to_record_is_replaying
Markus Metzger [Tue, 8 Sep 2015 06:26:16 +0000 (08:26 +0200)] 
target, record: add PTID argument to to_record_is_replaying

The to_record_is_replaying target method is used to query record targets if
they are replaying.  This is currently interpreted as "is any thread being
replayed".

Add a PTID argument and change the interpretation to "is any thread matching
PTID being replayed".

Change all users to pass minus_one_ptid to preserve the old meaning.

The record full target does not really support multi-threading and ignores
the PTID argument.

gdb/
* record-btrace.c (record_btrace_is_replaying): Add ptid argument.
Update users to pass minus_one_ptid.
* record-full.c (record_full_is_replaying): Add ptid argument (ignored).
* record.c (cmd_record_delete): Pass inferior_ptid to
target_record_is_replaying.
* target-delegates.c: Regenerated.
* target.c (target_record_is_replaying): Add ptid argument.
* target.h (struct target_ops) <to_record_is_replaying>: Add ptid
argument.
(target_record_is_replaying): Add ptid argument.

8 years agobtrace: non-stop
Markus Metzger [Wed, 26 Aug 2015 09:33:07 +0000 (11:33 +0200)] 
btrace: non-stop

Support non-stop mode in record btrace.

gdb/
* record-btrace.c (record_btrace_open): Remove non_stop check.
* NEWS: Announce that record btrace supports non-stop mode.

testsuite/
* gdb.btrace/non-stop.c: New.
* gdb.btrace/non-stop.exp: New.

8 years agoinfrun: switch to NO_HISTORY thread
Markus Metzger [Mon, 7 Sep 2015 08:00:46 +0000 (10:00 +0200)] 
infrun: switch to NO_HISTORY thread

A thread that runs out of its execution history is stopped.  We already set
stop_pc and call stop_waiting.  But we do not switch to the stopped thread.

In normal_stop, we call finish_thread_state_cleanup to set a thread's running
state.  In all-stop mode, we call it with minus_one_ptid; in non-stop mode, we
only call it for inferior_ptid.

If in non-stop mode normal_stop is called on behalf of a thread that is not
inferior_ptid, that other thread will still be reported as running.  If it is
actually stopped it can't be resumed again.

Record targets traditionally don't support non-stop and only resume
inferior_ptid.  So this has not been a problem, so far.

Switch to the eventing thread for NO_HISTORY events as preparation to support
non-stop for the record btrace target.

gdb/
* infrun.c (handle_inferior_event_1): Switch to the eventing thread
in the TARKET_WAITKIND_NO_HISTORY case.

8 years agobtrace: async
Markus Metzger [Thu, 27 Aug 2015 14:24:38 +0000 (16:24 +0200)] 
btrace: async

The record btrace target runs synchronous with GDB.  That is, GDB steps
resumed threads in record btrace's to_wait method.  Without GDB calling
to_wait, nothing happens 'on the target'.

Check for further expected events in to_wait before reporting the current
event and mark record btrace's async event handler in async mode.

gdb/
* record-btrace.c (record_btrace_maybe_mark_async_event): New.
(record_btrace_wait): Call record_btrace_maybe_mark_async_event.

8 years agobtrace: temporarily set inferior_ptid in record_btrace_start_replaying
Markus Metzger [Wed, 26 Aug 2015 13:37:55 +0000 (15:37 +0200)] 
btrace: temporarily set inferior_ptid in record_btrace_start_replaying

Get_current_frame uses inferior_ptid.  In record_btrace_start_replaying,
we need to get the current frame of the argument thread.  So far, this
has always been inferior_ptid.  With non-stop, this is not guaranteed.

Temporarily set inferior_ptid to the ptid of the argument thread.

We already temporarily set the argument thread's executing flag to false.

Move both into a new function get_thread_current_frame that does the temporary
adjustments, calls get_current_frame, and restores the previous values.

gdb/
* record-btrace.c (get_thread_current_frame): New.
(record_btrace_start_replaying): Call get_thread_current_frame.

8 years agobtrace: resume all requested threads
Markus Metzger [Tue, 25 Aug 2015 11:42:39 +0000 (13:42 +0200)] 
btrace: resume all requested threads

The record targets are implicitly schedlocked.  They only step the current
thread and keep other threads where they are.

Change record btrace to step all requested threads in to_resume.

For maintenance and debugging, we keep the old behaviour when the target below
is not non-stop.  Enable with "maint set target-non-stop on".

gdb/
* record-btrace.c (record_btrace_resume_thread): A move request
overwrites a previous move request.
(record_btrace_find_resume_thread): Removed.
(record_btrace_resume): Resume all requested threads.

8 years agobtrace: lock-step
Markus Metzger [Mon, 24 Aug 2015 14:28:06 +0000 (16:28 +0200)] 
btrace: lock-step

Record btrace's to_wait method picks a single thread to step.  When passed
minus_one_ptid, it picks the current thread.  All other threads remain where
they are.

Change this to step all resumed threads together, one step at a time, until
the first thread reports an event.

We do delay reporting NO_HISTORY events until there are no other events to
report to prevent threads at the end of their execution history from starving
other threads.

We keep threads at the end of their execution history moving and replaying
until we announce their stop in to_wait.  This shouldn't really be user-visible
but its a detail worth mentioning.

Since record btrace's to_resume method also picks only a single thread to
resume, there shouldn't be a difference with the current all-stop.

With non-stop or all-stop on top of non-stop, we will see differences.  The
behaviour should be more natural as we're moving all threads.

gdb/
* record-btrace.c: Include vec.h.
(record_btrace_find_thread_to_move): Removed.
(btrace_step_no_resumed, btrace_step_again)
(record_btrace_stop_replaying_at_end): New.
(record_btrace_cancel_resume): Call record_btrace_stop_replaying_at_end.
(record_btrace_single_step_forward): Remove calls to
record_btrace_stop_replaying.
(record_btrace_step_thread): Do only one step for BTHR_CONT and
BTHR_RCONT.  Keep threads at the end of their history moving.
(record_btrace_wait): Call record_btrace_step_thread for all threads
until one reports an event.  Call record_btrace_stop_replaying_at_end
for the eventing thread.

8 years agobtrace: add missing NO_HISTORY
Markus Metzger [Fri, 4 Sep 2015 08:33:05 +0000 (10:33 +0200)] 
btrace: add missing NO_HISTORY

If a single-step ended right at the end of the execution history, we forgot
to announce that.  Fix it.

gdb/
* record-btrace.c (record_btrace_single_step_forward): Return
NO_HISTORY if a step brings us to the end of the execution history.

8 years agobtrace: move breakpoint checking into stepping functions
Markus Metzger [Mon, 24 Aug 2015 13:55:02 +0000 (15:55 +0200)] 
btrace: move breakpoint checking into stepping functions

Breakpoints are only checked for BTHR_CONT and BTHR_RCONT stepping requests.
A BTHR_STEP and BTHR_RSTEP request will always report stopped without reason.
Since breakpoints are reported correctly, I assume infrun is handling this.

Move the breakpoint check into the btrace single stepping functions.  This
will cause us to report breakpoint hits now also for single-step requests.

One thing to notice is that

  - when executing forwards, the breakpoint is checked before 'executing'
    the instruction, i.e. before moving the PC to the next instruction.

  - when executing backwards,  the breakpoint is checked after 'executing'
    the instruction, i.e. after moving the PC to the preceding instruction
    in the recorded execution.

There is code in infrun (see, for example proceed and adjust_pc_after_break)
that handles this and also depends on this behaviour.

gdb/
* record-btrace.c (record_btrace_step_thread): Move breakpoint check
to ...
(record_btrace_single_step_forward): ... here and
(record_btrace_single_step_backward): ... here.

8 years agobtrace: split record_btrace_step_thread
Markus Metzger [Mon, 24 Aug 2015 12:49:43 +0000 (14:49 +0200)] 
btrace: split record_btrace_step_thread

The code for BTHR_STEP and BTHR_CONT is fairly similar.  Extract the common
parts into a new function record_btrace_single_step_forward.  The function
returns TARGET_WAITKIND_SPURIOUS to indicate that the single-step completed
without triggering a trap.

Same for BTHR_RSTEP and BTHR_RCONT.

gdb/
* record-btrace.c (btrace_step_spurious)
(record_btrace_single_step_forward)
(record_btrace_single_step_backward): New.
(record_btrace_step_thread): Call record_btrace_single_step_forward
and record_btrace_single_step_backward.

8 years agobtrace: extract the breakpoint check from record_btrace_step_thread
Markus Metzger [Tue, 25 Aug 2015 08:49:11 +0000 (10:49 +0200)] 
btrace: extract the breakpoint check from record_btrace_step_thread

There are two places where record_btrace_step_thread checks for a breakpoint
at the current replay position.  Move this code into its own function.

gdb/
* record-btrace.c (record_btrace_replay_at_breakpoint): New.
(record_btrace_step_thread): Call record_btrace_replay_at_breakpoint.

8 years agobtrace: improve stepping debugging
Markus Metzger [Mon, 24 Aug 2015 11:34:57 +0000 (13:34 +0200)] 
btrace: improve stepping debugging

gdb/
* record-btrace.c (btrace_thread_flag_to_str)
(record_btrace_cancel_resume): New.
(record_btrace_step_thread): Call btrace_thread_flag_to_str.
(record_btrace_resume): Print execution direction.
(record_btrace_resume_thread): Call btrace_thread_flag_to_str.
(record_btrace_wait): Call record_btrace_cancel_resume.

8 years agobtrace: support to_stop
Markus Metzger [Wed, 19 Aug 2015 11:35:52 +0000 (13:35 +0200)] 
btrace: support to_stop

Add support for the to_stop target method to the btrace record target.

gdb/
* btrace.h (enum btrace_thread_flag) <BTHR_STOP>: New.
* record-btrace (record_btrace_resume_thread): Clear BTHR_STOP.
(record_btrace_find_thread_to_move): Also accept threads that have
BTHR_STOP set.
(btrace_step_stopped_on_request, record_btrace_stop): New.
(record_btrace_step_thread): Support BTHR_STOP.
(record_btrace_wait): Also clear BTHR_STOP when stopping other threads.
(init_record_btrace_ops): Initialize to_stop.

8 years agobtrace: fix non-stop check in to_wait
Markus Metzger [Tue, 8 Sep 2015 14:13:47 +0000 (16:13 +0200)] 
btrace: fix non-stop check in to_wait

The record btrace target stops other threads in non-stop mode after stepping
the to-be-resumed thread.

The check is done on the non_stop variable.  It should rather be done on
target_is_non_stop_p ().  With all-stop on top of non-stop, infrun will
take care of stopping other threads.

gdb/
* record-btrace.c (record_btrace_wait): Replace non_stop check with
target_is_non_stop_p ().

8 years agoAdd missing PowerPC64 ld --save-restore-funcs doc
Alan Modra [Fri, 18 Sep 2015 05:21:50 +0000 (14:51 +0930)] 
Add missing PowerPC64 ld --save-restore-funcs doc

* ld.texinfo: Document --{no-,}save-restore-funcs.

8 years agoAdd PowerPC64 ld --tls-get-addr-optimize.
Alan Modra [Fri, 18 Sep 2015 06:47:49 +0000 (16:17 +0930)] 
Add PowerPC64 ld --tls-get-addr-optimize.

Sometimes it may be of benefit to force use of the __tls_get_addr_opt
call stub even when the glibc being used during linking does not
advertise __tls_get_addr_opt.

bfd/
* elf64-ppc.h (struct ppc64_elf_params <tls_get_addr_opt>): Rename
from no_tls_get_addr_opt.
* elf64-ppc.c: Update for rename and inversion of tls_get_addr_opt.
(ppc64_elf_tls_setup): Set tls_get_addr_opt to 0 only when at
default of -1.
ld/
* emultempl/ppc64elf.em (params): Init tls_get_addr_opt field to -1.
(OPTION_TLS_GET_ADDR_OPT): Define.
(PARSE_AND_LIST_LONGOPTS): Handle --tls-get-addr-opt.
(PARSE_AND_LIST_OPTIONS, PARSE_AND_LIST_ARGS_CASES): Likewise.
* ld.texinfo: Document --tls-get-addr-optimize and
--no-tls-get-addr-optimize.

8 years agoDelay converting linker script defined symbols from absolute
Alan Modra [Thu, 17 Sep 2015 23:44:25 +0000 (09:14 +0930)] 
Delay converting linker script defined symbols from absolute

Giving linker script symbols defined outside of output sections a
section-relative value early, leads to them being used in expressions
as if they were defined inside an output section.  This can mean loss
of the section VMA, and wrong results.

ld/
PR ld/18963
* ldexp.h (struct ldexp_control): Add rel_from_abs.
(ldexp_finalize_syms): Declare.
* ldexp.c (new_rel_from_abs): Keep absolute for expressions
outside of output section statements.  Set rel_from_abs.
(make_abs, exp_fold_tree, exp_fold_tree_no_dot): Clear rel_from_abs.
(struct definedness_hash_entry): Add final_sec, and comment.
(update_definedness): Set final_sec.
(set_sym_sections, ldexp_finalize_syms): New functions.
* ldlang.c (lang_process): Call ldexp_finalize_syms.
ld/testsuite
PR ld/18963
* ld-scripts/pr18963.d,
* ld-scripts/pr18963.t: New test.
* ld-scripts/expr.exp: Run it.
* ld-elf/provide-hidden-2.ld: Explicitly make "dot" absolute.
* ld-mips-elf/gp-hidden.sd: Don't care about _gp section.
* ld-mips-elf/no-shared-1-n32.d: Don't care about symbol shown at
start of .data section.
* ld-mips-elf/no-shared-1-n64.d: Likewise.
* ld-mips-elf/no-shared-1-o32.d: Likewise.

8 years agoRemove one unnecessary iteration in insertion sort
Alan Modra [Thu, 17 Sep 2015 03:23:29 +0000 (12:53 +0930)] 
Remove one unnecessary iteration in insertion sort

PR 18867
* elflink.c (elf_link_adjust_relocs): Correct start of insertion
sort main loop.

8 years agoAutomatic date update in version.in
GDB Administrator [Fri, 18 Sep 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoAdd test case for tracepoints with conditions
Pierre Langlois [Thu, 17 Sep 2015 10:39:10 +0000 (11:39 +0100)] 
Add test case for tracepoints with conditions

This patch adds a test case for tracepoints with a condition expression.
Each case will test a condition against the number of frames that should
have been traced.  Some of these tests fail on x86_64 and others on
i386, which have been marked as known failures for now, see PR/18955.

gdb/testsuite/ChangeLog:

2015-09-17  Pierre Langlois  <pierre.langlois@arm.com>
    Yao Qi  <yao.qi@linaro.org>

* gdb.trace/trace-condition.c: New file.
* gdb.trace/trace-condition.exp: New file.

8 years agoAutomatic date update in version.in
GDB Administrator [Thu, 17 Sep 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoFix argument to compiled_cond, and add cases for compiled-condition.
Wei-cheng Wang [Wed, 16 Sep 2015 15:20:51 +0000 (16:20 +0100)] 
Fix argument to compiled_cond, and add cases for compiled-condition.

This patch fixes the argument passed to compiled_cond.  It should be
regs buffer instead of tracepoint_hit_ctx.  Test case is added as
well for testing compiled-cond.

gdb/gdbserver/ChangeLog

2015-09-16  Wei-cheng Wang  <cole945@gmail.com>

* tracepoint.c (eval_result_type): Change prototype.
(condition_true_at_tracepoint): Fix argument to compiled_cond.

gdb/testsuite/ChangeLog

2015-09-16  Wei-cheng Wang  <cole945@gmail.com>

* gdb.trace/ftrace.exp: (test_ftrace_condition) New function
for testing bytecode compilation.

8 years agonon-stop-fair-events.exp slower on software single-step && !displ-step targets
Pedro Alves [Wed, 16 Sep 2015 14:51:36 +0000 (15:51 +0100)] 
non-stop-fair-events.exp slower on software single-step && !displ-step targets

On software single-step targets that don't support displaced stepping,
threads keep hitting each other's single-step breakpoints, and then
GDB needs to pause all threads to step past those.  The end result is
that progress in the main thread will be slower and it may take a bit
longer for the signal to be queued.  This patch bumps the timeout on
such targets.

gdb/testsuite/ChangeLog:
2015-09-16  Pedro Alves  <palves@redhat.com>
    Sandra Loosemore <sandra@codesourcery.com>

* gdb.threads/non-stop-fair-events.c (timeout): New global.
(SECONDS): Redefine.
(main): Call pthread_kill and alarm early.
* gdb.threads/non-stop-fair-events.exp: Probe displaced stepping
support.
(test): If the target can't hardware step and doesn't support
displaced stepping, increase the timeout.

8 years agoMake it easier to debug non-stop-fair-events.exp
Pedro Alves [Wed, 16 Sep 2015 14:51:36 +0000 (15:51 +0100)] 
Make it easier to debug non-stop-fair-events.exp

If we enable infrun debug running this test, it quickly fails with a
full expect buffer.  That can be simply handled with a couple
exp_continues.  As it's annoying to hack this every time we need to
debug the test, this patch adds bits to enable debugging support
easily, with a one-line change.

And then, if any iteration of the test fails, we end up with a long
cascade of time outs.  Just bail out when we see the first fail.

gdb/testsuite/
2015-09-16  Pedro Alves  <palves@redhat.com>

* gdb.threads/non-stop-fair-events.exp (gdb_test_no_anchor)
(enable_debug): New procedures.
(test): Use them.  Bail out if waiting for threads fails.
(top level): Bail out if a test fails.

8 years agoDon't skip gdb.asm/asm-source.exp on aarch64
Yao Qi [Wed, 16 Sep 2015 14:13:29 +0000 (15:13 +0100)] 
Don't skip gdb.asm/asm-source.exp on aarch64

This patch adds gdb.asm/aarch64.inc, so asm-source.exp isn't skipped
on aarch64 any more.

gdb/testsuite:

2015-09-16  Yao Qi  <yao.qi@linaro.org>

* gdb.asm/asm-source.exp: Set asm-arch for
aarch64*-*-* target.
* gdb.asm/aarch64.inc: New file.

8 years agoFix slowdown in ld -r for most common case of out-of-order relocs
Alan Modra [Wed, 16 Sep 2015 08:37:03 +0000 (18:07 +0930)] 
Fix slowdown in ld -r for most common case of out-of-order relocs

I chose insertion sort since relocs are mostly sorted, but there is a
common case we can handle better;  A run of relocs put out of order
due to not linking input files in order.

PR 18867
* elflink.c (elf_link_adjust_relocs): Modify insertion sort to
insert a run.  Return status in case of malloc failure.
Adjust callers.

8 years agoAutomatic date update in version.in
GDB Administrator [Wed, 16 Sep 2015 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years ago[Ada] Enhance type printing for arrays with variable-sized elements
Pierre-Marie de Rodat [Tue, 15 Sep 2015 09:56:03 +0000 (11:56 +0200)] 
[Ada] Enhance type printing for arrays with variable-sized elements

This change is relevant only for standard DWARF (as opposed to the GNAT
encodings extensions): at the time of writing it only makes a difference
with GCC patches that are to be integrated: see the patch series
submission at
<https://gcc.gnu.org/ml/gcc-patches/2015-07/msg01353.html>.

Given the following Ada declarations:

   subtype Small_Int is Natural range 0 .. 100;
   type R_Type (L : Small_Int := 0) is record
      S : String (1 .. L);
   end record;
   type A_Type is array (Natural range <>) of R_Type;

   A : A_Type := (1 => (L => 0, S => ""),
                  2 => (L => 2, S => "ab"));

Before this change, we would get the following GDB session:

    (gdb) ptype a
    type = array (1 .. 2) of foo.r_type <packed: 838-bit elements>

This is wrong: "a" is not a packed array.  This output comes from the
fact that, because R_Type has a dynamic size (with a maximum), the
compiler has to describe in the debugging information the size allocated
for each array element (i.e. the stride, in DWARF parlance: see
DW_AT_byte_stride).  Ada type printing currently assumes that arrays
with a stride are packed, hence the above output.

In practice, GNAT never performs bit-packing for arrays that contain
variable-sized elements.  Leveraging this fact, this patch enhances type
printing so that ptype does not pretend that arrays are packed when they
have a stride and they contain dynamic elements.  After this change, we
get the following expected output:

    (gdb) ptype a
    type = array (1 .. 2) of foo.r_type

gdb/ChangeLog:

* ada-typeprint.c (print_array_type): Do not describe arrays as
packed when they embed dynamic elements.

gdb/testsuite/ChangeLog:

* gdb.ada/array_of_variable_length.exp: New testcase.
* gdb.ada/array_of_variable_length/foo.adb: New file.
* gdb.ada/array_of_variable_length/pck.adb: New file.
* gdb.ada/array_of_variable_length/pck.ads: New file.

Tested on x86_64-linux, no regression.

8 years agoHandle clang naming of function static local variable.
Doug Evans [Tue, 15 Sep 2015 20:21:28 +0000 (13:21 -0700)] 
Handle clang naming of function static local variable.

clang names the local variable t_structs_a.buf.

gdb/testsuite/ChangeLog:

* gdb.base/callfuncs.exp (do_function_calls): Handle clang naming
of function static local variable.

8 years agoxtensa: generate PLT entries for call0 ABI
Max Filippov [Tue, 15 Sep 2015 03:37:14 +0000 (06:37 +0300)] 
xtensa: generate PLT entries for call0 ABI

2015-09-15  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
* elf32-xtensa.c (elf_xtensa_be_plt_entry)
(elf_xtensa_le_plt_entry): Emit 'entry' instruction only for
windowed ABI.
(elf_xtensa_create_plt_entry): Generate 'l32r' offsets and fix
up instructions according to ABI.

8 years agoFix PR/18564 - regression in showing __thread so extern variable
Philippe Waroquiers [Tue, 15 Sep 2015 19:02:15 +0000 (21:02 +0200)] 
Fix PR/18564 - regression in showing __thread so extern variable

Ensure tls variable address is not relocated, as the msym addr
is an offset in the thread local storage of the shared library/object.

8 years agogdb/doc: revert previous vforkdone change
Pedro Alves [Tue, 15 Sep 2015 18:29:37 +0000 (19:29 +0100)] 
gdb/doc: revert previous vforkdone change

The previous manual change was wrong.  The vfork parent thread ID
should be reported with the usual "thread" magic register:

   Sending packet: $vCont;c:p7260.7260#1e...Packet received: OK
 -   Notification received: Stop:T05vforkdone:;
 +   Notification received: Stop:T05vforkdone:;thread:p7260.7260
                                               ^^^^^^^^^^^^^^^^^

This is already how the parent is reported in the vfork/fork events,
and is actually what the fix made gdbserver do.  Following the
documentation change, the event would have been reported like this
instead:

    Notification received: Stop:T05vforkdone:p7260.7260

gdb/doc/ChangeLog:
2015-09-15  Pedro Alves  <palves@redhat.com>

PR remote/18965
* gdb.texinfo (Stop Reply Packets): Revert previous change to
the vforkdone description.

8 years ago[AArch64] Use debug_printf instead of fprintf_unfiltered
Pierre Langlois [Tue, 15 Sep 2015 17:38:57 +0000 (18:38 +0100)] 
[AArch64] Use debug_printf instead of fprintf_unfiltered

GDBserver uses debug_printf to print debugging output.  This patch makes
GDB use this too so we can share some of this code with GDBserver later.

gdb/ChangeLog:

* aarch64-tdep.c (decode_add_sub_imm): Use debug_printf.
(decode_adrp): Likewise.
(decode_b): Likewise.
(decode_bcond): Likewise.
(decode_br): Likewise.
(decode_cb): Likewise.
(decode_eret): Likewise.
(decode_movz): Likewise.
(decode_orr_shifted_register_x): Likewise.
(decode_ret): Likewise.
(decode_stp_offset): Likewise.
(decode_stp_offset_wb): Likewise.
(decode_stur): Likewise.
(decode_tb): Likewise.
(aarch64_analyze_prologue): Likewise.
(pass_in_x): Likewise.
(pass_in_v): Likewise.
(pass_on_stack): Likewise.
(aarch64_push_dummy_call): Likewise.
(aarch64_extract_return_value): Likewise.
(aarch64_store_return_value): Likewise.
(aarch64_return_value): Likewise.
(aarch64_record_asimd_load_store): Likewise.
(aarch64_record_load_store): Likewise.
(aarch64_record_data_proc_simd_fp): Likewise.

8 years ago[ppc64le] Use skip_entrypoint for skip_trampoline_code
Jan Kratochvil [Tue, 15 Sep 2015 17:08:04 +0000 (19:08 +0200)] 
[ppc64le] Use skip_entrypoint for skip_trampoline_code

ppc64le loses control when stepping between two PLT-called functions inside
a shared library:

29        shlib_second (); /* first-hit */^M
(gdb) PASS: gdb.base/solib-intra-step.exp: first-hit
step^M
^M
Program received signal SIGABRT, Aborted.^M
0x00003fffb7cbe578 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56^M
56        return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);^M
(gdb) FAIL: gdb.base/solib-intra-step.exp: second-hit
->
29        shlib_second (); /* first-hit */^M
(gdb) PASS: gdb.base/solib-intra-step.exp: first-hit
step^M
shlib_second () at ./gdb.base/solib-intra-step-lib.c:23^M
23        abort (); /* second-hit */^M
(gdb) PASS: gdb.base/solib-intra-step.exp: second-hit

This is because gdbarch_skip_trampoline_code() will resolve the final function
as shlib_second+0 and place there the breakpoint, but ld.so will jump after
the breakpoint - at shlib_second+8 - as it is ELFv2 local symbol optimization:

Dump of assembler code for function shlib_second:
   0x0000000000000804 <+0>:     addis   r2,r12,2
   0x0000000000000808 <+4>:     addi    r2,r2,30668
   0x000000000000080c <+8>:     mflr    r0

Currently gdbarch_skip_entrypoint() has been called in skip_prologue_sal() and
fill_in_stop_func() but that is not enough.  I believe
gdbarch_skip_entrypoint() should be called after every
gdbarch_skip_trampoline_code().

gdb/ChangeLog
2015-09-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

* linespec.c (minsym_found): Call gdbarch_skip_entrypoint.
* ppc64-tdep.c (ppc64_skip_trampoline_code): Rename to ...
(ppc64_skip_trampoline_code_1): ... here.
(ppc64_skip_trampoline_code): New wrapper function.
* symtab.c (find_function_start_sal): Call gdbarch_skip_entrypoint.

gdb/testsuite/ChangeLog
2015-09-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.opt/solib-intra-step-lib.c: New file.
* gdb.opt/solib-intra-step-main.c: New file.
* gdb.opt/solib-intra-step.exp: New file.

8 years agogdbserver: Fix exec stop reply reporting conditions
Pedro Alves [Tue, 15 Sep 2015 16:38:05 +0000 (17:38 +0100)] 
gdbserver: Fix exec stop reply reporting conditions

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

* remote-utils.c (prepare_resume_reply) <TARGET_WAITKIND_EXECD>:
Check whether to report exec events instead of checking whether
multiprocess is enabled.

8 years agoMove ChangeLog entry to proper place
Pedro Alves [Tue, 15 Sep 2015 16:35:21 +0000 (17:35 +0100)] 
Move ChangeLog entry to proper place

gdb/ChangeLog -> gdb/gdbserver/ChangeLog

2015-09-15  Pedro Alves  <palves@redhat.com>

PR remote/18965
* remote-utils.c (prepare_resume_reply): Merge
TARGET_WAITKIND_VFORK_DONE switch case with the
TARGET_WAITKIND_FORKED case.

8 years agoPR remote/18965: vforkdone stop reply should indicate parent PID
Pedro Alves [Tue, 15 Sep 2015 16:32:45 +0000 (17:32 +0100)] 
PR remote/18965: vforkdone stop reply should indicate parent PID

The vforkdone stop reply misses indicating the thread ID of the vfork
parent which the event relates to:

 @cindex vfork events, remote reply
 @item vfork
 The packet indicates that @code{vfork} was called, and @var{r}
 is the thread ID of the new child process. Refer to
 @ref{thread-id syntax} for the format of the @var{thread-id}
 field.  This packet is only applicable to targets that support
 vfork events.

 @cindex vforkdone events, remote reply
 @item vforkdone
 The packet indicates that a child process created by a vfork
 has either called @code{exec} or terminated, so that the
 address spaces of the parent and child process are no longer
 shared. The @var{r} part is ignored.  This packet is only
 applicable to targets that support vforkdone events.

Unfortunately, this is not just a documentation issue.  GDBserver
is really not specifying the thread ID.  I noticed because
in non-stop mode, gdb complains:

 [Thread 6089.6089] #1 stopped.
 #0  0x0000003615a011f0 in ?? ()
 0x0000003615a011f0 in ?? ()
 (gdb) set debug remote 1
 (gdb) c
 Continuing.
 Sending packet: $QPassSignals:e;10;14;17;1a;1b;1c;21;24;25;2c;4c;#5f...Packet received: OK
 Sending packet: $vCont;c:p17c9.17c9#88...Packet received: OK
   Notification received: Stop:T05vfork:p17ce.17ce;06:40d7ffffff7f0000;07:30d7ffffff7f0000;10:e4c9eb1536000000;thread:p17c9.17c9;core:2;
 Sending packet: $vStopped#55...Packet received: OK
 Sending packet: $D;17ce#af...Packet received: OK
 Sending packet: $vCont;c:p17c9.17c9#88...Packet received: OK
   Notification received: Stop:T05vforkdone:;
 No process or thread specified in stop reply: T05vforkdone:;
 (gdb)

This is not non-stop-mode-specific, however.  Consider e.g., that in
all-stop, you may be debugging more than one process at the same time.
You continue, and both processes vfork.  So when you next get a
T05vforkdone, there's no way to tell which of the parent processes is
done with the vfork.

Tests will be added later.

Tested on x86_64 Fedora 20.

gdb/ChangeLog:
2015-09-15  Pedro Alves  <palves@redhat.com>

PR remote/18965
* remote-utils.c (prepare_resume_reply): Merge
TARGET_WAITKIND_VFORK_DONE switch case with the
TARGET_WAITKIND_FORKED case.

gdb/doc/ChangeLog:
2015-09-15  Pedro Alves  <palves@redhat.com>

PR remote/18965
* gdb.texinfo (Stop Reply Packets): Explain that vforkdone's 'r'
part indicates the thread ID of the parent process.

This page took 0.057512 seconds and 4 git commands to generate.