aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2019-03-06Fortran function calls with argumentsRichard Bunt8-3/+457
Prior to this patch, calling functions on the inferior with arguments and then using these arguments within a function resulted in an invalid memory access. This is because Fortran arguments are typically passed as pointers to values. It is possible to call Fortran functions, but memory must be allocated in the inferior, so a pointer can be passed to the function, and the language must be set to C to enable C-style casting. This is cumbersome and not a pleasant debug experience. This patch implements the GNU Fortran argument passing conventions with caveats. Firstly, it does not handle the VALUE attribute as there is insufficient DWARF information to determine when this is the case. Secondly, functions with optional parameters can only be called with all parameters present. Both these cases are marked as KFAILS in the test. Since the GNU Fortran argument passing convention has been implemented, there is no guarantee that this patch will work correctly, in all cases, with other compilers. Despite these limitations, this patch improves the ease with which functions can be called in many cases, without taking away the existing approach of calling with the language set to C. Regression tested on x86_64, aarch64 and POWER9 with GCC 7.3.0. Regression tested with Ada on x86_64. Regression tested with native-extended-gdbserver target board. gdb/ChangeLog: * eval.c (evaluate_subexp_standard): Call Fortran argument wrapping logic. * f-lang.c (struct value): A value which can be passed into a Fortran function call. (fortran_argument_convert): Wrap Fortran arguments in a pointer where appropriate. (struct type): Value ready for a Fortran function call. (fortran_preserve_arg_pointer): Undo check_typedef, the pointer is needed. * f-lang.h (fortran_argument_convert): Declaration. (fortran_preserve_arg_pointer): Declaration. * infcall.c (value_arg_coerce): Call Fortran argument logic. gdb/testsuite/ChangeLog: * gdb.fortran/function-calls.exp: New file. * gdb.fortran/function-calls.f90: New test.
2019-03-06Automatic date update in version.inGDB Administrator1-1/+1
2019-03-05Remove some Python 3 #ifsTom Tromey3-14/+7
A recent patch from Kevin Buettner taught me that the PyBytes API is available on Python 2. This patch removes a couple of related #ifs in the Python code. Tested on x86-64 Fedora 29, using both Python 3.7 and Python 2.7. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * python/py-prettyprint.c (print_string_repr): Remove #if. * python/py-utils.c (unicode_to_encoded_string): Remove #if.
2019-03-05Change the_dummy_target to be a globalTom Tromey2-5/+12
While debugging gdb, I printed the target stack and got: (top-gdb) p g_target_stack $10 = { m_top = thread_stratum, m_stack = {0x142b0b0, 0x13da600 <exec_ops>, 0x1c70690, 0x13d63b0 <ravenscar_ops>, 0x0, 0x0, 0x0} } (This is clearly from before the change to make ravenscar multi-target-capable.) Here, 0x142b0b0 is the singleton dummy target. It seems to me that since this is always a singleton, it would be a bit nicer if it were a global, so that it would be noted in the above. This patch implements this idea, and now I get: (top-gdb) p g_target_stack $2 = { m_top = dummy_stratum, m_stack = {0x1f1b040 <the_dummy_target>, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0} } I did not do the same for the debug target. It didn't seem as useful to me. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * target.c (the_dummy_target): Move later. Change type to "dummy_target". (initialize_targets): Don't initialize the_dummy_target.
2019-03-05Small fix to gdb.Value constructor docSimon Marchi2-1/+6
The synopsis of the two-parameters form of the gdb.Value constructor is currently shown as Value.__init__ (val, [, type ]) in the documentation. First, there is an extra comma, which I think we can remove in any case. Then, since the type parameter is not optional, I would not put in between square brackets. Those usually indicate that something is optional. With this patch, it appears as: Value.__init__ (val, type) gdb/doc/ChangeLog: * python.texi (Values From Inferior): Change synopsys of the second form of Value.__init__.
2019-03-05Fix a spelling mistake: "complaint" instead of "compliant".Nick Clifton2-1/+6
PR 24295 * doc/binutils.texi (ar cmdline): Fix spelling mistake.
2019-03-05Remove gdb_bfd_fdopenrTom Tromey3-15/+5
I noticed that gdb_bfd_fdopenr is no longer used, so this patch removes it. Tested by rebuilding and by grep. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * gdb_bfd.c (gdb_bfd_fdopenr): Remove. * gdb_bfd.h (gdb_bfd_fdopenr): Don't declare.
2019-03-05Updated Swedish translation for the binutils sub-directory.Nick Clifton2-1698/+1802
2019-03-05Remove excess calls to gdb_flushTom Tromey25-58/+38
A customer noticed some mildly odd MI output, where CLI output was split into multiple MI strings at unusual boundaries, like this: ~"$1 = (b => true" ~", p => 0x407260" This is technically correct according to the MI spec, but still unusual, in that there's no particular reason for the string to be split where it is. I tracked this down to a call to gdb_flush in generic_val_print. Then, I went through all calls to gdb_flush and removed the ones I thought were superfluous. In particular: * Any call in the value-printing code; * Likewise the type-printing code (just a single call); and * Any call that immediately followed a printf that obviously ended with a newline, my belief being that gdb's standard output streams are line buffered (by inheriting the behavior from stdio) Regression tested on x86-64 Fedora 29. I didn't add a new test case. I tend to think we don't necessarily want to specify this behavior in the tests. Let me know what you think of this. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * windows-nat.c (windows_nat_target::attach) (windows_nat_target::detach): Don't call gdb_flush. * valprint.c (generic_val_print, val_print, val_print_string): Don't call gdb_flush. * utils.c (defaulted_query): Don't call gdb_flush. * typeprint.c (print_type_scalar): Don't call gdb_flush. * target.c (target_announce_detach): Don't call gdb_flush. * sparc64-tdep.c (adi_print_versions): Don't call gdb_flush. * remote.c (extended_remote_target::attach): Don't call gdb_flush. * procfs.c (procfs_target::detach): Don't call gdb_flush. * printcmd.c (do_examine): Don't call gdb_flush. (info_display_command): Don't call gdb_flush. * p-valprint.c (pascal_val_print): Don't call gdb_flush. * nto-procfs.c (nto_procfs_target::attach): Don't call gdb_flush. * memattr.c (info_mem_command): Don't call gdb_flush. * mdebugread.c (mdebug_build_psymtabs): Don't call gdb_flush. * m2-valprint.c (m2_val_print): Don't call gdb_flush. * infrun.c (follow_exec, handle_command): Don't call gdb_flush. * inf-ptrace.c (inf_ptrace_target::attach): Don't call gdb_flush. * hppa-tdep.c (unwind_command): Don't call gdb_flush. * gnu-nat.c (gnu_nat_target::attach): Don't call gdb_flush. (gnu_nat_target::detach): Don't call gdb_flush. * f-valprint.c (f_val_print): Don't call gdb_flush. * darwin-nat.c (darwin_nat_target::attach): Don't call gdb_flush. * cli/cli-script.c (read_command_lines): Don't call gdb_flush. * cli/cli-cmds.c (shell_escape, print_disassembly): Don't call gdb_flush. * c-valprint.c (c_val_print): Don't call gdb_flush. * ada-valprint.c (ada_print_scalar): Don't call gdb_flush.
2019-03-05Add ATTRIBUTE_UNUSED_RESULT to ref_ptr::releaseTom Tromey5-10/+18
This applies ATTRIBUTE_UNUSED_RESULT to ref_ptr::release and updates a few spots to comply. I believe one use in install_default_visualizer was in error, fixed by this patch. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * varobj.c (update_dynamic_varobj_children): Update. (install_default_visualizer): Use reset, not release. * value.c (set_internalvar): Update. * dwarf2loc.c (value_of_dwarf_reg_entry): Update. * common/gdb_ref_ptr.h (class ref_ptr) <release>: Add ATTRIBUTE_UNUSED_RESULT.
2019-03-05Add ATTRIBUTE_UNUSED_RESULT to scoped_remote_fd::releaseTom Tromey2-1/+6
This applies ATTRIBUTE_UNUSED_RESULT to scoped_remote_fd::release. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * remote.c (class scoped_remote_fd) <release>: Add ATTRIBUTE_UNUSED_RESULT.
2019-03-05Add ATTRIBUTE_UNUSED_RESULT to macro_bufferTom Tromey2-1/+6
This applies ATTRIBUTE_UNUSED_RESULT to macro_buffer::release. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * macroexp.c (struct macro_buffer) <release>: Add ATTRIBUTE_UNUSED_RESULT.
2019-03-05Add ATTRIBUTE_UNUSED_RESULT to scoped_mmapTom Tromey3-7/+10
This applies ATTRIBUTE_UNUSED_RESULT to scoped_mmap::release and fixes a couple of spots to comply. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * nat/linux-btrace.c (linux_enable_bts, linux_enable_pt): Update. * common/scoped_mmap.h (class scoped_mmap) <release>: Add ATTRIBUTE_UNUSED_RESULT.
2019-03-05Add ATTRIBUTE_UNUSED_RESULT to scoped_fdTom Tromey2-1/+6
This applies ATTRIBUTE_UNUSED_RESULT to scoped_fd::release. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * common/scoped_fd.h (class scoped_fd) <release>: Add ATTRIBUTE_UNUSED_RESULT.
2019-03-05Add ATTRIBUTE_UNUSED_RESULT to parser_stateTom Tromey2-1/+6
This applies ATTRIBUTE_UNUSED_RESULT to parser_state::release. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * parser-defs.h (struct parser_state) <release>: Add ATTRIBUTE_UNUSED_RESULT.
2019-03-05Introduce ATTRIBUTE_UNUSED_RESULT and use itTom Tromey3-1/+13
This introduces the new ATTRIBUTE_UNUSED_RESULT define, and applies it to gdb_argv::release. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * utils.h (class gdb_argv) <release>: Add ATTRIBUTE_UNUSED_RESULT. * common/common-defs.h (ATTRIBUTE_UNUSED_RESULT): Define.
2019-03-05Allow multiple tests to be run on systems with older versions of TCL installed.Matthew Malcomson2-4/+10
PR 24287 * testsuite/lib/binutils-common.exp (run_dump_test): Replace a use of "lmap" with a "foreach" loop.
2019-03-05Automatic date update in version.inGDB Administrator1-1/+1
2019-03-04Use '$enable_unittest' instead of '$development' on gdbserver/configure.srv ↵Sergio Durigan Junior2-1/+7
(for 'aarch64*-*-linux*' case) On commit 8ecfd7bd4acd69213c06fac6de9af38299123547 ("Add parameter to allow enabling/disabling selftests via configure") it seems that I forgot to use the proper '$enable_unittest' variable when checking to see whether to add selftest-related objects to 'srv_regobj'. This causes a build failure on Aarch64 when 'development=false' (which is the case for the 8.3 branch) and 'enable_unittest=true'. This patch fixes the problem by using '$enable_unittest' instead of '$development' when performing the check. As a reminder, it's important to notice that '$enable_unittest's default value (i.e., when the option '--enable-unit-tests' is not passed to configure) is the same as '$development', so this patch doesn't affect the current build. I'd like to install this patch both on master and on the 8.3 branch. OK? gdb/gdbserver/ChangeLog: 2019-03-04 Sergio Durigan Junior <sergiodj@redhat.com> * configure.srv: Use '$enable_unittest' instead of '$development' when checking whether to fill 'srv_regobj' on 'aarch64*-*-linux*' case.
2019-03-04gdbserver short-circuit-argument-list failuresRichard Bunt3-26/+89
This patch fixes test case failures observed when running short-circuit-argument-list.exp with gdb server boards. Thanks to Sergio Durigan Junior for pointing this out. Assertions failed with the native{,-extended}-gdbserver boards as the standard output from the test program appears in a different location than observed on non-gdbserver boards. This standard output was used to determine whether a function, which had been logically short-circuited, was called or not. Since the location of the standard out cannot be relied upon to verify this, a new mechanism was needed. The test program now records function calls in variables named the same as the function with a "_called" suffix. These variables can then be queried from the test case to verify the occurrence of a call. A method to reset the call counts has been included in the test case, so that any future assertions added to this test can ensure a fresh set of initial values before proceeding. Not resetting values between groups of assertions creates a dependency between them, which increases the likelihood that a single failure causes subsequent assertions to fail. Regression tested on x86_64, aarch64 and ppc64le. Regression tested with Ada on x86_64. Regression tested with the native{,-extended}-gdbserver boards on x86_64.
2019-03-04Stop objcopy from attempting to copy thin archives.Nick Clifton2-0/+26
PR 24281 * objcopy.c (copy_archive): Do not copy thin archives.
2019-03-04Automatic date update in version.inGDB Administrator1-1/+1
2019-03-03Automatic date update in version.inGDB Administrator1-1/+1
2019-03-02Fix documentation of styles.Eli Zaretskii2-6/+15
gdb/doc/ChangeLog: 2019-03-02 Eli Zaretskii <eliz@gnu.org> * gdb.texinfo (Output Styling): Fix typos. Document the default foreground colors of the available styles.
2019-03-02Avoid compilation warnings on MinGW.Eli Zaretskii3-2/+10
gdb/ChangeLog: 2019-03-02 Eli Zaretskii <eliz@gnu.org> * xml-syscall.c (xml_list_syscalls_by_group): Drop 'struct' from for-loop range, to avoid compiler warnings. * tui/tui.c (tui_enable) [__MINGW32__]: Don't declare 'cap', to avoid compiler warnings about unused variables.
2019-03-02GDB no longer supports Windows before XP.Eli Zaretskii2-0/+8
gdb/ChangeLog: 2019-03-02 Eli Zaretskii <eliz@gnu.org> * NEWS: Mention end of support for native debugging on MS-Windows before XP.
2019-03-02Fix GDB compilation on MinGW (PR gdb/24292)Eli Zaretskii6-10/+39
gdb/ChangeLog: 2019-03-02 Eli Zaretskii <eliz@gnu.org> PR gdb/24292 * common/netstuff.c: * gdbserver/gdbreplay.c * gdbserver/remote-utils.c: * ser-tcp.c: * unittests/parse-connection-spec-selftests.c [USE_WIN32API]: Include ws2tcpip.h instead of wsiapi.h and winsock2.h. Redefine _WIN32_WINNT to 0x0501 if defined to a smaller value, as 'getaddrinfo' and 'freeaddrinfo' were not available before Windows XP, and mingw.org's MinGW headers by default define _WIN32_WINNT to 0x500.
2019-03-02Automatic date update in version.inGDB Administrator1-1/+1
2019-03-01Revert "Add support to GNU ld to separate got related plt entries"Andreas Krebbel19-106/+130
bfd/ChangeLog: 2019-03-01 Andreas Krebbel <krebbel@linux.ibm.com> This reverts commit 5a12586d44fa8d5dfc74cbca4f2f36a273a16335. 2019-01-14 Maamoun Tarsha <maamountk@hotmail.com> PR 20113 * elf32-s390.c (allocate_dynrelocs): Update comment. ld/ChangeLog: 2019-03-01 Andreas Krebbel <krebbel@linux.ibm.com> This reverts commit 5a12586d44fa8d5dfc74cbca4f2f36a273a16335. 2019-01-14 Maamoun Tarsha <maamountk@hotmail.com> PR 20113 * emulparams/elf64_s390.sh (SEPARATE_GOTPLT): Define. * emulparams/elf_s390.sh (SEPARATE_GOTPLT): Define. * testsuite/ld-s390/gotreloc_31-1.dd: Update expected output. * testsuite/ld-s390/tlsbin.dd: Likewise. * testsuite/ld-s390/tlsbin.rd: Likewise. * testsuite/ld-s390/tlsbin.sd: Likewise. * testsuite/ld-s390/tlsbin_64.dd: Likewise. * testsuite/ld-s390/tlsbin_64.rd: Likewise. * testsuite/ld-s390/tlsbin_64.sd: Likewise. * testsuite/ld-s390/tlspic.dd: Likewise. * testsuite/ld-s390/tlspic.rd: Likewise. * testsuite/ld-s390/tlspic.sd: Likewise. * testsuite/ld-s390/tlspic_64.dd: Likewise. * testsuite/ld-s390/tlspic_64.rd: Likewise. * testsuite/ld-s390/tlspic_64.sd: Likewise. * testsuite/ld-s390/s390.exp: Skip s390 tests for tpf targets.
2019-03-01Fix coff_start_symtab resource leak found by CoverityGary Benson2-4/+5
This commit fixes a resource leak found by Coverity, where coff_start_symtab performs an xstrdup that is now performed within start_symtab by buildsym_compunit::buildsym_compunit. gdb/ChangeLog: * coffread.c (coff_start_symtab): Remove unnecessary xstrdup.
2019-03-01Binutils: Always skip only 1 byte for CIE version 1's return address register.Tamar Christina2-4/+12
According to the specification for the CIE entries, when the CIE version is 1 then the return address register field is always 1 byte. Readelf does this correctly in read_cie in dwarf.c but ld does this incorrectly and always tries to read a skip_leb128. If the value here has the top bit set then ld will incorrectly read at least another byte, causing either an assert failure or an incorrect address to be used in eh_frame. I'm not sure how to generate a generic test for this as I'd need to write assembly, and it's a bit hard to trigger. Essentially the relocated value needs to start with something that & 0x70 != 0x10 while trying to write a personality. bfd/ChangeLog: * elf-eh-frame.c (_bfd_elf_write_section_eh_frame): Correct CIE parse.
2019-03-01PR24272, out-of-bounds read in pex64_xdata_print_uwd_codesAlan Modra2-39/+38
The fix here is to use an unsigned comparison for if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) include/ PR 24272 * coff/internal.h (struct internal_extra_pe_aouthdr): Change type of SizeOfCode, SizeOfInitializedData, and SizeOfUninitializedData to bfd_vma. Change type of SectionAlignment, FileAlignment, Reserved1, SizeOfImage, SizeOfHeaders, CheckSum, LoaderFlags, and NumberOfRvaAndSizes to uint32_t. bfd/ PR 24272 * peXXigen.c (_bfd_XXi_swap_aouthdr_in): Use unsigned index. (_bfd_XX_print_private_bfd_data_common): Adjust for type changes.
2019-03-01Automatic date update in version.inGDB Administrator1-1/+1
2019-02-28Testsuite: Catch gdbserver socket listen errorsAlan Hayward2-1/+6
When launching gdbserver, the testsuite checks for binding failure but does not check for failure to listen to socket error (which can happen due to another gdbserver binding to the socket at the same time). When this error occurs, the test will ignore the error and connect GDB to the failed port. This may succeed and GDB will now be connected to the gdbserver from another test. This eventually causes both tests to fail. When running the tests suite with native-gdbserver across many cores, this issue may happen once or twice, each causing random failures for two .exp testscripts. Example gdb.log output for the failure: The testsuite sucessfully notices a failure to connect to port 2348. It launches again with port 2349, which also fails. The testsuite ignores this error and uses gdb to connect to the port - which succeeds. spawn /work/build/gdb/testsuite/../gdbserver/gdbserver --once localhost:2348 /work/build/gdb/testsuite/outputs/gdb.ada/arrayidx/p^M Can't bind address: Address already in use.^M Exiting^M Port 2348 is already in use. spawn /work/build/gdb/testsuite/../gdbserver/gdbserver --once localhost:2349 /work/build/gdb/testsuite/outputs/gdb.ada/arrayidx/p^M Can't listen on socket: Address already in use.^M Exiting^M target remote localhost:2349^M Remote debugging using localhost:2349^M Reading /lib/ld-linux-aarch64.so.1 from remote target...^M warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.^M Reading /lib/ld-linux-aarch64.so.1 from remote target...^M Reading symbols from target:/lib/ld-linux-aarch64.so.1...^M Reading /lib/ld-2.23.so from remote target...^M Reading /lib/.debug/ld-2.23.so from remote target...^M Reading /work/build/install/lib/debug//lib/ld-2.23.so from remote target...^M Reading /work/build/install/lib/debug/lib//ld-2.23.so from remote target...^M Reading target:/work/build/install/lib/debug/lib//ld-2.23.so from remote target...^M (No debugging symbols found in target:/lib/ld-linux-aarch64.so.1)^M 0x0000ffffbf6d2cc0 in ?? () from target:/lib/ld-linux-aarch64.so.1^M (gdb) continue^M Continuing.^M Reading /lib/aarch64-linux-gnu/libc.so.6 from remote target...^M Reading /lib/aarch64-linux-gnu/libc-2.23.so from remote target...^M Reading /lib/aarch64-linux-gnu/.debug/libc-2.23.so from remote target...^M Reading /work/build/install/lib/debug//lib/aarch64-linux-gnu/libc-2.23.so from remote target...^M Reading /work/build/install/lib/debug/lib/aarch64-linux-gnu//libc-2.23.so from remote target...^M Reading target:/work/build/install/lib/debug/lib/aarch64-linux-gnu//libc-2.23.so from remote target...^M [Inferior 1 (process 35351) exited normally]^M (gdb) FAIL: gdb.ada/arrayidx.exp: can't run to main Meanwhile, at the same time, in another test, gdbserver successfully connects to port 2349. GDB then tries to connect to the port, but it times out because the GDB in the test above has already connected to it. spawn /work/build/gdb/testsuite/../gdbserver/gdbserver --once localhost:2348 /work/build/gdb/testsuite/outputs/gdb.ada/rdv_wait/foo^M Can't bind address: Address already in use.^M Exiting^M Port 2348 is already in use. spawn /work/build/gdb/testsuite/../gdbserver/gdbserver --once localhost:2349 /work/build/gdb/testsuite/outputs/gdb.ada/rdv_wait/foo^M Process /work/build/gdb/testsuite/outputs/gdb.ada/rdv_wait/foo created; pid = 65162^M Listening on port 2349^M Remote debugging from host 127.0.0.1, port 45154^M target remote localhost:2349^M localhost:2349: Connection timed out.^M (gdb) ^CQuit^M (gdb) task 2^M Cannot inspect Ada tasks when program is not running^M gdb/testsuite/ChangeLog: * lib/gdbserver-support.exp (gdbserver_start): Check for listen failure.
2019-02-28Can't interrupt process without controlling terminal on Solaris (PR gdb/8527)Rainer Orth5-0/+170
If gdb attaches to a process that either has no controlling terminal, or the controlling terminal differs from the one gdb is running under, break/^C doesn't interrupt the debugged process on Solaris. Fixed as follows, analogous to what all all other targets do. Patch from the PR, recently re-submitted by Brian Vandenberg. Tested on amd64-pc-solaris2.11, sparcv9-sun-solaris2.11, and x86_64-pc-linux-gnu. 2019-02-28 Brian Vandenberg <phantall@gmail.com> Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> gdb: PR gdb/8527 * procfs.c (proc_wait_for_stop): Wrap write of PCWSTOP in set_sigint_trap, clear_sigint_trap. gdb/testsuite: PR gdb/8527 * gdb.base/interrupt-daemon-attach.c, gdb.base/interrupt-daemon-attach.exp: New test.
2019-02-28Prevent a buffer overrun error when attempting to parse a corrupt ELF file.Nick Clifton2-1/+17
PR 24273 * elf.c (bfd_elf_string_from_elf_section): Check for a string section that is not NUL terminated.
2019-02-28(gdb/sim) Move Mike Frysinger to past maintainers sectionJoel Brobecker2-1/+5
sim/ChangeLog: * MAINTAINERS: Move Mike Frysinger to past maintainers' section.
2019-02-28Automatic date update in version.inGDB Administrator1-1/+1
2019-02-27Fix regcache leak, and avoid possible regcache access after detach.Philippe Waroquiers2-1/+17
Valgrind reports leaks like the below in various tests, e.g. gdb.threads/attach-slow-waitpid.exp, gdb.ada/task_switch_in_core.exp, ... Fix the leak by clearing the regcache when detaching from an inferior. Note that these leaks are 'created' when GDB exits, when the regcache::current_regcache is destroyed : the elements of the forward_list are pointers, and the 'pointed to' memory is not deleted by the forward_list destructor. Nevertheless, fixing this leak is good as it makes a bunch of tests 'leak clean'. Also, it seems strange to keep a register cache for a process from which GDB detached : it is not clear if this cache is still valid after detach. And effectively, when clearing only the regcache, (and not the frame cache), then the frame cache was still 'pointing' at this regcache and was used when switching to the child process in the test gdb.threads/watchpoint-fork.exp, which seems strange. So, we solve the leak and avoid possible accesses to the regcache and frame cache of the detached inferior, by clearing both the regcache and the frame cache. Tested on debian/amd64, natively, under Valgrind, and with make check RUNTESTFLAGS="--target_board=native-gdbserver". ==27679== VALGRIND_GDB_ERROR_BEGIN ==27679== 1,123 (72 direct, 1,051 indirect) bytes in 1 blocks are definitely lost in loss record 2,942 of 3,400 ==27679== at 0x4C2C4CC: operator new(unsigned long) (vg_replace_malloc.c:344) ==27679== by 0x5CDF71: get_thread_arch_aspace_regcache(ptid_t, gdbarch*, address_space*) (regcache.c:330) ==27679== by 0x5CE12A: get_thread_regcache (regcache.c:366) ==27679== by 0x5CE12A: get_current_regcache() (regcache.c:372) ==27679== by 0x4FF63D: post_create_inferior(target_ops*, int) (infcmd.c:452) ==27679== by 0x43AF62: core_target_open(char const*, int) (corelow.c:458) ==27679== by 0x408B68: cmd_func(cmd_list_element*, char const*, int) (cli-decode.c:1892) ... gdb/ChangeLog 2019-02-27 Philippe Waroquiers <philippe.waroquiers@skynet.be> * target.c (target_detach): Clear the regcache and the frame cache.
2019-02-27x86-64: Skip protected check on symbol defined by linkerH.J. Lu9-0/+56
Skip symbol defined by linker when checking copy reloc on protected symbol. bfd/ PR ld/24276 * elf64-x86-64.c (elf_x86_64_check_relocs): Skip symbol defined by linker when checking copy reloc on protected symbol. ld/ PR ld/24276 * testsuite/ld-i386/i386.exp: Run PR ld/24276 test. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr24276.dso: New file. * testsuite/ld-i386/pr24276.warn: Likewise. * testsuite/ld-x86-64/pr24276.dso: Likewise. * testsuite/ld-x86-64/pr24276.warn: Likewise.
2019-02-27Handle \r\n in gdbreplayTom Tromey2-2/+22
I tried gdbreplay yesterday, but the remotelogfile I received was made on Windows, so the lines were terminated with \r\n rather than plain \n. This patch changes gdbreplay to allow \r\n line termination when reading the log file. gdb/gdbserver/ChangeLog 2019-02-27 Tom Tromey <tromey@adacore.com> * gdbreplay.c (logchar): Handle \r\n.
2019-02-27Test "set width/height -1"Pedro Alves2-0/+7
As a follow up to the previous commit, add a test for "set width/height -1", to make sure we don't overflow in readline with negative values either. gdb/testsuite/ChangeLog: 2019-02-27 Pedro Alves <palves@redhat.com> * gdb.base/page.exp: Add tests for "set width/height -1".
2019-02-27Make 'show width/height' display "unlimited" when capped for readlinePedro Alves4-2/+42
When we cap the height/width sizes before passing to readline, tweak the corresponding command variable to show "unlimited": (gdb) set height 0x8000 (gdb) show height Number of lines gdb thinks are in a page is unlimited. Instead of the current output: (gdb) set height 0x8000 (gdb) show height Number of lines gdb thinks are in a page is 32768. gdb/ChangeLog: 2019-02-27 Pedro Alves <palves@redhat.com> * utils.c (set_screen_size): When we cap the height/width sizes, tweak the corresponding command variable to show "unlimited": gdb/testsuite/ChangeLog: 2019-02-27 Pedro Alves <palves@redhat.com> * gdb.base/page.exp: Add tests for "set/show width/height" with "infinite" values.
2019-02-27Prevent overflow in rl_set_screen_sizeSaagar Jha2-4/+23
GDB calls rl_set_screen_size in readline with the current screen size, measured in rows and columns. To represent "infinite" sizes, GDB passes in INT_MAX; however, since rl_set_screen_size internally multiplies the number of rows and columns, this causes a signed integer overflow. To prevent this we can instead pass in the approximate square root of INT_MAX (which is still reasonably large), so that even when the number of rows and columns is "infinite" we don't overflow. gdb/ChangeLog: 2019-02-27 Saagar Jha <saagar@saagarjha.com> Pedro Alves <palves@redhat.com> * utils.c (set_screen_size): Reduce "infinite" rows and columns before calling rl_set_screen_size.
2019-02-27Remove Python 2.4 and 2.5 supportTom Tromey15-303/+46
This removes all the remainings spots I could find that work around issues in Python 2.4 and 2.5. I don't have a good way to test that Python 2.6 still works. Tested by the buildbot. gdb/ChangeLog 2019-02-27 Tom Tromey <tromey@adacore.com> * config.in, configure: Rebuild. * configure.ac (HAVE_LIBPYTHON2_4, HAVE_LIBPYTHON2_5): Never define. * python/py-value.c: Remove Python 2.4 workaround. * python/py-utils.c (gdb_pymodule_addobject): Remove Python 2.4 workaround. * python/py-type.c (convert_field, gdbpy_initialize_types): Remove Python 2.4 workaround. * python/python-internal.h: Remove Python 2.4 comment. (Py_ssize_t): Don't define. (PyVarObject_HEAD_INIT, Py_TYPE): Don't define. (gdb_Py_DECREF): Remove Python 2.4 workaround. (gdb_PyObject_GetAttrString, PyObject_GetAttrString): Remove. (gdb_PyObject_HasAttrString, PyObject_HasAttrString): Remove. * python/python.c (do_start_initialization): Remove Python 2.4 workaround. * python/py-prettyprint.c (class dummy_python_frame): Remove. (print_children): Remove Python 2.4 workaround. * python/py-inferior.c (buffer_procs): Remove Python 2.4 workaround. (CHARBUFFERPROC_NAME): Remove. * python/py-breakpoint.c (gdbpy_initialize_breakpoints): Remove Python 2.4 workaround. gdb/testsuite/ChangeLog 2019-02-27 Tom Tromey <tromey@adacore.com> * lib/gdb.exp (skip_python_tests_prompt): Don't check for Python 2.4. * gdb.python/py-finish-breakpoint.exp: Remove Python 2.4 workaround. gdb/ChangeLog 2019-02-27 Tom Tromey <tromey@adacore.com> * config.in, configure: Rebuild. * configure.ac (HAVE_LIBPYTHON2_4, HAVE_LIBPYTHON2_5): Never define. * python/py-value.c: Remove Python 2.4 workaround. * python/py-utils.c (gdb_pymodule_addobject): Remove Python 2.4 workaround. * python/py-type.c (convert_field, gdbpy_initialize_types): Remove Python 2.4 workaround. * python/python-internal.h: Remove Python 2.4 comment. (Py_ssize_t): Don't define. (PyVarObject_HEAD_INIT, Py_TYPE): Don't define. (gdb_Py_DECREF): Remove Python 2.4 workaround. (gdb_PyObject_GetAttrString, PyObject_GetAttrString): Remove. (gdb_PyObject_HasAttrString, PyObject_HasAttrString): Remove. * python/python.c (do_start_initialization): Remove Python 2.4 workaround. * python/py-prettyprint.c (class dummy_python_frame): Remove. (print_children): Remove Python 2.4 workaround. * python/py-inferior.c (buffer_procs): Remove Python 2.4 workaround. (CHARBUFFERPROC_NAME): Remove. * python/py-breakpoint.c (gdbpy_initialize_breakpoints): Remove Python 2.4 workaround.
2019-02-27Document fact that mininum Python version is now 2.6Kevin Buettner4-1/+12
gdb/ChangeLog: * NEWS: Note minimum Python version. gdb/doc/ChangeLog: * gdb.texinfo (Configure Options): Document minimum python version.
2019-02-27Use Python 2.[67] / 3.X / PEP 3118 buffer protocolKevin Buettner2-56/+16
This patch removes the non-IS_PY3K code in infpy_write_memory() and infpy_search_memory(). In both cases, the remaining code from these ifdefs is related to use of the PEP 3118 buffer protocol. (Deleted code is either due to simplification or related to use of the old buffer protocol.) PEP 3118 is sometimes referred to as the "new" buffer protocol, though it's not that new anymore. The link below describes new features in Python 2.6. In particular, it says that the buffer protocol described by PEP 3118 is in Python 2.6. It also says (at the top of the page) that Python 2.6 was released on Oct 1, 2008. https://docs.python.org/3/whatsnew/2.6.html#pep-3118-revised-buffer-protocol The last security release for the Python 2.6 series was 2.6.9. It was released on Oct 29, 2013. According to this document... https://www.python.org/download/releases/2.6.9/ ...support for the 2.6 series has ended: With the 2.6.9 release, and five years after its first release, the Python 2.6 series is now officially retired. All official maintenance for Python 2.6, including security patches, has ended. For ongoing maintenance releases, please see the Python 2.7 series. As noted earlier, Python 2.6, Python 2.7, and Python 3.X all have support for the PEP 3118 buffer protocol. Python releases prior to 2.6 use an older buffer protocol. Since Python 2.6 has been retired for a good while now, it seems reasonable to me to remove code using the older buffer protocol from GDB. I have also simplified some of the code via use of the Py_buffer unique_ptr specialization which I introduced in the two argument gdb.Value constructor patch series. Therefore, there is a dependency on patch #1 from that series. I have tested against both Python 2.7.15 and 3.7.2. I see no regressions among the non-racy tests. I've also verified that PyBuffer_Release is being called when the affected functions exit while running the tests in gdb.python/py-inferior.exp by hand. I've also tried running valgrind on GDB while running this test, but I'm puzzled by the results that I'm seeing - I'm seeing no additional leaks when I comment out the Py_buffer_up lines that I introduced. That said, I'm not seeing any leaks that obviously originate from either infpy_write_memory() or infpy_search_memory(). gdb/ChangeLog: * python/py-inferior.c (infpy_write_memory): Remove non-IS_PY3K code from these functions. Remove corresponding ifdefs. Use Py_buffer_up instead of explicit calls to PyBuffer_Release. Remove gotos and target of gotos. (infpy_search_memory): Likewise.
2019-02-27gdb/hppa: Use default gdbarch method default_dummy_id.Andrew Burgess2-9/+6
Make use of the default gdbarch method for gdbarch_dummy_id. I have not tested this change but, by inspecting the code, I believe the default method is equivalent to the code being deleted. gdb/ChangeLog: * gdb/hppa-tdep.c (hppa_dummy_id): Delete. (hppa_gdbarch_init): Don't register deleted functions with gdbarch.
2019-02-27gdb/h8300: Use default gdbarch methods where possibleAndrew Burgess2-22/+8
Make use of the default gdbarch methods for gdbarch_dummy_id, gdbarch_unwind_pc, and gdbarch_unwind_sp where possible. I have not tested this change but, by inspecting the code, I believe the default methods are equivalent to the code being deleted. gdb/ChangeLog: * gdb/h8300-tdep.c (h8300_unwind_pc): Delete. (h8300_unwind_sp): Delete. (h8300_dummy_id): Delete. (h8300_gdbarch_init): Don't register deleted functions with gdbarch.
2019-02-27gdb/ft32: Use default gdbarch methods where possibleAndrew Burgess2-33/+8
Make use of the default gdbarch methods for gdbarch_dummy_id, gdbarch_unwind_pc, and gdbarch_unwind_sp where possible. I have not tested this change but, by inspecting the code, I believe the default methods are equivalent to the code being deleted. gdb/ChangeLog: * gdb/ft32-tdep.c (ft32_dummy_id): Delete. (ft32_unwind_pc): Delete. (ft32_unwind_sp): Delete. (ft32_gdbarch_init): Don't register deleted functions with gdbarch.