aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2017-02-23Decouple user selection from internal selectionusers/simark/user-selection-rfcSimon Marchi30-318/+766
I am sending this as an RFC because it's far from complete and definitive, but I'd like to gather some comments and opinions before going further in this direction. The goal of this patch is to decouple the notion of the user-selected inferior/thread/frame from GDB's internally selected inferior/thread/frame. Currently, for example, the inferior_ptid variable has two jobs: - it's the user-selected thread: it's changed by the "thread" command. Other commands (continue, backtrace, etc) apply to this thread. - it's the internally-selected thread: it defines the thread GDB is currently "working" on. For example, implementations of to_xfer_partial will refer to it to know from which thread to read/write memory. Because of this dual usage, if we want to do some operations on a thread other than the currently selected one, we have to save the current inferior/thread/frame and restore them when we're done. Failing to do so would result in an unexpected selection switch for the user. To improve this, Pedro suggested in [1] to decouple the two concepts. This is essentially what this patch is trying to do. A new "user_selection" object is introduced, which contains the selected inferior/thread/frame from the point of view of the user. Before every command, we "apply" this selection to the core of GDB to make sure the internal selection matches the user selection. There is a single user selection for the whole GDB (named "global user-selection"), but as was mentioned in the linked thread, it opens the door to having different selections for different UIs. This means that each UI would have its own user-selection object, which would be applied to the core prior to executing commands from this UI. The global user-selection object only gets modified when we really intend to change it. It can be because of the thread / -thread-select / up / down / frame / inferior commands, a breakpoint hit in all-stop, an inferior exit, etc. The problem that initially prompted this effort is that the "--thread" flag of MI commands changes the user-selected thread under the user's feet. My initial attempt to fix it was to restore the selection after the MI command execution. However, some cases are hard to get right. For example: (thread 1 is currently selected) -interpreter-exec --thread 2 console "thread 3" Restoring the selected thread to thread 1 after the MI command execution wrongfully cancels the switch to thread 3. So it's hard to determine when we should or shouldn't restore. With the current patch, it works naturally: the --thread flag doesn't touch the user-selected thread, only the internal one. The "thread 3" command updates the user selection. Another difficulty is to send the right notifications to MI when the user selection changes. That means to not miss any, but not send too many either. Getting it somewhat right lead to ugly hacks (see the command_notifies_uscc_observer function) and even then it's not perfect (see the kfails in user-selected-context-sync.exp test). With the proposed method, it's easy to know when the user-selection changes and send notifications. With this patch, there are probably a few usage of make_cleanup_restore_current_thread that are not needed anymore, if they are only used to restore the user selection. I kept removing them for a later time though. In the current state, there are a few minor regressions in the testsuite (especially some follow-fork stuff I'm not sure how to handle), but the vast majority of the previously passing tests still pass. Comments are welcome! Thanks, Simon [1] https://sourceware.org/ml/gdb-patches/2016-08/msg00031.html
2017-02-23DWARF-5: testcaseJan Kratochvil4-0/+1065
binutils/ 2017-02-23 Jan Kratochvil <jan.kratochvil@redhat.com> * testsuite/binutils-all/dw5.S: New file. * testsuite/binutils-all/dw5.W: New file. * testsuite/binutils-all/readelf.exp (readelf -wiaoRlL): New test.
2017-02-23DWARF-5: DW_FORM_data16Jan Kratochvil2-0/+30
binutils/ 2017-02-23 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (read_and_display_attr_value): Support DW_FORM_data16.
2017-02-23DWARF-5: MacrosJan Kratochvil2-28/+33
binutils/ 2017-02-23 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (display_debug_macro): Support DWARF-5. Rename DW_MACRO_GNU_*.
2017-02-23DWARF-5: call sitesJan Kratochvil2-7/+45
binutils/ 2017-02-23 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (decode_location_expression): Support DW_OP_implicit_pointer, DW_OP_const_type, DW_OP_regval_type, DW_OP_deref_type, DW_OP_convert and DW_OP_reinterpret. (read_and_display_attr_value): Support DW_AT_call_value, DW_AT_call_data_value, DW_AT_call_target and DW_AT_call_target_clobbered.
2017-02-23DWARF-5 basic functionalityJan Kratochvil4-204/+994
binutils/ 2017-02-23 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (fetch_indirect_line_string): New function. (abbrev_attr): New field implicit_const. (add_abbrev_attr): New parameter implicit_const. (process_abbrev_section): Support DW_FORM_implicit_const. (decode_location_expression): Support DW_OP_entry_value. (read_and_display_attr_value): Add parameter implicit_const. Support DW_FORM_line_strp and DW_FORM_implicit_const. (read_and_display_attr): Add parameter implicit_const. (process_debug_info): Support line_str and DWARF-5. (read_debug_line_header): Support DWARF-5. (display_formatted_table): New function. (display_debug_lines_raw): New parameter file. Support DWARF-5. (display_debug_lines_decoded): New parameter fileptr. Support DWARF-5. (display_debug_lines): Pass file parameter. (display_debug_macro): Update read_and_display_attr_value caller. (display_debug_abbrev): Support DW_FORM_implicit_const. (display_loclists_list): New function. (display_loc_list): Support .debug_loclists. (display_debug_ranges_list): New function from display_debug_ranges. (display_debug_rnglists_list): New function. (display_debug_ranges): Support .debug_rnglists. (debug_displays): Add .debug_line_str, .debug_loclists and .debug_rnglists. * dwarf.h: Include dwarf2.h (DWARF2_Internal_LineInfo): Add li_offset_size. (DWARF2_Internal_CompUnit): Add cu_unit_type. (enum dwarf_section_display_enum): Add line_str. * readelf.c (process_section_headers): Add rnglists and loclists.
2017-02-23DWARF attrs: add delimiterJan Kratochvil2-25/+33
binutils/ 2017-02-23 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (display_block): Add parameter delimiter. (decode_location_expression): Update display_block callers. (read_and_display_attr_value): Add parameter delimiter. (read_and_display_attr, display_debug_macro): Update read_and_display_attr_value caller.
2017-02-23PR21166: Validate rdrand/rdseed support separately in ↵Luis Machado2-9/+35
gdb.reverse/insn-reverse-x86.c As reported in PR21166, there are Intel processors out there that support rdrand but not rdseed. The fix is to verify both features separately and only run rdrand/rdseed tests if supported. gdb/testsuite/ChangeLog: 2017-02-23 Luis Machado <lgustavo@codesourcery.com> * gdb.reverse/insn-reverse.x86.c (check_rdrand_support): Renamed to ... (check_supported_features): ... this. Changed return type to void. (supports_rdseed): New static global. (rdseed): Check supports_rdseed. (initialize): Call check_supported_features.
2017-02-23dwarf.c: Use more dwarf_vmaJan Kratochvil2-23/+34
binutils/ 2017-02-23 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (display_loc_list): Use dwarf_vma for offset, base_address and off. (display_loc_list_dwo): Use dwarf_vma for offset. (display_debug_loc): Use dwarf_vma for offset, base_address. (struct range_entry, range_entry_compar): Use dwarf_vma for ranges_offset. (display_debug_ranges): Use dwarf_vma for ranges_offset, offset and base_address.
2017-02-23S/390: Add support for new cpu architecture - arch12.Andreas Krebbel11-92/+726
This adds support of new instructions to the S/390 specific parts. The important feature of the new instruction set is the support of single and extended precision floating point vector operations. Note: arch12 is NOT the official name of the new CPU. It just continues the series of archXX options supported as alternate names. The archXX terminology refers to the edition number of the Principle of Operations manual. The official CPU name will be added later while keeping support of the arch12 for backwards compatibility. No testsuite regressions. Committed to mainline. Bye, -Andreas- opcodes/ChangeLog: 2017-02-23 Andreas Krebbel <krebbel@linux.vnet.ibm.com> * s390-mkopc.c (main): Accept arch12 as cpu string and vx2 as facility. * s390-opc.c: Add new operand description macros, new instruction types, instruction masks, and new .insn instruction types. * s390-opc.txt: Add new arch12 instructions. include/ChangeLog: 2017-02-23 Andreas Krebbel <krebbel@linux.vnet.ibm.com> * opcode/s390.h (enum s390_opcode_cpu_val): New value S390_OPCODE_ARCH12. (S390_INSTR_FLAG_VX2): New macro definition. gas/ChangeLog: 2017-02-23 Andreas Krebbel <krebbel@linux.vnet.ibm.com> * config/tc-s390.c (s390_parse_cpu): New entry for arch12. * doc/as.texinfo: Document arch12 as cpu type. * doc/c-s390.texi: Likewise. * testsuite/gas/s390/s390.exp: Run arch12 specific tests. * testsuite/gas/s390/zarch-arch12.d: New test. * testsuite/gas/s390/zarch-arch12.s: New test. * testsuite/gas/s390/zarch-z13.d: Rename some mnemonics in the output patterns.
2017-02-23Use gdb::function_view in iterate_over_symtabs & coPedro Alves16-690/+581
I wanted to pass a lambda to iterate_over_symtabs (see following patch), so I converted it to function_view, and then the rest is cascaded from that. This gets rid of a bunch of single-use callback functions and corresponding manually managed callback capture types (add_partial_datum, search_symbols_data, etc.) in favor of letting the compiler generate them for us by using lambdas with a capture. In a couple cases, it was more natural to convert the existing function callbacks to function objects (i.e., operator(), e.g., decode_compound_collector). gdb/ChangeLog: 2017-02-23 Pedro Alves <palves@redhat.com> * ada-lang.c: Include "common/function-view.h". (ada_iterate_over_symbols): Adjust to use function_view as callback type. (struct add_partial_datum, ada_complete_symbol_matcher): Delete. (ada_make_symbol_completion_list): Use a lambda. (ada_exc_search_name_matches): Delete. (name_matches_regex): New. (ada_add_global_exceptions): Use a lambda and name_matches_regex. * compile/compile-c-support.c: Include "common/function-view.h". (print_one_macro): Change prototype to accept a ui_file pointer. (write_macro_definitions): Use a lambda. * dwarf2read.c: Include "common/function-view.h". (dw2_map_expand_apply, dw2_map_symtabs_matching_filename) (dw2_expand_symtabs_matching): Adjust to use function_view as callback type. * language.h: Include "common/function-view.h". (struct language_defn) <la_iterate_over_symbols>: Adjust to use function_view as callback type. (LA_ITERATE_OVER_SYMBOLS): Remove DATA parameter. * linespec.c: Include "common/function-view.h". (collect_info::add_symbol): New method. (struct symbol_and_data_callback, iterate_inline_only, struct symbol_matcher_data, iterate_name_matcher): Delete. (iterate_over_all_matching_symtabs): Adjust to use function_view as callback type and lambdas. (iterate_over_file_blocks): Adjust to use function_view as callback type. (decode_compound_collector): Now a class with private fields. (decode_compound_collector::release_symbols): New method. (collect_one_symbol): Rename to... (decode_compound_collector::operator()): ... this and adjust. (lookup_prefix_sym): decode_compound_collector construction bits move to decode_compound_collector ctor. Pass the decode_compound_collector object directly as callback. Remove cleanups and use decode_compound_collector::release_symbols instead. (symtab_collector): Now a class with private fields. (symtab_collector::release_symtabs): New method. (add_symtabs_to_list): Rename to... (symtab_collector::operator()): ... this and adjust. (collect_symtabs_from_filename): symtab_collector construction bits move to symtab_collector ctor. Pass the symtab_collector object directly as callback. Remove cleanups and use symtab_collector::release_symtabs instead. (collect_symbols): Delete. (add_matching_symbols_to_info): Use lambdas. * macrocmd.c (print_macro_callback): Delete. (info_macro_command): Use a lambda. (info_macros_command): Pass print_macro_definition as callable directly. (print_one_macro): Remove 'ignore' parameter. (macro_list_command): Adjust. * macrotab.c (macro_for_each_data::fn): Now a function_view. (macro_for_each_data::user_data): Delete field. (foreach_macro): Adjust to call the function_view. (macro_for_each): Adjust to use function_view as callback type. (foreach_macro_in_scope): Adjust to call the function_view. (macro_for_each_in_scope): Adjust to use function_view as callback type. * macrotab.h: Include "common/function-view.h". (macro_callback_fn): Declare a prototype instead of a pointer. Remove "user_data" parameter. (macro_for_each, macro_for_each_in_scope): Adjust to use function_view as callback type. * psymtab.c (partial_map_expand_apply) (psym_map_symtabs_matching_filename, recursively_search_psymtabs): Adjust to use function_view as callback type and to return bool. (psym_expand_symtabs_matching): Adjust to use function_view as callback types. * symfile-debug.c (debug_qf_map_symtabs_matching_filename): Adjust to use function_view as callback type and to return bool. (debug_qf_expand_symtabs_matching): Adjust to use function_view as callback types. * symfile.c (expand_symtabs_matching): Adjust to use function_view as callback types. * symfile.h: Include "common/function-view.h". (expand_symtabs_file_matcher_ftype) (expand_symtabs_symbol_matcher_ftype) (expand_symtabs_exp_notify_ftype): Remove "data" parameter and return bool. (quick_symbol_functions::map_symtabs_matching_filename) (quick_symbol_functions::expand_symtabs_matching): Adjust to use function_view as callback type and return bool. (expand_symtabs_matching): Adjust to use function_view as callback type. (maintenance_expand_name_matcher) (maintenance_expand_file_matcher): Delete. (maintenance_expand_symtabs): Use lambdas. * symtab.c (iterate_over_some_symtabs): Adjust to use function_view as callback types and return bool. (iterate_over_symtabs): Likewise. Use unique_xmalloc_ptr instead of a cleanup. (lookup_symtab_callback): Delete. (lookup_symtab): Use a lambda. (iterate_over_symbols): Adjust to use function_view as callback type. (struct search_symbols_data, search_symbols_file_matches) (search_symbols_name_matches): Delete. (search_symbols): Use a pair of lambdas. (struct add_name_data, add_macro_name, symbol_completion_matcher) (symtab_expansion_callback): Delete. (default_make_symbol_completion_list_break_on_1): Use lambdas. * symtab.h: Include "common/function-view.h". (iterate_over_some_symtabs): Adjust to use function_view as callback type and return bool. (iterate_over_symtabs): Adjust to use function_view as callback type. (symbol_found_callback_ftype): Remove 'data' parameter and return bool. (iterate_over_symbols): Adjust to use function_view as callback type.
2017-02-23Introduce gdb::function_viewPedro Alves6-0/+557
This commit adds a new function_view type. This type holds a non-owning reference to a callable. It is meant to be used as callback type of functions, instead of using the C-style pair of function pointer and 'void *data' arguments. function_view allows passing references to stateful function objects / lambdas with captures as callbacks efficiently, while function pointer + 'void *' does not. See the intro in the new function-view.h header for more. Unit tests included, put into a new gdb/unittests/ subdir. gdb/ChangeLog: 2017-02-23 Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS, SUBDIR_UNITTESTS_OBS): New. (%.o) <unittests/%.c>: New pattern. * configure.ac ($development): Add $(SUBDIR_UNITTESTS_OBS) to CONFIG_OBS, and $(SUBDIR_UNITTESTS_SRCS) to CONFIG_SRCS. * common/function-view.h: New file. * unittests/function-view-selftests.c: New file. * configure: Regenerate.
2017-02-23opcodes,gas: associate SPARC ASIs with an architecture level.Sheldon Lobo5-203/+256
With this change an architecture level bump due to assembly ASIs will show up as a warning/error depending on options passed to gas. Tested with sparc64-linux-gnu, and it does not introduce any regressions. gas/ChangeLog: Add support for associating SPARC ASIs with an architecture level. * config/tc-sparc.c (parse_sparc_asi): New encode SPARC ASIs. opcodes/ChangeLog: Add support for associating SPARC ASIs with an architecture level. * include/opcode/sparc.h (sparc_asi): New sparc_asi struct. * opcodes/sparc-opc.c (asi_table): Updated asi_table and encoding/ decoding of SPARC ASIs.
2017-02-23Fix usage of inferior_ptid in two thread_alive implementationsSimon Marchi3-2/+8
While inspecting some target code, I noticed that in these two implementations of thread_alive, inferior_ptid is referenced directly instead of using the ptid passed as parameters. I guess that it is wrong, although I can't really test it in both cases. gdb/ChangeLog: * bsd-uthread.c (bsd_uthread_thread_alive): Use ptid instead of inferior_ptid. * go32-nat.c (go32_thread_alive): Likewise.
2017-02-23Add support to readelf for displaying gnu attributes in architectures not ↵Nick Clifton2-76/+99
known to support them. * readelf.c (display_tag_value): Use an explicit signed type for the tag parameter. (display_gnu_attributes): Use an unsigned integer type for attribute tags. (display_power_gnu_attribute): Likewise. (display_s390_gnu_attribute): Likewise. (display_sparc_hwcaps): Likewise. (display_sparc_hwcaps2): Likewise. (display_sparc_gnu_attribute): Likewise. (display_mips_gnu_attribute): Likewise. (display_tic6x_attribute): Likewise. (display_raw_attribute): Likewise. (process_attributes): Likewise. (process_arm_specific): Delete redundant function. (process_power_specific): Likewise. (process_s390_specific): Likewise. (process_sparc_specific): Likewise. (process_tic6x_specific): Likewise. (process_msp430x_specific): Likewise. (display_public_gnu_attributes): New function. Displays known information about an unknown gnu attribute. (display_generic_attribute): New function. Calls display_tag_value for non-nul tags. (process_arch_specific): Call process_attributes even for architectures not known to specifically support gnu attributes.
2017-02-23Use xfree rather than delete for varobj_iterYao Qi2-1/+6
ASAN reports an error, -var-create container @ c^M =================================================================^M ^[[1m^[[31m==21639==ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x6030000805c0^M ^[[1m^[[0m #0 0x7f2449b01b2a in operator delete(void*) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x99b2a)^M #1 0xbb601d in update_dynamic_varobj_children ../../binutils-gdb/gdb/varobj.c:794^M #2 0xbb6556 in varobj_get_num_children(varobj*) ../../binutils-gdb/gdb/varobj.c:854^M #3 0x580cb4 in print_varobj ../../binutils-gdb/gdb/mi/mi-cmd-var.c:61^M #4 0x58138b in mi_cmd_var_create(char*, char**, int) ../../binutils-gdb/gdb/mi/mi-cmd-var.c:145^M #5 0x5967ce in mi_cmd_execute ../../binutils-gdb/gdb/mi/mi-main.c:2301^M #6 0x594b05 in captured_mi_execute_command ../../binutils-gdb/gdb/mi/mi-main.c:2001 .... ^M ^[[1m^[[32m0x6030000805c0 is located 0 bytes inside of 32-byte region [0x6030000805c0,0x6030000805e0)^M ^[[1m^[[0m^[[1m^[[35mallocated by thread T0 here:^[[1m^[[0m^M #0 0x7f2449b00602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)^M #1 0x7d1596 in xmalloc ../../binutils-gdb/gdb/common/common-utils.c:43^M #2 0x604176 in py_varobj_iter_new ../../binutils-gdb/gdb/python/py-varobj.c:159^M #3 0x6042da in py_varobj_get_iterator(varobj*, _object*) ../../binutils-gdb/gdb/python/py-varobj.c:198^M #4 0xbb5806 in varobj_get_iterator ../../binutils-gdb/gdb/varobj.c:720^M #5 0xbb5b9b in update_dynamic_varobj_children ../../binutils-gdb/gdb/varobj.c:758^M gdb: 2017-02-23 Yao Qi <yao.qi@linaro.org> * varobj-iter.h (varobj_iter_delete): Call xfree instead of delete.
2017-02-23Use delete instead of xfree for varobj_itemYao Qi2-2/+8
In commit 2f408ec (Use ui_file_as_string throughout more), we start to new varobj_item, > - vitem = XNEW (struct varobj_item); > + vitem = new varobj_item (); but we still use xfree. This causes some ASAN errors, -var-update container^M =================================================================^M ^[[1m^[[31m==20660==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new vs free) on 0x602000090c10^M ^[[1m^[[0m #0 0x2baa77d03631 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x54631)^M #1 0x80e0c8 in xfree(void*) /home/yao/SourceCode/gnu/gdb/git/gdb/common/common-utils.c:100^M #2 0xc13670 in varobj_clear_saved_item /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:727^M #3 0xc13957 in update_dynamic_varobj_children /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:752^M #4 0xc1841c in varobj_update(varobj**, int) /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:1699^M #5 0x5a2bf7 in varobj_update_one /home/yao/SourceCode/gnu/gdb/git/gdb/mi/mi-cmd-var.c:712^M #6 0x5a2a41 in mi_cmd_var_update(char*, char**, int) /home/yao/SourceCode/gnu/gdb/git/gdb/mi/mi-cmd-var.c:695^ ........ ^M ^[[1m^[[32m0x602000090c10 is located 0 bytes inside of 16-byte region [0x602000090c10,0x602000090c20)^M ^[[1m^[[0m^[[1m^[[35mallocated by thread T0 here:^[[1m^[[0m^M #0 0x2baa77d0415f in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5515f)^M #1 0x63613e in py_varobj_iter_next /home/yao/SourceCode/gnu/gdb/git/gdb/python/py-varobj.c:112^M #2 0xc13b89 in update_dynamic_varobj_children /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:776^M #3 0xc1841c in varobj_update(varobj**, int) /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:1699^M #4 0x5a2bf7 in varobj_update_one /home/yao/SourceCode/gnu/gdb/git/gdb/mi/mi-cmd-var.c:712^M #5 0x5a2a41 in mi_cmd_var_update(char*, char**, int) /home/yao/SourceCode/gnu/gdb/git/gdb/mi/mi-cmd-var.c:695^M gdb: 2017-02-23 Yao Qi <yao.qi@linaro.org> * varobj.c (varobj_clear_saved_item): Use delete instead of xfree. (update_dynamic_varobj_children): Likewise.
2017-02-23gas: slightly relax .startof.()/.sizeof.() testcaseJan Beulich2-6/+8
2017-02-23x86: drop stray VEX opcode 82 referencesJan Beulich2-4/+9
No such ModR/M-less opcode has ever existed in public documentation afaict, so I can't see why it had been added in the first place. Furthermore opcode 77 is special only with implied prefix 0F.
2017-02-23x86: extend 64-bit invalid MPX insn forms testcaseJan Beulich3-171/+226
2017-02-23Correct VLE 16D and SDAREL relocationsAlan Modra5-75/+79
PR 20744 bfd/ * elf32-ppc.c (ppc_elf_howto_raw): Correct dst_mask on all VLE 16D relocations. (ppc_elf_vle_split16): Correct field mask and shift for 16D relocs. (ppc_elf_relocate_section): Correct calculation for VLE SDAREL relocs. ld/ * testsuite/ld-powerpc/vle-reloc-2.s: Use r6 for last insn of each group. * testsuite/ld-powerpc/vle-reloc-2.d: Update for above change and sdarel reloc fix.
2017-02-23Automatic date update in version.inGDB Administrator1-1/+1
2017-02-22Display user op byteJan Kratochvil2-2/+6
binutils/ 2017-02-22 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (decode_location_expression): Display also OP.
2017-02-22readelf: Restore a lost new line in version informationMaciej W. Rozycki2-1/+7
Fix a commit 74e1a04b9787 ("More fixes for reading corrupt ELF files.") `readelf --version-info' output formatting regression where a dropped new line caused section header information from the `.gnu.version_d' version definition section to be printed on the same line as this section's first entry. For example with the `mips-linux' target we get: $ cat ver_def.s .data .globl new_foo .type new_foo, %object new_foo: .symver new_foo, foo@@ver_foo $ cat ver_def.ver { global: *foo*; local: *; }; $ as -o ver_def.o ver_def.s $ ld -e 0 --export-dynamic --version-script=ver_def.ver -o ver_def ver_def.o $ readelf -V ver_def Version symbols section '.gnu.version' contains 4 entries: Addr: 000000000000007e Offset: 0x01007e Link: 2 (.dynsym) 000: 0 (*local*) 2 (ver_foo) 1 (*global*) 2 (ver_foo) Version definition section '.gnu.version_d' contains 2 entries: Addr: 0x0000000000000088 Offset: 0x010088 Link: 3 (.dynstr) 000000: Rev: 1 Flags: BASE Index: 1 Cnt: 1 Name: ver_def 0x001c: Rev: 1 Flags: none Index: 2 Cnt: 1 Name: ver_foo Version definition past end of section $ Add the new line then, to get: $ readelf -V ver_def Version symbols section '.gnu.version' contains 4 entries: Addr: 000000000000007e Offset: 0x01007e Link: 2 (.dynsym) 000: 0 (*local*) 2 (ver_foo) 1 (*global*) 2 (ver_foo) Version definition section '.gnu.version_d' contains 2 entries: Addr: 0x0000000000000088 Offset: 0x010088 Link: 3 (.dynstr) 000000: Rev: 1 Flags: BASE Index: 1 Cnt: 1 Name: ver_def 0x001c: Rev: 1 Flags: none Index: 2 Cnt: 1 Name: ver_foo Version definition past end of section $ instead. binutils/ * readelf.c (process_version_sections) <SHT_GNU_verdef>: Print a new line between the heading and the first version definition entry.
2017-02-22PR ld/20828: Move symbol version processing ahead of GC symbol sweepMaciej W. Rozycki11-336/+466
Complement commit b531344c34b0 ("PR ld/20828: Reorder the symbol sweep stage of section GC") and commit 81ff47b3a546 ("PR ld/20828: Fix linker script symbols wrongly forced local with section GC") and move symbol version processing ahead of the symbol sweep stage of section GC, all in `bfd_elf_size_dynamic_sections', so that version symbols created stay in the global scope and are not output as local symbols to the dynamic symbol table in the presence of corresponding symbol definitions pulled from a DSO involved in a link. Consolidate the whole of symbol version processing into a single block from all parts scattered across the function and rearranging the local variables used as necessary, however leaving the setting of dynamic entries associated with the DT_VERDEF, DT_VERDEFNUM, DT_VERNEED and DT_VERNEEDNUM tags and the SEC_EXCLUDE flag for unused `.gnu.version' section in the original places. With the rearrangement of code blocks `Elf_Internal_Verneed *t' would shadow the previous definition of `struct bfd_elf_version_tree *t', so rename the former variable to `vn'. bfd/ PR ld/20828 * elflink.c (bfd_elf_size_dynamic_sections): Move symbol version processing ahead of the call to `elf_gc_sweep_symbol'. ld/ PR ld/20828 * testsuite/ld-elf/pr20828-d.sd: New test. * testsuite/ld-elf/pr20828-e.sd: New test. * testsuite/ld-elf/pr20828-v.od: New test. * testsuite/ld-elf/pr20828-v.ver: New test version script. * testsuite/ld-elf/pr20828-v.ld: New test linker script. * testsuite/ld-elf/pr20828.ld: Add `.gnu.version' and `.gnu.version_d'. * testsuite/ld-elf/shared.exp: Run the new tests.
2017-02-22GAS: Consistently fix labels at the `.end' pseudo-opMaciej W. Rozycki8-4/+101
Fix a functional regression with the `.end' pseudo-op, introduced with commit ecb4347adecd ("Last take: approval for MIPS_STABS_ELF killing"), <https://sourceware.org/ml/binutils/2002-06/msg00443.html>, and commit dcd410fe1544 ("GNU as 2.14 on IRIX 6: crashes with shared libs"), <https://sourceware.org/ml/binutils/2003-07/msg00415.html>, which caused symbol values for labels placed between the end of a function's contents and its terminating `.end' followed by one of the alignment pseudo-ops to be different depending on whether either `-mdebug', or `-mno-pdr', or neither of the command-line options is in effect, be it implied or specified. Given debug-label-end.s as follows and the `mips-linux' target we have: $ cat debug-label-end.s .text .globl foo .globl bar .align 4, 0 .ent foo foo: nop .aent bar bar: .insn .end foo .align 4, 0 .space 16 .globl baz .ent baz baz: nop .end baz .align 4, 0 .space 16 $ as -o debug-label-end.o debug-label-end.s $ readelf -s debug-label-end.o | grep bar 9: 00000004 0 FUNC GLOBAL DEFAULT 1 bar $ as -mdebug -o debug-label-end.o debug-label-end.s $ readelf -s debug-label-end.o | grep bar 9: 00000010 0 FUNC GLOBAL DEFAULT 1 bar $ as -mno-pdr -o debug-label-end.o debug-label-end.s $ readelf -s debug-label-end.o | grep bar 8: 00000010 0 FUNC GLOBAL DEFAULT 1 bar $ The reason is the call to `md_flush_pending_output', which in the case of `mips*-*-*' targets expands to `mips_emit_delays', which in turn calls `mips_no_prev_insn', which calls `mips_clear_insn_labels', which clears the list of outstanding labels. That list is in turn consulted in `mips_align', called in the interpretation of alignment directives, and the labels adjusted to the current location. A call to `md_flush_pending_output' is only made from `s_mips_end' and then only if `-mpdr' is in effect, which is the default for `*-*-linux*' and some other `mips*-*-*' targets. A call to `md_flush_pending_output' is never made from `ecoff_directive_end', which is used in place of `s_mips_end' when `-mdebug' is in effect. Consequently if `-mno-pdr' or `-mdebug' is in effect the list of outstanding labels makes it through to any alignment directive that follows and the labels are differently interpreted depending on the command-lines options used. And we want code produced to be always the same. Call `md_flush_pending_output' unconditionally then in `s_mips_end' and add such a call from `ecoff_directive_end' as well, as long as the macro is defined. While `ecoff_directive_end' is shared among targets, the only one other than `mips*-*-*' actually using it is `alpha*-*-*' and it does not define `md_flush_pending_output'. So the semantics isn't going to change for it and neither it has to have its `s_alpha_end' updated or have code in `ecoff_directive_end' conditionalized. gas/ * ecoff.c (ecoff_directive_end) [md_flush_pending_output]: Call `md_flush_pending_output'. * config/tc-mips.c (s_mips_end) [md_flush_pending_output]: Call `md_flush_pending_output' unconditionally. * testsuite/gas/mips/debug-label-end-1.d: New test. * testsuite/gas/mips/debug-label-end-2.d: New test. * testsuite/gas/mips/debug-label-end-3.d: New test. * testsuite/gas/mips/debug-label-end.s: New test source. * testsuite/gas/mips/mips.exp: Run the new tests.
2017-02-22Align .gnu_debuglink sections on a 4-byte boundary.Nick Clifton2-0/+13
PR binutils/21193 * opncls.c (bfd_create_gnu_debuglink_section): Give the newly created section 4-byte alignment.
2017-02-22Fix gas/all/err-sizeof.s for cris*-*-*Hans-Peter Nilsson2-1/+6
2017-02-22Skip ARM vcmp-noprefix-imm test on non-ELF targetsNick Clifton2-0/+5
2017-02-22gas: require an operand to .startof.()/.sizeof.()Jan Beulich3-0/+49
2017-02-22aarch64: actually copy first operand in convert_bfc_to_bfm()Jan Beulich2-2/+7
Commit 93562a343c ("[AArch64] PR target/20666, fix wrong encoding of new introduced BFC pseudo") changed the destination operand to 0, making the whole function invocation a no-op. We really want to copy operand 0 (a register) to operand 1 (an immediate before coming here), even if right now this likely is only a latent bug.
2017-02-22Automatic date update in version.inGDB Administrator1-1/+1
2017-02-22Fix a regression by: Code cleanup: Split dwarf2_ranges_read to a callbackJan Kratochvil2-0/+6
On some Fedora 23 systems an internal error has been printed. gdb/ChangeLog 2017-02-21 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf2read.c (dwarf2_record_block_ranges): Add forgotten BASEADDR.
2017-02-22PowerPC ld segfault on script discarding dynamic sectionsAlan Modra5-14/+33
bfd/ * elf64-ppc.c (ppc64_elf_finish_dynamic_sections): Don't segfault on .got or .plt output section being discarded by script. * elf32-ppc.c (ppc_elf_finish_dynamic_sections): Likewise. Move vxworks splt temp. gold/ * powerpc.cc (Target_powerpc::make_iplt_section): Check that output_section exists before attempting add_output_section_data. (Target_powerpc::make_brlt_section): Likewise.
2017-02-21Default initialize enum flags to 0Simon Marchi2-1/+7
... so that we don't need to do it manually, and potentially forget. For example, this allows to do: my_flags flags; ... flags |= some_flag; gdb/ChangeLog: * common/enum-flags.h (enum_flags::enum_flags): Initialize m_enum_value to 0 in default constructor.
2017-02-21[ppc64] Add POWER8/ISA 2.07 atomic sequences single-stepping supportEdjunior Barbosa Machado6-18/+295
gdb/ 2017-02-21 Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com> * rs6000-tdep.c (LOAD_AND_RESERVE_MASK): Rename from LWARX_MASK. (STORE_CONDITIONAL_MASK): Rename from STWCX_MASK. (LBARX_INSTRUCTION, LHARX_INSTRUCTION, LQARX_INSTRUCTION, STBCX_INSTRUCTION, STHCX_INSTRUCTION, STQCX_INSTRUCTION): New defines. (IS_LOAD_AND_RESERVE_INSN, IS_STORE_CONDITIONAL_INSN): New macros. (ppc_displaced_step_copy_insn): Use IS_LOAD_AND_RESERVE_INSN. (ppc_deal_with_atomic_sequence): Use IS_LOAD_AND_RESERVE_INSN and IS_STORE_CONDITIONAL_INSN. gdb/testsuite/ 2017-02-21 Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com> * gdb.arch/ppc64-isa207-atomic-inst.exp: New testcase based on gdb.arch/ppc64-atomic-inst.exp. Add tests for lbarx/stbcx, lharx/sthcx and lqarx/stqcx. * gdb.arch/ppc64-isa207-atomic-inst.S: New file. * gdb.arch/ppc64-isa207-atomic-inst.c: Likewise.
2017-02-21Fix test names starting with uppercase in gdb.arch/ppc64-atomic-inst.expEdjunior Barbosa Machado2-6/+11
gdb/testsuite/ 2017-02-21 Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com> * gdb.arch/ppc64-atomic-inst.exp: Fix test names starting with uppercase.
2017-02-21Fix compile time warning message in linker testsuite test.Nick Clifton2-6/+13
* testsuite/ld-ifunc/pr18808b.c (bar): Fix compile time warning about non-void function returning without a result.
2017-02-21Fix recent compiler warnings.Jan Kratochvil2-1/+6
gcc-4.8.5-11.el7.x86_64 dwarf2read.c: In function ‘pc_bounds_kind dwarf2_get_pc_bounds(die_info*, CORE_ADDR*, CORE_ADDR*, dwarf2_cu*, partial_symtab*)’: dwarf2read.c:12134:7: error: ‘range_end’ may be used uninitialized in this function [-Werror=maybe-uninitialized] dwarf2read.c:12133:7: error: ‘range_beginning’ may be used uninitialized in this function [-Werror=maybe-uninitialized] gdb/ChangeLog 2017-02-21 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf2_rnglists_process: Initialize range_beginning and range_end.
2017-02-21Alpha DT_RELAAlan Modra2-8/+19
* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Only emit DT_RELA, DT_RELASZ, and DT_RELAENT when DT_RELASZ is non-zero.
2017-02-21Automatic date update in version.inGDB Administrator1-1/+1
2017-02-20DWARF-5: NEWSJan Kratochvil2-0/+7
a NEWS entry. gdb/ChangeLog 2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com> * NEWS (Changes since GDB 7.12): Add DWARF-5.
2017-02-20DWARF-5: DW_FORM_data16Jan Kratochvil6-1/+140
DWARF-5 has new form DW_FORM_data16. The problem is that GDB cannot pass 16-byte constant as a constant value as that would require GDB to use GCC extension __int128. Formerly such data was coded as DW_FORM_block* so GDB still decodes DW_FORM_data16 like DW_FORM_block*. gdb/ChangeLog 2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf2read.c (skip_one_die, read_attribute_value) (dwarf2_const_value_attr, dump_die_shallow) (dwarf2_get_attr_constant_value, dwarf2_fetch_constant_bytes) (skip_form_bytes, attr_form_is_constant): Handle DW_FORM_data16. gdb/testsuite/ChangeLog 2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com> * gdb.dwarf2/formdata16.c: New file. * gdb.dwarf2/formdata16.exp: New file. * lib/dwarf.exp (Dwarf): Add DW_FORM_data16.
2017-02-20DWARF-5: MacrosJan Kratochvil2-38/+46
DWARF-5 renamed DW_MACRO_GNU_* to DW_MACRO_*. gdb/ChangeLog 2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf2read.c (read_file_scope): Rename DW_MACRO_GNU_*. (dwarf_parse_macro_header): Accept DWARF version 5. (dwarf_decode_macro_bytes, dwarf_decode_macros): Rename DW_MACRO_GNU_*.
2017-02-20DWARF-5: call sitesJan Kratochvil18-100/+965
this patch updates all call sites related DWARF-5 renames. gdb/ChangeLog 2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com> * block.c (call_site_for_pc): Rename DW_OP_GNU_*, DW_TAG_GNU_* and DW_AT_GNU_*. * common/common-exceptions.h (enum errors): Likewise. * dwarf2-frame.c (class dwarf_expr_executor): Likewise. * dwarf2expr.c (dwarf_block_to_dwarf_reg) (dwarf_expr_context::execute_stack_op): Likewise. * dwarf2expr.h (struct dwarf_expr_context, struct dwarf_expr_piece): Likewise. * dwarf2loc.c (dwarf_evaluate_loc_desc::get_base_type) (dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value) (show_entry_values_debug, call_site_to_target_addr) (func_addr_to_tail_call_list, func_verify_no_selftailcall) (dwarf_expr_reg_to_entry_parameter, dwarf_entry_parameter_to_value) (entry_data_value_free_closure, value_of_dwarf_reg_entry) (value_of_dwarf_block_entry, indirect_pieced_value) (symbol_needs_eval_context::push_dwarf_reg_entry_value): (disassemble_dwarf_expression): Likewise. * dwarf2read.c (process_die, inherit_abstract_dies) (read_call_site_scope): Likewise. * gdbtypes.h (struct func_type, struct call_site_parameter) (struct call_site): Likewise. * stack.c (read_frame_arg): Likewise. * std-operator.def (OP_VAR_ENTRY_VALUE): Likewise. gdb/doc/ChangeLog 2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com> * gdb.texinfo (Print Settings, Tail Call Frames): Rename DW_OP_GNU_*, DW_TAG_GNU_* and DW_AT_GNU_*. gdb/testsuite/ChangeLog 2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com> * gdb.arch/amd64-entry-value-param-dwarf5.S: New file. * gdb.arch/amd64-entry-value-param-dwarf5.c: New file. * gdb.arch/amd64-entry-value-param-dwarf5.exp: New file. * gdb.arch/amd64-entry-value.exp: Rename DW_OP_GNU_*, DW_TAG_GNU_* and DW_AT_GNU_*.
2017-02-20DWARF-5 basic functionalityJan Kratochvil9-140/+805
this is a kitchen-sink patch for everything that did not fit into its own patch. DWO is not yet implemented. gdb/ChangeLog 2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com> * defs.h (read_unsigned_leb128): New declaration. * dwarf2loc.c (decode_debug_loclists_addresses): New function. (decode_debug_loc_dwo_addresses): Update DEBUG_LOC_* to DW_LLE_*. (dwarf2_find_location_expression): Call also decode_debug_loclists_addresses. Handle DWARF-5 ULEB128 length. * dwarf2loc.h (dwarf2_version): New declaration. * dwarf2read.c (struct dwarf2_per_objfile): Add loclists, line_str, rnglists. (dwarf2_elf_names): Add .debug_loclists, .debug_line_str, .debug_rnglists. (struct dwop_section_names): Add loclists_dwo. (dwop_section_names): Add .debug_loclists.dwo. (struct comp_unit_head): Add unit_type, signature, type_offset_in_tu. (struct dwarf2_per_cu_data): Add dwarf_version. (struct dwo_sections): Add loclists. (struct attr_abbrev): Add implicit_const. (read_indirect_line_string): New declaration. (read_unsigned_leb128): Delete declaration. (rcuh_kind): New definition. (read_and_check_comp_unit_head): Change parameter is_debug_types_section to section_kind. (dwarf2_locate_sections): Handle loclists, line_str and rnglists. (read_comp_unit_head): Change parameter abfd to section, add parameter section_kind. Handle DWARF-5. (error_check_comp_unit_head): Accept also DWARF version 5. (read_and_check_comp_unit_head): Change parameter is_debug_types_section to section_kind. (read_and_check_type_unit_head): Delete function. (read_abbrev_offset): Handle DWARF-5. (create_debug_type_hash_table): Add parameter section_kind. Process only DW_UT_type. Use signature and type_offset_in_tu from struct comp_unit_head. (create_debug_types_hash_table): Update create_debug_type_hash_table caller. (create_all_type_units): Call create_debug_type_hash_table. (read_cutu_die_from_dwo, init_cutu_and_read_dies): Change read_and_check_type_unit_head caller to read_and_check_comp_unit_head caller. (skip_one_die): Handle DW_FORM_implicit_const. (dwarf2_rnglists_process): New function. (dwarf2_ranges_process): Call dwarf2_rnglists_process for DWARF-5. (abbrev_table_read_table): Handle DW_FORM_implicit_const. (read_attribute_value): Handle DW_FORM_implicit_const, DW_FORM_line_strp. (read_attribute): Handle DW_FORM_implicit_const. (read_indirect_string_at_offset_from): New function from read_indirect_string_at_offset. (read_indirect_string_at_offset): Call read_indirect_string_at_offset_from. (read_indirect_line_string_at_offset): New function. (read_indirect_string): New function comment. (read_indirect_line_string): New function. (read_unsigned_leb128): Make it global. (dwarf2_string_attr): Handle DWARF-5. (add_include_dir_stub, read_formatted_entries): New functions. (dwarf_decode_line_header, dump_die_shallow, cu_debug_loc_section): Handle DWARF-5. (per_cu_header_read_in): Update read_comp_unit_head caller. (dwarf2_version): New function. * symfile.h (struct dwarf2_debug_sections): Add loclists, line_str and rnglists. * xcoffread.c (dwarf2_xcoff_names): Update struct dwarf2_debug_sections fields. gdb/testsuite/ChangeLog 2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com> * gdb.dwarf2/dw2-error.exp (file $testfile): Update expected string.
2017-02-20Code cleanup: Refactor abbrev_table_read_table cycleJan Kratochvil2-10/+15
I find it as an improvement on its own, it prevents more code duplication in a future patch. gdb/ChangeLog 2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf2read.c (abbrev_table_read_table): Read the data only once.
2017-02-20Code cleanup: Split dwarf2_ranges_read to a callbackJan Kratochvil2-85/+49
DWARF-5 has .debug_rnglists which is somehow similar to .debug_ranges. This patch converts dwarf2_ranges_read to dwarf2_ranges_process which can work with both DWARF kinds of range lists through a callback. It also simplifies dwarf2_record_block_ranges which can benefit from it. gdb/ChangeLog 2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf2read.c (dwarf2_ranges_process): New function from dwarf2_ranges_read. (dwarf2_ranges_read, dwarf2_record_block_ranges): Use dwarf2_ranges_process.
2017-02-20Code cleanup: Split create_debug_types_hash_tableJan Kratochvil2-125/+139
DWARF-5 moved .debug_types into .debug_info and so the types reading code needs to be reused more (in a future patch). gdb/ChangeLog 2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf2read.c (create_debug_type_hash_table): New function from create_debug_types_hash_table. (create_debug_types_hash_table): Call create_debug_type_hash_table. (create_all_type_units, open_and_init_dwo_file): Update create_debug_types_hash_table callers.
2017-02-20Fix another memory access error in readelf when parsing a corrupt binary.Nick Clifton2-14/+30
PR binutils/21156 * dwarf.c (cu_tu_indexes_read): Move into... (load_cu_tu_indexes): ... here. Change the variable into tri-state. Change the function into boolean, returning false if the indicies could not be loaded. (find_cu_tu_set): Return NULL if the indicies could not be loaded.