aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2019-11-21Hi Andrewusers/simark/mi-symbols-outputSimon Marchi1-153/+61
Change-Id: I695d9860d6f7dae86f966dfc0524b934660478da
2019-11-20gdb/mi: Add new commands -symbol-info-{functions,variables,types}Andrew Burgess11-6/+827
Add new MI commands -symbol-info-functions, -symbol-info-variables, and -symbol-info-types which correspond to the CLI commands 'info functions', 'info variables', and 'info types' respectively. gdb/ChangeLog: * mi/mi-cmds.c (mi_cmds): Add '-symbol-info-functions', '-symbol-info-variables', and '-symbol-info-types'. * mi/mi-cmds.h (mi_cmd_symbol_info_functions): Declare. (mi_cmd_symbol_info_variables): Declare. (mi_cmd_symbol_info_types): Declare. * mi/mi-symbol-cmds.c: Add 'source.h' and 'mi-getopt.h' includes. (mi_info_one_symbol_details): New function. (class mi_symbol_info_emitter): New class. (mi_symbol_info): New function. (mi_info_functions_or_variables): New function. (mi_cmd_symbol_info_functions): New function. (mi_cmd_symbol_info_types): New function. (mi_cmd_symbol_info_variables): New function. * NEWS: Mention new commands. gdb/testsuite/ChangeLog: * gdb.mi/mi-sym-info-1.c: New file. * gdb.mi/mi-sym-info-2.c: New file. * gdb.mi/mi-sym-info.exp: New file. gdb/doc/ChangeLog: * doc/gdb.texinfo (GDB/MI Symbol Query): Document new MI command -symbol-info-functions, -symbol-info-types, and -symbol-info-variables. Change-Id: Ic2fc6a6750bbce91cdde2344791014e5ef45642d
2019-11-20gdb: Split print_symbol_info into two partsAndrew Burgess3-35/+73
Split the function print_symbol_info into two parts, the new worker core returns a string, which print_symbol_info then prints. This will be useful in a later commit when some new MI commands will be added which will use the worker core to fill some MI output fields. There should be no user visible changes after this commit. gdb/ChangeLog: * symtab.c (symbol_to_info_string): New function, most content moved from print_symbol_info, but updated to return a std::string. (print_symbol_info): Update to use symbol_to_info_string and print returned string. * symtab.h (symbol_to_info_string): Declare new function. Change-Id: I6454ce43cacb61d32fbadb9e3655e70823085777
2019-11-20gdb: Introduce global_symbol_searcherAndrew Burgess4-100/+124
Introduce a new class to wrap up the parameters needed for the function search_symbols, which has now become a member function of this new class. The motivation is that search_symbols already takes a lot of parameters, and a future commit is going to add even more. This commit hopefully makes collecting the state required for a search easier. As part of this conversion the list of filenames in which to search has been converted to a std::vector. There should be no user visible changes after this commit. gdb/ChangeLog: * python/python.c (gdbpy_rbreak): Convert to using global_symbol_searcher. * symtab.c (file_matches): Convert return type to bool, change file list to std::vector. (search_symbols): Rename to... (global_symbol_searcher::search): ...this and update now its a member function of global_symbol_searcher. Take account of the changes to file_matches. (symtab_symbol_info): Convert to using global_symbol_searcher. (rbreak_command): Likewise. (search_module_symbols): Likewise. * symtab.h (enum symbol_search): Update comment. (search_symbols): Remove declaration. (class global_symbol_searcher): New class. Change-Id: I488ab292a892d9e9e84775c632c5f198b6ad3710
2019-11-21Automatic date update in version.inGDB Administrator1-1/+1
2019-11-20Add missing parentheses on 'print' (gdb.python/py-progspace.exp)Sergio Durigan Junior2-3/+8
Commit 33d569b709886a1208145806da80b689d9cae9da ("gdb/python: Return None from Progspace.block_for_pc on error") added a few tests on gdb.python/py-progspace.exp which use 'print', but forgot to use parentheses when passing the arguments to be printed. This fails on Python 3. This commit adds these missing parentheses. Pushed as obvious. gdb/testsuite/ChangeLog: 2019-11-20 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.python/py-progspace.exp: Add missing parentheses on some 'print' commands. Change-Id: Iac0a7578855d128bbee3b98e7ea5888dae55fc00
2019-11-20Improve target description check for SVE in gdbserverLuis Machado4-1/+29
The current code checks for the presence of a SVE target description by comparing the number of registers. This is a bit fragile since the number of registers can change whenever we add new sets. Like PAC, for example. If the comparison breaks, then we're left with SVE registers in the description, but gdbserver doesn't send the registers to GDB, which in turn displays stale information to the user. The following patch changes the check to use the SVE feature string instead, which hopefully should be more stable. gdb/gdbserver/ChangeLog: 2019-11-20 Luis Machado <luis.machado@linaro.org> * linux-aarch64-low.c (is_sve_tdesc): Check against target feature instead of register count. * tdesc.c (tdesc_contains_feature): New function. * tdesc.h (tdesc_contains_feature): New prototype. Change-Id: I28b782cb1677560ca9a06a1be442974b25aabae4
2019-11-20PR24944, gas doesn't read enough digits when parsing a floating point numberAlan Modra4-8/+23
PR 24944 * atof-generic.c (atof_generic): Increase decimal guard digits. * testsuite/gas/i386/fp.s: Add more tests. * testsuite/gas/i386/fp.d: Update.
2019-11-20cpu: fix comment in bpf.cpuJose E. Marchesi2-1/+5
2019-11-20 Jose E. Marchesi <jose.marchesi@oracle.com> * bpf.cpu: Fix comment describing the 128-bit instruction format.
2019-11-20Automatic date update in version.inGDB Administrator1-1/+1
2019-11-19Fix the "winheight" commandTom Tromey6-27/+71
The "winheight" command is broken. I probably broke it in one of my TUI refactoring patches, though I didn't track down exactly which one. The bug is that the code does: *buf_ptr = '\0'; ... but then never advances buf_ptr past this point, so no window name is seen. This patch refactors the code a bit so that a copy of the argument string is not needed, also fixing the bug. A new test case is included. gdb/ChangeLog 2019-11-19 Tom Tromey <tom@tromey.com> * tui/tui-win.c (tui_partial_win_by_name): Move from tui-data.c. Now static. Change type of "name". (tui_set_win_height_command): Don't copy "arg". * tui/tui-data.h (tui_partial_win_by_name): Don't declare. * tui/tui-data.c (tui_partial_win_by_name): Move to tui-win.c. gdb/testsuite/ChangeLog 2019-11-19 Tom Tromey <tom@tromey.com> * gdb.tui/winheight.exp: New file. Change-Id: I0871e93777a70036dbec9c9543f862f42e3a81e5
2019-11-19Replace "if (attr)" with "if (attr != nullptr)".Ali Tamur2-48/+75
This is a cleanup patch in response to a reviewer comment on "Dwarf 5: Handle debug_str_offsets" patch.
2019-11-19Report GetLastError value when DebugActiveProcess failsTom Tromey2-1/+7
When DebugActiveProcess fails, the error message is fairly generic: error (_("Can't attach to process.")); It would be more useful for diagnosing problems if the Windows error code was included in the message. This patch implements this. gdb/ChangeLog 2019-11-19 Tom Tromey <tromey@adacore.com> * windows-nat.c (windows_nat_target::attach): Include GetLastError result in error when DebugActiveProcess fails. Change-Id: Ie1bf502a0d96bb7c09bd5b1c5e0c924ba58cd68c
2019-11-19PR24499, ignore --add-gnu-debuglink for archivesAlan Modra2-0/+13
objcopy --add-gnu-debuglink=foo.a.dbg foo.a just doesn't make any sense. Who puts executables in archives? PR 24499 * objcopy.c (copy_file): Ignore --add-gnu-debuglink for archives.
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'".