When I triage some reverse debugging test fails on arm-linux, I find
arm_record_coproc_data_proc and arm_record_data_proc_misc_ld_str is not
friendly to instruction encoding on ARM ARM. This patch rewrites them, in
a way match more closely to the manual.
gdb:
2018-02-01 Yao Qi <yao.qi@linaro.org>
* arm-tdep.c (arm_record_data_proc_misc_ld_str): Rewrite it.
(arm_record_coproc_data_proc): Likewise.
Variable 'ret' should be int rather than unsigned, as it can be -1.
gdb:
2018-02-01 Yao Qi <yao.qi@linaro.org>
* arm-tdep.c (arm_record_extension_space): Change ret to signed.
I see some test fails in gdb.base/attach.exp when gdb is configured
--with-sysroot=/.
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
If gdb is configured this way, sysroot is "/" in default, and if binfile
is a absolute path, the regexp pattern $sysroot$escapedbinfile is
incorrect.
There are different ways to fix it, but I don't want to complicate the
test, so I choose this naive way.
gdb/testsuite:
2018-02-01 Yao Qi <yao.qi@linaro.org>
* gdb.base/attach.exp (do_attach_tests): Set sysroot to
"\[^\r\n\]*".
bfdI would like to fix instances of the following warning, when building
with clang with no special CFLAGS other than -g3 -O0.
/home/emaisin/src/binutils-gdb/bfd/elflink.c:5425:45: error: performing pointer arithmetic on a null pointer has undefined behavior [-Werror,-Wnull-pointer-arithmetic]
return (struct elf_link_hash_entry *) 0 - 1;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
Replacing those with "(struct elf_link_hash_entry *) -1" gets rid of the
warning. I wanted to check that it didn't change the resulting code, so
I tried to build this:
$ cat test.c
int *before()
{
return (int *) 0 - 1;
}
int *after()
{
return (int *) - 1;
}
$ gcc -c test.c -g
$ objdump -d test.o
test.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <before>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 48 c7 c0 fc ff ff ff mov $0xfffffffffffffffc,%rax
b: 5d pop %rbp
c: c3 retq
000000000000000d <after>:
d: 55 push %rbp
e: 48 89 e5 mov %rsp,%rbp
11: 48 c7 c0 ff ff ff ff mov $0xffffffffffffffff,%rax
18: 5d pop %rbp
19: c3 retq
This shows that the previous code doesn't actually return -1 as the
function documentation says, but the new one does, so it's kind of a
bugfix.
bfd * elf64-ppc.c (ppc64_elf_archive_symbol_lookup): Avoid pointer
arithmetic on NULL pointer.
* elflink.c (_bfd_elf_archive_symbol_lookup,
elf_link_add_archive_symbols): Likewise.
ld * ldexp.c (fold_name, exp_fold_tree_1): Avoid pointer arithmetic
on NULL pointer.
One of conditions in skip_prologue() was never visited if there was mflr
instruction that moves the link register to a register different than r0.
This condition expects non shifted value of `lr_reg`. Previously offset
of link register was never saved for registers different than r0.
gdb/ChangeLog:
2018-01-31 Nikola Prica <nikola.prica@rt-rk.com>
* rs6000-tdep.c (skip_prologue): Remove shifting for lr_reg and
assign shifted lr_reg to fdata->lr_register when lr_reg is set.
gdb/testsuite/ChangeLog:
2018-01-31 Nikola Prica <nikola.prica@rt-rk.com>
* gdb.arch/powerpc-prologue-frame.s: New file.
* gdb.arch/powerpc-prologue-frame.c: Likewise.
* gdb.arch/powerpc-prologue-frame.exp: Likewise.
Correct LD test suite failures with VR4100, VR4300 and VR5000 bare metal
MIPS/ELF targets which do not default to linking with shared libraries,
which leads to link failures like:
.../ld/ld-new: cannot find -lcomm-data
FAIL: Common symbol override test
or:
.../ld/ld-new: attempted static link of dynamic object `tmpdir/pr14170.so'
FAIL: PR ld/14170
removing:
FAIL: Build pr22471b.so
FAIL: Build pr22471
FAIL: Build pr22649-2b.so
FAIL: Build pr22649-2d.so
FAIL: Build pr22150
FAIL: PR ld/14170
FAIL: --gc-sections with __gxx_personality
test failures.
ld/
* testsuite/ld-elf/comm-data.exp: Pass `-call_shared' to links
involving a shared library for `mips*vr4100*-*-elf*',
`mips*vr4300*-*-elf*' and `mips*vr5000*-*-elf*' targets.
* testsuite/ld-elf/provide-hidden.exp: Likewise.
* testsuite/ld-elf/shared.exp: Likewise.
* testsuite/ld-gc/gc.exp: Likewise.
* testsuite/ld-mips-elf/comm-data.exp: Likewise.
Move those ELF shared library tests that are in ld-elf/elf.exp over to
ld-elf/shared.exp, to keep them all together and make the maintenance of
extra flags needed with some targets and shared library builds easier,
and also removing the need for the large:
if { [check_shared_lib_support] } then {
[...]
}
conditional block and consequently reducing indentation, which always
helps with TCL code. No functional change, except for the order of
individual test case execution which has changed accordingly, i.e. the
test results are shuffled.
ld/
* testsuite/ld-elf/elf.exp: Move shared library tests over to...
* testsuite/ld-elf/shared.exp: ... here.
(Add missing ChangeLog entry)
The recent commit e671cd59 ("Per-inferior target_terminal state, fix
PR gdb/13211, more") missed adjusting a few targets to the new
target_ops->to_interrupt interface, breaking the build for those
targets. This fixes it.
Note: remote-sim doesn't really support async execution, so I don't
think gdbsim_interrupt is ever reached via target_interrupt. (It is
reached via gdbsim_cntrl_c though).
The inflow.c changes are a bit ugly, but they're just doing what other
parts of the file already do to handle the same missing functions.
Targets that don't have 'kill', like mingw have their own
target_ops->to_interrupt implementation, so it's fine to make
child_interrupt be a nop.
gdb/ChangeLog:
2018-01-31 Pedro Alves <palves@redhat.com>
* darwin-nat.c (darwin_interrupt): Remove ptid_t parameter.
* inflow.c (child_terminal_save_inferior): Wrap reference to
tcgetpgrp in HAVE_TERMIOS_H.
(child_interrupt, child_pass_ctrlc): Wrap references to signal in
_WIN32.
* remote-sim.c (gdbsim_interrupt): Remove ptid_t parameter and
always iterate over all inferiors.
(gdbsim_cntrl_c): Adjust.
* windows-nat.c (windows_interrupt): Remove 'ptid_t' parameter.
The recent commit e671cd59 ("Per-inferior target_terminal state, fix
PR gdb/13211, more") missed adjusting a few targets to the new
target_ops->to_interrupt interface, breaking the build for those
targets. This fixes it.
Note: remote-sim doesn't really support async execution, so I don't
think gdbsim_interrupt is ever reached via target_interrupt. (It is
reached via gdbsim_cntrl_c though).
The inflow.c changes are a bit ugly, but they're just doing what other
parts of the file already do to handle the same missing functions.
Targets that don't have 'kill', like mingw have their own
target_ops->to_interrupt implementation, so it's fine to make
child_interrupt be a nop.
gdb/ChangeLog:
2018-01-31 Pedro Alves <palves@redhat.com>
* darwin-nat.c (darwin_interrupt): Remove ptid_t parameter.
* inflow.c (child_terminal_save_inferior): Wrap reference to
tcgetpgrp in HAVE_TERMIOS_H.
(child_interrupt, child_pass_ctrlc): Wrap references to signal in
_WIN32.
* remote-sim.c (gdbsim_interrupt): Remove ptid_t parameter and
always iterate over all inferiors.
(gdbsim_cntrl_c): Adjust.
* windows-nat.c (windows_interrupt): Remove 'ptid_t' parameter.
We really need to check for a dynamic def, not only a ref.
See added testcase.
bfd/
* elflink.c (bfd_elf_define_start_stop): Fix check of
def_dynamic.
ld/
* testsuite/ld-elf/pr21964-5.c: New test.
* testsuite/ld-elf/shared.exp: Run it.
Define __start/__stop symbols if they are referenced by shared objects,
not if they are also defined in shared objects.
bfd/
PR ld/21964
* elflink.c (bfd_elf_define_start_stop): Check if __start and
__stop symbols are referenced by shared objects.
ld/
PR ld/21964
* testsuite/ld-elf/pr21964-4.c: New file.
* testsuite/ld-elf/shared.exp: Run pr21964-4 test on Linux.
Following my previous commit which add support for stopping at start of
exception handler, this commit adds required gdb-mi support for this
feature.
gdb/ChangeLog:
* mi/mi-cmd-catch.c (mi_cmd_catch_handlers): New function.
* mi/mi-cmds.c (mi_cmds): Add catch-handlers command.
* mi/mi-cmds.h (mi_cmd_catch_handlers): Add external declaration.
* NEWS: Document "-catch-handlers" command.
gdb/doc/ChangeLog:
* gdb.texinfo (Ada Exception gdb/mi Catchpoints): Add
documentation for new "-catch-handlers" command.
gdb/testsuite/ChangeLog:
* gdb.ada/mi_catch_ex_hand.exp: New testcase.
* gdb.ada/mi_catch_ex_hand/foo.adb: New file.
Tested on x86_64-linux.
This commit C++fy the conditional string used when catching Ada exception.
gdb/ChangeLog:
* ada-lang.c (catch_ada_exception_command_split)
(create_ada_exception_catchpoint) <cond_string>: Change parameter
type. Update code accordingly.
(catch_ada_exception_command, catch_ada_handlers_command): Use
C++ string instead of char* for conditional var.
(catch_ada_assert_command_split) <cond_string>: Change parameter
type. Update code accordingly.
(catch_assert_command): Use C++ string instead of char* for
conditional var.
* ada-lang.h (create_ada_exception_catchpoint) <cond_string>:
Update declaration.
* mi/mi-cmd-catch.c (mi_cmd_catch_assert, mi_cmd_catch_exception):
Use std::string instead of char* for condition string.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
* gdb.ada/mi_catch_assert.exp: New testcase.
* gdb.ada/mi_catch_assert/bla.adb: New file.
* gdb.ada/mi_catch_assert/pck.ads: New file.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
* gdb.ada/catch_assert_if.exp: New testcase.
* gdb.ada/catch_assert_if/bla.adb: New file.
* gdb.ada/catch_assert_if/pck.ads: New file.
Tested on x86_64-linux.
Using the following Ada declarations (the same as in
gdb.ada/dyn_stride.exp)...
subtype Small_Type is Integer range L .. U;
type Record_Type (I : Small_Type := L) is record
S : String (1 .. I);
end record;
type Array_Type is array (Integer range <>) of Record_Type;
A1 : Array_Type :=
(1 => (I => U, S => (others => ASCII.NUL)),
2 => (I => 1, S => "A"),
3 => (I => 2, S => "AB"));
... where "L" and "U" are variables, trying to apply the repeat
operator to "A1(1)" yields to an internal error:
| (gdb) print a1(1)@3
| $5 = /[...]/gdbtypes.c:4883: internal-error: type* copy_type(const type*):
| Assertion `TYPE_OBJFILE_OWNED (type)' failed.
What happens first is that the ada-lang module evaluated the "A1(1)"
sub-expression returning a structure where "I" (one of the fields
in that structure) has a type which is dynamic, because it is
a range type whose bounds are not statically known.
Next, we apply the repeat ('@') operator, which is done via
allocate_repeat_value, which creates an array type with the correct
bounds to associate to our value, by calling lookup_array_range_type:
| struct type *
| lookup_array_range_type (struct type *element_type,
| LONGEST low_bound, LONGEST high_bound)
| {
| struct gdbarch *gdbarch = get_type_arch (element_type);
| struct type *index_type = builtin_type (gdbarch)->builtin_int;
| struct type *range_type
| = create_static_range_type (NULL, index_type, low_bound, high_bound);
|
| return create_array_type (NULL, element_type, range_type);
| }
As we can see, this creates an array type whose index type is
always owned by the gdbarch. This is where the problem lies.
Next, we use that type to construct a struct value. That value
then gets passed to the valprint module, which then checks
whether our object is dynamic or not. And because field "I" above
had a dynamic range type, we end up determining by association
that the artificial repeat array itself is also dynamic. So
we attempt to resolve the type, which leads to trying to copying
that type. And because the artifical array created by
lookup_array_range_type has an index which is not objfile-owned,
we trip the assertion.
This patch fixes the issue by enhancing lookup_array_range_type
to create an index type which has the same owner as the element
type.
gdb/ChangeLog:
* gdbtypes.c (lookup_array_range_type): Make sure the array's
index type is objfile-owned if the element type is as well.
gdb/testsuite/ChangeLog:
* testsuite/gdb.ada/dyn_stride.exp: Add "print a1(1)@3" test.
The PR22714 testcase is such that the input buffer processed by
do_scrub_chars ends on this line
1: bug "Returning to usermode but unexpected PSR bits set?", \@
right at the backslash. (The line is part of a macro definition.)
The next input buffer then starts with '@' which starts a comment on
ARM, and the check for \@ fails due to to == tostart. Now it would be
possible to simply access to[-1] in this particular case, but that's
ugly, and to be absolutely safe from people deliberately trying to
crash gas we'd need the read.c:read_a_source_file buffer passed to
do_scrub_chars to have a single byte pad at the start.
PR 22714
* app.c (last_char): New static var.
(struct app_save): Add last_char field.
(app_push, app_pop): Handle it.
(do_scrub_chars): Use last_char in test for "\@". Set last_char.
PR 22734
* doc/binutils.texi (nm): Update description to point out that
zero-initialized values can also be shown as type B, b, S or s
since they can be stored in the BSS section.
With 7042632bf7 (s390: Hook s390 into OSABI mechanism) assigning a
default target description was moved from s390_gdbarch_init to
s390_linux_init_abi_*. This causes problems when GDB is built with
--enable-targets=all and the user sets an unsupported OSABI, e.g. "set
osabi AIX". In this case there is no valid tdesc, and GDB crashes with an
internal error. Fix this by reverting parts of 7042632bf7.
gdb/ChangeLog:
* s390-linux-tdep.c: Remove includes "features/s390-linux32.c" and
"features/s390x-linux64.c".
(_initialize_s390_linux_tdep): Remove initialization of tdescs
s390_linux32 and s390x_linux64.
(s390_linux_init_abi_31, s390_linux_init_abi_64): Don't set
default tdesc.
* s390-tdep.c: Include "features/s390-linux32.c" and
"features/s390x-linux64.c".
(s390_tdesc_valid): Add check for tdesc_has_registers.
(s390_gdbarch_init): Make sure there is always a valid tdesc.
(_initialize_s390_tdep): Initialize tdesc_s390_linux32 and
tdesc_s390x_linux64.
* s390-linux-tdep.h: Move export of tdesc_s390_linux32 and
tdesc_s390x_linux64 to...
* s390-tdep.h: ...here.
In my multi-target branch I ran into problems with GDB's terminal
handling that exist in master as well, with multi-inferior debugging.
This patch adds a testcase for said problems
(gdb.multi/multi-term-settings.exp), fixes the problems, fixes PR
gdb/13211 as well (and adds a testcase for that too,
gdb.base/interrupt-daemon.exp).
The basis of the problem I ran into is the following. Consider a
scenario where you have:
- inferior 1 - started with "attach", process is running on some
other terminal.
- inferior 2 - started with "run", process is sharing gdb's terminal.
In this scenario, when you stop/resume both inferiors, you want GDB to
save/restore the terminal settings of inferior 2, the one that is
sharing GDB's terminal. I.e., you want inferior 2 to "own" the
terminal (in target_terminal::is_ours/target_terminal::is_inferior
sense).
Unfortunately, that's not what you get currently. Because GDB doesn't
know whether an attached inferior is actually sharing GDB's terminal,
it tries to save/restore its settings anyway, ignoring errors. In
this case, this is pointless, because inferior 1 is running on a
different terminal, but GDB doesn't know better.
And then, because it is only possible to have the terminal settings of
a single inferior be in effect at a time, or make one inferior/pgrp be
the terminal's foreground pgrp (aka, only one inferior can "own" the
terminal, ignoring fork children here), if GDB happens to try to
restore the terminal settings of inferior 1 first, then GDB never
restores the terminal settings of inferior 2.
This patch fixes that and a few things more along the way:
- Moves enum target_terminal::terminal_state out of the
target_terminal class (it's currently private) and makes it a
scoped enum so that it can be easily used elsewhere.
- Replaces the inflow.c:terminal_is_ours boolean with a
target_terminal_state variable. This allows distinguishing is_ours
and is_ours_for_output states. This allows finally making
child_terminal_ours_1 do something with its "output_only"
parameter.
- Makes each inferior have its own copy of the
is_ours/is_ours_for_output/is_inferior state.
- Adds a way for GDB to tell whether the inferior is sharing GDB's
terminal. Works best on Linux and Solaris; the fallback works just
as well as currently.
- With that, we can remove the inf->attach_flag tests from
child_terminal_inferior/child_terminal_ours.
- Currently target_ops.to_ours is responsible for both saving the
current inferior's terminal state, and restoring gdb's state.
Because each inferior has its own terminal state (possibly handled
by different targets in a multi-target world, even), we need to
split the inferior-saving part from the gdb-restoring part. The
patch adds a new target_ops.to_save_inferior target method for
that.
- Adds a new target_terminal::save_inferior() function, so that
sequences like:
scoped_restore_terminal_state save_state;
target_terminal::ours_for_output ();
... restore back inferiors that were
target_terminal_state::is_inferior before back to is_inferior, and
leaves inferiors that were is_ours alone.
- Along the way, this adds a default implementation of
target_pass_ctrlc to inflow.c (for inf-child.c), that handles
passing the Ctrl-C to a process running on GDB's terminal or to
some other process otherwise.
- Similarly, adds a new target default implementation of
target_interrupt, for the "interrupt" command. The current
implementation of this hook in inf-ptrace.c kills the whole process
group, but that's incorrect/undesirable because we may not be
attached to all processes in the process group. And also, it's
incorrect because inferior_process_group() doesn't really return
the inferior's real process group id if the inferior is not a
process group leader... This is the cause of PR gdb/13211 [1],
which this patch fixes. While at it, that target method's "ptid"
parameter is eliminated, because it's not really used.
- A new test is included that exercises and fixes PR gdb/13211, and
also fixes a GDB issue reported on stackoverflow that I ran into
while working on this [2]. The problem is similar to PR gdb/13211,
except that it also triggers with Ctrl-C. When debugging a daemon
(i.e., a process that disconnects from the controlling terminal and
is not a process group leader, then Ctrl-C doesn't work, you just
can't interrupt the inferior at all, resulting in a hung debug
session. The problem is that since the inferior is no longer
associated with gdb's session / controlling terminal, then trying
to put the inferior in the foreground fails. And so Ctrl-C never
reaches the inferior directly. pass_signal is only used when the
inferior is attached, but that is not the case here. This is fixed
by the new child_pass_ctrlc. Without the fix, the new
interrupt-daemon.exp testcase fails with timeout waiting for a
SIGINT that never arrives.
[1] PR gdb/13211 - Async / Process group and interrupt not working
https://sourceware.org/bugzilla/show_bug.cgi?id=13211
[2] GDB not reacting Ctrl-C when after fork() and setsid()
https://stackoverflow.com/questions/46101292/gdb-not-reacting-ctrl-c-when-after-fork-and-setsid
Note this patch does _not_ fix:
- PR gdb/14559 - The 'interrupt' command does not work if sigwait is in use
https://sourceware.org/bugzilla/show_bug.cgi?id=14559
- PR gdb/9425 - When using "sigwait" GDB doesn't trap SIGINT. Ctrl+C terminates program when should break gdb.
https://sourceware.org/bugzilla/show_bug.cgi?id=9425
The only way to fix that that I know of (without changing the kernel)
is to make GDB put inferiors in a separate session (create a
pseudo-tty master/slave pair, make the inferior run with the slave as
its terminal, and have gdb pump output/input on the master end).
gdb/ChangeLog:
2018-01-30 Pedro Alves <palves@redhat.com>
PR gdb/13211
* config.in, configure: Regenerate.
* configure.ac: Check for getpgid.
* go32-nat.c (go32_pass_ctrlc): New.
(go32_target): Install it.
* inf-child.c (inf_child_target): Install
child_terminal_save_inferior, child_pass_ctrlc and
child_interrupt.
* inf-ptrace.c (inf_ptrace_interrupt): Delete.
(inf_ptrace_target): No longer install it.
* infcmd.c (interrupt_target_1): Adjust.
* inferior.h (child_terminal_save_inferior, child_pass_ctrlc)
(child_interrupt): Declare.
(inferior::terminal_state): New.
* inflow.c (struct terminal_info): Update comments.
(inferior_process_group): Delete.
(terminal_is_ours): Delete.
(gdb_tty_state): New.
(child_terminal_init): Adjust.
(is_gdb_terminal, sharing_input_terminal_1)
(sharing_input_terminal): New functions.
(child_terminal_inferior): Adjust. Use sharing_input_terminal.
Set the process's actual process group in the foreground if
possible. Handle is_ours_for_output/is_ours distinction. Don't
mark terminal as the inferior's if not sharing GDB's terminal.
Don't check attach_flag.
(child_terminal_ours_for_output, child_terminal_ours): Adjust to
pass down a target_terminal_state.
(child_terminal_save_inferior): New, factored out from ...
(child_terminal_ours_1): ... this. Handle
target_terminal_state::is_ours_for_output.
(child_interrupt, child_pass_ctrlc): New.
(inflow_inferior_exit): Clear the inferior's terminal_state.
(copy_terminal_info): Copy the inferior's terminal state.
(_initialize_inflow): Remove reference to terminal_is_ours.
* inflow.h (inferior_process_group): Delete.
* nto-procfs.c (nto_handle_sigint, procfs_interrupt): Adjust.
* procfs.c (procfs_target): Don't install procfs_interrupt.
(procfs_interrupt): Delete.
* remote.c (remote_serial_quit_handler): Adjust.
(remote_interrupt): Remove ptid parameter. Adjust.
* target-delegates.c: Regenerate.
* target.c: Include "terminal.h".
(target_terminal::terminal_state): Rename to ...
(target_terminal::m_terminal_state): ... this.
(target_terminal::init): Adjust.
(target_terminal::inferior): Adjust to per-inferior
terminal_state.
(target_terminal::restore_inferior, target_terminal_is_ours_kind): New.
(target_terminal::ours, target_terminal::ours_for_output): Use
target_terminal_is_ours_kind.
(target_interrupt): Remove ptid parameter. Adjust.
(default_target_pass_ctrlc): Adjust.
* target.h (target_ops::to_terminal_save_inferior): New field.
(target_ops::to_interrupt): Remove ptid_t parameter.
(target_interrupt): Remove ptid_t parameter. Update comment.
(target_pass_ctrlc): Update comment.
* target/target.h (target_terminal_state): New scoped enum,
factored out of ...
(target_terminal::terminal_state): ... here.
(target_terminal::inferior): Update comments.
(target_terminal::restore_inferior): New.
(target_terminal::is_inferior, target_terminal::is_ours)
(target_terminal::is_ours_for_output): Adjust.
(target_terminal::scoped_restore_terminal_state): Adjust to
rename, and call restore_inferior() instead of inferior().
(target_terminal::scoped_restore_terminal_state::m_state): Change
type.
(target_terminal::terminal_state): Rename to ...
(target_terminal::m_terminal_state): ... this and change type.
gdb/gdbserver/ChangeLog:
2018-01-30 Pedro Alves <palves@redhat.com>
PR gdb/13211
* target.c (target_terminal::terminal_state): Rename to ...
(target_terminal::m_terminal_state): ... this.
gdb/testsuite/ChangeLog:
2018-01-30 Pedro Alves <palves@redhat.com>
PR gdb/13211
* gdb.base/interrupt-daemon.c: New.
* gdb.base/interrupt-daemon.exp: New.
* gdb.multi/multi-term-settings.c: New.
* gdb.multi/multi-term-settings.exp: New.
This patch gets rid of linux-nat.c's custom
target_terminal_inferior/target_terminal_ours implementations.
The only remaining reason those overrides exist is to install
clear_sigint_trap in order to pass Ctrl-C/SIGINT to the inferior
process in case the inferior is not sharing GDB's terminal (and
target_wait was called without TARGET_WNOHANG).
However, I think that's better handled by QUIT / target_pass_ctrlc
nowadays. Going that route avoids the issue with set_sigint_trap only
looking at the current inferior to know whether to override SIGINT or
not, which doesn't really work correctly with multi-inferior in the
picture. Also centralizing on a single SIGINT handler as much as
possible seems better considering a future multi-target world.
Tested on x86-64 GNU/Linux.
gdb/ChangeLog:
2018-01-30 Pedro Alves <palves@redhat.com>
* linux-nat.c (wait_for_signal): New function.
(wait_lwp, linux_nat_wait_1): Use it instead of calling sigsuspend
directly.
(async_terminal_is_ours)
(linux_nat_terminal_inferior, linux_nat_terminal_ours): Delete.
(linux_nat_add_target): Don't override
to_terminal_inferior/to_terminal_ours.
We can't map different disk pages into the same memory page; The last
page mapped will simply overwrite any previous pages. The
executable/non-executable new_segment test ignored this fact, leading
to a ld.so segfault on hppa when .dynamic is overwritten with zeros.
This patch moves existing tests for demand paging with lma on the same
memory page, to a new test performed before any case where we want a
new segment due to protection or loadable conflicts.
PR 22758
* elf.c (_bfd_elf_map_sections_to_segments): Don't start a new
segment when demand paged with lma on the same page. Test this
before load/non-load, executable/non-executable,
writable/non-writable tests and simplify. Delete bogus relro
condition in writable/non-writable test. Delete outdated
comment. Formatting.
The last test of this testcase fails when run on Ubuntu 16.04 using
the system compiler (16.04):
FAIL: gdb.base/break.exp: verify that they were cleared
This is because the testcase expected that a breakpoint on line 47 of break.c...
printf ("%d\n", factorial (atoi ("6"))); /* set breakpoint 1 here */
... would actually be inserted on an instruction belonging to
that line. However, what actually happens is that system GCC on
that version of Ubuntu ends up inlining everything, including
the call to printf, thus reporting every instruction of generated
for this line of code as belonging to a different function. As
a result, GDB ends up insering the breakpoint on the next line
of code, which is line 49:
(gdb) break break.c:$l
Breakpoint 3 at 0x4005c1: file /[...]/gdb.base/break.c, line 49.
This causes a spurious failure in the "info break" test later on,
as it assumed that the breakpoint above is inserted on line 47:
gdb_test "info break" "$srcfile:$line" "verify that they were cleared"
This patch fixes the issue by saving the actual source location where
the breakpoint was inserted.
gdb/testsuite/ChangeLog:
* gdb.base/break.exp: Save the location where the breakpoint
on break.c:47 was actually inserted when debugging the version
compiled at -O2 and use it in the expected output of the "info
break" test performed soon after.
tested on x86_64-linux, with two configurations:
- Ubuntu 16.04 with the system compiler (breakpoint lands on line 49)
- Ubuntu 16.04 with GCC 7.3.1 (breakpoint lands on line 47)
Fix commit d664fd41e1 ("Ignore dynamic references on forced local
symbols") and use alternative test actions and match patterns to
correctly handle messages like:
.../ld/ld-new: Removing unused section '.reginfo' in file 'tmpdir/pr22649-2b.o'
or:
.../ld/ld-new: Removing unused section '.MIPS.options' in file 'tmpdir/pr22649-2b.o'
produced by LD on MIPS targets, removing:
FAIL: Build pr22649-2c.so
FAIL: Build pr22649-2d.so
test suite failures and tightening checks made with `pr22649-2a.so' and
`pr22649-2b.so' test cases.
Keep the original empty action with `pr22649-2c.so' and `pr22649-2d.so'
links and MIPS/ELF targets though, because for them the linker does not
garbage-collect the `.reginfo' section. This is because the section has
its flags set differently by code in GAS in `md_begin':
if (strncmp (TARGET_OS, "elf", 3) != 0)
flags |= SEC_ALLOC | SEC_LOAD;
and consequently BFD linker code in `_bfd_elf_gc_mark_extra_sections':
else if (((isec->flags & SEC_DEBUGGING) != 0
|| (isec->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0)
&& elf_next_in_group (isec) == NULL)
isec->gc_mark = 1;
marks these sections to be kept due to their SEC_ALLOC, SEC_LOAD and
SEC_RELOC flags all being zero (`.reginfo' sections never have
relocations attached).
ld/
PR ld/22649
* testsuite/ld-elf/pr22649-2ab-mips.msg: New stderr output.
* testsuite/ld-elf/pr22649-2cd-mips.msg: New stderr output.
* testsuite/ld-elf/shared.exp: Use the new outputs with
`mips*-*-*' targets.
Update `readelf' symbol table dump match patterns to handle SHN_MIPS_DATA
and SHN_MIPS_TEXT special section indexes produced by the IRIX ELF format
variation used with a number of MIPS targets and printed by `readelf' as
PRC[0xff02] and PRC[0xff01] respectively, correcting LD test suite
failures:
extra regexps in .../ld/testsuite/ld-elf/comm-data1.sd starting with "^ +[0-9]+: +[0-9a-f]+ +0 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo$"
EOF from dump.out
FAIL: Common symbol override test (auxiliary shared object build)
extra regexps in .../ld/testsuite/ld-elf/pr21703-shared.sd starting with "^ +[0-9]+: +[0-9a-f]+ +4 +FUNC +GLOBAL +DEFAULT +[0-9] +foo@FOO$"
EOF from dump.out
FAIL: PR ld/21703 shared
extra regexps in .../ld/testsuite/ld-elf/comm-data1.sd starting with "^ +[0-9]+: +[0-9a-f]+ +0 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo$"
EOF from dump.out
FAIL: MIPS o32/copyreloc common symbol override test (auxiliary shared object build)
extra regexps in .../ld/testsuite/ld-elf/comm-data1.sd starting with "^ +[0-9]+: +[0-9a-f]+ +0 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo$"
EOF from dump.out
FAIL: MIPS o32/nocopyreloc common symbol override test (auxiliary shared object build)
observed due to file contents like:
7: 5ffe02e8 0 OBJECT GLOBAL DEFAULT PRC[0xff02] foo
shown by `readelf -s' vs:
+[0-9]+: +[0-9a-f]+ +0 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo
pattern expected, triggered by widening testing to these targets by commit
05a5feafdd ("Rewrite check_shared_lib_support").
ld/
* testsuite/ld-elf/comm-data1.sd: Alternatively accept
`PRC[0xff02]' in place of a regular section index.
* testsuite/ld-elf/pr21703-shared.sd: Likewise `PRC[0xff01]'.
bfd/
* elflink.c (bfd_elf_define_start_stop): Make __start and __stop
symbols dynamic.
ld/
* testsuite/ld-elf/pr21964-3a.c: New file.
* testsuite/ld-elf/pr21964-3c.c: New file.
* testsuite/ld-elf/shared.exp: Run new __start/__stop testcase.
On the SPARC architecture, you need to pass a special flag to GNU as
when you're assembling PIC/PIE code or else you get a wrong relocation
for the GOT symbol.
ld/
* testsuite/ld-elf/shared.exp (AFLAGS_PIC): Define on SPARC.
(pr22269-1): Pass AFLAGS_PIC to the assembler.
The .dc.a directive has wrong size (32 bits) on SPARC 64-bit because
the assembler sets the correct BFD architecture only at the very end
of the processing and it's too late for the directive. It's fixed by
defining TARGET_MACH and making it return a sensible default value.
gas/
* config/tc-sparc.h (sparc_mach): Declare.
(TARGET_MACH): Define to above.
* config/tc-sparc.c (sparc_mach): New function.
(sparc_md_end): Minor tweak.
ld/
* testsuite/ld-elf/pr22450.d: Remove reference to SPARC64.
Update the ld-mips-elf/comm-data.exp test script to correctly select
emulations for targets using non-traditional MIPS emulation and also
correctly select ABIs for targets that do not support all of them, and
finally use the default endianness selection to benefit targets which
support only one, complementing commit 05a5feafdd ("Rewrite
check_shared_lib_support") and removing numerous test failures such as:
FAIL: MIPS o32/copyreloc common symbol override test (auxiliary shared object build)
FAIL: MIPS o32/copyreloc common symbol override test
FAIL: MIPS o32/nocopyreloc common symbol override test (auxiliary shared objectbuild)
FAIL: MIPS o32/nocopyreloc common symbol override test
FAIL: MIPS n32/copyreloc common symbol override test (auxiliary shared object build)
FAIL: MIPS n32/copyreloc common symbol override test
FAIL: MIPS n32/nocopyreloc common symbol override test (auxiliary shared objectbuild)
FAIL: MIPS n32/nocopyreloc common symbol override test
due to:
.../ld/ld-new: unrecognised emulation mode: elf32btsmip
Supported emulations: elf64btsmip elf64ltsmip
or:
.../ld/ld-new: unrecognised emulation mode: elf32btsmip
Supported emulations: elf32ebmip
or:
.../ld/ld-new: unrecognised emulation mode: elf32btsmip
Supported emulations: elf32l4300
etc., and:
ERROR: -n32 -march=mips3 -EB -call_shared .../ld/testsuite/ld-mips-elf/../ld-elf/comm-data1.s: assembly failed
UNRESOLVED: MIPS n32/copyreloc common symbol override test (auxiliary shared object build)
ERROR: -n32 -march=mips3 -EB -call_nonpic .../ld/testsuite/ld-mips-elf/../ld-elf/comm-data2.s: assembly failed
UNRESOLVED: MIPS n32/copyreloc common symbol override test
ERROR: -n32 -march=mips3 -EB -call_shared .../ld/testsuite/ld-mips-elf/../ld-elf/comm-data1.s: assembly failed
UNRESOLVED: MIPS n32/nocopyreloc common symbol override test (auxiliary shared object build)
ERROR: -n32 -march=mips3 -EB -call_nonpic .../ld/testsuite/ld-mips-elf/../ld-elf/comm-data2.s: assembly failed
UNRESOLVED: MIPS n32/nocopyreloc common symbol override test
due to:
Assembler messages:
Fatal error: selected target format 'elf32-nbigmips' unknown
and:
ERROR: -64 -march=mips3 -EB -call_shared .../ld/testsuite/ld-mips-elf/../ld-elf/comm-data1.s: assembly failed
UNRESOLVED: MIPS n64/copyreloc common symbol override test (auxiliary shared object build)
ERROR: -64 -march=mips3 -EB --defsym ELF64=1 -call_nonpic .../ld/testsuite/ld-mips-elf/../ld-elf/comm-data2.s:assembly failed
UNRESOLVED: MIPS n64/copyreloc common symbol override test
ERROR: -64 -march=mips3 -EB -call_shared .../ld/testsuite/ld-mips-elf/../ld-elf/comm-data1.s: assembly failed
UNRESOLVED: MIPS n64/nocopyreloc common symbol override test (auxiliary shared object build)
ERROR: -64 -march=mips3 -EB --defsym ELF64=1 -call_nonpic .../ld/testsuite/ld-mips-elf/../ld-elf/comm-data2.s:assembly failed
UNRESOLVED: MIPS n64/nocopyreloc common symbol override test
due to:
Assembler messages:
Fatal error: no compiled in support for 64 bit object file format
ld/
* testsuite/ld-mips-elf/comm-data.exp: Correct support for
targets using non-traditional MIPS emulation or having a limited
selection of ABIs available. Don't force big endianness, use
defaults.
This patch fixes a regression that has been introduced by:
commit bc09b0c14f
Date: Fri Jan 19 11:48:11 2018 -0500
Make linux_nat_detach/thread_db_detach use the inferior parameter
It is possible to trigger this failure with gdb.base/foll-fork.exp (in
which case a bunch of ERROR's will be printed), but one can also use
the test below.
Consider the following example program:
#include <unistd.h>
int
main (int argc, char *argv[])
{
fork ();
return 0;
}
When running it under gdbserver:
# ./gdb/gdbserver/gdbserver --multi --once :2345
And debugging it under GDB, we see a segmentation fault:
# ./gdb/gdb -q -batch -ex 'set remote exec-file ./a.out' -ex 'tar extended-remote :2345' -ex r ./a.out
Starting program:
...
[Detaching after fork from child process 16102.]
Segmentation fault (core dumped)
The problem happens on inferior.c:detach_inferior:
void
detach_inferior (inferior *inf)
{
/* Save the pid, since exit_inferior_1 will reset it. */
int pid = inf->pid;
^^^^^^^^^
exit_inferior_1 (inf, 0);
if (print_inferior_events)
printf_unfiltered (_("[Inferior %d detached]\n"), pid);
}
When this code is called from remote.c:remote_follow_fork, the PID is
valid but there is no 'inferior' associated with it, which means that
'inf == NULL'.
The proper fix here is to not call "detach_inferior" when doing remote
follow-fork, because we don't have an inferior to detach on the host
side.
Before bc09b0c1, that call was already a nop (exit_inferior_1 bails
out early if you pass it a NULL inferior), except that it printed
"Inferior PID detached" when "set print inferior-events" is on. Since
native debugging doesn't call detach_inferior in this case, removing
the call from remote aligns remote debugging output with native
debugging output further.
This has been regtested using BuildBot and no regressions were found.
gdb/ChangeLog:
2018-01-29 Sergio Durigan Junior <sergiodj@redhat.com>
* remote.c (remote_follow_fork): Don't call "detach_inferior".
Skip static executable tests if static executable is unsupported.
Tested on Linux/x86 without libc.a.
PR ld/22732
* testsuite/config/default.exp (STATIC_LDFLAGS): New. Set to
"-static" if target compiler supports it.
* testsuite/ld-bootstrap/bootstrap.exp: Skip static executable
tests if target compiler doesn't support it.
* testsuite/ld-ifunc/ifunc.exp: Likewise.
* testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Likewise.
(run_cc_link_tests): Likewise.
I got some crashes while doing some work with dwarf2_per_objfile. It
turns out that dwarf2_per_objfile_free is using the dwarf2_per_objfile
objects after their destructor has ran.
The easiest way to reproduce this is to run the inferior twice (do
"start" twice). Currently, it goes unnoticed, but when I tried to
change all_comp_units and all_type_units to std::vectors, things started
crashing.
The dwarf2_per_objfile objects get destroyed here:
#0 dwarf2_per_objfile::~dwarf2_per_objfile (this=0x35afe70, __in_chrg=<optimized out>) at /home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:2422
#1 0x0000000000833282 in dwarf2_free_objfile (objfile=0x356cff0) at /home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:25363
#2 0x0000000000699255 in elf_symfile_finish (objfile=0x356cff0) at /home/emaisin/src/binutils-gdb/gdb/elfread.c:1309
#3 0x0000000000911ed3 in objfile::~objfile (this=0x356cff0, __in_chrg=<optimized out>) at /home/emaisin/src/binutils-gdb/gdb/objfiles.c:674
and just after that the dwarf2read per-objfile registry cleanup function
gets called:
#0 dwarf2_per_objfile_free (objfile=0x356cff0, d=0x35afe70) at /home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:25667
... registry boilerplate ...
#4 0x00000000009103ea in objfile_free_data (container=0x356cff0) at /home/emaisin/src/binutils-gdb/gdb/objfiles.c:61
#5 0x0000000000911ee2 in objfile::~objfile (this=0x356cff0, __in_chrg=<optimized out>) at /home/emaisin/src/binutils-gdb/gdb/objfiles.c:678
In dwarf2_per_objfile_free, we access fields of the dwarf2_per_objfile
object, which is invalid since its destructor has been executed.
This patch moves the content of dwarf2_per_objfile_free to the
destructor of dwarf2_per_objfile. The call to
register_objfile_data_with_cleanup in _initialize_dwarf2_read can be
changed to the simpler register_objfile_data.
gdb/ChangeLog:
* dwarf2read.c (free_dwo_files): Add forward-declaration.
(dwarf2_per_objfile::~dwarf2_per_objfile): Move content from
dwarf2_per_objfile_free here.
(dwarf2_per_objfile_free): Remove.
(_initialize_dwarf2_read): Don't register
dwarf2_per_objfile_free as a registry cleanup.
Since dummy.o must be placed before
-Wl,--whole-archive tmpdir/pr22751.a -Wl,--no-whole-archive
to trigger the bug, this patch adds an optional trailing ld options to
run_ld_link_exec_tests.
PR ld/22751
* testsuite/config/default.exp (INT128_CFLAGS): New.
* testsuite/ld-plugin/lto.exp (INT128_CFLAGS): New.
Run ld/22751 tests.
* testsuite/ld-plugin/pr22751.c: New file.
* testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Add
ld trailing options.