aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2017-12-05Address review comments for the previous seriesSimon Marchi2-2/+10
I failed at git and missed adding/lost changes on the wrong branch, the result being that I didn't incorporate fixes resulting from Yao's review comments. This patch fixes that. There are two places where we should use the unique pointer typedef, and ChangeLog entries missing. gdb/ChangeLog: * target-descriptions.c (struct tdesc_feature) <registers>: Use tdesc_reg_up typedef. (struct target_desc) <features>: Use tdesc_feature_up typedef.
2017-12-05Split tdesc_type into multiple classesSimon Marchi42-1074/+1187
This patch makes tdesc_type an abstract base class and creates three subclasses: - tdesc_type_builtin, for builtin types - tdesc_type_vector, for vector types - tdesc_type_with_fields, for struct, union, flag and enum types This allows getting rid of the union in tdesc_type and to not allow the std::vector separately. I tried to go further and create separate classes for struct, union, flag and enum, but it proved too difficult. One problem is that from the point of the of the target description code, the types tdesc_type_* are opaque (only forward-declared). Therefore, it doesn't know about inheritance relationship between those classes. This makes it impossible to make functions that accept a pointer to a base class and pass a pointer to a derived class, for example. I think this patch here is a good compromise, and if somebody wants to improve things further, the door is open. A make_gdb_type virtual pure method is added to tdesc_type, which replaces the current tdesc_gdb_type function. Calling this method on a tdesc_type returns the corresponding built gdb type. gdb/ChangeLog: * target-descriptions.c (struct tdesc_type): Use default destructor. <u>: Remove. <accept>: Remove. (struct tdesc_type_builtin): New. (struct tdesc_type_vector): New. (struct tdesc_type_with_fields): New. (tdesc_predefined_types): Change type to tdesc_type_builtin[]. (tdesc_gdb_type): Remove. (tdesc_register_type): Adjust. (tdesc_create_vector): Create tdesc_type_vector. (tdesc_create_struct): Create tdesc_type_with_fields. (tdesc_set_struct_size): Change parameter type. (tdesc_create_union): Create tdesc_type_with_fields. (tdesc_create_flags): Likewise. (tdesc_create_enum): Likewise. (tdesc_add_field): Change parameter type. (tdesc_add_typed_bitfield): Likewise. (tdesc_add_bitfield): Likewise. (tdesc_add_flag): Likewise. (tdesc_add_enum_value): Likewise. (print_c_tdesc) <visit>: Remove overload with tdesc_type parameter, add overloads for tdesc_type_builtin, tdesc_type_with_fields and tdesc_type_vector. <m_printed_type>: Remove. <m_printed_element_type, m_printed_type_with_fields>: Add. * target-descriptions.h (tdesc_create_enum): Change return type. (tdesc_add_typed_bitfield): Change parameter type. (tdesc_add_enum_value): Change parameter type. * xml-tdesc.c (struct tdesc_parsing_data) <current_type>: Change type to tdesc_type_with_fields. (tdesc_start_struct): Adjust. (tdesc_start_flags): Adjust. (tdesc_start_enum): Adjust. (tdesc_start_field): Adjust. * arch/tdesc.h (struct tdesc_type_builtin): Forward-declare. (struct tdesc_type_vector): Forward-declare. (struct tdesc_type_with_fields): Forward-declare. (tdesc_create_struct): Change return type. (tdesc_create_union): Likewise. (tdesc_create_flags): Likewise. (tdesc_add_field): Change parameter type. (tdesc_set_struct_size): Likewise. (tdesc_add_bitfield): Likewise. (tdesc_add_flag): Likewise. * features: Re-generate C files. gdb/gdbserver/ChangeLog: * tdesc.c (struct tdesc_type): Change return type. (tdesc_add_flag): Change parameter type. (tdesc_add_bitfield): Likewise. (tdesc_add_field): Likewise. (tdesc_set_struct_size): Likewise.
2017-12-05Make tdesc_arch_data::arch_regs an std::vectorSimon Marchi2-42/+54
Make tdesc_arch_data::arch_regs be an std::vector of tdesc_arch_reg objects. On particularity is that the tdesc_arch_data linked to a gdbarch is allocated on the gdbarch's obstack. To be safe, I did not change it and called placement-new on the area returned by OBSTACK_ZALLOC. gdb/ChangeLog: * target-descriptions.c (tdesc_arch_reg): Remove typedef. (struct tdesc_arch_reg): Add constructor. (DEF_VEC_O (tdesc_arch_reg)): Remove. (struct tdesc_arch_data): Initialize fields. <arch_regs>: Change type to std::vector. (target_find_description): Adjust. (tdesc_find_type): Adjust. (tdesc_data_init): Call tdesc_arch_data constructor. (tdesc_data_alloc): Allocate tdesc_arch_data with new. (tdesc_data_cleanup): Free data with delete. (tdesc_numbered_register): Adjust. (tdesc_find_arch_register): Adjust. (tdesc_use_registers): Adjust.
2017-12-05Make tdesc_type::u::u::fields an std::vectorSimon Marchi2-119/+95
This patch makes the tdesc_type::u::u::fields an std::vector of tdesc_type_field. The difficulty here is that the vector is part of a union. Because of this, I made fields a pointer to a vector, and instantiate/destroy the vector if the type is one that uses this member of the union The field tdesc_type_field::name is changed to an std::string at the same time. gdb/ChangeLog: * target-descriptions.c (tdesc_type_field): Remove typedef. (DEF_VEC_O (tdesc_type_field)): Remove. (struct tdesc_type_field): Add constructor. <name>: Change type to std::string. (struct tdesc_type) <tdesc_type>: Instantiate vector if the type kind uses it. <~tdesc_type>: Destroy vector if the type kind uses it. <u::u::fields>: Change type to std::vector. (tdesc_gdb_type): Adjust. (tdesc_add_field): Adjust. (tdesc_add_typed_bitfield): Adjust. (tdesc_add_field): Adjust. (tdesc_add_enum_value): Adjust. (class print_c_tdesc) <visit>: Adjust.
2017-12-05Make tdesc_type::name an std::stringSimon Marchi2-27/+35
This patch makes tdesc_type::name an std::string. This way, we don't need to free it manually in ~tdesc_type. I think the comment on top of name is not correct, the string is always malloc'ed. gdb/ChangeLog: * target-descriptions.c (struct tdesc_type) <name>: Change type to std::string. <~tdesc_type>: Don't manually free name. <operator==>: Adjust. (tdesc_named_type): Adjust. (tdesc_find_type): Adjust. (tdesc_gdb_type): Adjust. (class print_c_tdesc) <visit>: Adjust.
2017-12-05Make tdesc_feature::types an std::vectorSimon Marchi2-40/+34
This patch makes tdesc_feature::types an std::vector of unique_ptr of tdesc_type. This way, we don't need to manually free the objects and the vector in ~tdesc_feature. gdb/ChangeLog: * target-descriptions.c (tdesc_type_p): Remove typedef. (DEF_VEC_P (tdesc_type_p)): Remove. (struct tdesc_feature) <types>: Change type to std::vector. <~tdesc_feature>: Replace with default implementation. <accept>: Adjust. (tdesc_named_type): Adjust. (tdesc_create_vector): Adjust. (tdesc_create_struct): Adjust. (tdesc_create_union): Adjust. (tdesc_create_flags): Adjust. (tdesc_create_enum): Adjust.
2017-12-05Make tdesc_reg string fields std::stringSimon Marchi4-41/+51
Make the name, group and type fields of tdesc_reg std::strings. This way, we don't have to manually free them in ~tdesc_reg. Doing so results in a small change in the generated tdesc. Instead of passing an empty string for the group parameter of tdesc_create_reg, the two modified tdesc now pass NULL. The end result should be the same. gdb/ChangeLog: * target-descriptions.c (struct tdesc_reg) <tdesc_reg>: Change type of name_ parameter, adjust to std::string change. <name, group, type>: Change type to std::string. <~tdesc_reg>: Replace with default implementation. <operator==>: Adjust. (tdesc_find_register_early): Adjust. (tdesc_register_name): Adjust. (tdesc_register_type): Adjust. (tdesc_register_in_reggroup_p): Adjust. (class print_c_tdesc) <visit>: Adjust. (class print_c_feature) <visit>: Adjust.
2017-12-05Make tdesc_feature::registers an std::vectorSimon Marchi2-47/+35
This patch makes tdesc_feature::registers an std::vector of unique_ptr to tdesc_reg. This way, we don't have to manually free the tdesc_reg objects and the vector in the tdesc_feature destructor. gdb/ChangeLog: * target-descriptions.c (tdesc_reg_p): Remove typedef. (DEF_VEC_P (tdesc_reg_p)): Remove. (struct tdesc_feature) <registers>: Change type to std::vector. <~tdesc_feature>: Don't manually free registers. <accept>: Adjust. <operator==>: Adjust. (tdesc_has_registers): Adjust. (tdesc_find_register_early): Adjust. (tdesc_use_registers): Adjust. (tdesc_create_reg): Adjust.
2017-12-05Make tdesc_feature::name an std::stringSimon Marchi2-10/+19
... so we don't have to manually free it in ~tdesc_feature. gdb/ChangeLog: * target-descriptions.c (tdesc_feature) <name>: Change type to std::string. <~tdesc_feature>: Don't manually free name. <operator==>: Adjust. (tdesc_find_feature): Adjust. (tdesc_feature_name): Adjust. (class print_c_tdesc) <visit_pre>: Adjust. (class print_c_feature) <visit_pre>: Adjust.
2017-12-05Make target_desc::features an std::vectorSimon Marchi2-52/+33
This patch makes target_desc to be a vector of unique_ptr to tdesc_feature objects. This way, we don't have to manually free the features and the vector in the target_desc destructor. gdb/ChangeLog: * target-descriptions.c (tdesc_feature_p): Remove typedef. (DEF_VEC_P (tdesc_feature_p)): Remove. (struct target_desc) <features>: Change type to std::vector. <~target_desc>: Replace with default implementation. <accept>: Adjust. <operator==>: Adjust. (tdesc_has_registers): Adjust. (tdesc_find_feature): Adjust. (tdesc_use_registers): Adjust. (tdesc_create_feature): Adjust.
2017-12-05Make target_desc::compatible an std::vectorSimon Marchi2-30/+19
This patch changes target_desc::compatible to be a vector of bfd_arch_info *. This way, we don't need to manually free the vector in the target_desc destructor. gdb/ChangeLog: * target-descriptions.c (arch_p): Remove typedef. (DEF_VEC_P (arch_p)): Remove. (struct target_desc) <compatible>: Change type to std::vector. <~target_desc>: Don't manually free compatible. (tdesc_compatible_p): Adjust. (tdesc_add_compatible): Adjust. (class print_c_tdesc) <visit_pre>: Adjust.
2017-12-05Make target_desc::properties an std::vectorSimon Marchi2-40/+30
This patch changes target_desc::properties to be a vector of property objects. This way, we don't need to manually free the property members as well as the property objects themselves. gdb/ChangeLog: * target-descriptions.c (property_s): Remove typedef. (DEF_VEC_O (property_s)): Remove. (struct target_desc) <properties>: Make an std::vector. <~target_desc>: Don't manually free properties. (tdesc_property): Adjust. (set_tdesc_property): Adjust. (class print_c_tdesc) <visit_pre>: Adjust.
2017-12-05Redefine gdb_static_assert as static_assertSimon Marchi2-2/+6
Since we use C++11, we can use static_assert instead doing the trick that makes a negative-sized array if the expression is false. static_assert is built in the language and gives clearer error messages. To avoid modifying the usages of gdb_static_assert, redefine gdb_static_assert in terms of static_assert, passing an empty message. If we want to add an assert with a message, it's always possible to use static_assert directly. gdb/ChangeLog: * common/gdb_assert.h (gdb_static_assert): Redefine using static_assert.
2017-12-05Remove some unused variablesSimon Marchi85-224/+179
This patch removes some unused variables, found with -Wunused. I have not removed everything reported by -Wunused, because some expressions such as struct type *arg_type = check_typedef (value_type); in bfin-tdep.c could have an unexpected but important side-effect. I removed others that I considered more low-risk, such as: struct gdbarch *gdbarch = get_objfile_arch (objfile); I tested building with Python 2/Python 3/no Python, with/without expat, with/without libipt and with/without babeltrace. gdb/ChangeLog: * ada-lang.c (ada_collect_symbol_completion_matches): Remove unused variables. (ada_is_redundant_range_encoding): Likewise. * ada-varobj.c (ada_varobj_get_value_of_array_variable): Likewise. * alpha-tdep.c (alpha_software_single_step): Likewise. * arm-tdep.c (_initialize_arm_tdep): Likewise. * auto-load.c (info_auto_load_cmd): Likewise. * break-catch-syscall.c (insert_catch_syscall): Likewise. (remove_catch_syscall): Likewise. * breakpoint.c (condition_completer): Likewise. (clear_command): Likewise. (update_breakpoint_locations): Likewise. * btrace.c (btrace_disable): Likewise. (btrace_teardown): Likewise. (btrace_maint_update_pt_packets): Likewise. (maint_btrace_clear_cmd): Likewise. * cli/cli-decode.c (lookup_cmd_1): Likewise. (lookup_cmd_composition): Likewise. * cli/cli-dump.c (scan_filename): Likewise. (restore_command): Likewise. * compile/compile-loc2c.c (compute_stack_depth): Likewise. * compile/compile-object-load.c (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * compile/compile.c (compile_to_object): Likewise. * completer.c (filename_completer): Likewise. (complete_files_symbols): Likewise. (complete_expression): Likewise. * corelow.c (core_open): Likewise. * ctf.c (ctf_start): Likewise. (ctf_write_status): Likewise. (ctf_write_uploaded_tsv): Likewise. (ctf_write_definition_end): Likewise. (ctf_open_dir): Likewise. (ctf_xfer_partial): Likewise. (ctf_trace_find): Likewise. * disasm.c (gdb_pretty_print_disassembler::pretty_print_insn): Likewise. * dwarf2loc.c (allocate_piece_closure): Likewise. (indirect_pieced_value): Likewise. (dwarf2_evaluate_loc_desc_full): Likewise. * dwarf2read.c (dw2_expand_marked_cus): Likewise. (dw2_expand_symtabs_matching): Likewise. (dw2_map_symbol_filenames): Likewise. (read_and_check_comp_unit_head): Likewise. (read_cutu_die_from_dwo): Likewise. (lookup_dwo_unit): Likewise. (read_comp_units_from_section): Likewise. (dwarf2_compute_name): Likewise. (handle_DW_AT_stmt_list): Likewise. (create_cus_hash_table): Likewise. (create_dwp_v2_section): Likewise. (dwarf2_rnglists_process): Likewise. (dwarf2_ranges_process): Likewise. (dwarf2_record_block_ranges): Likewise. (is_vtable_name): Likewise. (read_formatted_entries): Likewise. (skip_form_bytes): Likewise. * elfread.c (elf_symtab_read): Likewise. * exec.c (exec_file_command): Likewise. * f-valprint.c (f_val_print): Likewise. (info_common_command_for_block): Likewise. * guile/guile.c (initialize_scheme_side): Likewise. * guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Likewise. * guile/scm-cmd.c (cmdscm_completer): Likewise. (gdbscm_register_command_x): Likewise. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-param.c (gdbscm_parameter_value): Likewise. * guile/scm-ports.c (file_port_magic): Likewise. * guile/scm-pretty-print.c (ppscm_search_pp_list): Likewise. (ppscm_pretty_print_one_value): Likewise. (ppscm_print_children): Likewise. * guile/scm-string.c (gdbscm_string_to_argv): Likewise. * guile/scm-symtab.c (gdbscm_sal_symtab): Likewise. * guile/scm-type.c (gdbscm_type_next_field_x): Likewise. * guile/scm-utils.c (gdbscm_parse_function_args): Likewise. * i386-tdep.c (i386_register_reggroup_p): Likewise. * infcmd.c (run_command_1): Likewise. (until_next_fsm_clean_up): Likewise. * linespec.c (linespec_complete): Likewise. (find_label_symbols): Likewise. * m2-valprint.c (m2_val_print): Likewise. * memattr.c (require_user_regions): Likewise. (lookup_mem_region): Likewise. (disable_mem_command): Likewise. (mem_delete): Likewise. * mep-tdep.c (mep_register_name): Likewise. (mep_analyze_prologue): Likewise. * mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries): Likewise. * mi/mi-interp.c (mi_on_sync_execution_done): Likewise. * mi/mi-main.c (mi_cmd_trace_frame_collected): Likewise. * microblaze-linux-tdep.c (microblaze_linux_init_abi): Likewise. * minidebug.c (lzma_open): Likewise. * minsyms.c (lookup_minimal_symbol): Likewise. * mips-linux-tdep.c (mips64_fill_fpregset): Likewise. * mips-tdep.c (mips_stub_frame_sniffer): Likewise. (mips_o64_return_value): Likewise. (mips_single_step_through_delay): Likewise. (_initialize_mips_tdep): Likewise. * nios2-tdep.c (nios2_push_dummy_call): Likewise. (nios2_software_single_step): Likewise. * parse.c (find_minsym_type_and_address): Likewise. * psymtab.c (psym_relocate): Likewise. * python/py-breakpoint.c (bppy_get_commands): Likewise. (gdbpy_breakpoint_modified): Likewise. * python/py-infevents.c (create_inferior_call_event_object): Likewise. * python/py-record-btrace.c (btpy_list_item): Likewise. * python/py-type.c (typy_str): Likewise. * python/py-value.c (valpy_call): Likewise. * python/python.c (do_start_initialization): Likewise. * record-btrace.c (record_btrace_insn_history_range): Likewise. (record_btrace_call_history_range): Likewise. (record_btrace_record_method): Likewise. (record_btrace_xfer_partial): Likewise. (btrace_get_frame_function): Likewise. * record-full.c (record_full_open): Likewise. * record.c (get_context_size): Likewise. * registry.h (DEFINE_REGISTRY): Likewise. * remote-fileio.c (remote_fileio_request): Likewise. * remote.c (remote_update_thread_list): Likewise. (remote_check_symbols): Likewise. (remote_commit_resume): Likewise. (remote_interrupt): Likewise. (remote_insert_breakpoint): Likewise. (compare_sections_command): Likewise. * rust-exp.y (super_name): Likewise. (lex_string): Likewise. (convert_ast_to_type): Likewise. (convert_ast_to_expression): Likewise. * rust-lang.c (rust_print_struct_def): Likewise. (rust_print_type): Likewise. (rust_evaluate_subexp): Likewise. * rx-tdep.c (rx_register_type): Likewise. * ser-event.c (serial_event_clear): Likewise. * serial.c (serial_open): Likewise. * spu-tdep.c (spu_overlay_new_objfile): Likewise. * symfile.c (section_is_overlay): Likewise. (overlay_unmapped_address): Likewise. (overlay_mapped_address): Likewise. (simple_overlay_update_1): Likewise. (simple_overlay_update): Likewise. * symtab.c (symbol_find_demangled_name): Likewise. (search_symbols): Likewise. * target-descriptions.c (tdesc_predefined_type): Likewise. * target.c (target_commit_resume): Likewise. * thread.c (print_selected_thread_frame): Likewise. * top.c (new_ui_command): Likewise. (gdb_readline_no_editing): Likewise. * tracefile-tfile.c (tfile_open): Likewise. * tracepoint.c (create_tsv_from_upload): Likewise. * utils.c (quit): Likewise. (defaulted_query): Likewise. * valarith.c (value_concat): Likewise. * xml-syscall.c (xml_list_syscalls_by_group): Likewise. * xml-tdesc.c (target_fetch_description_xml): Likewise. * xtensa-tdep.c (xtensa_pseudo_register_read): Likewise. (xtensa_pseudo_register_write): Likewise. gdb/gdbserver/ChangeLog: * regcache.c (registers_to_string): Remove unused variable.
2017-12-04Riscv shared libraries should not export __global_pointer$.Jim Wilson13-2/+106
ld/ * emulparams/elf32lriscv-defs.sh (SDATA_START_SYMBOLS): Mark __global_pointer$ as HIDDEN. * testsuite/ld-riscv-elf/gp-hidden-64.rd: New. * testsuite/ld-riscv-elf/gp-hidden-lib.rd: New. * testsuite/ld-riscv-elf/gp-hidden-lib.s: New. * testsuite/ld-riscv-elf/gp-hidden-ver-64.rd: New. * testsuite/ld-riscv-elf/gp-hidden-ver.rd: New. * testsuite/ld-riscv-elf/gp-hidden-ver.s: New. * testsuite/ld-riscv-elf/gp-hidder-ver.ver: New. * testsuite/ld-riscv-elf/gp-hidden.rd: New. * testsuite/ld-riscv-elf/gp-hidden.s: New. * testsuite/ld-riscv-elf/gp-hidden.sd: New. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Change riscv to riscv*. Run the new tests with run_ld_link_tests.
2017-12-05Automatic date update in version.inGDB Administrator1-1/+1
2017-12-04Extend gdb.core/coredump-filter.exp to test dump-excluded-mappings.Sergio Lopez1-12/+34
gdb/testsuite/ChangeLog: 2017-11-30 Sergio Lopez <slp@redhat.com> * gdb.core/coredump-filter.exp: Extend test to verify the functionality of the dump-excluded-mappings command.
2017-12-04Document the new "-a" command line option for gcoreSergio Lopez2-1/+13
gdb/ChangeLog: 2017-11-29 Sergio Lopez <slp@redhat.com> * NEWS (Changes since GDB 8.0): Announce new "-a" command line option for gcore. gdb/doc/ChangeLog: 2017-11-29 Sergio Lopez <slp@redhat.com> * gdb.texinfo (gcore man): Document new "-a" command line option.
2017-12-04Implement "-a" command line option for gcoreSergio Lopez1-17/+30
With the new "-a" command line option, the user may request gcore to actually dump all present memory mappings. The actual effect of this argument is OS dependent. On GNU/Linux, it will disable use-coredump-filter and enable dump-excluded-mappings. gdb/ChangeLog: 2017-11-29 Sergio Lopez <slp@redhat.com> * gcore.in: Add "-a" command line option for instructing gdb to dump all memory mappings (OS dependent).
2017-12-04Document new {set,show} dump-excluded-mappings commands.Sergio Lopez2-1/+18
gdb/ChangeLog: 2017-11-29 Sergio Lopez <slp@redhat.com> * NEWS (Changes since GDB 8.0): Announce {set,show} dump_excluded_mappings commands. gdb/doc/ChangeLog: 2017-11-29 Sergio Lopez <slp@redhat.com> * gdb.texinfo (gcore): Mention new {set,show} dump-excluded-mappings commands. (set dump-excluded-mappings): Document new command.
2017-12-04Implement 'set dump-excluded-mappings' commandSergio Lopez1-1/+29
Commit df8411da087dc05481926f4c4a82deabc5bc3859 implemented support for checking /proc/PID/coredump_filter, and also changed gcore behavior to unconditionally honor the VM_DONTDUMP flag, preventing sections marked as such for being dumped into the core file. This patch implements the 'set dump-excluded-mappings' command for instructing gdb to ignore the VM_DONTDUMP flag. Combined with 'set use-coredump-filter', this allows the user to restore the old behavior, dumping all sections (except the ones marked as IO) unconditionally. gdb/Changelog: 2017-11-29 Sergio Lopez <slp@redhat.com> * linux-tdep.c (dump_excluded_mappings): New variable. (dump_mapping_p): Use dump_excluded_mappings variable. (_initialize_linux_tdep): New command 'set dump_excluded_mappings'.
2017-12-04Update manual for Rust changeTom Tromey4-3/+11
I realized today that a recent change to the Rust support required an update to the manual; and so I updated NEWS as well. 2017-12-04 Tom Tromey <tom@tromey.com> * NEWS: Mention Rust trait object inspection. 2017-12-04 Tom Tromey <tom@tromey.com> * gdb.texinfo (Rust): Update trait object status
2017-12-04Fix displaced-stepping RIP-relative VEX-encoded instructions (AVX) (PR ↵Pedro Alves5-9/+274
gdb/22499) PR gdb/22499 is about a latent bug exposed by the switch to "maint set target-non-stop on" by default on x86-64 GNU/Linux, a while ago. With that on, GDB is also preferring to use displaced-stepping by default. The testcase in the bug is failing because GDB ends up incorrectly displaced-stepping over a RIP-relative VEX-encoded instruction, like this: 0x00000000004007f5 <+15>: c5 fb 10 05 8b 01 00 00 vmovsd 0x18b(%rip),%xmm0 # 0x400988 While RIP-relative instructions need adjustment when relocated to the scratch pad, GDB ends up just copying VEX-encoded instructions to the scratch pad unmodified, with the end result that the inferior ends up executing an instruction that fetches/writes memory from the wrong address... This patch teaches GDB about the VEX-encoding prefixes, fixing the problem, and adds a testcase that fails without the GDB fix. I think we may need a similar treatment for EVEX-encoded instructions, but I didn't address that simply because I couldn't find any EVEX-encoded RIP-relative instruction in the gas testsuite. In any case, this commit is forward progress as-is already. gdb/ChangeLog: 2017-12-04 Pedro Alves <palves@redhat.com> PR gdb/22499 * amd64-tdep.c (amd64_insn::rex_offset): Rename to... (amd64_insn::enc_prefix_offset): ... this, and tweak comment. (vex2_prefix_p, vex3_prefix_p): New functions. (amd64_get_insn_details): Adjust to rename. Also skip VEX2 and VEX3 prefixes. (fixup_riprel): Set VEX3.!B. gdb/testsuite/ChangeLog: 2017-12-04 Pedro Alves <palves@redhat.com> PR gdb/22499 * gdb.arch/amd64-disp-step-avx.S: New file. * gdb.arch/amd64-disp-step-avx.exp: New file.
2017-12-04x86 map file textrelAlan Modra8-47/+72
bfd/ * elfxx-x86.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function. Always prints via minfo and correct "readonly" to "read-only" in warning message., replacing.. (_bfd_x86_elf_readonly_dynrelocs): ..this. (_bfd_x86_elf_size_dynamic_sections): Correct "readonly" to "read-only" in warning message. Formatting. (_bfd_x86_elf_adjust_dynamic_symbol): Use readonly_dynrelocs. * linker.c (bfd_link_hash_traverse): Comment typo fix. ld/ * testsuite/ld-i386/pr17935-1.d: Adjust expected error. * testsuite/ld-i386/pr17935-2.d: Likewise. * testsuite/ld-x86-64/pr17935-1.d: Likewise. * testsuite/ld-x86-64/pr17935-2.d: Likewise.
2017-12-04Documentation fixAlan Modra2-1/+6
PR 22544 * doc/as.texinfo (8byte): Correct.
2017-12-04Automatic date update in version.inGDB Administrator1-1/+1
2017-12-04Run powerpc vle gas tests for all powerpc ELF targetsAlan Modra19-39/+58
* testsuite/gas/ppc/ppc.exp: Don't exclude VLE tests when little-endian. * testsuite/gas/ppc/efs.d: Add -mbig to assembler options. * testsuite/gas/ppc/efs2.d: Likewise. * testsuite/gas/ppc/lsp-checks.d: Likewise. * testsuite/gas/ppc/lsp.d: Likewise. * testsuite/gas/ppc/spe.d: Likewise. * testsuite/gas/ppc/spe2-checks.d: Likewise. * testsuite/gas/ppc/spe2.d: Likewise. * testsuite/gas/ppc/spe_ambiguous.d: Likewise. * testsuite/gas/ppc/vle-mult-ld-st-insns.d: Likewise. * testsuite/gas/ppc/vle-reloc.d: Likewise. * testsuite/gas/ppc/vle-simple-1.d: Likewise. * testsuite/gas/ppc/vle-simple-2.d: Likewise. * testsuite/gas/ppc/vle-simple-3.d: Likewise. * testsuite/gas/ppc/vle-simple-4.d: Likewise. * testsuite/gas/ppc/vle-simple-5.d: Likewise. * testsuite/gas/ppc/vle-simple-6.d: Likewise. * testsuite/gas/ppc/vle.d: Likewise.
2017-12-04Modify ppceabi ld tests to run on all powerpc ELF targetsAlan Modra2-19/+23
* testsuite/ld-powerpc/powerpc.exp (ppceabitests): Add -a32 -mbig to assembler options, and -melf32ppc to linker options. Always run these tests.
2017-12-03Fix for texinfo 4.8.Jim Wilson2-2/+6
gas/ * doc/c-riscv.texi (RISC-V-Directives): Move @section immediately after @node.
2017-12-03Remove mem_region_vector typedefSimon Marchi4-12/+17
Now that make-target-delegates understands namespaces and templates, this typedef is no longer useful. gdb/ChangeLog: * target.h (mem_region_vector): Remove. (struct target_ops) <to_memory_map>: Change return type to std::vector<mem_region>. * target-debug.h (target_debug_print_mem_region_vector): Rename to ... (target_debug_print_std_vector_mem_region): ... this. * target-delegates.c: Re-generate.
2017-12-03Make make-target-delegates grok namespace scope op and template paramsPedro Alves4-3/+24
The next patch will want to use gdb::array_view<int> as parameter type of a target_ops method. However, that runs into a make-target-delegates limitation: target_debug_foo calls in target-delegates.c for parameters/return types with namespace scope operators ("::") or template parameters, end up looking like: @@ -1313,9 +1313,7 @@ debug_set_syscall_catchpoint (struct target_ops *self, int arg1, int arg2, int a fputs_unfiltered (", ", gdb_stdlog); target_debug_print_int (arg3); fputs_unfiltered (", ", gdb_stdlog); - target_debug_print_int (arg4); - fputs_unfiltered (", ", gdb_stdlog); - target_debug_print_int_p (arg5); + target_debug_print_gdb::array_view<const_int> (arg4); which obviously isn't something that compiles. The problem is that make-target-delegates wasn't ever taught that '::', '<', and '>' can appear in parameter/return types. You could work around it by hidding the unsupported characters behind a typedef in the target method declaration, or by using an explicit TARGET_DEBUG_PRINTER, but it's better to just remove the limitation. While at it, also fix an "abuse" of reserved identifiers. gdb/ChangeLog: * make-target-delegates (munge_type): Also munge '<', '>', and ':'. Avoid double underscores in identifiers, and trailing underscores. * target-debug.h (target_debug_print_VEC_static_tracepoint_marker_p__p): Rename to ... (target_debug_print_VEC_static_tracepoint_marker_p_p): ... this. * target-delegates.c: Regenerate.
2017-12-03Fix gdb.threads/process-dies-while-detaching.expPedro Alves3-22/+71
I noticed [1] a test bug in gdb.threads/process-dies-while-detaching.exp. Simplified, the test code in question looks somewhat like this: ~~~ # Detach from a process, and ensure that it exits after detaching. # This relies on inferior I/O. proc detach_and_expect_exit {test} { gdb_test_multiple "detach" $test .... set saw_prompt 0 set saw_inf_exit 0 while { !$saw_prompt && !$saw_inf_exit } { gdb_test_multiple "" $test { -re "exited, status=0" { set saw_inf_exit 1 } -re "$gdb_prompt " { set saw_prompt 1 } } } pass $test } ~~~ The bug is in the while loop's condition. We want to make sure we see both the inferior output and the prompt, so the loop's test should be: - while { !$saw_prompt && !$saw_inf_exit } { + while { !$saw_prompt || !$saw_inf_exit } { If we just fix that, the test starts failing though, because it exposes a couple latent problems: - When called from test_detach_killed_outside, the parent doesn't print "exited, status=0", because in that case the child dies with a signal, and so detach_and_expect_exit times out. Fix it by making the parent print "signaled, sig=9" in that case, and have the .exp expect it. - When testing against --target_board=native-gdbserver, sometimes we'd get this: ERROR: Process no longer exists ERROR: : spawn id exp9 not open while executing "expect { -i exp8 -timeout 220 -i $server_spawn_id eof { pass $test wait -i $server_spawn_id unset server_spawn_id } timeout { ..." ("uplevel" body line 1) invoked from within "uplevel $body" NONE : spawn id exp9 not open The problem is that: - inferior_spawn_id and server_spawn_id are the same when testing with gdbserver. - gdbserver exits after "detach", so we get an eof for $inferior_spawn_id in the loop in detach_and_expect_exit. That's the first "ERROR: Process no longer exists". - and then when we reach test_server_exit, server_spawn_id is already closed (because server_spawn_id==inferior_spawn_id). To handle this, make the loop in detach_and_expect_exit use an indirect spawn id list and remove $inferior_spawn_id from the list as soon as we got the inferior output we're expecting, so that the "eof" is left unprocessed until we reach test_server_exit. [1] I changed GDB in a way that should have made the test fail, but it didn't. gdb/testsuite/ChangeLog: 2017-12-03 Pedro Alves <palves@redhat.com> * gdb.threads/process-dies-while-detaching.c: Include <errno.h> and <string.h>. (parent_function): Print distinct messages when waitpid fails, or the child exits with a signal, or the child exits for an unhandled reason. * gdb.threads/process-dies-while-detaching.exp (detach_and_expect_exit): New 'inf_output_re' parameter and use it. Wait for both inferior output and GDB's prompt. Use an indirect spawn id list. (do_detach): New parameter 'child_exit'. Use it to compute expected inferior output. (test_detach, test_detach_watch, test_detach_killed_outside): Adjust to pass down the expected child exit kind.
2017-12-03Fix "FAIL: VLE relocations 3"Alan Modra2-7/+7
Correct sign extension. * ppc-opc.c (extract_li20): Rewrite.
2017-12-02Remove for_each_inferior_with_dataSimon Marchi4-20/+12
Remove for_each_inferior_with_data, replacing its sole usage with for_each_thread. gdb/gdbserver/ChangeLog: * inferiors.c (for_each_inferior_with_data): Remove. * inferiors.h (for_each_inferior_with_data): Remove. * server.c (handle_qxfer_threads_worker): Change parameter type. (handle_qxfer_threads_proper): Use for_each_thread.
2017-12-02Remove for_each_inferiorSimon Marchi7-35/+32
This patch removes for_each_inferior, replacing all its usages with for_each_thread. gdb/gdbserver/ChangeLog: * inferiors.c (for_each_inferior): Remove. (clear_inferiors): Use for_each_thread. * inferiors.h (for_each_inferior): Remove. * linux-low.c (linux_wait_for_event_filtered): Use for_each_thread. (linux_stabilize_threads): Likewise. * regcache.c (regcache_release): Likewise. * server.c (gdb_wants_all_threads_stopped): Likewise. (clear_pending_status_callback): Remove. (handle_status): Use for_each_thread. (captured_main): Likewise. * win32-low.c (child_init_thread_list): Likewise. (win32_clear_inferiors): Likewise. (fake_breakpoint_event): Likewise.
2017-12-02Remove find_inferiorSimon Marchi3-14/+5
All the usages of find_inferior were removed, so the function itself can be removed. gdb/gdbserver/ChangeLog: * inferiors.h (find_inferior): Remove. * inferiors.c (find_inferior): Remove.
2017-12-02Update commentsSimon Marchi2-3/+8
These functions were modified in the previous patch series, but I forgot to update some comments. gdb/gdbserver/ChangeLog: * linux-low.c (resume_status_pending_p): Update comment. (need_step_over_p): Update comment.
2017-12-02Remove usages of find_inferior that call proceed_one_lwpSimon Marchi2-16/+32
Replace with for_each_thread. gdb/gdbserver/ChangeLog: * linux-low.c (proceed_one_lwp): Return void, change parameter type. (unsuspend_and_proceed_one_lwp): Likewise. (proceed_all_lwps): Use for_each_thread. (unstop_all_lwps): Likewise.
2017-12-02Remove usage of find_inferior in linux_resumeSimon Marchi2-9/+15
Replace with for_each_thread. gdb/gdbserver/ChangeLog: * linux-low.c (linux_resume_one_thread): Return void, take parameter directly. (linux_resume): Use for_each_thread.
2017-12-02Remove usages of find_inferior in stop_all_lwpsSimon Marchi2-11/+27
Replace with for_each_thread. gdb/gdbserver/ChangeLog: * linux-low.c (send_sigstop_callback): Return void, change parameter type. Rename to... (send_sigstop): ... this. (suspend_and_send_sigstop_callback): Return void, change parameter type. Rename to... (suspend_and_send_sigstop): ... this. (stop_all_lwps): Use for_each_thread.
2017-12-02Remove usage of find_inferior in linux_stabilize_threadsSimon Marchi2-8/+13
Replace with find_thread. gdb/gdbserver/ChangeLog: * linux-low.c (lwp_running): Return bool, remove unused argument. (linux_stabilize_threads): Use find_thread.
2017-12-02Remove usages of find_inferior in select_event_lwpSimon Marchi2-62/+38
Replace with find_thread/for_each_thread. I inlined the callbacks, because they are relatively simple. gdb/gdbserver/ChangeLog: * linux-low.c (select_singlestep_lwp_callback): Remove. (count_events_callback): Remove. (select_event_lwp_callback): Remove. (select_event_lwp): Use find_thread/for_each_thread.
2017-12-02Remove usages of find_inferior calling not_stopped_callbackSimon Marchi2-19/+27
Replace with find_thread. Writing a lambda inline in directly in the if conditions would be a bit messy, so I chose to assign them to variables instead. gdb/gdbserver/ChangeLog: * linux-low.c (not_stopped_callback): Return bool, take filter argument directly. (linux_wait_for_event_filtered): Use find_thread. (linux_wait_1): Likewise.
2017-12-02Remove usage of find_inferior in find_lwp_pidSimon Marchi2-18/+10
Replace with find_thread. We could almost use find_thread_ptid, except that find_lwp_pid uses the pid of the input ptid of the lwp is 0, so the behavior is not quite the same. gdb/gdbserver/ChangeLog: * linux-low.c (same_lwp): Remove. (find_lwp_pid): Use find_thread.
2017-12-02Remove usage of find_inferior in linux_mournSimon Marchi2-13/+9
Replace with for_each_thread with pid filtering. The callback becomes trivial enough that it's better to inline it. gdb/gdbserver/ChangeLog: * linux-low.c (delete_lwp_callback): Remove. (linux_mourn): Use for_each_thread.
2017-12-02Remove usage of find_inferior in linux_detachSimon Marchi2-15/+13
Replace with for_each_thread with pid filtering. gdb/gdbserver/ChangeLog: * linux-low.c (linux_detach_lwp_callback): Return void, remove args parameter, don't check for pid. (linux_detach): Use for_each_thread.
2017-12-02Remove usage of find_inferior in last_thread_of_process_pSimon Marchi2-22/+22
Replace it with find_thread. I also modified the code a bit to use a lambda and a boolean. gdb/gdbserver/ChangeLog: * linux-low.c (struct counter): Remove. (second_thread_of_pid_p): Remove. (last_thread_of_process_p): Use find_thread.
2017-12-02Remove find_inferior_in_randomSimon Marchi4-29/+29
Replace with find_thread_in_random. gdb/gdbserver/ChangeLog: * inferiors.c (find_inferior_in_random): Remove. * inferiors.h (find_inferior_in_random): Remove. * linux-low.c (status_pending_p_callback): Return bool, accept parameter ptid directly. (linux_wait_for_event_filtered): Use find_thread_in_random. (linux_wait_1): Likewise.
2017-12-02Remove find_inferior_idSimon Marchi6-40/+28
Remove find_inferior_id, replacing its usages with find_thread_ptid. find_thread_ptid was implemented using find_inferior_id, so move the implementation there instead. gdb/gdbserver/ChangeLog: * inferiors.c (find_inferior_id): Remove. (find_thread_ptid): Move implemention from find_inferior_id to here. * inferiors.h (find_inferior_id): Remove. * server.c (handle_status): Use find_thread_ptid. (process_serial_event): Likewise. * thread-db.c (find_one_thread): Likewise. (thread_db_thread_handle): Likewise. * win32-low.c (thread_rec): Likewise. (child_delete_thread): Likewise. (win32_thread_alive): Likewise. (get_child_debug_event): Likewise.
2017-12-02Remove usages of find_inferior in linux-mips-low.cSimon Marchi2-24/+19
Replace with for_each_thread with pid filtering. This allows simplifying the callback a little bit. gdb/gdbserver/ChangeLog: * linux-mips-low.c (update_watch_registers_callback): Return void, remove pid_p parameter, don't check for pid. (mips_insert_point, mips_remove_point): Use for_each_thread.