aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2020-03-05gdbsupport/configure.ac: source development.shVyacheslav Petrishchev3-0/+11
[Commit message by Simon Marchi] The GDB build in non-development mode (turn development to false in bfd/development.sh if you want to try) is currently broken: CXXLD gdb /home/smarchi/src/binutils-gdb/gdb/disasm-selftests.c:218: error: undefined reference to 'selftests::register_test_foreach_arch(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, void (*)(gdbarch*))' /home/smarchi/src/binutils-gdb/gdb/disasm-selftests.c:220: error: undefined reference to 'selftests::register_test_foreach_arch(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, void (*)(gdbarch*))' /home/smarchi/src/binutils-gdb/gdb/dwarf2/frame.c:2310: error: undefined reference to 'selftests::register_test_foreach_arch(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, void (*)(gdbarch*))' /home/smarchi/src/binutils-gdb/gdb/gdbarch-selftests.c:168: error: undefined reference to 'selftests::register_test_foreach_arch(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, void (*)(gdbarch*))' /home/smarchi/src/binutils-gdb/gdbsupport/selftest.cc:96: error: undefined reference to 'selftests::reset()' This is because the gdbsupport configure script doesn't source bfd/development.sh to set the development variable. When $development is unset, GDB_AC_SELFTEST defaults to enabling selftests. I don't think the macro was written with this intention in mind, it just happens to be that way. So gdbsupport thinks selftests are enabled, while gdb thinks they are disabled. gdbsupport compiles in code that calls selftests:: functions, which are normally provided by gdb, but gdb doesn't provide them, hence the undefined references. Fix this by sourcing bfd/development.sh in gdbsupport/configure.ac, so that the development variable is set. gdbsupport/ChangeLog: * configure.ac: Added call development.sh. * configure: Regenerate.
2020-03-05Add support for ELF files which contain multiple reloc sections which all ↵Nick Clifton7-13/+465
target the same section. * elf-bfd.h (struct elf_backend_data): Add new fields: init_secondary_reloc_section, slurp_secondary_reloc_section, write_secondary_reloc_section. (_bfd_elf_init_secondary_reloc_section): Prototype. (_bfd_elf_slurp_secondary_reloc_section): Prototype. (_bfd_elf_write_secondary_reloc_section): Prototype. * elf.c ( bfd_section_from_shdr): Invoke the new init_secondary_reloc_section backend function, if defined, when a second reloc section is encountered. (swap_out_syms): Invoke the new symbol_section_index function, if defined, when computing the section index of an OS/PROC specific symbol. (_bfd_elf_init_secondary_reloc_section): New function. (_bfd_elf_slurp_secondary_reloc_section): New function. (_bfd_elf_write_secondary_reloc_section): New function. (_bfd_elf_copy_special_section_fields): New function. * elfcode.h (elf_write_relocs): Invoke the new write_secondary_relocs function, if defined, in order to emit secondary relocs. (elf_slurp_reloc_table): Invoke the new slurp_secondary_relocs function, if defined, in order to read in secondary relocs. * elfxx-target.h (elf_backend_copy_special_section_fields): Provide a non-NULL default definition. (elf_backend_init_secondary_reloc_section): Likewise. (elf_backend_slurp_secondary_reloc_section): Likewise. (elf_backend_write_secondary_reloc_section): Likewise. (struct elf_backend_data elfNN_bed): Add initialisers for the new fields. * configure.ac (score_elf32_[bl]e_vec): Add elf64.lo * configure: Regenerate.
2020-03-05gdb, gdbserver, gdbsupport: add .gitattributes filesTankut Baris Aktemur6-0/+31
Create .gitattributes files in gdb/, gdbserver/, and gdbsupport/. The files specify cpp-style diffs for .h and .c files. This is particularly helpful if a class in a header file is modified. For instance, if the `stop_requested` field of `thread_info` in gdb/gdbthread.h is modified, we get the following diff with 'git diff' (using git version 2.17.1): @@ -379,7 +379,7 @@ public: struct target_waitstatus pending_follow; /* True if this thread has been explicitly requested to stop. */ - int stop_requested = 0; + bool stop_requested = 0; /* The initiating frame of a nexting operation, used for deciding which exceptions to intercept. If it is null_frame_id no Note that the context of the change shows up as 'public:'; not so useful. With the .gitattributes file, we get: @@ -379,7 +379,7 @@ class thread_info : public refcounted_object struct target_waitstatus pending_follow; /* True if this thread has been explicitly requested to stop. */ - int stop_requested = 0; + bool stop_requested = 0; /* The initiating frame of a nexting operation, used for deciding which exceptions to intercept. If it is null_frame_id no The context is successfully shown as 'class thread_info'. This patch creates a .gitattributes file per each of gdb, gdbserver, and gdbsupport folders. An alternative would be to define the attributes in the root folder -- this would impact all the top-level folders, though. I opted for the more conservative approach. gdb/ChangeLog: 2020-03-05 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * .gitattributes: New file. gdbserver/ChangeLog: 2020-03-05 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * .gitattributes: New file. gdbsupport/ChangeLog: 2020-03-05 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * .gitattributes: New file.
2020-03-05Reduce --warn-section-align outputAlan Modra2-1/+14
PR 25570 * ldlang.c (lang_size_sections_1): Don't report changes on second and subsequent iterations that make no change in alignment from that already reported.
2020-03-05[gdb/testsuite] Update maint.exp for string cacheTom de Vries2-1/+5
When running gdb.base/maint.exp, I see: ... FAIL: gdb.base/maint.exp: maint print statistics ... This is due to commit be1e3d3eab "Introduce objfile::intern", which replaces the macro and filename caches with a string cache. Update maint.exp accordingly. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-03-05 Tom de Vries <tdevries@suse.de> * gdb.base/maint.exp: Update "main print statistics" expected output.
2020-03-05PR25629, objcopy : SIGSEGV in filter_symbolsAlan Modra2-2/+13
PR 25629 * objcopy.c (filter_symbols): Don't segfault on NULL prefix_symbols_string.
2020-03-04RISC-V: Support assembler modifier %got_pcrel_hi.Nelson Chu7-7/+45
gas/ * config/tc-riscv.c: Support the modifier %got_pcrel_hi. * doc/c-riscv.texi: Add documentation. * testsuite/gas/riscv/no-relax-reloc.d: Add test case for the new modifier %got_pcrel_hi. * testsuite/gas/riscv/no-relax-reloc.s: Likewise. * testsuite/gas/riscv/relax-reloc.d: Likewise. * testsuite/gas/riscv/relax-reloc.s: Likewise.
2020-03-04RISC-V: Add description for RISC-V Modifiers to as doc.Nelson Chu2-1/+117
gas/ * doc/c-riscv.texi (relocation modifiers): Add documentation. (RISC-V-Formats): Update the section name from "Instruction Formats" to "RISC-V Instruction Formats".
2020-03-05Large memory allocation reading fuzzed 64-bit archiveAlan Modra2-1/+15
This patch adds a sanity check for the size of an armap. * archive64.c (_bfd_archive_64_bit_slurp_armap): Check parsed_size against file size before allocating memory. Use bfd_alloc rather than bfd_zalloc for carsym/strings memory.
2020-03-05Automatic date update in version.inGDB Administrator1-1/+1
2020-03-04Introduce objfile::internTom Tromey8-52/+64
This introduces a string cache on the per-BFD object, replacing the macro and filename caches. Both of these caches just store strings, so this consolidation by itself saves a little memory (about the size of a bcache per objfile). Then this patch switches some allocations on the objfile obstack to use this bcache instead. This saves more space; and turns out to be a bit faster as well. Here are the before and after "maint time" + "maint space" results of "file ./gdb": Command execution time: 4.664021 (cpu), 4.728518 (wall) Space used: 39190528 (+29212672 for this command) Command execution time: 4.216209 (cpu), 4.107023 (wall) Space used: 36667392 (+26689536 for this command) The main interface to the string cache is a new pair of overloaded methods, objfile::intern. gdb/ChangeLog 2020-03-04 Tom Tromey <tom@tromey.com> * symmisc.c (print_symbol_bcache_statistics) (print_objfile_statistics): Update. * symfile.c (allocate_symtab): Use intern. * psymtab.c (partial_symtab::partial_symtab): Use intern. * objfiles.h (struct objfile_per_bfd_storage) <filename_cache, macro_cache>: Remove. <string_cache>: New member. (struct objfile) <intern>: New methods. * elfread.c (elf_symtab_read): Use intern. * dwarf2/read.c (fixup_go_packaging): Intern package name. (dwarf2_compute_name, dwarf2_physname) (create_dwo_unit_in_dwp_v1, create_dwo_unit_in_dwp_v2): Intern names. (guess_partial_die_structure_name): Update. (partial_die_info::fixup): Intern name. (dwarf2_canonicalize_name): Change parameter to objfile. Intern name. (dwarf2_name): Intern name. Update. * buildsym.c (buildsym_compunit::get_macro_table): Use string_cache.
2020-03-04Make "gnutarget" constTom Tromey4-3/+10
I noticed that gnutarget was not "const". Since writing through this pointer would probably be a bug, I think it ought to be. This patch makes the change. gdb/ChangeLog 2020-03-04 Tom Tromey <tom@tromey.com> * jit.c (bfd_open_from_target_memory): Make "target" const. * corefile.c (gnutarget): Now const. * gdbcore.h (gnutarget): Now const.
2020-03-05PR25570, ld duplicate "warning: changing start of section"Alan Modra2-13/+30
Note that because we should report a signed delta from the previous VMA it isn't possible to use ngettext. ngettext only supports unsigned long values. So byte/bytes goes from the message. PR 25570 * ldlang.c (lang_sizing_iteration): New static var. (lang_size_sections_1): Warn about no memory region only on first iteration. Warn about changing start address on first iteration then any delta from that on subsequent iterations. Report a signed delta. (one_lang_size_sections_pass): Increment lang_sizing_iteration.
2020-03-04Implement debugging of WOW64 processesHannes Domani7-100/+463
For WOW64 processes, the Wow64* variants of SuspendThread, GetThreadContext, SetThreadContext, and GetThreadSelectorEntry have to be used instead. And instead of EnumProcessModules, EnumProcessModulesEx with LIST_MODULES_32BIT is necessary. gdb/ChangeLog: 2020-03-04 Hannes Domani <ssbssa@yahoo.de> * NEWS: Mention support for WOW64 processes. * amd64-windows-nat.c (amd64_mappings): Rename and remove static. (amd64_windows_segment_register_p): Remove static. (_initialize_amd64_windows_nat): Update. * configure.nat <windows> (NATDEPFILES): Add i386-windows-nat.o. * i386-windows-nat.c (context_offset): Update. (i386_mappings): Rename and remove static. (i386_windows_segment_register_p): Remove static. (_initialize_i386_windows_nat): Update. * windows-nat.c (STATUS_WX86_BREAKPOINT): New macro. (STATUS_WX86_SINGLE_STEP): New macro. (EnumProcessModulesEx): New macro. (Wow64SuspendThread): New macro. (Wow64GetThreadContext): New macro. (Wow64SetThreadContext): New macro. (Wow64GetThreadSelectorEntry): New macro. (windows_set_context_register_offsets): Add static. (windows_set_segment_register_p): Likewise. (windows_add_thread): Adapt for WOW64 processes. (windows_fetch_one_register): Likewise. (windows_nat_target::fetch_registers): Likewise. (windows_store_one_register): Likewise. (display_selector): Likewise. (display_selectors): Likewise. (handle_exception): Likewise. (windows_continue): Likewise. (windows_nat_target::resume): Likewise. (windows_add_all_dlls): Likewise. (do_initial_windows_stuff): Likewise. (windows_nat_target::attach): Likewise. (windows_get_exec_module_filename): Likewise. (windows_nat_target::create_inferior): Likewise. (windows_xfer_siginfo): Likewise. (_initialize_loadable): Initialize Wow64SuspendThread, Wow64GetThreadContext, Wow64SetThreadContext, Wow64GetThreadSelectorEntry and EnumProcessModulesEx. * windows-nat.h (windows_set_context_register_offsets): Remove declaration. (windows_set_segment_register_p): Likewise. (i386_windows_segment_register_p): Add declaration. (amd64_windows_segment_register_p): Likewise.
2020-03-04Generate a warning in the ARM assembler if a PC-relative thumb load ↵Alexandre Oliva7-6/+24
instruction is detected in a section with insufficient alignment. * config/tc-arm.c (md_apply_fix): Warn if a PC-relative load is detected in a section which does not have at least 4 byte alignment. * testsuite/gas/arm/armv8-ar-it-bad.s: Add alignment directive. * testsuite/gas/arm/ldr-t.s: Likewise. * testsuite/gas/arm/sp-pc-usage-t.s: Likewise. * testsuite/gas/arm/sp-pc-usage-t.d: Finish test at end of disassembly, ignoring any NOPs that may have been inserted because of section alignment. * testsuite/gas/arm/ldr-t.d: Likewise.
2020-03-04Revert "gdb: Do not print empty-group regs when printing general ones"Luis Machado2-8/+19
Revert the change since it breaks existing behavior of "info registers" for some architectures. At least AArch64 and ARM are impacted by this change. gdb/ChangeLog: 2020-03-04 Luis Machado <luis.machado@linaro.org> Revert aa66aac47b4dd38f9524ddb5546c08cc09930d37 due to regressions in "info registers" for AArch64/ARM. The change caused "info registers" to not print GPR's. gdb/ChangeLog: 2020-02-01 Shahab Vahedi <shahab@synopsys.com> * target-descriptions.c (tdesc_register_in_reggroup_p): Return 0 when reg->group is empty and reggroup is not.
2020-03-04[gdb/doc] Remove trailing done from "Reading symbols from" linesTom de Vries3-4/+9
Since commit 3453e7e409 'Clean up "Reading symbols" output' we no longer print "done." after the "Reading symbols from" message: ... $ gdb -q a.out Reading symbols from a.out... (gdb) ... Update docs accordingly. Build on x86_64-linux. gdb/doc/ChangeLog: 2020-03-04 Tom de Vries <tdevries@suse.de> * gdb.texinfo: Remove trailing "done." in "Reading symbols from" lines. * python.texi: Same.
2020-03-04gdb.fortran: Allow Flang kind printing in fortran testingAlok Kumar Sharma2-14/+31
In lib/fortran.exp, in the helper function fortran_int4, kind parameter is expected to be printed as (kind=4) for the LLVM Fortran compiler, Flang along with gfortran. And in the helper function fortran_int8 kind parameter is expected to be printed as (kind=8). But for the Flang compiler default kind is not printed and non default kind is printed differently than gfortran as below. integer(kind=4) => integer integer(kind=8) => integer*8 real(kind=4) => real real(kind=8) => double precision complex(kind=4) => complex logical(kind=4) => logical character(kind=1) => character This commit adds support for printing of kind parameter for the Flang. There should be no change when testing with gfortran. Note: The current patch overrides earlier patch with below details. commit c3b149eb7697b376df1b3a47d0102afda389ee6d Author Alok Kumar Sharma (alokkumar.sharma@amd.com) Earlier patch was incomplete and based on assumption that flang should be changed to dump a type with kind like the way gfortan does. Later it was realized that the way flang dumps this info is not incorrect but different. And changes in gdb test framework are finalized. gdb/testsuite/ChangeLog: * lib/fortran.exp (fortran_int4): Handle flang kind printing. (fortran_int8): Likewise. (fortran_real4): Likewise. (fortran_real8): Likewise. (fortran_complex4): Likewise. (fortran_logical4): Likewise. (fortran_character1): Likewise.
2020-03-04x86: support VMGEXITJan Beulich14-4104/+4169
It has been publicly documented for quite some time, albeit not in the "General-Purpose and System Instructions" volume: https://www.amd.com/system/files/TechDocs/24593.pdf.
2020-03-04Revert "PR25570, ld duplicate "warning: changing start of section""Alan Modra3-10/+3
This reverts commit 91114f7583fac8fdf57c58a1f632839da62e43da.
2020-03-04PR25570, ld duplicate "warning: changing start of section"Alan Modra3-3/+10
PR 25570 * ldlang.c (lang_size_sections_1): Delay emitting non-fatal errors/warnings until final pass. * ldexp.c (fold_name): Likewise.
2020-03-04sh_addralign inconsistent with sh_addrAlan Modra2-1/+10
The ELF gABI says in part of sh_addralign: "The value of sh_addr must be congruent to 0, modulo the value of sh_addralign." * elf.c (elf_fake_sections): Ensure sh_addralign is such that sh_addr mod sh_addalign is zero.
2020-03-04Call cleanup on bfd_check_format_matches error exitAlan Modra2-0/+8
* format.c (bfd_check_format_matches): Call cleanup on error exit.
2020-03-04objcopy: Fix for pr19005 on machines with more than one octet per byte.Christian Eggers2-12/+21
On machines with more than one octet per byte, objcopy fills only a part of the gap between sections. * objcopy.c (copy_object): Convert from bytes to octets for --gap-fill and --pad-to.
2020-03-04Automatic date update in version.inGDB Administrator1-1/+1
2020-03-03Find tailcall frames before inline framesTom Tromey3-32/+47
A customer reported a failure to unwind in a certain core dump. A lengthy investigation showed that the problem came from the interaction between the tailcall and inline frame sniffers. Normally, the regular DWARF unwinder may discover a chain of tail calls ending in the current frame. In this case, it sets a member on the dwarf2_frame_cache object, so that a subsequent call into the tailcall sniffer will create the tailcall frames. However, in this scenario, what happened is that the DWARF unwinder did find tailcall frames -- but then the PC of the first such frame was recognized and claimed by the inline frame sniffer. This then caused unwinding to go astray further up the stack. This patch fixes the problem by arranging for the tailcall sniffer to be called before the inline sniffer. This way, if a DWARF frame has tailcall information, the tailcalls will always be processed first. This is safe to do, because the tailcall sniffer can only claim a frame if the previous frame did in fact find this information. (So, for example, if no DWARF frame is ever found, then this sniffer will never trigger.) This patch also partially reverts: commit 1ec56e88aa9b052ab10b806d82fbdbc8d153d977 Author: Pedro Alves <palves@redhat.com> Date: Fri Nov 22 13:17:46 2013 +0000 Eliminate dwarf2_frame_cache recursion, don't unwind from the dwarf2 sniffer (move dwarf2_tailcall_sniffer_first elsewhere). That patch moved the call to dwarf2_tailcall_sniffer_first out of dwarf2_frame_cache, and into dwarf2_frame_prev_register. However, in this situation, this is too late -- by the time dwarf2_frame_prev_register is called, the frame in question is already recognized by the inline frame sniffer. Rather than fully revert that patch, though, this just arranges to call dwarf2_tailcall_sniffer_first from dwarf2_frame_cache -- which is called shortly after the DWARF frame sniffer succeeds, via compute_frame_id. I don't know how to write a test case for this. gdb/ChangeLog 2020-03-03 Tom Tromey <tromey@adacore.com> * dwarf2/frame.c (struct dwarf2_frame_cache) <checked_tailcall_bottom, entry_cfa_sp_offset, entry_cfa_sp_offset_p>: Remove members. (dwarf2_frame_cache): Call dwarf2_tailcall_sniffer_first. (dwarf2_frame_prev_register): Don't call dwarf2_tailcall_sniffer_first. (dwarf2_append_unwinders): Don't append tailcall unwinder. * frame-unwind.c (add_unwinder): New fuction. (frame_unwind_init): Use it. Add tailcall unwinder.
2020-03-03gdbsupport: re-generate Makefile.inSimon Marchi2-1/+7
It looks like after doing last minute changes to Makefile.am in commit 06b3c5bdb ("gdbsupport: rename source files to .cc"), I forgot to re-generate Makefile.in. This patch fixes it. gdbsupport/ChangeLog: * Makefile.in: Re-generate.
2020-03-03x86: Replace IgnoreSize/DefaultSize with MnemonicSizeH.J. Lu7-10870/+10895
Since an instruction template can't have both IgnoreSize and DefaultSize, this patch replaces IgnoreSize and DefaultSize with MnemonicSize. gas/ * config/tc-i386.c (match_template): Replace ignoresize and defaultsize with mnemonicsize. (process_suffix): Likewise. opcodes/ * i386-gen.c (opcode_modifiers): Replace IgnoreSize/DefaultSize with MnemonicSize. * i386-opc.h (IGNORESIZE): New. (DEFAULTSIZE): Likewise. (IgnoreSize): Removed. (DefaultSize): Likewise. (MnemonicSize): New. (i386_opcode_modifier): Replace ignoresize/defaultsize with mnemonicsize. * i386-opc.tbl (IgnoreSize): New. (DefaultSize): Likewise. * i386-tbl.h: Regenerated.
2020-03-03gdb/fortran: Fix printing of logical true values for FlangAndrew Burgess4-1/+53
GDB is not able to print logical true values for Flang compiler. Actual result: (gdb) p l $1 = 4294967295 Expected result: (gdb) p l $1 = .TRUE. This is due to GDB expecting representation of true value being 1. The Fortran standard doesnt specify how LOGICAL types are represented. Different compilers use different non-zero values to represent logical true. The gfortran compiler uses 1 to represent logical true and the flang compiler uses -1. GDB should accept all the non-zero values as true. This is achieved by handling TYPE_CODE_BOOL in f_val_print and printing any non-zero value as true. gdb/ChangeLog: * f-valprint.c (f_val_print): Handle TYPE_CODE_BOOL, any non-zero value should be printed as true. gdb/testsuite/ChangeLog: * gdb.fortran/logical.exp: Add tests that any non-zero value is printed as true.
2020-03-03Rebase executable to match relocated base addressHannes Domani2-1/+59
Windows executables linked with -dynamicbase get a new base address when loaded, which makes debugging impossible if the executable isn't also rebased in gdb. The new base address is read from the Process Environment Block. gdb/ChangeLog: 2020-03-03 Hannes Domani <ssbssa@yahoo.de> * windows-tdep.c (windows_solib_create_inferior_hook): New function. (windows_init_abi): Set and use windows_so_ops.
2020-03-03The patch fixed invalid compilation of instruction LD IY,(HL) and ↵Sergey Belyashov8-6/+62
disassemble of this and LD (HL),IX instruction. Also it update testsuit. PR 25627 opcodes * z80-dis.c: Fix disassembly of LD IY,(HL) and D (HL),IX instructions. gas * config/tc-z80.c (emit_ld_rr_m): Fix invalid compilation of instruction LD IY,(HL). * testsuite/gas/z80/ez80_adl_all.d: Update expected disassembly. * testsuite/gas/z80/ez80_adl_all.s: Add tests of the instruction. * testsuite/gas/z80/ez80_z80_all.d: Update expected disassembly. * testsuite/gas/z80/ez80_z80_all.s: Add tests of the instruction.
2020-03-03Fix printf of a convenience variable holding an inferior addressSergio Durigan Junior4-1/+20
Back at: commit 1f6f6e21fa86dc3411a6498608f32e9eb24b7851 Author: Philippe Waroquiers <philippe.waroquiers@skynet.be> Date: Mon Jun 10 21:41:51 2019 +0200 Ensure GDB printf command can print convenience var strings without a target. GDB was extended in order to allow the printing of convenience variables that are strings without a target. However, this introduced a regression that hasn't been caught by our testsuite (because there were no tests for it). The problem happens when we try to print a convenience variable that holds the address of a string in the inferior. The following two-liners can reproduce the issue: $ echo -e 'int main(){const char a[]="test";return 0;}' | gcc -x c - -O0-g3 $ ./gdb/gdb --data-directory ./gdb/data-directory -q ./a.out -ex 'start' -ex 'set $x = (const char *) (&a[0] + 2)' -ex 'printf "%s\n", $x' After some investigation, I found that the problem happens on printcmd.c:printf_c_string. In the case above, we're taking the first branch of the 'if' condition, which assumes that there will be a value to be printed at "value_contents (value)". There isn't. We actually need to obtain the address that the variable points to, and read the contents from memory. It seems to me that we should avoid this branch if the TYPE_CODE of "value_type (value)" is TYPE_CODE_PTR (i.e., a pointer to the inferior's memory). This is what this patch does. I took the liberty to extend the current testcase under gdb.base/printcmds.exp and create a test that exercises this scenario. No regressions have been found on Buildbot. gdb/ChangeLog: 2020-03-03 Sergio Durigan Junior <sergiodj@redhat.com> * printcmd.c (print_c_string): Check also for TYPE_CODE_PTR when verifying if dealing with a convenience variable. gdb/testsuite/ChangeLog: 2020-03-03 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/printcmds.exp: Add test to verify printf of a variable holding an address.
2020-03-03Remove a call to abort which can be triggered by running objdump on a ↵Nick Clifton2-1/+6
corrupt input file. PR 25625 * prdbg.c (pr_tag_type): Remove call to abort.
2020-03-03x86: Allow integer conversion without suffix in AT&T syntaxH.J. Lu11-44/+250
According to gas manual, suffix in instruction mnemonics isn't always required: When there is no sizing suffix and no (suitable) register operands to deduce the size of memory operands, with a few exceptions and where long operand size is possible in the first place, operand size will default to long in 32- and 64-bit modes. This includes cvtsi2sd, cvtsi2ss, vcvtsi2sd, vcvtsi2ss, vcvtusi2sd and vcvtusi2ss. Since they are used in GCC 8 and older GCC releases, they must be allowed without suffix in AT&T syntax. gas/ PR gas/25622 * testsuite/gas/i386/i386.exp: Run x86-64-default-suffix and x86-64-default-suffix-avx. * testsuite/gas/i386/noreg64.s: Remove cvtsi2sd, cvtsi2ss, vcvtsi2sd, vcvtsi2ss, vcvtusi2sd and vcvtusi2ss entries. * testsuite/gas/i386/noreg64.d: Updated. * testsuite/gas/i386/noreg64.l: Likewise. * testsuite/gas/i386/x86-64-default-suffix-avx.d: New file. * testsuite/gas/i386/x86-64-default-suffix.d: Likewise. * testsuite/gas/i386/x86-64-default-suffix.s: Likewise. opcodes/ PR gas/25622 * i386-opc.tbl: Add IgnoreSize to cvtsi2sd, cvtsi2ss, vcvtsi2sd, vcvtsi2ss, vcvtusi2sd and vcvtusi2ss for AT&T syntax. * i386-tbl.h: Regenerated.
2020-03-03x86: Improve -malign-branchHongtao Liu7-32/+378
According to intel SDM manual, not all compare flag-modifying instructions are marcro-fusible with subsequent jcc instructions. For those non-fusible instructions, -malign-branch doesn't need to align them, only jcc itself needs to be aligned. Here are 2 restrictions which separate macro-fusible instruction from not Restriction 1: If TEST/AND/CMP/ADD/SUB/INC/DEC is one of the following format: cmp m, imm add m, imm sub m, imm test m, imm and m, imm inc m dec m it is unfusible with any jcc instruction. Restriction 2: /* Table 3-2. Macro-Fusible Instructions in Haswell Microarchitecture Note it also works for Skylake and Cascadelake. --------------------------------------------------------------------- | JCC | ADD/SUB/CMP | INC/DEC | TEST/AND | | ------ | ----------- | ------- | -------- | | Jo | N | N | Y | | Jno | N | N | Y | | Jc/Jb | Y | N | Y | | Jae/Jnb | Y | N | Y | | Je/Jz | Y | Y | Y | | Jne/Jnz | Y | Y | Y | | Jna/Jbe | Y | N | Y | | Ja/Jnbe | Y | N | Y | | Js | N | N | Y | | Jns | N | N | Y | | Jp/Jpe | N | N | Y | | Jnp/Jpo | N | N | Y | | Jl/Jnge | Y | Y | Y | | Jge/Jnl | Y | Y | Y | | Jle/Jng | Y | Y | Y | | Jg/Jnle | Y | Y | Y | Update maybe_fused_with_jcc_p to check if operands of CMP like instructions can be fused with condition jump. * gas/config/tc-i386.h (i386_tc_frag_data): Add member mf_type. (TC_FRAG_INIT): Init mf_type. * gas/config/tc-i386.c (enum mf_jcc_kind): New enum. (enum mf_cmp_kind): Ditto. (maybe_fused_with_jcc_p): Add argument mf_cmp_p to get mf_type of corresponding instructons, exclude unfusible instructions. (add_fused_jcc_padding_frag_p): Likewise. (add_branch_padding_frag_p): Likewise. (output_insn): Record mf_type for corresponding instructions. (i386_macro_fusible_p): New function. (i386_next_fusible_jcc_frag): Rename from i386_next_jcc_frag, add argument cmp_fragP to return next fusible jcc frag only. (i386_classify_machine_dependant_frag): Seperate macro-fusible instructions from condition jump. * gas/testsuite/gas/i386/align-branch-9.s: New file. * gas/testsuite/gas/i386/align-branch-9.d: Ditto. * gas/testsuite/gas/i386/x86-64-align-branch-9.s: Ditto. * gas/testsuite/gas/i386/x86-64-align-branch-9.d: Ditto. * gas/testsuite/gas/i386/i386.exp: Run new tests.
2020-03-03Update GDB to use new AUXV entry typesLuis Machado2-0/+16
I noticed GDB didn't know a particular AT tag (51) when doing some debugging. Turns out we're missing a few entries compared to glibc's headers. This patch adds them to GDB and fixes a failure in gdb.base/auxv.exp as a result. gdb/ChangeLog: 2020-03-03 Luis Machado <luis.machado@linaro.org> * auxv.c (default_print_auxv_entry): Add new AUXV entries.
2020-03-03Add missing AT tags to the ELF common header.Luis Machado2-0/+22
* elf/common.h (AT_L1I_CACHESIZE, AT_L1I_CACHEGEOMETRY) (AT_L1D_CACHESIZE, AT_L1D_CACHEGEOMETRY, AT_L2_CACHESIZE) (AT_L2_CACHEGEOMETRY, AT_L3_CACHESIZE, AT_L3_CACHEGEOMETRY) (AT_MINSIGSTKSZ): New defines, imported from glibc.
2020-03-03Fix a potential illegal memory access in the Z80 assembler.Sergey Belyashov2-8/+30
PR 25604 * config/tc-z80.c (contains_register): Prevent an illegal memory access when checking an expression for a register name.
2020-03-03Note that the --rpath-link command line option will search the contents of ↵Nick Clifton2-2/+19
the SEARCH_DIR linker script directive, if one is provided. PR 25588 * ld.texi (Options): Update the description of the --rpath-link option.
2020-03-03bfd_check_format_matches preserving matches vs. cleanupsAlan Modra2-5/+29
It didn't take long for oss-fuzz to find double frees due to a bug in the cleanup logic. It's seen when reading in any alpha-vms object file except when alpha_vms_vec is the default. But alpha_vms_vec is of course the default when building for --target=alpha-dec-vms (and naturally what I used to test the cleanup support since that is the only target with a cleanup that does anything currently). Anyway, the bug is that if bfd_check_format_matches is to preserve a match the cleanup for that match can't be run. Quite obviously that would destroy part of the match state. * format.c (struct bfd_preserve): Add cleanup field. (bfd_preserve_save): Add cleanup param and save. (bfd_preserve_restore): Return cleanup. (bfd_preserve_finish): Call the cleanup for the discarded match. (bfd_check_format_matches): Pass cleanup to bfd_preserve_save, and clear when preserving a match. Restore cleanup too when restoring that match.
2020-03-03[gdb/testsuite] Fix gdb.mi/gdb2549.exp with check-read1Tom de Vries2-3/+34
When running gdb.mi/gdb2549.exp with check-read1, we get: ... Running src/gdb/testsuite/gdb.mi/gdb2549.exp ... FAIL: gdb.mi/gdb2549.exp: register values t (timeout) ... The problem is that the command generates a lot of output, which is matched by a single '.*': ... mi_gdb_test "666-data-list-register-values t" \ "666\\^done,register-values=\\\[\{number=\"$decimal\",value=\"$binary\"\}.*\\\]" \ "register values t" ... Fix this by splitting up the matching and calling exp_continue after each number/value pair. Tested on x86_64-linux with make targets check and check-read1. gdb/testsuite/ChangeLog: 2020-03-03 Tom de Vries <tdevries@suse.de> * gdb.mi/gdb2549.exp: Fix "register values t" check-read1 timeout.
2020-03-03[gdb/testsuite] Fix tcl error in gdb.mi/list-thread-groups-available.expTom de Vries2-2/+9
When running gdb.mi/list-thread-groups-available.exp, we get: ... Running gdb.mi/list-thread-groups-available.exp ... ERROR: tcl error sourcing gdb.mi/list-thread-groups-available.exp. ERROR: Too many arguments to gdb_test_multiple ... The problem is that the gdb_test_multiple call has as last argument a $mi_gdb_prompt, which is no longer supported syntax since 590003dc0e "[gdb/testsuite] Add -lbl option in gdb_test_multiple". Fix this by using the new -prompt syntax. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-03-03 Tom de Vries <tdevries@suse.de> * gdb.mi/list-thread-groups-available.exp: Use -prompt syntax for gdb_test_multiple call.
2020-03-03[gdb/testsuite] Fix mi-sym-info.exp with check-read1Tom de Vries2-2/+9
When running gdb.mi/mi-sym-info.exp with check-read1, we run into: ... FAIL: gdb.mi/mi-sym-info.exp: List all functions FAIL: gdb.mi/mi-sym-info.exp: List all variables ... The problem is that while the $mi_gdb_prompt is active, gdb_test_multiple is used without -prompt "$mi_gdb_prompt$", so it defaults to matching $gdb_prompt. Fix this by adding the missing gdb_test_multiple arguments. Reg-tested on x86_64-linux with make targets check and check-read1. gdb/testsuite/ChangeLog: 2020-03-03 Tom de Vries <tdevries@suse.de> * gdb.mi/mi-sym-info.exp: Add missing -prompt "$mi_gdb_prompt$" to gdb_test_multiple calls.
2020-03-03Automatic date update in version.inGDB Administrator1-1/+1
2020-03-03Tidy obj-coff.hAlan Modra2-14/+5
* config/obj-coff.h: Remove vestiges of coff-m68k and pe-mips support.
2020-03-02Small clean up of use_displaced_steppingSimon Marchi2-13/+50
This function returns the result of a quite big condition. I think it would be more readeable if it was broken up in smaller pieces and commented. This is what this patch does. I also introduced gdbarch_supports_displaced_stepping, since it shows the intent better than checking for gdbarch_displaced_step_copy_insn_p. I also used that new function in displaced_step_prepare_throw. I also updated the comment on top of can_use_displaced_stepping, which seemed a bit outdated with respect to non-stop. The comment likely dates from before it was possible to have targets that always operate non-stop under the hood, even when the user-visible mode is all-stop. No functional changes intended. gdb/ChangeLog: * infrun.c (gdbarch_supports_displaced_stepping): New. (use_displaced_stepping): Break up conditions in smaller pieces. Use gdbarch_supports_displaced_stepping. (displaced_step_prepare_throw): Use gdbarch_supports_displaced_stepping.
2020-03-02gdb: Allow GDB to _not_ load a previous command historyAndrew Burgess9-15/+259
This commit aims to give a cleaner mechanism by which the user can prevent GDB from trying to load any previous command history. Currently the user can change the path to the history file, either using a command line flag, or by setting the GDBHISTFILE environment variable, and if the path is set to a non-existent file, then obviously GDB wont load any command history. However, this feels like a bit of a bodge, I'd like to add an official mechanism by which we can disable command history loading. Why would we want to prevent command history loading? The specific use case I have is GDB starting with a CWD that is a network mounted directory, and there is no command history present. Still GDB will access the network in order to check for the file. In my particular use case I'm actually starting a large number of GDB instances in parallel, all in the same network mounted directory, the large number of network accesses looking for this file introduces a noticeable delay at GDB startup. The approach I'm proposing here is a slight adjustment to the current rules for setting up the history filename. Currently, if a user does this, they see an error: (gdb) set history filename Argument required (filename to set it to.). However, if a user does this: $ GDBHISTFILE= gdb --quiet (gdb) set history save on (gdb) q warning: Could not rename -gdb18416~ to : No such file or directory So, we already have a bug in this area. My plan is to allow the empty filename to be accepted, and for this to mean, neither load, nor save the command history. This does mean that we now have two mechanisms to prevent saving the command history: (gdb) set history filename or (gdb) set history save off But the only way to prevent loading the command history is to set the filename to the empty string _before_ you get to a GDB prompt, either using a command line option, or the environment variable. I've updated some of the show commands, for example this session: (gdb) set history filename (gdb) show history filename There is no filename currently set for recording the command history in. (gdb) show history save Saving of the history record on exit is off. (gdb) set history save on (gdb) show history save Saving of the history is disabled due to the value of 'history filename'. (gdb) set history filename /tmp/hist (gdb) show history save Saving of the history record on exit is on. I've updated the manual, and added some tests. gdb/ChangeLog: * NEWS: Mention new behaviour of the history filename. * top.c (write_history_p): Add comment. (show_write_history_p): Add header comment, give a different message when history writing is on, but the history filename is empty. (history_filename): Add comment. (history_filename_empty): New function. (show_history_filename): Add header comment, give a different message when the filename is empty. (init_history): Compare history_filename against nullptr, and only read history if the filename is not empty. (set_history_filename): Add header comment, and only make non-empty filenames absolute. (init_main): Make the filename argument to 'set history filename' optional. gdb/doc/ChangeLog: * gdb.texinfo (Command History): Extend description for GDBHISTFILE and GDBHISTSIZE, add detail about the filename for 'set history filename' being optional. Describe the effect of an empty history filename on 'set history save on'. gdb/testsuite/ChangeLog: * gdb.base/default.exp: Remove test of 'set history filename'. * gdb.base/gdbinit-history.exp: Add tests for setting the history filename to the empty string. * lib/gdb.exp (gdb_init): Unset environment variables GDBHISTFILE and GDBHISTSIZE. Change-Id: Ia586e4311182fac99113b60f11ef8a11fbd5450b
2020-03-02Fix arm-netbsd build error: convert from FPA to VFPChristian Biesinger2-53/+79
The floating point register interface has changed to this: https://github.com/NetBSD/src/blob/trunk/sys/arch/arm/include/reg.h It now uses VFP instead of FPA registers. This patch updates arm-nbsd-nat.c accordingly. Also implements read_description so that these registers are correctly printed by "info registers" et al. Tested by compiling & running on arm-netbsd on qemu. gdb/ChangeLog: 2020-03-02 Christian Biesinger <cbiesinger@google.com> * arm-nbsd-nat.c (arm_supply_fparegset): Rename to... (arm_supply_vfpregset): ...this, and update to use VFP registers. (fetch_fp_register): Update. (fetch_fp_regs): Update. (store_fp_register): Update. (store_fp_regs): Update. (arm_netbsd_nat_target::read_description): New function. (fetch_elfcore_registers): Update.
2020-03-02gdb/remote: Restore support for 'S' stop reply packetAndrew Burgess5-45/+101
With this commit: commit 5b6d1e4fa4fc6827c7b3f0e99ff120dfa14d65d2 Date: Fri Jan 10 20:06:08 2020 +0000 Multi-target support There was a regression in GDB's support for older aspects of the remote protocol. Specifically, when a target sends the 'S' stop reply packet (which doesn't include a thread-id) then GDB has to figure out which thread actually stopped. Before the above commit GDB figured this out by using inferior_ptid in process_stop_reply, which contained the ptid of the current process/thread. This would be fine for single threaded targets (which is the only place using an S packet makes sense), but in the general case, relying on inferior_ptid for processing a stop is wrong - there's no reason to believe that what was GDB's current thread will be the same thread that just stopped in the target. With the above commit the inferior_ptid now has the value null_ptid inside process_stop_reply, this can be seen in do_target_wait, where we call switch_to_inferior_no_thread before calling do_target_wait_1. The problem this causes can be seen in the new test that runs gdbserver using the flag --disable-packet=T, and causes GDB to throw this assertion: inferior.c:279: internal-error: inferior* find_inferior_pid(process_stratum_target*, int): Assertion `pid != 0' failed. A similar problem was fixed in this commit: commit 3cada74087687907311b52781354ff551e10a0ed Date: Thu Jan 11 00:23:04 2018 +0000 Fix backwards compatibility with old GDBservers (PR remote/22597) However, this commit deals with the case where the T packet doesn't include a thread-id, not the S packet case. This commit solves the problem providing a thread-id at the GDB side if the remote target doesn't provide one. The thread-id provided comes from remote_state::general_thread, however, though this does work, I don't think it is the ideal solution. The remote_state tracks two threads, the continue_thread and the general_thread, these are updated when GDB asks the remote target to switch threads. The general_thread is set before performing things like register or memory accesses, and the continue_thread is set before things like continue or step commands. Further, the general_thread is updated after a target stops to reference the thread that stopped. The first thing to note from the above description is that we have a cycle of dependency, when a T packet arrives without a thread-id we fill in the thread-id from the general_thread data. The thread-id from the stop event is then used to set the general_thread. This in itself feels a little weird. The second question is why use the general_thread at all? You'd think given how they are originally set that the continue thread would be a better choice. The problem with this is that the continue_thread, if the user just does "continue", will be set to the minus_one_ptid, in the remote protocol this means all threads. When the stop arrives with no thread-id and we use continue_thread we end up with a very similar assertion to before because we now end up trying to lookup a thread using the minus_one_ptid. By contrast, once GDB has connected to a remote target the general_thread will be set to a valid thread-id, after which, if the target is single threaded, and stop events arrive without a thread-id, everything works fine. There is one slight weirdness with the above behaviour though. When GDB first connects to the remote target inferior_ptid is null_ptid, however, upon connecting we query the remote for its threads. As the thread information arrives GDB adds the threads to its internal database, and this process involves setting inferior_ptid to the id of each new thread in turn. Once we know about all the threads we wait for a stop event from the remote target to indicate that GDB is now in control of the target. The problem is that after adding the new threads we don't reset inferior_ptid, and the code path we use to wait for a stop event from the target also doesn't reset inferior_ptid, so it turns out that during the initial connection inferior_ptid is not null_ptid. This is lucky, because during the initial connection the general_thread variable _is_ set to null_ptid. So, during the initial connection, if the first stop event is missing a thread-id then we "provide" a thead-id from general_thread. This turns out to be null_ptid meaning no thread-id is known, and then during process_stop_reply we fill in the missing thread-id using inferior_ptid. This was all discussed on the mailing list here: https://sourceware.org/ml/gdb-patches/2020-02/msg01011.html My proposal for a fix then is: 1. Move the call to switch_to_inferior_no_thread into do_target_wait_1, this means that in all cases where we are waiting for an inferior the inferior_ptid will be set to null_ptid. This is good as no wait code should rely on inferior_ptid. 2. Remove the use of general_thread from the 'T' packet processing. The general_thread read here was only ever correct by chance, and we shouldn't be using it this way. 3. Remove use of inferior_ptid from process_stop_event as this is wrong, and will always be null_ptid now anyway. 4. When a stop_event has null_ptid due to a lack of thread-id (either from a T packet or an S packet) then pick the first non exited thread in the target and use that. This will be fine for single threaded targets. A multi-thread or multi-inferior aware remote target should be using T packets with a thread-id, so we give a warning if the target is multi-threaded, and we are still missing a thread-id. 5. Extend the existing test that covered the T packet with missing thread-id to also cover the S packet. gdb/ChangeLog: * remote.c (remote_target::remote_parse_stop_reply): Don't use the general_thread if the stop reply is missing a thread-id. (remote_target::process_stop_reply): Use the first non-exited thread if the target didn't pass a thread-id. * infrun.c (do_target_wait): Move call to switch_to_inferior_no_thread to .... (do_target_wait_1): ... here. gdb/testsuite/ChangeLog: * gdb.server/stop-reply-no-thread.exp: Add test where T packet is disabled.
2020-03-02gdbserver: Add mechanism to prevent sending T stop packetsAndrew Burgess4-0/+32
There is a developer only feature in gdbserver that provides a command line option --disable-packet that prevents some packets from being sent, which is used to increase test coverage within GDB. This commit extends this mechanism to prevent GDBserver from sending the T stop reply packets, instead limiting GDBserver to only send the S stop reply packets. The S stop reply packet is part of the older target control mechanism, which has design flaws that were worked around with the introduction of the newer target control mechanism, which uses the T stop reply packet. Limiting GDBserver to use S stop packets instead of T stop packets will, inevitably, mean that GDBserver doesn't function correctly in many cases involving multiple threads, however, I don't think this is too important, this is a developer only feature, intended to allow us to test GDB. A new test that makes use of this feature will be added in the next commit. gdbserver/ChangeLog: * remote-utils.cc (prepare_resume_reply): Add ability to convert T reply into an S reply. * server.cc (disable_packet_T): New global. (captured_main): Set new global when appropriate. * server.h (disable_packet_T): Declare.