gold/
PR gold/16504
* dynobj.cc (Versions::symbol_section_contents): Don't set
VERSYM_HIDDEN flag for undefined symbols.
* symtab.cc (Symbol_table::add_from_object): Don't override default
version definition with a different default version.
* symtab.h (Symbol::from_dyn): New method.
* testsuite/plugin_test.c (struct sym_info): Add ver field.
(claim_file_hook): Pass symbol version to plugin API.
(parse_readelf_line): Parse symbol version.
* testsuite/Makefile.am (ver_test_pr16504): New test case.
* testsuite/Makefile.in: Regenerate.
* testsuite/ver_test_pr16504.sh: New test script.
* testsuite/ver_test_pr16504_a.c: New source file.
* testsuite/ver_test_pr16504_a.script: New version script.
* testsuite/ver_test_pr16504_b.c: New source file.
* testsuite/ver_test_pr16504_b.script: New version script.
This patch aims to turn 'set print inferior-events' always on, and do
some cleanup on the messages printed by GDB when various inferior
events happen (attach, detach, fork, kill, exit).
To make sure that the patch is correct, I've tested it with a handful
of combinations of 'set follow-fork-mode', 'set detach-on-fork' and
'set print inferior-events'. In the end, I decided to make my
hand-made test into an official testcase. More on that below.
Using the following program as an example:
#include <unistd.h>
int main ()
{
fork ();
return 0;
}
We see the following outputs from the patched GDB:
- With 'set print inferior-events on':
(gdb) r
Starting program: a.out
[Detaching after fork from child process 27749]
[Inferior 1 (process 27745) exited normally]
(gdb)
- With 'set print inferior-events off':
(gdb) r
Starting program: a.out
[Inferior 1 (process 27823) exited normally]
(gdb)
Comparing this against an unpatched GDB:
- With 'set print inferior-events off' and 'set follow-fork-mode
child':
(gdb) r
Starting program: a.out
[Inferior 2 (process 5993) exited normally]
(gdb)
Compare this against an unpatched GDB:
(unpatched-gdb) r
Starting program: a.out
[New process 5702]
[Inferior 2 (process 5702) exited normally]
(unpatched-gdb)
It is possible to notice that, in this scenario, the patched GDB
will lose the '[New process %d]' message.
- With 'set print inferior-events on', 'set follow-fork-mode child'
and 'set detach-on-fork on':
(gdb) r
Starting program: a.out
[Attaching after process 27905 fork to child process 27909]
[New inferior 2 (process 27909)]
[Detaching after fork from parent process 27905]
[Inferior 1 (process 27905) detached]
[Inferior 2 (process 27909) exited normally]
(gdb)
Compare this output with an unpatched GDB, using the same settings:
(unpatched-gdb) r
Starting program: a.out
[New inferior 28033]
[Inferior 28029 detached]
[New process 28033]
[Inferior 2 (process 28033) exited normally]
[Inferior 28033 exited]
(unpatched-gdb)
As can be seen above, I've also made a few modifications to messages
that are printed when 'set print inferior-events' is on. For example,
a few of the messages did not contain the '[' and ']' as
prefix/suffix, which led to a few inconsistencies like:
Attaching after process 22995 fork to child process 22999.
[New inferior 22999]
Detaching after fork from child process 22999.
[Inferior 22995 detached]
[Inferior 2 (process 22999) exited normally]
So I took the opportunity and included the square brackets where
applicable. I have also made the existing messages more uniform, by
always printing "Inferior %d (process %d)..." where applicable. This
makes it easier to identify the inferior number and the PID number
from the messages.
As suggested by Pedro, the "[Inferior %d exited]" message from
'exit_inferior' has been removed, because it got duplicated when
'inferior-events' is on. I'm also using the
'add_{thread,inferior}_silent' versions (instead of their verbose
counterparts) on some locations, also to avoid duplicated messages.
For example, a patched GDB with 'set print inferior-events on', 'set
detach-on-fork on' and 'set follow-fork-mode child', but using
'add_thread', would print:
(gdb) run
Starting program: a.out
[Attaching after process 25088 fork to child process 25092.]
[New inferior 25092] <--- duplicated
[Detaching after fork from child process 25092.]
[Inferior 25088 detached]
[New process 25092] <--- duplicated
[Inferior 2 (process 25092) exited normally]
But if we use 'add_thread_silent' (with the same configuration as
before):
(gdb) run
Starting program: a.out
[Attaching after process 31606 fork to child process 31610]
[New inferior 2 (process 31610)]
[Detaching after fork from parent process 31606]
[Inferior 1 (process 31606) detached]
[Inferior 2 (process 31610) exited normally]
As for the tests, the configuration options being exercised are:
- follow-fork-mode: child/parent
- detach-on-fork: on/off
- print inferior-events: on/off
It was also necessary to perform adjustments on several testcases,
because the expected messages changed considerably.
Built and regtested on BuildBot, without regressions.
gdb/ChangeLog:
2018-04-24 Jan Kratochvil <jan.kratochvil@redhat.com>
Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
* infcmd.c (kill_command): Print message when inferior has
been killed.
* inferior.c (print_inferior_events): Remove 'static'. Set as
'1'.
(add_inferior): Improve message printed when
'print_inferior_events' is on.
(exit_inferior): Remove message printed when
'print_inferior_events' is on.
(detach_inferior): Improve message printed when
'print_inferior_events' is on.
(initialize_inferiors): Use 'add_inferior_silent' to set
'current_inferior_'.
* inferior.h (print_inferior_events): Declare here as
'extern'.
* infrun.c (follow_fork_inferior): Print '[Attaching...]' or
'[Detaching...]' messages when 'print_inferior_events' is on.
Use 'add_thread_silent' instead of 'add_thread'. Add '[' and ']'
as prefix/suffix for messages. Remove periods. Fix erroneous
'Detaching after fork from child...', replace it by '... from
parent...'.
(handle_vfork_child_exec_or_exit): Add '[' and ']' as
prefix/suffix when printing 'Detaching...' messages. Print
them when 'print_inferior_events' is on.
* remote.c (remote_detach_1): Print message when detaching
from inferior and '!is_fork_parent'.
gdb/testsuite/ChangeLog:
2018-04-24 Jan Kratochvil <jan.kratochvil@redhat.com>
Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
* gdb.base/attach-non-pgrp-leader.exp: Adjust 'Detaching...'
regexps to expect for '[Inferior ... detached]' as well.
* gdb.base/attach.exp: Likewise.
* gdb.base/catch-syscall.exp (check_for_program_end): Adjust
"gdb_continue_to_end".
(test_catch_syscall_with_wrong_args): Likewise.
* gdb.base/foll-fork.exp: Adjust regexps to match '[' and
']'. Don't set 'verbose' on.
* gdb.base/foll-vfork.exp: Likewise.
* gdb.base/fork-print-inferior-events.c: New file.
* gdb.base/fork-print-inferior-events.exp: New file.
* gdb.base/hook-stop.exp: Adjust regexps to expect for new
'[Inferior ... has been killed]' message.
* gdb.base/kill-after-signal.exp: Likewise.
* gdb.base/solib-overlap.exp: Adjust regexps to expect for new
detach message.
* gdb.threads/kill.exp: Adjust regexps to expect for new kill
message.
* gdb.threads/clone-attach-detach.exp: Adjust 'Detaching...'
regexps to expect for '[Inferior ... detached]' as well.
* gdb.threads/process-dies-while-detaching.exp: Likewise.
As reported in PR 23104, -ldl doesn't work on FreeBSD. Replace it with
shlib_load, which adds the right flags for dynamic library loading based
on the current target platform.
The test still passes on Linux, and should now pass on FreeBSD, though I
did not test personally.
gdb/testsuite/ChangeLog:
PR gdb/23104
* gdb.base/info-shared.exp: Replace libs=-ldl with shlib_load.
I noticed that cli-out.h had incorrect indentation in some spots.
This fixes it.
ChangeLog
2018-04-24 Tom Tromey <tom@tromey.com>
* cli-out.h: Reindent.
I noticed that cli_ui_out::out_field_fmt is only used by a single
caller, and it can easily be replaced by fputs_filtered. So, this
patch removes it.
ChangeLog
2018-04-24 Tom Tromey <tom@tromey.com>
* cli-out.c (cli_ui_out::out_field_fmt): Remove.
(cli_ui_out::do_field_string): Use fputs_filtered.
* cli-out.h (class cli_ui_out) <out_field_fmt>: Remove.
This removes a cleanup from scm-frame.c, replacing it with
unique_xmalloc_ptr and a new scope. I believe this also fixes a
latent bug involving calling do_cleanups twice for a single cleanup.
Regression tested using the gdb.guile test suite on x86-64 Fedora 26.
ChangeLog
2018-04-23 Tom Tromey <tom@tromey.com>
* guile/scm-frame.c (gdbscm_frame_read_var): Use
gdb::unique_xmalloc_ptr.
Pedro pointed out that gdb/configure and gdbserver/configure weren't
updated after some recent *.m4 changes.
This patch rebuilds those files. Tested by rebuilding. Pedro
approved this in the thread where he raised this issue, so I'm pushing
it in.
ChangeLog
2018-04-23 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
gdbserver/ChangeLog
2018-04-23 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
The gcc warning has been fixed, and the patch regressed builds with
some older versions of gcc.
* elf-linux-core.h: Revert last change.
* elf.c: Likewise.
All of these warnings were false positives. -Wstringop-truncation is
particularly annoying when it warns about strncpy used quite correctly.
bfd/
* elf-linux-core.h (swap_linux_prpsinfo32_ugid32_out): Disable
gcc-8 string truncation warning.
(swap_linux_prpsinfo32_ugid16_out): Likewise.
(swap_linux_prpsinfo64_ugid32_out): Likewise.
(swap_linux_prpsinfo64_ugid16_out): Likewise.
* elf.c (elfcore_write_prpsinfo): Likewise.
gas/
* stabs.c (generate_asm_file): Use memcpy rather than strncpy.
Remove call to strlen inside loop.
* config/tc-cr16.c (getreg_image): Warning fix.
* config/tc-crx.c (getreg_image): Warning fix.
Problems:
1. linking -dl lib on FreeBSD platform
2. backtrace from ld-elf shows r_debug_state() instead of _dl_debug_state()
Cause:
1. There is no dl library on FreeBSD platform test has to ignore linking "-ldl"
2. The stop due to a shared library event shows backtrace frame #0
function as r_debug_state()
gdb/ChangeLog:
PR gdb/23095
* gdb/testsuite/gdb.base/break-probes.exp: Pass shlib_load to
prepare_for_testing. Set normal_bp to r_debug_state if target
is bsd.
As Rajendra SY reported at
<https://sourceware.org/ml/gdb-patches/2018-04/msg00399.html>, several
attach-related tests are failing on FreeBSD. The "attach" command
errors with "Couldn't get registers: Device busy".
When the "attach" command is executed, it calls target_attach ->
inf_ptrace_attach, which just does the ptrace(PT_ATTACH), it does not
wait for the child to stop with SIGSTOP. Afterwards, the command is
complete and we go back to the event loop. The event loop wakes up
and we end up in target_wait -> fbsd_wait, and handle the SIGSTOP
stop.
At the end of execute_command, though, before going back to the event
loop, we check if the frame language changed via
check_frame_language_change(). That reads the current PC, which is
what leads to the registers read that fails.
The problem is that we fail to mark the attached-to thread as
executing between the initial attach, and the subsequent target_wait.
Until we see the thread stop with SIGSTOP, we shouldn't try to read
registers off of it. I guess there may a timing issue here - if
you're "lucky", the thread may stop before gdb reads its registers,
masking the problem.
With that fixed, check_frame_language_change() becomes a nop until the
thread is marked not-executing again, after target_wait is called and
we go through handle_inferior_event -> normal_stop.
We haven't seen the problem on Linux because there, the target_attach
implementation waits for the thread to stop before returning. Still,
that's supposedly hidden from the core, since the Linux target, like
most targets, is a '!to_attach_no_wait' target.
This fixes:
FAIL: gdb.base/attach.exp: attach1, after setting file
FAIL: gdb.base/attach.exp: attach2, with no file
FAIL: gdb.base/attach.exp: load file manually, after attach2 (re-read) (got interactive prompt)
FAIL: gdb.base/attach.exp: attach when process' a.out not in cwd
FAIL: gdb.base/dprintf-detach.exp: bai=on ds=gdb dd=on: re-attach to inferior
FAIL: gdb.base/dprintf-detach.exp: bai=on ds=gdb dd=off: re-attach to inferior
FAIL: gdb.base/dprintf-detach.exp: bai=on ds=call dd=on: re-attach to inferior
FAIL: gdb.base/dprintf-detach.exp: bai=on ds=call dd=off: re-attach to inferior
FAIL: gdb.base/dprintf-detach.exp: bai=on ds=agent dd=on: re-attach to inferior
FAIL: gdb.base/dprintf-detach.exp: bai=on ds=agent dd=off: re-attach to inferior
FAIL: gdb.base/dprintf-detach.exp: bai=off ds=gdb dd=on: re-attach to inferior
FAIL: gdb.base/dprintf-detach.exp: bai=off ds=gdb dd=off: re-attach to inferior
FAIL: gdb.base/dprintf-detach.exp: bai=off ds=call dd=on: re-attach to inferior
FAIL: gdb.base/dprintf-detach.exp: bai=off ds=call dd=off: re-attach to inferior
FAIL: gdb.base/dprintf-detach.exp: bai=off ds=agent dd=on: re-attach to inferior
FAIL: gdb.base/dprintf-detach.exp: bai=off ds=agent dd=off: re-attach to inferior
gdb/ChangeLog:
2018-04-21 Pedro Alves <palves@redhat.com>
Rajendra SY <rajendra.sy@gmail.com>
* inf-ptrace.c (inf_ptrace_attach): Mark the thread as executing.
* remote.c (extended_remote_attach): In all-stop mode, mark the
thread as executing.
gcc configured using --with-ld always uses that particular version of
ld if it exists. This patch adds a check that the ld version reported
directly from ld-new matches that reported via gcc. I chose to
compare the ld --version output rather than a more strict test (for
example by gcc --print-prog-name=ld), because the version test allows
a user to run the ld testsuite after installing a new ld (in the place
expected by gcc).
Sample output:
Running target unix
Using /usr/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /usr/share/dejagnu/config/unix.exp as generic interface file for target.
Using /home/alan/src/binutils-gdb/ld/testsuite/config/default.exp as tool-and-target-specific interface file.
ERROR: ************************************************************************
ERROR: Your compiler driver ignores -B when choosing ld.
ERROR: You will not be testing the new ld in many of the following tests.
ERROR: It seems you will be testing /usr/bin/x86_64-w64-mingw32-ld instead.
ERROR: ************************************************************************
WARNING: Assuming target board is the local machine (which is probably wrong).
You may need to set your DEJAGNU environment variable.
Running /home/alan/src/binutils-gdb/ld/testsuite/ld-aarch64/aarch64-elf.exp ...
* testsuite/lib/ld-lib.exp (run_host_cmd): Check that gcc -B
works.
Add a Usage: line for thread_apply_command, in particular to mention
the thread ID list.
In thread_apply_command and thread_apply_all_command help, use
uppercase for arg names, as this style seems to be more standard.
2018-04-20 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* thread.c (_initialize_thread): improve on-line help for
thread_apply_command and thread_apply_all_command.
We were emitting dynamic relocs on the second word of a TLS GD GOT
entry pair (the dtprel offset), without the addend necessary when no
symbol is present on the dynamic reloc. Unfortunately the simple
solution of providing the proper addend doesn't work due to an hppa
glibc ld.so bug that ignores such addends. So instead optimize the
relocs. The dtprel offset is known at link time for locally defined
symbols (the only case where we'll end up with no symbol on a dynamic
reloc) so we can omit the dynamic reloc in that case.
Furthermore, we can omit a dynamic reloc on the first word of a TLS GD
GOT entry pair (the module id) if the symbol is local and we are
producing an executable. Similarly, a tprel reloc on a TLS IE GOT
entry is not needed for local symbols in an executable. So the
condition for TLS GOT relocs can become bfd_link_dll(info) rather than
bfd_link_pic(info) as needed for normal GOT relocs.
This all presumes hppa ld.so doesn't need to differentiate TLS GD GOT
pairs from TLS LD GOT pairs, which is currently true.
PR 22978
* elf32-hppa.c (got_relocs_needed): Add extra param to special
case both dtprel and tprel relocs.
(allocate_dynrelocs): Adjust conditions for got relocs.
(elf32_hppa_relocate_section): Likewise for local sym got relocs.
Emit dynamic relocs on TLS GOT entries for shared libraries,
not when pic. Omit dynamic reloc on dtprel entry when local,
and on tprel entry when local and executable.
The hang occurs when GDB tries to call inferior functions on two
different threads with scheduler-locking turned on. The first call works
fine, with the call to infrun_async(1) causing the signal_handler to be
marked and the event to be handled, but then the event loop resets the
"ready" member to zero, while leaving infrun_is_async set to 1. As a
result, GDB hangs if the user switches to another thread and calls a
second function because calling infrun_async(1) a second time has no
effect, meaning the inferior call events are never handled.
The added test case provokes the above issue.
gdb/testsuite/ChangeLog:
* gdb.threads/multiple-successive-infcall.c: New test.
* gdb.threads/multiple-successive-infcall.exp: New file.
Fix some typos.
Remove obsolete comment about dispatch to thread_apply_command,
rather tell that thread_command either switches to a thread,
or prints the current thread.
2018-04-19 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* thread.c (thread_apply_all_command): Fix comment.
(thread_command): Fix comment.
The dependency tracking (the thing that knows which source file included
which other source file during last build to know what to rebuild when
an included file changes) is broken for gdbserver subdirectories (arch
and common).
The dependency tracking files are created in the form
arch/.deps/i386.Po
but we try to include
.deps/arch/i386.Po
An easy smoke test is too "touch" the gdb/features/i386/32bit-core.c
file in the source directory and try to rebuild gdbserver. This file is
included by gdb/arch/i386.c, so it should cause
gdb/gdbserver/arch/i386.o in the build directory to be rebuilt. It
currently isn't rebuilt, but is with this patch applied.
This patch copies the technique used in GDB to transform the dep file
paths to the proper form.
Also, while testing using the depcomp method of dependency tracking (by
just hacking the condition), I noticed that depcomp was not found. The
path to depcomp seems to be missing a "..".
gdb/gdbserver/ChangeLog:
* Makefile.in (depcomp): Add "..".
(all_deps_files): New and use it.
When checking a R_ARM_TARGET[12] relocation, we need a valid target
pointer, but the garbage collection code was passing a NULL instead.
The previous fix for this bug fixed the call to
scan.global_reloc_may_be_function_pointer, but missed the similar
call to scan.local_reloc_may_be_function_pointer.
gold/
PR gold/23046
* gc.h (gc_process_relocs): Pass target to
scan.local_reloc_may_be_function_pointer.
The only stub type that makes sense for undefined symbols, or those
defined in shared libraries, is a plt call stub. This patch arranges
to have "destination" set to -1 on such symbols, making for an easy
test in hppa_type_of_stub.
PR 22537
* elf32-hppa.c (elf32_hppa_size_stubs): Init "destination" to -1.
(hppa_type_of_stub): Don't return a long branch stub for
symbols other than those defined statically.
For ports which use new target descriptions, remove
the xml files from being built into gdbserver.
gdbserver/
* configure.srv (aarch64*-*-linux*): Don't include xml.
(i[34567]86-*-cygwin*): Likewise.
(i[34567]86-*-linux*): Likewise.
(i[34567]86-*-lynxos*): Likewise.
(i[34567]86-*-mingw32ce*): Likewise.
(i[34567]86-*-mingw*): Likewise.
(i[34567]86-*-nto*): Likewise.
(tic6x-*-uclinux): Likewise.
(x86_64-*-linux*): Likewise.
(x86_64-*-mingw*): Likewise.
(x86_64-*-cygwin*): Likewise.
Add a print_xml_feature visitor class which turns a
target description into xml. Both gdb and gdbserver can do this.
gdb/
* common/tdesc.c (print_xml_feature::visit_pre): Add xml parsing.
(print_xml_feature::visit_post): Likewise.
(print_xml_feature::visit): Likewise.
* common/tdesc.h (tdesc_get_features_xml): Use const tdesc.
(print_xml_feature): Add new class.
* regformats/regdat.sh: Null xmltarget on feature targets.
* target-descriptions.c (struct target_desc): Add xmltarget.
(maintenance_check_tdesc_xml_convert): Add unittest function.
(tdesc_get_features_xml): Add function to get xml.
(maintenance_check_xml_descriptions): Test xml generation.
* xml-tdesc.c (string_read_description_xml): Add function.
* xml-tdesc.h (string_read_description_xml): Add declaration.
gdbserver/
* gdb/gdbserver/server.c (get_features_xml): Remove cast.
* tdesc.c (void target_desc::accept): Fill in function.
(tdesc_get_features_xml): Remove old xml creation.
(print_xml_feature::visit_pre): Add xml vistor.
* tdesc.h (struct target_desc): Make xmltarget mutable.
(tdesc_get_features_xml): Remove declaration.
Define elf32_bed and elf64_bed before including "elf32-target.h" and
"elf64-target.h" to avoid local elf32_bed and elf64_bed variables.
* elf32-i386.c (elf32_bed): Define before including
"elf32-target.h".
* elf64-x86-64.c (elf64_bed): Define before including
"elf64-target.h".
(elf32_bed): Define before including "elf32-target.h".
Use a normal input file with compatible relocation to hold linker
created sections,
PR ld/23055
* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Use a
normal input file with compatible relocation.