aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2019-11-19PR24968, make objcopy use output ELF arch if -B not givenAlan Modra2-2/+16
This should make objcopy -B redundant for the common case of producing ELF output where the -O target defaults to the desired arch:mach. PR 24968 * objcopy.c (copy_object): For ELF output and non-ELF input without arch, take arch from output file if not given by -B. Don't bfd_get_arch_info when we already have iarch.
2019-11-19PR25191, internal error in _bfd_elf_set_section_contentsAlan Modra2-10/+24
This PR copies a fuzzed PE input file to ELF output, in the process confusing the ELF backend by copying COFF-only section flags to the output. SEC_COFF_SHARED has the same value as SEC_ELF_COMPRESS. One approach to fixing this problem is of course not to reuse flag bits, but we've run out. So this patch only copies section flags that are in the bfd_applicable_section_flags set when changing the flavour of the output file. PR 25191 * objcopy.c (is_nondebug_keep_contents_section): Use bfd_get_flavour. (copy_object): Likewise. (setup_section): Likewise. If flavour of input and output files differ, restrict section flags to the intersection of input and output bfd_applicable_section_flags.
2019-11-19PR25197, assertion fail coffgen.cAlan Modra2-15/+19
The testcase in this PR triggered "BFD_ASSERT (p2->is_sym)" by sneakily generating a C_FILE sym whose value pointed into auxents. The fix then is in the last changed line of this patch, to check p->is_sym as well as p->u.syment.n_sclass. The other changes fix various overflow checks that weren't as solid as they could be. PR 25197 * coffgen.c (coff_find_nearest_line_with_names): Check that C_FILE u.syment.n_value does point at another C_FILE sym and not into some auxent that happens to look like a C_FILE. Properly check for integer overflow and avoid possible pointer wrap-around. Simplify pr17512 checks.
2019-11-19Add space between program name and file for objcopy/strip/objdump messagesAlan Modra2-6/+11
The GNU coding standard does indicate there should be no space in messages like these, but we tend to put a space in all other messages. This patch cures the inconsistency in: $ binutils/strip-new -F elf32-little -N .text -o pr25200 pr25200.bin binutils/strip-new: pr25200: R_X86_64_PLT32 unsupported binutils/strip-new:pr25200: sorry, cannot handle this file * bucomm.c (bfd_nonfatal_message): Add a space between program name and file.
2019-11-19gdb/testsuite: Merge whatis.exp and ctf-whatis.expAndrew Burgess4-1142/+469
The recently added gdb.base/ctf-whatis.exp test is a slightly modified version of gdb.base/whatis.exp, with a few tests removed, and the source compiled with different compiler options. This patch merges the two tests together into a single test script. I tested using a version of GCC with CTF support added. gdb/testsuite/ChangeLog: * gdb.base/ctf-whatis.c: Delete. * gdb.base/ctf-whatis.exp: Delete. * gdb.base/whatis.exp: Rewrite to compile as both dwarf and ctf. Change-Id: I09e11c70f197b79d2b1e0ae8c86a21c622be6c51
2019-11-19gdb/testsuite: Merge cvexpr.exp and ctf-cvexpr.expAndrew Burgess3-718/+247
The recently added gdb.base/ctf-cvexpr.exp is just a copy of gdb.base/cvexpr.exp but compiled with different options. This patch merges these two tests together into a single test script. I tested this change using a version of GCC with CTF support added. gdb/testsuite/ChangeLog: * gdb.base/ctf-cvexpr.exp: Delete. * gdb.base/cvexpr.exp: Rewrite to compile as both dwarf and ctf. Change-Id: If678c3e38cb444867defa970203d26563f15dba4
2019-11-19gdb/testsuite: Introduce skip_ctf_tests guard functionAndrew Burgess5-20/+42
Most versions of GCC in the wild don't support CTF debug format right now, so, rather than attempting to compile the tests and failing each time, this patch introduces a guard function to check if the compiler supports CTF. If we don't have CTF support then the CTF tests are skipped. This patch only updates 3 of the 4 CTF tests, the fourth will be handled in the next patch. gdb/testsuite/ChangeLog: * gdb.base/ctf-constvars.exp: Skip test if CTF is not supported in the compiler. Clean up header comment a little. * gdb.base/ctf-ptype.exp: Likewise. * gdb.base/ctf-whatis.exp: Likewise. * lib/gdb.exp (skip_ctf_tests): New proc. Change-Id: I505c11169a9bc9871a31fc0c61e119f92f32cc63
2019-11-18Fix crash with core + TUI + runSergio Durigan Junior4-5/+74
Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1765117 A segfault can happen in a specific scenario when using TUI + a corefile, as explained in the bug mentioned above. The problem happens when opening a corefile on GDB: $ gdb ./core program entering TUI (C-x a), and then issuing a "run" command. GDB segfaults with the following stack trace: (top-gdb) bt #0 0x00000000004cd5da in target_ops::shortname (this=0x0) at ../../binutils-gdb/gdb/target.h:449 #1 0x0000000000ac08fb in target_shortname () at ../../binutils-gdb/gdb/target.h:1323 #2 0x0000000000ac09ae in tui_locator_window::make_status_line[abi:cxx11]() const (this=0x23e1fa0 <_locator>) at ../../binutils-gdb/gdb/tui/tui-stack.c:86 #3 0x0000000000ac1043 in tui_locator_window::rerender (this=0x23e1fa0 <_locator>) at ../../binutils-gdb/gdb/tui/tui-stack.c:231 #4 0x0000000000ac1632 in tui_show_locator_content () at ../../binutils-gdb/gdb/tui/tui-stack.c:369 #5 0x0000000000ac63b6 in tui_set_key_mode (mode=TUI_COMMAND_MODE) at ../../binutils-gdb/gdb/tui/tui.c:321 #6 0x0000000000aaf9be in tui_inferior_exit (inf=0x2d446a0) at ../../binutils-gdb/gdb/tui/tui-hooks.c:181 #7 0x000000000044cddf in std::_Function_handler<void (inferior*), void (*)(inferior*)>::_M_invoke(std::_Any_data const&, inferior*&&) (__functor=..., __args#0=@0x7fffffffd650: 0x2d446a0) at /usr/include/c++/9/bits/std_function.h:300 #8 0x0000000000757db9 in std::function<void (inferior*)>::operator()(inferior*) const (this=0x2cf3168, __args#0=0x2d446a0) at /usr/include/c++/9/bits/std_function.h:690 #9 0x0000000000757876 in gdb::observers::observable<inferior*>::notify (this=0x23de0c0 <gdb::observers::inferior_exit>, args#0=0x2d446a0) at ../../binutils-gdb/gdb/gdbsupport/observable.h:106 #10 0x000000000075532d in exit_inferior_1 (inftoex=0x2d446a0, silent=1) at ../../binutils-gdb/gdb/inferior.c:191 #11 0x0000000000755460 in exit_inferior_silent (inf=0x2d446a0) at ../../binutils-gdb/gdb/inferior.c:234 #12 0x000000000059f47c in core_target::close (this=0x2d68590) at ../../binutils-gdb/gdb/corelow.c:265 #13 0x0000000000a7688c in target_close (targ=0x2d68590) at ../../binutils-gdb/gdb/target.c:3293 #14 0x0000000000a63d74 in target_stack::push (this=0x23e1800 <g_target_stack>, t=0x23c38c8 <the_amd64_linux_nat_target>) at ../../binutils-gdb/gdb/target.c:568 #15 0x0000000000a63dbf in push_target (t=0x23c38c8 <the_amd64_linux_nat_target>) at ../../binutils-gdb/gdb/target.c:583 #16 0x0000000000748088 in inf_ptrace_target::create_inferior (this=0x23c38c8 <the_amd64_linux_nat_target>, exec_file=0x2d58d30 "/usr/bin/cat", allargs="", env=0x25f12b0, from_tty=1) at ../../binutils-gdb/gdb/inf-ptrace.c:128 #17 0x0000000000795ccb in linux_nat_target::create_inferior (this=0x23c38c8 <the_amd64_linux_nat_target>, exec_file=0x2d58d30 "/usr/bin/cat", allargs="", env=0x25f12b0, from_tty=1) at ../../binutils-gdb/gdb/linux-nat.c:1094 #18 0x000000000074eae9 in run_command_1 (args=0x0, from_tty=1, run_how=RUN_NORMAL) at ../../binutils-gdb/gdb/infcmd.c:639 ... The problem happens because 'tui_locator_window::make_status_line' needs the value of 'target_shortname' in order to update the status line. 'target_shortname' is a macro which expands to: #define target_shortname (current_top_target ()->shortname ()) and, in our scenario, 'current_top_target ()' returns NULL, which obviously causes a segfault. But why does it return NULL, since, according to its comment on target.h, it should never do that? What is happening is that we're being caught in the middle of a "target switch". We had the 'core_target' on top, because we were inspecting a corefile, but when the user decided to invoke "run" GDB had to actually create the inferior, which ends up detecting that we have a target already, and tries to close it (from target.c): /* See target.h. */ void target_stack::push (target_ops *t) { /* If there's already a target at this stratum, remove it. */ strata stratum = t->stratum (); if (m_stack[stratum] != NULL) { target_ops *prev = m_stack[stratum]; m_stack[stratum] = NULL; target_close (prev); // <-- here } ... When the current target ('core_target') is being closed, it checks for possible observers registered with it and calls them. TUI is one of those observers, it gets called, tries to update the status line, and GDB crashes. The real problem is that we are clearing 'm_stack[stratum]', but forgetting to adjust 'm_top'. Interestingly, this scenario is covered in 'target_stack::unpush', but Pedro said he forgot to call it here.. The fix, therefore, is to call '::unpush' if there's a target on the stack. This patch has been tested on the Buildbot and no regressions have been found. I'm also submitting a testcase for it. gdb/ChangeLog: 2019-11-18 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> https://bugzilla.redhat.com/show_bug.cgi?id=1765117 * target.c (target_stack::push): Call 'unpush' if there's a target on top of the stack. gdb/testsuite/ChangeLog: 2019-11-18 Sergio Durigan Junior <sergiodj@redhat.com> https://bugzilla.redhat.com/show_bug.cgi?id=1765117 * gdb.tui/corefile-run.exp: New file. Change-Id: I39e2f8b538c580c8ea5bf1d657ee877e47746c8f
2019-11-19Automatic date update in version.inGDB Administrator1-1/+1
2019-11-19[GOLD] OSABI not set when STT_GNU_IFUNC or STB_GNU_UNIQUE symbols outputAlan Modra4-4/+52
This patch arranges to have OSABI set to ELFOSABI_GNU (if not set to some other non-zero value) when gold outputs an ifunc local or global symbol, or a unique global symbol to either .dynsym or .symtab. STT_GNU_IFUNC and STB_GNU_UNIQUE have values in the LOOS to HIOS range and therefore require interpretation according to OSABI. I'm not sure why parameters->target() is const Target& while parameters->sized_target() is Sized_target*, but it's inconvenient to use the latter in Symbol_table::finalize. So this patch adds another const_cast complained about in layout.cc and gold.cc. PR 24853 * symtab.h (set_has_gnu_output, has_gnu_output_): New. * symtab.cc (Symbol_table::Symbol_table): Init has_gnu_output_. (Symbol_table::finalize): Set ELFOSABI_GNU when has_gnu_output_. (Symbol_table::set_dynsym_indexes, Symbol_table::sized_finalize): Call set_has_gnu_output for STT_GNU_IFUNC and STB_GNU_UNIQUE globals. * object.cc (Sized_relobj_file::do_finalize_local_symbols): Call set_has_gnu_output when STT_GNU_IFUNC locals will be output.
2019-11-19PR25200, SIGSEGV in _bfd_elf_validate_relocAlan Modra3-23/+12
PR 25200 * reloc.c (bfd_default_reloc_type_lookup): Don't BFD_FAIL. * elf.c (_bfd_elf_validate_reloc): Don't segfault on NULL howto.
2019-11-18Fix a bunch of python leaks due to missing calls to tp_free in *_dealloc ↵Philippe Waroquiers9-0/+21
functions. valgrind reports leaks in many python tests, such as: ==17162== VALGRIND_GDB_ERROR_BEGIN ==17162== 8,208 (5,472 direct, 2,736 indirect) bytes in 57 blocks are definitely lost in loss record 7,551 of 7,679 ==17162== at 0x4835753: malloc (vg_replace_malloc.c:307) ==17162== by 0x6EAFD1: _PyObject_New (object.c:279) ==17162== by 0x4720E6: blpy_iter(_object*) (py-block.c:92) ==17162== by 0x698772: PyObject_GetIter (abstract.c:2577) ==17162== by 0x2343BE: _PyEval_EvalFrameDefault (ceval.c:3159) ==17162== by 0x22E9E2: function_code_fastcall (call.c:283) ==17162== by 0x2340A8: _PyObject_Vectorcall (abstract.h:127) ==17162== by 0x2340A8: call_function (ceval.c:4987) ==17162== by 0x2340A8: _PyEval_EvalFrameDefault (ceval.c:3486) ==17162== by 0x22E9E2: function_code_fastcall (call.c:283) ==17162== by 0x82172B: _PyObject_Vectorcall (abstract.h:127) ==17162== by 0x82172B: method_vectorcall (classobject.c:67) ==17162== by 0x6AF474: _PyObject_Vectorcall (abstract.h:127) ==17162== by 0x6AF474: _PyObject_CallNoArg (abstract.h:153) ==17162== by 0x6AF474: _PyObject_CallFunctionVa (call.c:914) ==17162== by 0x6B0673: callmethod (call.c:1010) ==17162== by 0x6B0673: _PyObject_CallMethod_SizeT (call.c:1103) ==17162== by 0x477DFE: gdb_PyObject_CallMethod<> (python-internal.h:182) ==17162== by 0x477DFE: get_py_iter_from_func(_object*, char const*) (py-framefilter.c:272) ==17162== by 0x4791B4: py_print_args (py-framefilter.c:706) ==17162== by 0x4791B4: py_print_frame(_object*, enum_flags<frame_filter_flag>, ext_lang_frame_args, ui_out*, int, htab*) (py-framefilter.c:960) ==17162== by 0x47A130: gdbpy_apply_frame_filter(extension_language_defn const*, frame_info*, enum_flags<frame_filter_flag>, ext_lang_frame_args, ui_out*, int, int) (py-framefilter.c:1236) ==17162== by 0x369C39: apply_ext_lang_frame_filter(frame_info*, enum_flags<frame_filter_flag>, ext_lang_frame_args, ui_out*, int, int) (extension.c:563) ==17162== by 0x4EC9C9: backtrace_command_1 (stack.c:2031) ==17162== by 0x4EC9C9: backtrace_command(char const*, int) (stack.c:2183) ... Most of the leaks in python tests are due to the fact that many PyObject xxxxx_dealloc functions are missing the line to free self or obj such as: Py_TYPE (self)->tp_free (self); or Py_TYPE (obj)->tp_free (obj); With this patch, the number of python tests leaking decreases from 52 to 12. gdb/ChangeLog 2019-11-18 Philippe Waroquiers <philippe.waroquiers@skynet.be> * python/py-block.c (blpy_dealloc): Call tp_free. (blpy_block_syms_dealloc): Likewise. * python/py-finishbreakpoint.c (bpfinishpy_dealloc): Likewise. * python/py-inferior.c (infpy_dealloc): Likewise. * python/py-lazy-string.c (stpy_dealloc): Likewise. * python/py-linetable.c (ltpy_iterator_dealloc): Likewise. * python/py-symbol.c (sympy_dealloc): Likewise. * python/py-symtab.c (stpy_dealloc): Likewise. * python/py-type.c (typy_iterator_dealloc): Likewise.
2019-11-18Don't use class-initialization for the owner unionChristian Biesinger2-1/+9
As reported by PhilippeW, valgrind reports that symtab is uninitialized when compiling with GCC 4.8.5, which is the default compiler on CentOS 7. This is apparently a compiler bug fixed in later versions, but to keep CentOS 7 working, this patch initializes the union explicitly instead of using a class initializer. gdb/ChangeLog: 2019-11-18 Christian Biesinger <cbiesinger@google.com> * symtab.h (struct symbol) <owner>: Initialize explicitly in the constructor instead of using a class initializer. Change-Id: I94f48afeae5d29cf81a280295e2d02e2d7e1c1f1
2019-11-18elf_backend_init_file_headerAlan Modra20-107/+154
This patch renames elf_backend_post_process_headers and moves the prep_headers code into the new function. Naming the backend functions elf_backend_init_file_header and elf_backend_modify_headers makes it clear which function is called first. * elf-bfd.h (struct elf_backend_data <elf_backend_init_file_header>): Rename from elf_backend_post_process_headers. (_bfd_elf_post_process_headers): Delete. (_bfd_elf_init_file_header): Declare. * elf.c (_bfd_elf_compute_section_file_positions): Call new function in place of prep_headers and elf_backend_post_process_headers. (_bfd_elf_init_file_header): Renamed from prep_headers with updated args and made global. Delete dead code. (_bfd_elf_post_process_headers): Delete. * elf32-arm.c (elf32_arm_init_file_header): Rename from elf32_arm_post_process_headers and call _bfd_elf_init_file_header. Return status. (elf_backend_init_file_header): Define. (elf_backend_post_process_headers): Don't define. * elf32-i386.c (elf_i386_fbsd_init_file_header): Similarly. * elf32-m68hc1x.c (elf32_m68hc11_init_file_header): Similarly. * elf32-metag.c (elf_metag_init_file_header): Similarly. * elf32-spu.c (spu_elf_init_file_header * elf32-visium.c (visium_elf_init_file_header * elf64-alpha.c (elf64_alpha_fbsd_init_file_header * elf64-hppa.c (elf64_hppa_init_file_header * elf64-ia64-vms.c (elf64_vms_init_file_header * elfnn-aarch64.c (elfNN_aarch64_init_file_header * elfnn-ia64.c (elfNN_hpux_init_file_header * elfxx-mips.c (_bfd_mips_init_file_header * elfxx-mips.h (_bfd_mips_post_process_headers): Delete. (_bfd_mips_init_file_header): Declare. (elf_backend_post_process_headers): Delete. (elf_backend_init_file_header): Define. * elfxx-target.h (elf_backend_post_process_headers): Delete. (elf_backend_init_file_header): Define and use. * elf32-m68hc12.c (elf_backend_init_file_header): Define. (elf_backend_post_process_headers): Don't define. * elf32-m68hc1x.h (elf32_m68hc11_post_process_headers): Delete. (elf32_m68hc11_init_file_header): Declare. * elf32-ppc.c (elf_backend_post_process_headers): Remove unnecessary undef.
2019-11-18elf_backend_modify_headersAlan Modra13-196/+230
This patch renames elf_backend_modify_program_headers and moves the elf.c code tweaking the ELF file header for -pie -Ttext-segment to a new function, _bfd_elf_modify_headers, which then becomes the default elf_backed_modify_headers and is called from any other target elf_backed_modify_headers. * elf-bfd.h (struct elf_backend_data <elf_backend_modify_headers>): Rename from elf_backend_modify_program_headers. (_bfd_elf_modify_headers): Declare. * elf.c (assign_file_positions_except_relocs): Set elf_program_header_size. Always call elf_backend_modify_headers. Extract code modifying file header.. (_bfd_elf_modify_headers): ..to here. New function. * elf32-arm.c (elf_backend_modify_headers): Renamed from elf_backend_modify_program_headers. * elf32-i386.c: Similarly. * elf64-x86-64.c: Similarly. * elfxx-target.h: Similarly. Default elf_backend_modify_headers to _bfd_elf_modify_headers. * elf-nacl.h (nacl_modify_headers): Rename from nacl_modify_program_headers. * elf-nacl.c (nacl_modify_headers): Rename from nacl_modify_program_headers and call _bfd_elf_modify_headers. * elf32-rx.c (elf32_rx_modify_headers): Similarly. * elf32-spu.c (spu_elf_modify_headers): Similarly. * elfnn-ia64.c (elfNN_ia64_modify_headers): Similarly. * elf32-sh.c (elf_backend_modify_program_headers): Don't undef.
2019-11-18PR25196, abort in rewrite_elf_program_headerAlan Modra4-4/+19
This patch introduces a new "sorry, cannot handle this file" bfd error status. The idea is to use this error in cases where bfd hasn't found a bfd_bad_value error, ie. an input file or set of options that are invalid, but rather an input file that is simply too difficult to process. Typically this might happen with fuzzed object files such as the one in the PR, a wildly improbable core file. Some things are just not worth wasting time over to fix "properly". PR 25196 * bfd.c (bfd_error_type): Add bfd_error_sorry. (bfd_errmsgs): Likewise. * elf.c (rewrite_elf_program_header): Don't abort on confused lma/alignment. Replace bfd_error_bad_value with bfd_error_sorry. (_bfd_elf_validate_reloc): Use bfd_error_sorry. (_bfd_elf_final_write_processing): Likewise. * bfd-in2.h: Regenerate.
2019-11-18gas: Add --gdwarf-cie-version command line flagAndrew Burgess15-3/+129
Add a flag to control the version of CIE that is generated. By default gas produces CIE version 1, and this continues to be the default after this patch. However, a user can now provide --gdwarf-cie-version=NUMBER to switch to either version 3 or version 4 of CIE, version 2 was never released, and so causes an error as does any number less than 1 or greater than 4. Producing version 4 CIE requires two new fields to be added to the CIE, an address size field, and an segment selector field. For a flat address space the DWARF specification indicates that the segment selector should be 0, and the address size fields just contains the address size in bytes. For now we support 4 or 8 byte addresses, and the segment selector is always produced as 0. At some future time we might need to allow targets to override this. gas/ChangeLog: * as.c (parse_args): Parse --gdwarf-cie-version option. (flag_dwarf_cie_version): New variable. * as.h (flag_dwarf_cie_version): Declare. * dw2gencfi.c (output_cie): Switch from DW_CIE_VERSION to flag_dwarf_cie_version. * doc/as.texi (Overview): Document --gdwarf-cie-version. * NEWS: Likewise. * testsuite/gas/cfi/cfi.exp: Add new tests. * testsuite/gas/cfi/cie-version-0.d: New file. * testsuite/gas/cfi/cie-version-1.d: New file. * testsuite/gas/cfi/cie-version-2.d: New file. * testsuite/gas/cfi/cie-version-3.d: New file. * testsuite/gas/cfi/cie-version-4.d: New file. * testsuite/gas/cfi/cie-version.s: New file. include/ChangeLog: * dwarf2.h (DW_CIE_VERSION): Delete. Change-Id: I9de19461aeb8332b5a57bbfe802953d0725a7ae8
2019-11-18Automatic date update in version.inGDB Administrator1-1/+1
2019-11-18PR25198, use of out of date pointerAlan Modra2-2/+6
PR 25198 * prdbg.c (tg_start_class_type): Correct scope of idbuf.
2019-11-17Automatic date update in version.inGDB Administrator1-1/+1
2019-11-16Automatic date update in version.inGDB Administrator1-1/+1
2019-11-15Use gnulib's strerror_r on MinGWChristian Biesinger11-122/+23
There is no need to keep mingw-strerror around; we can just always use the code from posix-strerror. The main reason we had that code, it seems, is to handle winsock error codes, but gnulib's version handles those. Unfortunately the code can't be moved into common-utils.c because libinproctrace.so uses common-utils but not gnulib. gdb/ChangeLog: 2019-11-15 Christian Biesinger <cbiesinger@google.com> * Makefile.in: Replace {posix,mingw}-strerror.c with safe-strerror.c. * configure: Regenerate. * configure.ac: Don't source common.host. * gdbsupport/common.host: Remove. * gdbsupport/mingw-strerror.c: Remove. * gdbsupport/posix-strerror.c: Rename to... * gdbsupport/safe-strerror.c: ...this. gdb/gdbserver/ChangeLog: 2019-11-15 Christian Biesinger <cbiesinger@google.com> * Makefile.in: Add safe-strerror.c. * configure: Regenerate. * configure.ac: Don't source common.host. Change-Id: I9e6d8a752fc398784201f370cafee65e0ea05474
2019-11-15Add no-dist to gnulib configureTom Tromey6-818/+25
This adds the no-dist option to the gnulib configure script. gdb doesn't use "make dist", so there's no need for this. Adding this option makes the Makefiles less verbose. gnulib/ChangeLog 2019-11-15 Tom Tromey <tromey@adacore.com> * aclocal.m4, configure, Makefile.in, import/Makefile.in: Rebuild. * configure.ac: Remove obsolete comment. Add no-dist. Change-Id: I5224e18af9acd5284acb79d5756b0e84b00406e9
2019-11-15Minor updates to readline configuryTom Tromey5-14/+10
Christian's recent patches to gnulib made me realize that readline should be changed to use AC_CONFIG_MACRO_DIRS (ACLOCAL_AMFLAGS is deprecated) and that it can put the automake options into configure.ac. I also added no-define to the automake options. This doesn't matter much (we don't generate a config.h here), but gnulib does it, and it does make configure slightly smaller. readline/ChangeLog 2019-11-15 Tom Tromey <tromey@adacore.com> * configure, Makefile.in: Rebuild. * configure.ac: Use AC_CONFIG_MACRO_DIRS. Pass options to AM_INIT_AUTOMAKE. * Makefile.am (AUTOMAKE_OPTIONS, ACLOCAL_AMFLAGS): Remove. Change-Id: If421599cc9dd9c4c3c37b9b439ab2c22c01742ed
2019-11-15Use ctime_r and localtime_r for threadsafetyChristian Biesinger3-3/+15
To make these calls threadsafe. localtime_r is provided by gnulib if necessary, and for ctime_r we can just use it because it is in a linux- specific file. gdb/ChangeLog: 2019-11-15 Christian Biesinger <cbiesinger@google.com> * maint.c (scoped_command_stats::print_time): Use localtime_r instead of localtime (provided through gnulib if necessary). * nat/linux-osdata.c (time_from_time_t): Use ctime_r instead of ctime. Change-Id: I329bbdc39d5b576f51859ba00f1617e024c30cbd
2019-11-15Import the time_r gnulib moduleChristian Biesinger14-6/+277
This allows GDB to use localtime_r unconditionally. See https://lists.gnu.org/archive/html/bug-gnulib/2019-11/msg00022.html for details on the compile error mentioned below. gdb/ChangeLog: 2019-11-15 Christian Biesinger <cbiesinger@google.com> * gdbsupport/common-defs.h: Include time.h before pathmax.h to avoid compile errors. gnulib/ChangeLog: 2019-11-15 Christian Biesinger <cbiesinger@google.com> * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * config.in: Regenerate. * configure: Regenerate. * import/Makefile.am: Update. * import/Makefile.in: Regenerate. * import/m4/gnulib-cache.m4: Update. * import/m4/gnulib-comp.m4: Update. * import/m4/time_r.m4: New file. * import/time_r.c: New file. * update-gnulib.sh: Import time_r. Change-Id: I53fc861b192940d613ca97f2910b4533c730f667
2019-11-15Import the strerror_r-posix module and use it in GDB.Christian Biesinger29-163/+6663
Makes sure to assign the return value of strerror_r to an int, so that we get a compile error if we accidentally get the wrong version. gdb/ChangeLog: 2019-11-15 Christian Biesinger <cbiesinger@google.com> * config.in: Regenerate. * configure: Regenerate. * gdbsupport/common.m4: No longer check for strerror_r. * gdbsupport/posix-strerror.c (safe_strerror): Always call the POSIX version of strerror_r, now that gnulib provides it if necessary. gdb/gdbserver/ChangeLog: 2019-11-15 Christian Biesinger <cbiesinger@google.com> * config.in: Regenerate. * configure: Regenerate. gnulib/ChangeLog: 2019-11-15 Christian Biesinger <cbiesinger@google.com> * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * config.in: Regenerate. * configure: Regenerate. * import/Makefile.am: Update. * import/Makefile.in: Regenerate. * import/extra/config.rpath: New file. * import/glthread/lock.c: New file. * import/glthread/lock.h: New file. * import/glthread/threadlib.c: New file. * import/m4/gnulib-cache.m4: Update. * import/m4/gnulib-comp.m4: Update. * import/m4/lib-ld.m4: New file. * import/m4/lib-link.m4: New file. * import/m4/lib-prefix.m4: New file. * import/m4/lock.m4: New file. * import/m4/strerror_r.m4: New file. * import/m4/threadlib.m4: New file. * import/strerror_r.c: New file. * update-gnulib.sh: Import strerror_r-posix. Change-Id: I5cfeb12a5203a4cd94a78581541e6085a68685c3
2019-11-15Generate gnulib's toplevel Makefile.in using automakeChristian Biesinger6-356/+1952
This is a lot simpler and as a side-effect this will correctly regenerate import/Makefile and config.h during rebuilds if necessary. gnulib/ChangeLog: 2019-11-15 Christian Biesinger <cbiesinger@google.com> * Makefile.am: New file. * Makefile.in: Replace with generated file. * aclocal-m4-deps.mk: Remove. * configure.ac: Use the foreign option for automake and specify the aclocal search path here. * update-gnulib.sh: Don't generate aclocal-m4-deps.mk anymore. Also don't specify the aclocal include path here, now that it is in configure.ac. Change-Id: I6a2c4d41cf4f0e21d5c813197bad63ed5c08e408
2019-11-15Revert previous delta.Nick Clifton3-2/+8
PR 2587 * Makefile.am: Revert change from 2019-11-13. * Makefile.in: Regenerate.
2019-11-14Update READMEChristian Biesinger2-1/+24
Adds descriptions for some recent-ish configure options to README. Also updates the minimum Python version per commit 6c28e44a359e9f6cf455ddff0009ca99406f7224. 2019-11-14 Christian Biesinger <cbiesinger@google.com> * README (`configure' options): Update. Change-Id: I8ce8ca6935afbd130295e143802c585cf1e735f9
2019-11-15Automatic date update in version.inGDB Administrator1-1/+1
2019-11-14Allow re-assigning to convenience variablesTom Tromey4-1/+33
A customer reported somewhat odd gdb behavior, where re-assigning an array or string to a convenience variable would yield "Too many array elements". A test case is: (gdb) p $x = "x" (gdb) p $x = "xyz" This patch fixes the problem by making a special case in the evaluator for assignment to convenience variables, which seems like the correct behavior. Note that a previous patch implemented this for Ada, see commit f411722cb ("Allow re-assigning to convenience variables"). gdb/ChangeLog 2019-11-14 Tom Tromey <tromey@adacore.com> * eval.c (evaluate_subexp_standard) <BINOP_ASSIGN>: Do not pass an expected type for the RHS if the LHS is a convenience variable. gdb/testsuite/ChangeLog 2019-11-14 Tom Tromey <tromey@adacore.com> * gdb.base/gdbvars.exp (test_convenience_variables): Add regression tests. Change-Id: I5e66a2d243931a5c43c7af4bc9f6717464c2477e
2019-11-14[gdb/doc] Fix typosTom de Vries4-31/+37
Fix typos in gdb docs. gdb/doc/ChangeLog: 2019-11-14 Tom de Vries <tdevries@suse.de> * gdb.texinfo: Fix typos. * python.texi: Same. * stabs.texinfo: Same. Change-Id: I044d6788eeea48e4a9b73ee752e5aaf333e56a46
2019-11-14Another attempt at fixing building gprof with gmake.Nick Clifton3-4/+10
PR 2587 * Makefile.am (SUFFIXES): Add .c. * Makefile.in: Regenerate.
2019-11-14gdb: fix build error in unittests/vec-utils-selftests.cSimon Marchi2-0/+14
When building with gcc 9.2.0, I get the following build error: In file included from /home/simark/src/binutils-gdb/gdb/unittests/vec-utils-selftests.c:23: /home/simark/src/binutils-gdb/gdb/gdbsupport/gdb_vecs.h: In instantiation of ‘T unordered_remove(std::__debug::vector<T>&, typename std::__debug::vector<T>::iterator) [with T = selftests::vector_utils_tests::unordered_remove_tests()::obj; typename std::__debug::vector<T>::iterator = __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<selftests::vector_utils_tests::unordered_remove_tests()::obj*, std::__cxx1998::vector<selftests::vector_utils_tests::unordered_remove_tests()::obj, std::allocator<selftests::vector_utils_tests::unordered_remove_tests()::obj> > >, std::__debug::vector<selftests::vector_utils_tests::unordered_remove_tests()::obj>, std::random_access_iterator_tag>]’: /home/simark/src/binutils-gdb/gdb/unittests/vec-utils-selftests.c:53:26: required from here /home/simark/src/binutils-gdb/gdb/gdbsupport/gdb_vecs.h:53:5: error: implicitly-declared ‘selftests::vector_utils_tests::unordered_remove_tests()::obj::obj(const selftests::vector_utils_tests::unordered_remove_tests()::obj&)’ is deprecated [-Werror=deprecated-copy] 53 | T removed = std::move (*it); | ^~~~~~~ /home/simark/src/binutils-gdb/gdb/unittests/vec-utils-selftests.c:41:10: note: because ‘selftests::vector_utils_tests::unordered_remove_tests()::obj’ has user-provided ‘selftests::vector_utils_tests::unordered_remove_tests()::obj& selftests::vector_utils_tests::unordered_remove_tests()::obj::operator=(const selftests::vector_utils_tests::unordered_remove_tests()::obj&)’ 41 | obj &operator= (const obj &other) | ^~~~~~~~ In file included from /home/simark/src/binutils-gdb/gdb/unittests/vec-utils-selftests.c:23: /home/simark/src/binutils-gdb/gdb/gdbsupport/gdb_vecs.h:58:10: error: implicitly-declared ‘selftests::vector_utils_tests::unordered_remove_tests()::obj::obj(const selftests::vector_utils_tests::unordered_remove_tests()::obj&)’ is deprecated [-Werror=deprecated-copy] 58 | return removed; | ^~~~~~~ /home/simark/src/binutils-gdb/gdb/unittests/vec-utils-selftests.c:41:10: note: because ‘selftests::vector_utils_tests::unordered_remove_tests()::obj’ has user-provided ‘selftests::vector_utils_tests::unordered_remove_tests()::obj& selftests::vector_utils_tests::unordered_remove_tests()::obj::operator=(const selftests::vector_utils_tests::unordered_remove_tests()::obj&)’ 41 | obj &operator= (const obj &other) | ^~~~~~~~ I think gcc is just trying to be nice and recommends the good practice of providing a copy constructor if an assignment operator is provided. Silence the warning by providing that copy constructor. gdb/ChangeLog: * unittests/vec-utils-selftests.c (unordered_remove_tests::obj): Provide explicit default and copy constructor. Change-Id: I323361b1c120bf8525613b74e7e5983910e002df
2019-11-14x86: drop redundant SYSCALL/SYSRET templatesJan Beulich3-26/+5
The Cpu64 forms are no different in their attributes except for the CPU flags; there's no need to key these off of anything other than CpuSYSCALL even for the 64-bit forms. Dropping these improves the diagnostic on SYSRETQ used in 32-bit code from "unsupported instruction `sysret'" to "invalid instruction suffix for `sysret'".
2019-11-14x86: fold individual Jump* attributes into a single Jump oneJan Beulich8-14892/+10989
..., taking just 3 bits instead of 5. No two of them are used together.
2019-11-14x86: make JumpAbsolute an insn attributeJan Beulich9-26501/+26531
... instead of an operand one: There's only ever one operand here anyway.
2019-11-14x86: make AnySize an insn attributeJan Beulich7-14487/+14504
... instead of an operand one. Which operand it applies to can be determined from other operand properties, but as it turns out the only place it is actually used at doesn't even need further qualification.
2019-11-14x86/Intel: correct CMPSD test cases' regexp closing paren placementJan Beulich3-39/+45
The CMPS test case derivation from their MOVS counterparts I did in d241b91073 ("x86/Intel: correct MOVSD and CMPSD handling") ended up with misplaced closing parentheses in som regexps. Correct this.
2019-11-14x86/Intel: extend MOVSD/CMPSD testsuite coverageJan Beulich10-0/+386
This is still in the context of PR/gas 25167.
2019-11-14Fix python gdbpy_breakpoint_object leak.Philippe Waroquiers2-1/+6
valgrind reports a leak when a breakpoint is created then deleted: ==1313== 40 bytes in 1 blocks are definitely lost in loss record 1,115 of 8,596 ==1313== at 0x4835753: malloc (vg_replace_malloc.c:307) ==1313== by 0x6E05BC: _PyObject_New (object.c:255) ==1313== by 0x470E4B: gdbpy_breakpoint_created(breakpoint*) (py-breakpoint.c:1023) ==1313== by 0x2946D9: operator() (std_function.h:687) ==1313== by 0x2946D9: notify (observable.h:106) ==1313== by 0x2946D9: install_breakpoint(int, std::unique_ptr<breakpoint, std::default_delete<breakpoint> >&&, int) (breakpoint.c:8136) ==1313== by 0x295BCA: create_breakpoint_sal (breakpoint.c:8878) ==1313== by 0x295BCA: create_breakpoints_sal (breakpoint.c:8919) ==1313== by 0x295BCA: create_breakpoints_sal_default (breakpoint.c:13671) ... The leak is due to a superfluous Py_INCREF when the python object is allocated inside gdbpy_breakpoint_created, when the python object is allocated locally: this object has already a refcount of 1, and the only reference is the reference from the C breakpoint object. The Py_INCREF is however needed when the python object was created from python: the python object was stored in bppy_pending_object, and gdbpy_breakpoint_created creates a new reference to this object. Solve the leak by calling 'Py_INCREF (newbp);' only in the bppy_pending_object case. Regression tested on debian/amd64 natively and under valgrind on centos/amd64. Before the patch, 795 tests have a definite leak. After the patch, 197 have a definite leak. Thanks to Tom, that helped on irc with the python refcount logic. gdb/ChangeLog 2019-11-14 Philippe Waroquiers <philippe.waroquiers@skynet.be> * python/py-finishbreakpoint.c (gdbpy_breakpoint_created): only call Py_INCREF (newbp) in the bppy_pending_object case.
2019-11-14Automatic date update in version.inGDB Administrator1-1/+1
2019-11-13Remove symbol-related static assertsTom Tromey3-19/+6
commit 3573abe1d added static asserts to ensure that symbol sizes don't vary. However, this failed to build on Windows, on at least one ARM platform (see PR build/25182) and internally at AdaCore for PPC. So, I think it is probably best to just remove these assertions, effectively reverting 3573abe1d. gdb/ChangeLog 2019-11-13 Tom Tromey <tromey@adacore.com> PR build/25182: * psympriv.h (partial_symbol): Remove static assert. * symtab.h (general_symbol_info, symbol): Remove static assert. Change-Id: I51940fb2240c474838b48494b5072081701789bb
2019-11-13Fix the rule for building C files in the gprof makefile.Nick Clifton2-1/+6
PR 2587 * Makefile.am: Fix rule to build .c files from .m files.
2019-11-12gnulib: Fix path to import/Makefile{,.in}Christian Biesinger2-2/+6
I don't know why this path is what it is but it is clearly wrong. gnulib/ChangeLog: 2019-11-12 Christian Biesinger <cbiesinger@google.com> * Makefile.in: Fix path to say import/ instead of gnulib/. Change-Id: Ib7f6a319ee764d20072e38911766ca7032d6ca8e
2019-11-12RISC-V: Support the INSN_CLASS.*F.* classes for .insn directive.Jim Wilson4-61/+71
We have to enable the f extension through -march or ELF attribute if we use the FPR in .insn directive. The behavior is same as the riscv_opcodes. 2019-11-12 Nelson Chu <nelson.chu@sifive.com> opcodes/ * riscv-opc.c (riscv_insn_types): Replace the INSN_CLASS_I with INSN_CLASS_F and the INSN_CLASS_C with INSN_CLASS_F_AND_C if we use the floating point register (FPR). gas/ * testsuite/gas/riscv/insn.d: Add the f extension to -march option. Change-Id: I4f59d04c82673ef84c56ecd2659ad8ce164dd626
2019-11-13Automatic date update in version.inGDB Administrator1-1/+1
2019-11-12RISC-V: Fix ld relax failure with calls and align directives.Jim Wilson9-3/+68
Make _bfd_riscv_relax_call handle section alignment padding same as the _bfd_riscv_relax_lui and _bfd_riscv_relax_pc functions already do. Use the max section alignment if section boundaries are crossed, otherwise the alignment of the containing section. bfd/ PR 25181 * elfnn-riscv.c (_bfd_riscv_relax_call): Always add max_alignment to foff. If sym_sec->output_section and sec->output_section are the same and not *ABS* then set max_alignment to that section's alignment. ld/ PR 25181 * testsuite/ld-riscv-elf/call-relax-0.s: New file. * testsuite/ld-riscv-elf/call-relax-1.s: New file. * testsuite/ld-riscv-elf/call-relax-2.s: New file. * testsuite/ld-riscv-elf/call-relax-3.s: New file. * testsuite/ld-riscv-elf/call-relax.d: New test. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Run call-relax test. Change-Id: Iaf65cee52345abf1955f36e8e72c4f6cc0db8d9a
2019-11-12gdb: Support printf 'z' size modifierAndrew Burgess8-2/+106
The gdb format mechanism doesn't currently support the 'z' size modifier, there are a few places in GDB where this is used. Instead of removing these uses lets just add support to GDB for using 'z'. I found this issue when trying to use some of the debug output. Before this commit: (gdb) set debug dwarf-line 9 (gdb) file test Reading symbols from test... Unrecognized format specifier 'z' in printf (No debugging symbols found in test) (gdb) After this commit: (gdb) set debug dwarf-line 9 (gdb) file test Reading symbols from test... Adding dir 1: /usr/include Adding file 1: test.c Adding file 2: stdc-predef.h Processing actual line 3: file 1, address 0x4004a0, is_stmt 1, discrim 0 Processing actual line 4: file 1, address 0x4004a0, is_stmt 1, discrim 0 .... lots of debug output ... Processing actual line 10: file 1, address 0x4003b7, is_stmt 0, discrim 0 (gdb) I've added a self test to cover the integer format size modifiers, including the 'z' modifier. gdb/ChangeLog: * gdbsupport/format.c (format_pieces::format_pieces): Support printf 'z' size modifier. * gdbsupport/format.h (enum argclass): Add size_t_arg. * printcmd.c (ui_printf): Handle size_t_arg. * ui-out.c (ui_out::vmessage): Likewise. * unittests/format_pieces-selftests.c (test_format_int_sizes): New function. (run_tests): Call test_format_int_sizes. gdb/gdbserver/ChangeLog: * ax.c (ax_printf): Handle size_t_arg. Change-Id: Ib6c44d88aa5bce265d757e4c0698881803dd186f