binutils-gdb.git
5 years agoMake gdb.base/corefile.exp work on terminals with few rows
Simon Marchi [Thu, 7 Feb 2019 14:22:29 +0000 (09:22 -0500)]
Make gdb.base/corefile.exp work on terminals with few rows

When creating a pty to spawn a subprocess (such as gdb), Expect
copies the settings of its own controlling terminal, including the
number of rows and columns.  If you "make check" on a terminal with just
a few rows (e.g. 4), GDB will paginate before reaching the initial
prompt.  In default_gdb_start, used by most tests, this is already
handled: if we see the pagination prompt, we sent \n to continue.

Philippe reported that gdb.base/corefile.exp didn't work in terminals
with just a few rows.  This test spawns GDB by hand, because it needs to
check things before the initial prompt, which it couldn't do if it used
default_gdb_start.

In this case I think it's not safe to use the same technique as in
default_gdb_start.  Even if we could send a \n if we see a pagination
prompt, we match some multiline regexes in there.  So if a pagination
slips in there, it might make the regexes not match and fail the test.

It's also not possible to use -ex "set height 0" or -iex "set height 0",
it is handled after the introduction text is shown.

The simplest way I found to avoid showing the pagination completely is
to set stty_init (documented in expect's man page) to initialize gdb's
pty with a fixed number of rows.

And actually, if we set stty_init in gdb_init, it works nicely as a
general solution applicable to all tests.  We can therefore remove the
solution introduced in e882ef3cfc3 ("testsuite: expect possible
pagination when starting gdb") where we matched the pagination prompt
during startup.

gdb/testsuite/ChangeLog:

* lib/gdb.exp (default_gdb_start): Don't match pagination
prompt.
(gdb_init): Set stty_init.

5 years agoC++-ify struct thread_fsm
Tom Tromey [Wed, 2 Jan 2019 21:35:57 +0000 (14:35 -0700)]
C++-ify struct thread_fsm

This C++-ifies struct thread_fsm, replacing the "ops" structure with
virtual methods, and changing all the implementations to derive from
thread_fsm.

gdb/ChangeLog
2019-02-07  Tom Tromey  <tom@tromey.com>

* thread.c (thread_cancel_execution_command): Update.
* thread-fsm.h (struct thread_fsm): Add constructor, destructor,
methods.
(struct thread_fsm_ops): Remove.
(thread_fsm_ctor, thread_fsm_delete, thread_fsm_clean_up)
(thread_fsm_should_stop, thread_fsm_return_value)
(thread_fsm_set_finished, thread_fsm_finished_p)
(thread_fsm_async_reply_reason, thread_fsm_should_notify_stop):
Don't declare.
* mi/mi-interp.c (mi_on_normal_stop_1): Update.
* infrun.c (clear_proceed_status_thread)
(clean_up_just_stopped_threads_fsms, fetch_inferior_event)
(print_stop_event): Update.
* infcmd.c (struct step_command_fsm): Inherit from thread_fsm.
Add constructor.
(step_command_fsm_ops): Remove.
(new_step_command_fsm): Remove.
(step_1): Update.
(step_command_fsm::should_stop): Rename from
step_command_fsm_should_stop.
(step_command_fsm::clean_up): Rename from
step_command_fsm_clean_up.
(step_command_fsm::do_async_reply_reason): Rename from
step_command_fsm_async_reply_reason.
(struct until_next_fsm): Inherit from thread_fsm.  Add
constructor.
(until_next_fsm_ops): Remove.
(new_until_next_fsm): Remove.
(until_next_fsm::should_stop): Rename from
until_next_fsm_should_stop.
(until_next_fsm::clean_up): Rename from until_next_fsm_clean_up.
(until_next_fsm::do_async_reply_reason): Rename from
until_next_fsm_async_reply_reason.
(struct finish_command_fsm): Inherit from thread_fsm.  Add
constructor.  Change type of breakpoint.
(finish_command_fsm_ops): Remove.
(new_finish_command_fsm): Remove.
(finish_command_fsm::should_stop): Rename from
finish_command_fsm_should_stop.
(finish_command_fsm::clean_up): Rename from
finish_command_fsm_clean_up.
(finish_command_fsm::return_value): Rename from
finish_command_fsm_return_value.
(finish_command_fsm::do_async_reply_reason): Rename from
finish_command_fsm_async_reply_reason.
(finish_command): Update.
* infcall.c (struct call_thread_fsm): Inherit from thread_fsm.
Add constructor.
(call_thread_fsm_ops): Remove.
(call_thread_fsm::call_thread_fsm): Rename from
new_call_thread_fsm.
(call_thread_fsm::should_stop): Rename from
call_thread_fsm_should_stop.
(call_thread_fsm::should_notify_stop): Rename from
call_thread_fsm_should_notify_stop.
(run_inferior_call, call_function_by_hand_dummy): Update.
* cli/cli-interp.c (should_print_stop_to_console): Update.
* breakpoint.c (struct until_break_fsm): Inherit from thread_fsm.
Add constructor.  Change type of location_breakpoint,
caller_breakpoint.
(until_break_fsm_ops): Remove.
(new_until_break_fsm): Remove.
(until_break_fsm::should_stop): Rename from
until_break_fsm_should_stop.
(until_break_fsm::clean_up): Rename from
until_break_fsm_clean_up.
(until_break_fsm::do_async_reply_reason): Rename from
until_break_fsm_async_reply_reason.
(until_break_command): Update.
* thread-fsm.c: Remove.
* Makefile.in (COMMON_SFILES): Remove thread-fsm.c.

5 years agoNormalize include guards in gdb
Tom Tromey [Sun, 27 Jan 2019 19:51:36 +0000 (12:51 -0700)]
Normalize include guards in gdb

While working on my other scripts to deal with gdb headers, I noticed
that some files were missing include guards.  I wrote a script to add
the missing ones, but found that using the obvious names for the
guards ran into clashes -- for example, gdb/nat/linux-nat.h used
"LINUX_NAT_H", but this was also the script's choice for
gdb/linux-nat.h.

So, I changed the script to normalize all include guards in gdb.  This
patch is the result.

As usual the script is available here:

    https://github.com/tromey/gdb-refactoring-scripts

Tested by rebuilding; I also ran it through "Fedora-x86_64-m64" on the
buildbot.

gdb/ChangeLog
2019-02-07  Tom Tromey  <tom@tromey.com>

* yy-remap.h: Add include guard.
* xtensa-tdep.h: Add include guard.
* xcoffread.h: Rename include guard.
* varobj-iter.h: Add include guard.
* tui/tui.h: Rename include guard.
* tui/tui-winsource.h: Rename include guard.
* tui/tui-wingeneral.h: Rename include guard.
* tui/tui-windata.h: Rename include guard.
* tui/tui-win.h: Rename include guard.
* tui/tui-stack.h: Rename include guard.
* tui/tui-source.h: Rename include guard.
* tui/tui-regs.h: Rename include guard.
* tui/tui-out.h: Rename include guard.
* tui/tui-layout.h: Rename include guard.
* tui/tui-io.h: Rename include guard.
* tui/tui-hooks.h: Rename include guard.
* tui/tui-file.h: Rename include guard.
* tui/tui-disasm.h: Rename include guard.
* tui/tui-data.h: Rename include guard.
* tui/tui-command.h: Rename include guard.
* tic6x-tdep.h: Add include guard.
* target/waitstatus.h: Rename include guard.
* target/wait.h: Rename include guard.
* target/target.h: Rename include guard.
* target/resume.h: Rename include guard.
* target-float.h: Rename include guard.
* stabsread.h: Add include guard.
* rs6000-tdep.h: Add include guard.
* riscv-fbsd-tdep.h: Add include guard.
* regformats/regdef.h: Rename include guard.
* record.h: Rename include guard.
* python/python.h: Rename include guard.
* python/python-internal.h: Rename include guard.
* python/py-stopevent.h: Rename include guard.
* python/py-ref.h: Rename include guard.
* python/py-record.h: Rename include guard.
* python/py-record-full.h: Rename include guard.
* python/py-record-btrace.h: Rename include guard.
* python/py-instruction.h: Rename include guard.
* python/py-events.h: Rename include guard.
* python/py-event.h: Rename include guard.
* procfs.h: Add include guard.
* proc-utils.h: Add include guard.
* p-lang.h: Add include guard.
* or1k-tdep.h: Rename include guard.
* observable.h: Rename include guard.
* nto-tdep.h: Rename include guard.
* nat/x86-linux.h: Rename include guard.
* nat/x86-linux-dregs.h: Rename include guard.
* nat/x86-gcc-cpuid.h: Add include guard.
* nat/x86-dregs.h: Rename include guard.
* nat/x86-cpuid.h: Rename include guard.
* nat/ppc-linux.h: Rename include guard.
* nat/mips-linux-watch.h: Rename include guard.
* nat/linux-waitpid.h: Rename include guard.
* nat/linux-ptrace.h: Rename include guard.
* nat/linux-procfs.h: Rename include guard.
* nat/linux-osdata.h: Rename include guard.
* nat/linux-nat.h: Rename include guard.
* nat/linux-namespaces.h: Rename include guard.
* nat/linux-btrace.h: Rename include guard.
* nat/glibc_thread_db.h: Rename include guard.
* nat/gdb_thread_db.h: Rename include guard.
* nat/gdb_ptrace.h: Rename include guard.
* nat/fork-inferior.h: Rename include guard.
* nat/amd64-linux-siginfo.h: Rename include guard.
* nat/aarch64-sve-linux-sigcontext.h: Rename include guard.
* nat/aarch64-sve-linux-ptrace.h: Rename include guard.
* nat/aarch64-linux.h: Rename include guard.
* nat/aarch64-linux-hw-point.h: Rename include guard.
* mn10300-tdep.h: Add include guard.
* mips-linux-tdep.h: Add include guard.
* mi/mi-parse.h: Rename include guard.
* mi/mi-out.h: Rename include guard.
* mi/mi-main.h: Rename include guard.
* mi/mi-interp.h: Rename include guard.
* mi/mi-getopt.h: Rename include guard.
* mi/mi-console.h: Rename include guard.
* mi/mi-common.h: Rename include guard.
* mi/mi-cmds.h: Rename include guard.
* mi/mi-cmd-break.h: Rename include guard.
* m2-lang.h: Add include guard.
* location.h: Rename include guard.
* linux-record.h: Rename include guard.
* linux-nat.h: Add include guard.
* linux-fork.h: Add include guard.
* i386-darwin-tdep.h: Rename include guard.
* hppa-linux-offsets.h: Add include guard.
* guile/guile.h: Rename include guard.
* guile/guile-internal.h: Rename include guard.
* gnu-nat.h: Rename include guard.
* gdb-stabs.h: Rename include guard.
* frv-tdep.h: Add include guard.
* f-lang.h: Add include guard.
* event-loop.h: Add include guard.
* darwin-nat.h: Rename include guard.
* cp-abi.h: Rename include guard.
* config/sparc/nm-sol2.h: Rename include guard.
* config/nm-nto.h: Rename include guard.
* config/nm-linux.h: Add include guard.
* config/i386/nm-i386gnu.h: Rename include guard.
* config/djgpp/nl_types.h: Rename include guard.
* config/djgpp/langinfo.h: Rename include guard.
* compile/gcc-cp-plugin.h: Add include guard.
* compile/gcc-c-plugin.h: Add include guard.
* compile/compile.h: Rename include guard.
* compile/compile-object-run.h: Rename include guard.
* compile/compile-object-load.h: Rename include guard.
* compile/compile-internal.h: Rename include guard.
* compile/compile-cplus.h: Rename include guard.
* compile/compile-c.h: Rename include guard.
* common/xml-utils.h: Rename include guard.
* common/x86-xstate.h: Rename include guard.
* common/version.h: Rename include guard.
* common/vec.h: Rename include guard.
* common/tdesc.h: Rename include guard.
* common/selftest.h: Rename include guard.
* common/scoped_restore.h: Rename include guard.
* common/scoped_mmap.h: Rename include guard.
* common/scoped_fd.h: Rename include guard.
* common/safe-iterator.h: Rename include guard.
* common/run-time-clock.h: Rename include guard.
* common/refcounted-object.h: Rename include guard.
* common/queue.h: Rename include guard.
* common/ptid.h: Rename include guard.
* common/print-utils.h: Rename include guard.
* common/preprocessor.h: Rename include guard.
* common/pathstuff.h: Rename include guard.
* common/observable.h: Rename include guard.
* common/netstuff.h: Rename include guard.
* common/job-control.h: Rename include guard.
* common/host-defs.h: Rename include guard.
* common/gdb_wait.h: Rename include guard.
* common/gdb_vecs.h: Rename include guard.
* common/gdb_unlinker.h: Rename include guard.
* common/gdb_unique_ptr.h: Rename include guard.
* common/gdb_tilde_expand.h: Rename include guard.
* common/gdb_sys_time.h: Rename include guard.
* common/gdb_string_view.h: Rename include guard.
* common/gdb_splay_tree.h: Rename include guard.
* common/gdb_setjmp.h: Rename include guard.
* common/gdb_ref_ptr.h: Rename include guard.
* common/gdb_optional.h: Rename include guard.
* common/gdb_locale.h: Rename include guard.
* common/gdb_assert.h: Rename include guard.
* common/filtered-iterator.h: Rename include guard.
* common/filestuff.h: Rename include guard.
* common/fileio.h: Rename include guard.
* common/environ.h: Rename include guard.
* common/common-utils.h: Rename include guard.
* common/common-types.h: Rename include guard.
* common/common-regcache.h: Rename include guard.
* common/common-inferior.h: Rename include guard.
* common/common-gdbthread.h: Rename include guard.
* common/common-exceptions.h: Rename include guard.
* common/common-defs.h: Rename include guard.
* common/common-debug.h: Rename include guard.
* common/cleanups.h: Rename include guard.
* common/buffer.h: Rename include guard.
* common/btrace-common.h: Rename include guard.
* common/break-common.h: Rename include guard.
* cli/cli-utils.h: Rename include guard.
* cli/cli-style.h: Rename include guard.
* cli/cli-setshow.h: Rename include guard.
* cli/cli-script.h: Rename include guard.
* cli/cli-interp.h: Rename include guard.
* cli/cli-decode.h: Rename include guard.
* cli/cli-cmds.h: Rename include guard.
* charset-list.h: Add include guard.
* buildsym-legacy.h: Rename include guard.
* bfin-tdep.h: Add include guard.
* ax.h: Rename include guard.
* arm-linux-tdep.h: Add include guard.
* arm-fbsd-tdep.h: Add include guard.
* arch/xtensa.h: Rename include guard.
* arch/tic6x.h: Add include guard.
* arch/i386.h: Add include guard.
* arch/arm.h: Rename include guard.
* arch/arm-linux.h: Rename include guard.
* arch/arm-get-next-pcs.h: Rename include guard.
* arch/amd64.h: Add include guard.
* arch/aarch64-insn.h: Rename include guard.
* arch-utils.h: Rename include guard.
* annotate.h: Add include guard.
* amd64-darwin-tdep.h: Rename include guard.
* aarch64-linux-tdep.h: Add include guard.
* aarch64-fbsd-tdep.h: Add include guard.
* aarch32-linux-nat.h: Add include guard.

gdb/gdbserver/ChangeLog
2019-02-07  Tom Tromey  <tom@tromey.com>

* x86-tdesc.h: Rename include guard.
* x86-low.h: Add include guard.
* wincecompat.h: Rename include guard.
* win32-low.h: Add include guard.
* utils.h: Rename include guard.
* tracepoint.h: Rename include guard.
* tdesc.h: Rename include guard.
* target.h: Rename include guard.
* server.h: Rename include guard.
* remote-utils.h: Rename include guard.
* regcache.h: Rename include guard.
* nto-low.h: Rename include guard.
* notif.h: Add include guard.
* mem-break.h: Rename include guard.
* lynx-low.h: Add include guard.
* linux-x86-tdesc.h: Add include guard.
* linux-s390-tdesc.h: Add include guard.
* linux-ppc-tdesc-init.h: Add include guard.
* linux-low.h: Add include guard.
* linux-aarch64-tdesc.h: Add include guard.
* linux-aarch32-low.h: Add include guard.
* inferiors.h: Rename include guard.
* i387-fp.h: Rename include guard.
* hostio.h: Rename include guard.
* gdbthread.h: Rename include guard.
* gdb_proc_service.h: Rename include guard.
* event-loop.h: Rename include guard.
* dll.h: Rename include guard.
* debug.h: Rename include guard.
* ax.h: Rename include guard.

5 years agoAutomatic date update in version.in
GDB Administrator [Thu, 7 Feb 2019 00:00:52 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoFactorize macro definition code in macrotab.c
Philippe Waroquiers [Sat, 26 Jan 2019 11:32:45 +0000 (12:32 +0100)]
Factorize macro definition code in macrotab.c

When first fixing splay tree key leaks in macrotab.c, some duplicated code
logic was factorized.
The key leaks will be fixed in libiberty, but the code factorization
is better kept in any case.

gdb/ChangeLog
2019-02-06  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* macrotab.c (macro_define_internal): New function that
factorizes macro_define_object_internal and macro_define_function
code.
(macro_define_object_internal): Use macro_define_internal.
(macro_define_function): Likewise.

5 years agoFix leak of identifier in macro definition.
Philippe Waroquiers [Sat, 26 Jan 2019 11:29:00 +0000 (12:29 +0100)]
Fix leak of identifier in macro definition.

Valgrind detects leaks like the following (gdb.base/macscp.exp).
This patch fixes 1 of the 3 leaks (the last one in the list below).

The remaining leaks are better fixed in splay_tree_remove  and
splay_tree_insert in libiberty.
Tested on debian/amd64, natively and under valgrind.

==22285== 64 (48 direct, 16 indirect) bytes in 1 blocks are definitely lost in loss record 737 of 3,377
==22285==    at 0x4C2BE6D: malloc (vg_replace_malloc.c:309)
==22285==    by 0x4049E7: xmalloc (common-utils.c:44)
==22285==    by 0x533A20: new_macro_key(macro_table*, char const*, macro_source_file*, int) (macrotab.c:355)
==22285==    by 0x53438B: macro_define_function(macro_source_file*, int, char const*, int, char const**, char const*) (macrotab.c:822)
==22285==    by 0x52F945: macro_define_command(char const*, int) (macrocmd.c:409)
...
==22285== 128 (96 direct, 32 indirect) bytes in 2 blocks are definitely lost in loss record 1,083 of 3,377
==22285==    at 0x4C2BE6D: malloc (vg_replace_malloc.c:309)
==22285==    by 0x4049E7: xmalloc (common-utils.c:44)
==22285==    by 0x533A20: new_macro_key(macro_table*, char const*, macro_source_file*, int) (macrotab.c:355)
==22285==    by 0x534277: macro_define_object_internal(macro_source_file*, int, char const*, char const*, macro_special_kind) (macrotab.c:776)
==22285==    by 0x52F7E0: macro_define_command(char const*, int) (macrocmd.c:414)
...
==22285== 177 bytes in 19 blocks are definitely lost in loss record 1,193 of 3,377
==22285==    at 0x4C2BE6D: malloc (vg_replace_malloc.c:309)
==22285==    by 0x4049E7: xmalloc (common-utils.c:44)
==22285==    by 0x52F5BD: extract_identifier(char const**, int) (macrocmd.c:316)
==22285==    by 0x52F77D: macro_define_command(char const*, int) (macrocmd.c:355)
gdb/ChangeLog
2019-02-06  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* macrocmd.c (extract_identifier): Return
a gdb::unique_xmalloc_ptr<char> instead of a char *, and update
callers.

5 years agoFix 'info proc cmdline' for native FreeBSD processes.
John Baldwin [Wed, 6 Feb 2019 17:45:50 +0000 (09:45 -0800)]
Fix 'info proc cmdline' for native FreeBSD processes.

The kern.proc.args.<pid> sysctl returns the argv array as a packed
array of arguments, each null terminated.  To construct a complete
command line, the arguments must be joined with spaces by converting
the intermediate nul characters to spaces.  Previously only the first
argument was shown in cmdline output.  Now, all arguments are shown.

gdb/ChangeLog:

* fbsd-nat.c (fbsd_fetch_cmdline): Join arguments with spaces.

5 years agoFix some ldscripts/pr24008 fails
Alan Modra [Wed, 6 Feb 2019 06:56:23 +0000 (17:26 +1030)]
Fix some ldscripts/pr24008 fails

These targets were all failing due to extra symbols.
pdp11-dec-aout  +FAIL: ld-scripts/pr24008
powerpc-aix5.1  +FAIL: ld-scripts/pr24008
powerpc-aix5.2  +FAIL: ld-scripts/pr24008
rs6000-aix4.3.3  +FAIL: ld-scripts/pr24008
rs6000-aix5.1  +FAIL: ld-scripts/pr24008
rs6000-aix5.2  +FAIL: ld-scripts/pr24008

Some fails remain, those I saw were segfaults or assertion fails that
indicate target bugs.

PR ld/24008
* testsuite/ld-scripts/pr24008.d: Pass with extra target
defined symbols.

5 years agox86-64: Restore PIC check for PCREL reloc against protected symbol
H.J. Lu [Wed, 6 Feb 2019 02:45:23 +0000 (18:45 -0800)]
x86-64: Restore PIC check for PCREL reloc against protected symbol

commit bd7ab16b4537788ad53521c45469a1bdae84ad4a
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Feb 13 07:34:22 2018 -0800

    x86-64: Generate branch with PLT32 relocation

removed check R_X86_64_PC32 relocation against protected symbols in
shared objects.  Since elf_x86_64_check_relocs is called after we
have seen all input files, we can check for PC-relative relocations in
elf_x86_64_check_relocs.  We should not allow PC-relative relocations
against protected symbols since address of protected function and
location of protected data may not be in the shared object.

bfd/

PR ld/24151
* elf64-x86-64.c (elf_x86_64_need_pic): Check
SYMBOL_DEFINED_NON_SHARED_P instead of def_regular.
(elf_x86_64_relocate_section): Move PIC check for PC-relative
relocations to ...
(elf_x86_64_check_relocs): Here.
(elf_x86_64_finish_dynamic_symbol): Use SYMBOL_DEFINED_NON_SHARED_P
to check if a symbol is defined in a non-shared object.
* elfxx-x86.h (SYMBOL_DEFINED_NON_SHARED_P): New.

ld/

PR ld/24151
* testsuite/ld-x86-64/pr24151a-x32.d: New file.
* testsuite/ld-x86-64/pr24151a.d: Likewise.
* testsuite/ld-x86-64/pr24151a.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pr24151a and pr24151a-x32.

5 years agoAutomatic date update in version.in
GDB Administrator [Wed, 6 Feb 2019 00:00:22 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoHoist assertion in target_stack::unpush
Tom Tromey [Tue, 5 Feb 2019 11:59:11 +0000 (04:59 -0700)]
Hoist assertion in target_stack::unpush

I noticed that target_stack::unpush first uses the target "t", then
later asserts that it is non-NULL:

  strata stratum = t->stratum ();
[...]
  gdb_assert (t != NULL);

This is backwards, though, as the assertion must come first.

gdb/ChangeLog
2019-02-05  Tom Tromey  <tom@tromey.com>

* target.c (target_stack::unpush): Move assertion earlier.

5 years agoAutomatic date update in version.in
GDB Administrator [Tue, 5 Feb 2019 00:00:29 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoAdd more notes on how to make a release
Nick Clifton [Mon, 4 Feb 2019 11:19:42 +0000 (11:19 +0000)]
Add more notes on how to make a release

5 years agoAutomatic date update in version.in
GDB Administrator [Mon, 4 Feb 2019 00:00:43 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoAutomatic date update in version.in
GDB Administrator [Sun, 3 Feb 2019 00:00:54 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoAutomatic date update in version.in
GDB Administrator [Sat, 2 Feb 2019 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoUpdate binutils/MAINTAINERS for S12Z.
John Darrington [Fri, 1 Feb 2019 16:42:54 +0000 (17:42 +0100)]
Update binutils/MAINTAINERS for S12Z.

binutils/
* MAINTAINERS: Add self as S12Z maintainer.

5 years agoS12Z: GAS: Allow #_symbol operands as mov source
John Darrington [Fri, 1 Feb 2019 16:42:54 +0000 (17:42 +0100)]
S12Z: GAS: Allow #_symbol operands as mov source

mov.l, mov.p and mov.w (but not mov.b) when called with an immediate source
operand should be accepted a relocatable expression.  This change makes that
possible.

gas/
* config/tc-s12z.c (lex_imm): Add new argument exp_o.
(emit_reloc): New function.
(md_apply_fix): [BFD_RELOC_S12Z_OPR] Recognise that it
can be either 2 bytes or 3 bytes long.
* testsuite/gas/s12z/mov-imm-reloc.d: New file.
* testsuite/gas/s12z/mov-imm-reloc.s: New file.
* testsuite/gas/s12z/s12z.exp: Add them.

5 years agoS12Z: GAS: Fix incorrect range test for 16-bit PC relative offsets.
John Darrington [Fri, 1 Feb 2019 16:42:54 +0000 (17:42 +0100)]
S12Z: GAS: Fix incorrect range test for 16-bit PC relative offsets.

The limits for PC relative offsets were incorrect.  This change fixes
them and adds some tests.

gas/
* config/tc-s12z.c (md_apply_fix): Fix incorrect limits.
* testsuite/gas/s12z/pc-rel-bad.d: New file.
* testsuite/gas/s12z/pc-rel-bad.l: New file.
* testsuite/gas/s12z/pc-rel-bad.s: New file.
* testsuite/gas/s12z/pc-rel-good.d: New file.
* testsuite/gas/s12z/pc-rel-good.s: New file.
* testsuite/gas/s12z/s12z.exp: Add them.

5 years agoS12Z: GAS: Issue warning if TFR/EXG have identical source and destination.
John Darrington [Fri, 1 Feb 2019 16:42:54 +0000 (17:42 +0100)]
S12Z: GAS: Issue warning if TFR/EXG have identical source and destination.

It is permissible for the source and destination operands of TFR and EXG to be
the same register.  However it is a pointless instruction and anyone writing it
has probably made a mistake.  This change emits a warning if such an instruction
is encountered.

gas/
* config/tc-s12z.c (tfr): Emit warning if operands are the same.
* testsuite/gas/s12z/exg.d: New test case.
* testsuite/gas/s12z/exg.l: New file.

5 years agoS12Z: GAS: Disallow immediate destination operands
John Darrington [Fri, 1 Feb 2019 16:42:54 +0000 (17:42 +0100)]
S12Z: GAS: Disallow immediate destination operands

The assembler permitted instructions which attempted to assign to an immediate
operand.  Bizarrely there is a valid machine code for such operations (although
the documentation says it's "inappropriate").  This change causes such attempts
to fail with  an error message.

gas/

* config/tc-s12z.c (lex_opr): Add a parameter to indicate whether
immediate mode operands should be permitted.
* testsuite/s12z/imm-dest.d: New file.
* testsuite/s12z/imm-dest.l: New file.
* testsuite/s12z/imm-dest.s: New file.
* testsuite/s12z/s12z.exp: Add them.

5 years agoAutomatic date update in version.in
GDB Administrator [Fri, 1 Feb 2019 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoReadline: Cleanup some warnings
Alan Hayward [Thu, 31 Jan 2019 09:48:39 +0000 (09:48 +0000)]
Readline: Cleanup some warnings

Cleanup the readline warnings that gdb buildbot complains about.

To prevent wcwidth missing declaration warnings, add the SOURCE /
EXTENSION macros to config.in that have already checked for in
configure.

Ensure pid is a long before printing as one.  Also fix GNU style.

Check the return value of write the same way as history_do_write ().

These changes are consistent with upstream readline.

readline/ChangeLog.gdb:

* config.h.in: Add SOURCE/EXTENSION macros.
* histfile.c (history_truncate_file): Check return of write.
* util.c (_rl_tropen): Ensure pid is long.

5 years agoS/390: Implement instruction set extensions
Andreas Krebbel [Thu, 31 Jan 2019 16:01:27 +0000 (17:01 +0100)]
S/390: Implement instruction set extensions

opcodes/ChangeLog:

2019-01-31  Andreas Krebbel  <krebbel@linux.ibm.com>

* s390-mkopc.c (main): Accept arch13 as cpu string.
* s390-opc.c: Add new instruction formats and instruction opcode
masks.
* s390-opc.txt: Add new arch13 instructions.

include/ChangeLog:

2019-01-31  Andreas Krebbel  <krebbel@linux.ibm.com>

* opcode/s390.h (enum s390_opcode_cpu_val): Add
S390_OPCODE_ARCH13.

gas/ChangeLog:

2019-01-31  Andreas Krebbel  <krebbel@linux.ibm.com>

* config/tc-s390.c (s390_parse_cpu): New entry for arch13.
* doc/c-s390.texi: Document arch13 march option.
* testsuite/gas/s390/s390.exp: Run the arch13 related tests.
* testsuite/gas/s390/zarch-arch13.d: New test.
* testsuite/gas/s390/zarch-arch13.s: New test.
* testsuite/gas/s390/zarch-z13.d: Expect the renamed mnemonics
also for z13.

5 years agoAssorted warning fixes
Alan Modra [Thu, 31 Jan 2019 04:08:45 +0000 (14:38 +1030)]
Assorted warning fixes

gcc-9 flagged warnings at the places I'm patching here, all real bugs.

* config/tc-alpha.c (md_apply_fix): Correct range checks for
BFD_RELOC_ALPHA_NOP, BFD_RELOC_ALPHA_LDA, BFD_RELOC_ALPHA_BSR.
* config/tc-arm.c (md_apply_fix): Use llabs rather than abs.
* config/tc-csky.c (get_macro_reg_vals): Pass s to csky_show_error.

5 years agoDocument ld -t behaviour
Alan Modra [Thu, 31 Jan 2019 01:07:44 +0000 (11:37 +1030)]
Document ld -t behaviour

* NEWS: Mention -t change.
* ld.texi (--trace/-t): Expand documentation a little.

5 years agoAutomatic date update in version.in
GDB Administrator [Thu, 31 Jan 2019 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years ago[PR gdb/23985] Fix libinproctrace.so build
Szabolcs Nagy [Fri, 14 Dec 2018 14:02:54 +0000 (14:02 +0000)]
[PR gdb/23985] Fix libinproctrace.so build

The IPA objects currently may use gnulib replacement apis, which is
wrong: gnulib is not linked into the produced dso and it cannot be
because it is not built with -fPIC -fvisibility=hidden.

The gnulib replacement detection is broken under cross compilation:
for targets other than *-gnu*, replacements are enabled that depend
on execution time detection. This causes unnecessary build failure
when the target has proper support for the replaced api.

This fix tries to undo the replacements, which is tricky because the
gnulib headers are still used for various compile time fixups and
there is no simple knob in gnulib to only turn the replacements off.

Without this workaround gdb fails to cross build to non-gnu targets:

  ld: tracepoint-ipa.o: in function `gdb_agent_helper_thread(void*)':
  gdb/gdbserver/tracepoint.c:7221: undefined reference to `rpl_strerror'
  ...
  Makefile:434: recipe for target 'libinproctrace.so' failed

gdb/gdbserver/ChangeLog:

PR gdb/23985
* Makefile.in (IPAGENT_CFLAGS): Add UNDO_GNULIB_CFLAGS.
(UNDO_GNULIB_CFLAGS): Undo gnulib replacements.

5 years agoRelease the GIL while running a gdb command or expression
Tom Tromey [Sat, 8 Sep 2018 02:02:21 +0000 (20:02 -0600)]
Release the GIL while running a gdb command or expression

PR python/23615 points out that gdb.execute_gdb_command does not
release the Python GIL.  This means that, while the gdb command is
running, other Python threads do not run.

This patch solves the problem by introducing a new RAII class that can
be used to temporarily release and then re-acquire the GIL, then puts
this into the appropriate places in execute_gdb_command and
gdbpy_parse_and_eval.

This does not include a test case, because after some research I could
not find a way to write one that was not racy.

gdb/ChangeLog
2019-01-30  Tom Tromey  <tom@tromey.com>

PR python/23615:
* python/python.c (execute_gdb_command): Use gdbpy_allow_threads.
(gdbpy_parse_and_eval): Likewise.
* python/python-internal.h (gdbpy_allow_threads): New class.

5 years agoAutomatic date update in version.in
GDB Administrator [Wed, 30 Jan 2019 00:00:46 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoAdd a testcase for PR ld/24008
H.J. Lu [Tue, 29 Jan 2019 14:07:42 +0000 (06:07 -0800)]
Add a testcase for PR ld/24008

PR ld/24008
* testsuite/ld-scripts/defined.exp: Run pr24008.
* testsuite/ld-scripts/pr24008.d: New file.
* testsuite/ld-scripts/pr24008.map: Likewise.
* testsuite/ld-scripts/pr24008.s: Likewise.
* testsuite/ld-scripts/pr24008.t: Likewise.

5 years agoSkip ld/pr23169 on SPARC.
Eric Botcazou [Tue, 29 Jan 2019 09:11:01 +0000 (10:11 +0100)]
Skip ld/pr23169 on SPARC.

The test is already skipped on PowerPC and Aarch64 because it's invalid.

* testsuite/ld-ifunc/ifunc.exp: Skip pr23169 on SPARC.

5 years agoAutomatic date update in version.in
GDB Administrator [Tue, 29 Jan 2019 00:00:43 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoxtensa: gas: don't keep relocations for constants
Max Filippov [Sat, 26 Jan 2019 02:52:32 +0000 (18:52 -0800)]
xtensa: gas: don't keep relocations for constants

xtensa gas chokes on 8/16 bit data entries representing constant symbols
because it leaves BFD_RELOC_8/BFD_RELOC_16 fixups for which xtensa BFD
cannot emit relocations. Resolve fixups for constant symbols in
md_apply_fix.

gas/
2019-01-28  Max Filippov  <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (md_apply_fix): Mark fixups for constant
symbols as done in md_apply_fix.
* testsuite/gas/all/forward.d: Don't XFAIL for xtensa.

5 years agoUse trad_frame_set_reg_addr for FreeBSD arm signal trampoline unwinders.
John Baldwin [Mon, 28 Jan 2019 18:16:58 +0000 (10:16 -0800)]
Use trad_frame_set_reg_addr for FreeBSD arm signal trampoline unwinders.

Replace individual calls to trad_frame_set_reg_addr for the general
purpose and floating point registers in signal trampoline frames used
by FreeBSD/aarch64 and FreeBSD/arm with calls to
trad_frame_set_reg_addr using the register maps for the corresponding
register sets.

gdb/ChangeLog:

* aarch64-fbsd-tdep.c (aarch64_fbsd_gregmap)
(aarch64_fbsd_fpregmap): Move earlier.
(AARCH64_MCONTEXT_REG_SIZE, AARCH64_MCONTEXT_FPREG_SIZE): Delete.
(aarch64_fbsd_sigframe_init): Use trad_frame_set_reg_regmap
instead of individual calls to trad_frame_set_reg_addr.
* arm-fbsd-tdep.c (arm_fbsd_gregmap, arm_fbsd_vfpregmap): Move
earlier.
(ARM_MCONTEXT_REG_SIZE, ARM_MCONTEXT_VFP_REG_SIZE): Delete.
(arm_fbsd_sigframe_init): Use trad_frame_set_reg_regmap
instead of individual calls to trad_frame_set_reg_addr.

5 years agoRevert "gdbserver: When attaching, add process before lwps"
Alan Hayward [Mon, 28 Jan 2019 16:21:00 +0000 (16:21 +0000)]
Revert "gdbserver: When attaching, add process before lwps"

This reverts commit f084d335110408aa08ea06c7cb217ae19697db3d.

Accidently pushed. Reverted.

5 years agoFix GCC9 warning on elf32-arm.c:elf32_arm_final_link_relocate
Sergio Durigan Junior [Mon, 21 Jan 2019 20:36:41 +0000 (15:36 -0500)]
Fix GCC9 warning on elf32-arm.c:elf32_arm_final_link_relocate

Fedora Rawhide has just switched to GCC9, and now GDB doesn't compile
because of a BFD warning:

  BUILDSTDERR: ../../bfd/elf32-arm.c: In function 'elf32_arm_final_link_relocate':
  BUILDSTDERR: ../../bfd/elf32-arm.c:10907:10: error: absolute value function 'labs' given an argument of type 'bfd_signed_vma' {aka 'long long int'} but has parameter of type 'long int' which may cause truncation of value [-Werror=absolute-value]
  BUILDSTDERR: 10907 |  value = labs (relocation);
  BUILDSTDERR:       |          ^~~~

You can take a look at the full build log here:

  https://kojipkgs.fedoraproject.org//work/tasks/4828/32174828/build.log

The fix is (apparently) simple: instead of using 'labs', we should use
'llabs', since we're passing a 'bfd_signed_vma' to it, which is at
least a 'long long int', as far as I have checked.  This is what this
patch does.

bfd/ChangeLog:
2019-01-25  Sergio Durigan Junior  <sergiodj@redhat.com>

* elf32-arm.c (elf32_arm_final_link_relocate): Use 'llabs' instead
of 'labs' (and fix GCC warning).

5 years agoUpdated Russian and French translations for the gas sub-directory
Nick Clifton [Mon, 28 Jan 2019 15:21:58 +0000 (15:21 +0000)]
Updated Russian and French translations for the gas sub-directory

5 years agoReplace contribution list in CONTRIBUTE file with link
Alan Hayward [Mon, 28 Jan 2019 09:39:55 +0000 (09:39 +0000)]
Replace contribution list in CONTRIBUTE file with link

The GDB wiki page has a much better contribution checklist than
that in the GDB CONTRIBUTE file.  In addition, the wiki is easier
to keep up to date with current processes.

Reduce the CONTRIBUTE file down to a short paragraph followed by
a link to the contribution process.  This also ensures anyone
reading the CONTRIBUTE file for a given release has access to the
latest processes.

gdb/ChangeLog:

* CONTRIBUTE: Replace contribution list with wiki link.

5 years agogdbserver: When attaching, add process before lwps
Alan Hayward [Thu, 24 Jan 2019 18:55:20 +0000 (18:55 +0000)]
gdbserver: When attaching, add process before lwps

The recent BP/WP changes for AArch64 swapping the order in add_lwp()
so that the process was added before the lwp. This was due to the lwp
creation requiring the process data.

This also needs changing in linux_attach().

Fixes gdb.server/ext-attach.exp on Aarch64.

(This regression was hidden due to the racy nature of the gdb.server
tests - now they are no longer racy it'll be easier to spot. Also
checked X86).

gdb/gdbserver/ChangeLog:

2019-01-25  Alan Hayward  <alan.hayward@arm.com>

* linux-low.c (linux_attach): Add process before lwp.

5 years agoAutomatic date update in version.in
GDB Administrator [Mon, 28 Jan 2019 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoPR24008, Wrong value of ternary expression in map file
Alan Modra [Sun, 27 Jan 2019 23:29:29 +0000 (09:59 +1030)]
PR24008, Wrong value of ternary expression in map file

PR 24008
* ldexp.h (lang_phase_type): Add lang_fixed_phase_enum.
* ldexp.c (fold_name): Move expld.assign_name check later to
avoid an extra lookup.
(exp_fold_tree_1): When lang_fixed_phase_enum, don't change symbol
values, and don't clear expld.assign_name.
* ldlang.c (lang_map): Set expld.phase to lang_fixed_phase_enum.
(print_assignment): Resolve entire assignment expression.
Don't access symbol u.def unless symbol is defined.

5 years agoControl gas enable-checking default by bfd/development.sh
Alan Modra [Sun, 27 Jan 2019 23:03:28 +0000 (09:33 +1030)]
Control gas enable-checking default by bfd/development.sh

* configure.ac (ac_checking): Set from bfd/development.sh
development variable.
* configure: Regenerate.

5 years agoRemove duplicate skip_python_tests invocation
Tom Tromey [Sun, 27 Jan 2019 21:51:03 +0000 (14:51 -0700)]
Remove duplicate skip_python_tests invocation

I noticed that py-finish-breakpoint.exp had two calls to
skip_python_tests, in quick succession.  This patch removes the second
one.

gdb/testsuite/ChangeLog
2019-01-27  Tom Tromey  <tom@tromey.com>

* gdb.python/py-finish-breakpoint.exp: Remove duplicate call to
skip_python_tests.

5 years agoAutomatic date update in version.in
GDB Administrator [Sun, 27 Jan 2019 00:01:24 +0000 (00:01 +0000)]
Automatic date update in version.in

5 years agoFix the sim build
Tom Tromey [Sat, 26 Jan 2019 15:51:57 +0000 (08:51 -0700)]
Fix the sim build

Simon pointed out that the "common/" include change in gdb broke the
sim build.  The problem was that the sim was using gdb's
create-version.sh, which changed.

This patch copies create-version.sh to the sim, so that it can
generate "version.c" in a way that works in the sim build.

Tested by rebuilding.

sim/common/ChangeLog
2019-01-26  Tom Tromey  <tom@tromey.com>

* Make-common.in (version.c): Use sim's create-version.sh.
* create-version.sh: New file.

sim/ppc/ChangeLog
2019-01-26  Tom Tromey  <tom@tromey.com>

* Makefile.in (version.c): Use sim's create-version.sh.

5 years agoAutomatic date update in version.in
GDB Administrator [Sat, 26 Jan 2019 00:00:52 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoDon't use -I for common subdirectory
Tom Tromey [Tue, 22 Jan 2019 07:26:45 +0000 (00:26 -0700)]
Don't use -I for common subdirectory

This changes the Makefiles to remove the -I for the common/
subdirectory.  This will enforce the rule that includes must use the
'common/filename.h' form.

gdb/ChangeLog
2019-01-25  Tom Tromey  <tom@tromey.com>

* Makefile.in (GDB_CFLAGS): Don't add -I for common.

gdb/gdbserver/ChangeLog
2019-01-25  Tom Tromey  <tom@tromey.com>

* Makefile.in (INCLUDE_CFLAGS): Don't add -I for common.

5 years agoNormalize includes to use common/
Tom Tromey [Wed, 23 Jan 2019 17:21:39 +0000 (10:21 -0700)]
Normalize includes to use common/

This changes all includes to use the form "common/filename.h" rather
than just "filename.h".  This was written by a script.

gdb/ChangeLog
2019-01-25  Tom Tromey  <tom@tromey.com>

* xtensa-linux-nat.c: Fix common/ includes.
* xml-support.h: Fix common/ includes.
* xml-support.c: Fix common/ includes.
* x86-linux-nat.c: Fix common/ includes.
* windows-nat.c: Fix common/ includes.
* varobj.h: Fix common/ includes.
* varobj.c: Fix common/ includes.
* value.c: Fix common/ includes.
* valops.c: Fix common/ includes.
* utils.c: Fix common/ includes.
* unittests/xml-utils-selftests.c: Fix common/ includes.
* unittests/utils-selftests.c: Fix common/ includes.
* unittests/unpack-selftests.c: Fix common/ includes.
* unittests/tracepoint-selftests.c: Fix common/ includes.
* unittests/style-selftests.c: Fix common/ includes.
* unittests/string_view-selftests.c: Fix common/ includes.
* unittests/scoped_restore-selftests.c: Fix common/ includes.
* unittests/scoped_mmap-selftests.c: Fix common/ includes.
* unittests/scoped_fd-selftests.c: Fix common/ includes.
* unittests/rsp-low-selftests.c: Fix common/ includes.
* unittests/parse-connection-spec-selftests.c: Fix common/
includes.
* unittests/optional-selftests.c: Fix common/ includes.
* unittests/offset-type-selftests.c: Fix common/ includes.
* unittests/observable-selftests.c: Fix common/ includes.
* unittests/mkdir-recursive-selftests.c: Fix common/ includes.
* unittests/memrange-selftests.c: Fix common/ includes.
* unittests/memory-map-selftests.c: Fix common/ includes.
* unittests/lookup_name_info-selftests.c: Fix common/ includes.
* unittests/function-view-selftests.c: Fix common/ includes.
* unittests/environ-selftests.c: Fix common/ includes.
* unittests/copy_bitwise-selftests.c: Fix common/ includes.
* unittests/common-utils-selftests.c: Fix common/ includes.
* unittests/cli-utils-selftests.c: Fix common/ includes.
* unittests/array-view-selftests.c: Fix common/ includes.
* ui-file.c: Fix common/ includes.
* tui/tui-io.c: Fix common/ includes.
* tracepoint.h: Fix common/ includes.
* tracepoint.c: Fix common/ includes.
* tracefile-tfile.c: Fix common/ includes.
* top.h: Fix common/ includes.
* top.c: Fix common/ includes.
* thread.c: Fix common/ includes.
* target/waitstatus.h: Fix common/ includes.
* target/waitstatus.c: Fix common/ includes.
* target.h: Fix common/ includes.
* target.c: Fix common/ includes.
* target-memory.c: Fix common/ includes.
* target-descriptions.c: Fix common/ includes.
* symtab.h: Fix common/ includes.
* symfile.c: Fix common/ includes.
* stap-probe.c: Fix common/ includes.
* spu-linux-nat.c: Fix common/ includes.
* sparc-nat.c: Fix common/ includes.
* source.c: Fix common/ includes.
* solib.c: Fix common/ includes.
* solib-target.c: Fix common/ includes.
* ser-unix.c: Fix common/ includes.
* ser-tcp.c: Fix common/ includes.
* ser-pipe.c: Fix common/ includes.
* ser-base.c: Fix common/ includes.
* selftest-arch.c: Fix common/ includes.
* s12z-tdep.c: Fix common/ includes.
* rust-exp.y: Fix common/ includes.
* rs6000-aix-tdep.c: Fix common/ includes.
* riscv-tdep.c: Fix common/ includes.
* remote.c: Fix common/ includes.
* remote-notif.h: Fix common/ includes.
* remote-fileio.h: Fix common/ includes.
* remote-fileio.c: Fix common/ includes.
* regcache.h: Fix common/ includes.
* regcache.c: Fix common/ includes.
* record-btrace.c: Fix common/ includes.
* python/python.c: Fix common/ includes.
* python/py-type.c: Fix common/ includes.
* python/py-inferior.c: Fix common/ includes.
* progspace.h: Fix common/ includes.
* producer.c: Fix common/ includes.
* procfs.c: Fix common/ includes.
* proc-api.c: Fix common/ includes.
* printcmd.c: Fix common/ includes.
* ppc-linux-nat.c: Fix common/ includes.
* parser-defs.h: Fix common/ includes.
* osdata.c: Fix common/ includes.
* obsd-nat.c: Fix common/ includes.
* nat/x86-linux.c: Fix common/ includes.
* nat/x86-linux-dregs.c: Fix common/ includes.
* nat/x86-dregs.h: Fix common/ includes.
* nat/x86-dregs.c: Fix common/ includes.
* nat/ppc-linux.c: Fix common/ includes.
* nat/mips-linux-watch.h: Fix common/ includes.
* nat/mips-linux-watch.c: Fix common/ includes.
* nat/linux-waitpid.c: Fix common/ includes.
* nat/linux-ptrace.h: Fix common/ includes.
* nat/linux-ptrace.c: Fix common/ includes.
* nat/linux-procfs.c: Fix common/ includes.
* nat/linux-personality.c: Fix common/ includes.
* nat/linux-osdata.c: Fix common/ includes.
* nat/linux-namespaces.c: Fix common/ includes.
* nat/linux-btrace.h: Fix common/ includes.
* nat/linux-btrace.c: Fix common/ includes.
* nat/fork-inferior.c: Fix common/ includes.
* nat/amd64-linux-siginfo.c: Fix common/ includes.
* nat/aarch64-sve-linux-ptrace.c: Fix common/ includes.
* nat/aarch64-linux.c: Fix common/ includes.
* nat/aarch64-linux-hw-point.h: Fix common/ includes.
* nat/aarch64-linux-hw-point.c: Fix common/ includes.
* namespace.h: Fix common/ includes.
* mips-linux-tdep.c: Fix common/ includes.
* minsyms.c: Fix common/ includes.
* mi/mi-parse.h: Fix common/ includes.
* mi/mi-main.c: Fix common/ includes.
* mi/mi-cmd-env.c: Fix common/ includes.
* memrange.h: Fix common/ includes.
* memattr.c: Fix common/ includes.
* maint.h: Fix common/ includes.
* maint.c: Fix common/ includes.
* main.c: Fix common/ includes.
* machoread.c: Fix common/ includes.
* location.c: Fix common/ includes.
* linux-thread-db.c: Fix common/ includes.
* linux-nat.c: Fix common/ includes.
* linux-fork.c: Fix common/ includes.
* inline-frame.c: Fix common/ includes.
* infrun.c: Fix common/ includes.
* inflow.c: Fix common/ includes.
* inferior.h: Fix common/ includes.
* inferior.c: Fix common/ includes.
* infcmd.c: Fix common/ includes.
* inf-ptrace.c: Fix common/ includes.
* inf-child.c: Fix common/ includes.
* ia64-linux-nat.c: Fix common/ includes.
* i387-tdep.c: Fix common/ includes.
* i386-tdep.c: Fix common/ includes.
* i386-linux-tdep.c: Fix common/ includes.
* i386-linux-nat.c: Fix common/ includes.
* i386-go32-tdep.c: Fix common/ includes.
* i386-fbsd-tdep.c: Fix common/ includes.
* i386-fbsd-nat.c: Fix common/ includes.
* guile/scm-type.c: Fix common/ includes.
* guile/guile.c: Fix common/ includes.
* go32-nat.c: Fix common/ includes.
* gnu-nat.c: Fix common/ includes.
* gdbthread.h: Fix common/ includes.
* gdbarch-selftests.c: Fix common/ includes.
* gdb_usleep.c: Fix common/ includes.
* gdb_select.h: Fix common/ includes.
* gdb_bfd.c: Fix common/ includes.
* gcore.c: Fix common/ includes.
* fork-child.c: Fix common/ includes.
* findvar.c: Fix common/ includes.
* fbsd-nat.c: Fix common/ includes.
* event-top.c: Fix common/ includes.
* event-loop.c: Fix common/ includes.
* dwarf2read.c: Fix common/ includes.
* dwarf2loc.c: Fix common/ includes.
* dwarf2-frame.c: Fix common/ includes.
* dwarf-index-cache.c: Fix common/ includes.
* dtrace-probe.c: Fix common/ includes.
* disasm-selftests.c: Fix common/ includes.
* defs.h: Fix common/ includes.
* csky-tdep.c: Fix common/ includes.
* cp-valprint.c: Fix common/ includes.
* cp-support.h: Fix common/ includes.
* cp-support.c: Fix common/ includes.
* corelow.c: Fix common/ includes.
* completer.h: Fix common/ includes.
* completer.c: Fix common/ includes.
* compile/compile.c: Fix common/ includes.
* compile/compile-loc2c.c: Fix common/ includes.
* compile/compile-cplus-types.c: Fix common/ includes.
* compile/compile-cplus-symbols.c: Fix common/ includes.
* command.h: Fix common/ includes.
* cli/cli-dump.c: Fix common/ includes.
* cli/cli-cmds.c: Fix common/ includes.
* charset.c: Fix common/ includes.
* build-id.c: Fix common/ includes.
* btrace.h: Fix common/ includes.
* btrace.c: Fix common/ includes.
* breakpoint.h: Fix common/ includes.
* breakpoint.c: Fix common/ includes.
* ax.h:
(enum agent_op): Fix common/ includes.
* ax-general.c (struct aop_map): Fix common/ includes.
* ax-gdb.c: Fix common/ includes.
* auxv.c: Fix common/ includes.
* auto-load.c: Fix common/ includes.
* arm-tdep.c: Fix common/ includes.
* arch/riscv.c: Fix common/ includes.
* arch/ppc-linux-common.c: Fix common/ includes.
* arch/i386.c: Fix common/ includes.
* arch/arm.c: Fix common/ includes.
* arch/arm-linux.c: Fix common/ includes.
* arch/arm-get-next-pcs.c: Fix common/ includes.
* arch/amd64.c: Fix common/ includes.
* arch/aarch64.c: Fix common/ includes.
* arch/aarch64-insn.c: Fix common/ includes.
* arch-utils.c: Fix common/ includes.
* amd64-windows-tdep.c: Fix common/ includes.
* amd64-tdep.c: Fix common/ includes.
* amd64-sol2-tdep.c: Fix common/ includes.
* amd64-obsd-tdep.c: Fix common/ includes.
* amd64-nbsd-tdep.c: Fix common/ includes.
* amd64-linux-tdep.c: Fix common/ includes.
* amd64-linux-nat.c: Fix common/ includes.
* amd64-fbsd-tdep.c: Fix common/ includes.
* amd64-fbsd-nat.c: Fix common/ includes.
* amd64-dicos-tdep.c: Fix common/ includes.
* amd64-darwin-tdep.c: Fix common/ includes.
* agent.c: Fix common/ includes.
* ada-lang.h: Fix common/ includes.
* ada-lang.c: Fix common/ includes.
* aarch64-tdep.c: Fix common/ includes.

gdb/gdbserver/ChangeLog
2019-01-25  Tom Tromey  <tom@tromey.com>

* win32-low.c: Fix common/ includes.
* win32-i386-low.c: Fix common/ includes.
* tracepoint.c: Fix common/ includes.
* thread-db.c: Fix common/ includes.
* target.h: Fix common/ includes.
* symbol.c: Fix common/ includes.
* spu-low.c: Fix common/ includes.
* server.h: Fix common/ includes.
* server.c: Fix common/ includes.
* remote-utils.c: Fix common/ includes.
* regcache.h: Fix common/ includes.
* regcache.c: Fix common/ includes.
* nto-x86-low.c: Fix common/ includes.
* notif.h: Fix common/ includes.
* mem-break.h: Fix common/ includes.
* lynx-low.c: Fix common/ includes.
* lynx-i386-low.c: Fix common/ includes.
* linux-x86-tdesc-selftest.c: Fix common/ includes.
* linux-x86-low.c: Fix common/ includes.
* linux-low.c: Fix common/ includes.
* inferiors.h: Fix common/ includes.
* i387-fp.c: Fix common/ includes.
* hostio.c: Fix common/ includes.
* hostio-errno.c: Fix common/ includes.
* gdbthread.h: Fix common/ includes.
* gdbreplay.c: Fix common/ includes.
* fork-child.c: Fix common/ includes.
* event-loop.c: Fix common/ includes.
* ax.c:
(enum gdb_agent_op): Fix common/ includes.

5 years agoUpdate create-version.sh to use common/version.h
Tom Tromey [Tue, 22 Jan 2019 06:03:23 +0000 (23:03 -0700)]
Update create-version.sh to use common/version.h

This changes create-version.sh to have the generated file use
common/version.h as the file name.

gdb/ChangeLog
2019-01-25  Tom Tromey  <tom@tromey.com>

* common/create-version.sh: Use common/version.h.

5 years agoAArch64: Add missing changelog for Update encodings for stg, st2g, stzg and st2zg
Tamar Christina [Fri, 25 Jan 2019 15:50:01 +0000 (15:50 +0000)]
AArch64: Add missing changelog for Update encodings for stg, st2g, stzg and st2zg

5 years agoAArch64: Update encodings for stg, st2g, stzg and st2zg.
Sudi Das [Fri, 25 Jan 2019 14:28:07 +0000 (14:28 +0000)]
AArch64: Update encodings for stg, st2g, stzg and st2zg.

This patch is part of a series of patches to introduce a few changes to the
Armv8.5-A Memory Tagging Extension. This patch updates the st*g instructions
to use a previously reserved field for a new register operand. Thus the
new versions of the instructions are as follows:

- STG Xt, [<Xn|SP>, #<simm>]
- STG Xt, [<Xn|SP>, #<simm>]!
- STG Xt, [<Xn|SP>], #<simm>
- STZG Xt, [<Xn|SP>, #<simm>]
- STZG Xt, [<Xn|SP>, #<simm>]!
- STZG Xt, [<Xn|SP>], #<simm>
- ST2G Xt, [<Xn|SP>, #<simm>]
- ST2G Xt, [<Xn|SP>, #<simm>]!
- ST2G Xt, [<Xn|SP>], #<simm>
- STZ2G Xt, [<Xn|SP>, #<simm>]
- STZ2G Xt, [<Xn|SP>, #<simm>]!
- STZ2G Xt, [<Xn|SP>], #<simm>

Committed on behalf of Sudakshina Das.

*** gas/ChangeLog ***

* config/tc-aarch64.c (warn_unpredictable_ldst): Exempt
stg, st2g, stzg and stz2g from Xt == Xn with writeback warning.
* testsuite/gas/aarch64/armv8_5-a-memtag.d: Change tests for
stg, stzg, st2g and stz2g.
* testsuite/gas/aarch64/armv8_5-a-memtag.s: Likewise.
* testsuite/gas/aarch64/illegal-memtag.l: Likewise.
* testsuite/gas/aarch64/illegal-memtag.s: Likewise.

*** opcodes/ChangeLog ***

* aarch64-tbl.h (QL_LDST_AT): Update macro.
(aarch64_opcode): Change encoding for stg, stzg
st2g and st2zg.
* aarch64-asm-2.c: Regenerated.
* aarch64-dis-2.c: Regenerated.
* aarch64-opc-2.c: Regenerated.

5 years agoAArch64: Add new STZGM instruction for Armv8.5-A Memory Tagging Extension.
Sudi Das [Fri, 25 Jan 2019 14:15:45 +0000 (14:15 +0000)]
AArch64: Add new STZGM instruction for Armv8.5-A Memory Tagging Extension.

This patch is part of a series of patches to introduce a few changes to the
Armv8.5-A Memory Tagging Extension. This patch adds the new STZGM instruction.

STGZM Xt, [<Xn|SP>]

Committed on behalf of Sudakshina Das.

*** gas/ChangeLog ***

* testsuite/gas/aarch64/armv8_5-a-memtag.d: New tests for stzgm.
* testsuite/gas/aarch64/armv8_5-a-memtag.s: Likewise.
* testsuite/gas/aarch64/illegal-memtag.l: Likewise.
* testsuite/gas/aarch64/illegal-memtag.s: Likewise.

*** opcodes/ChangeLog ***

* aarch64-asm-2.c: Regenerated.
* aarch64-dis-2.c: Likewise.
* aarch64-opc-2.c: Likewise.
* aarch64-tbl.h (aarch64_opcode): Add new stzgm.

5 years agoAArch64: Remove ldgv and stgv instructions from Armv8.5-A Memory Tagging Extension.
Sudi Das [Fri, 25 Jan 2019 13:57:14 +0000 (13:57 +0000)]
AArch64: Remove ldgv and stgv instructions from Armv8.5-A Memory Tagging Extension.

This patch is part of a series of patches to introduce a few changes to the
Armv8.5-A Memory Tagging Extension. This patch removes the LDGV and STGV
instructions. These instructions needed special infrastructure to support
[base]! style for addressing mode. That is also removed now.

Committed on behalf of Sudakshina Das.

*** gas/ChangeLog ***

* config/tc-aarch64.c (parse_address_main): Remove support for
[base]! address expression.
(parse_operands): Remove support for AARCH64_OPND_ADDR_SIMPLE_2.
(warn_unpredictable_ldst): Remove support for ldstgv_indexed.
* testsuite/gas/aarch64/armv8_5-a-memtag.d: Remove tests for ldgv
and stgv.
* testsuite/gas/aarch64/armv8_5-a-memtag.s: Likewise.
* testsuite/gas/aarch64/illegal-memtag.l: Likewise.
* testsuite/gas/aarch64/illegal-memtag.s: Likewise.

*** include/ChangeLog ***

* opcode/aarch64.h (enum aarch64_opnd): Remove
AARCH64_OPND_ADDR_SIMPLE_2.
(enum aarch64_insn_class): Remove ldstgv_indexed.

*** opcodes/ChangeLog ***

* aarch64-asm.c (aarch64_ins_addr_simple_2): Remove.
* aarch64-asm.h (ins_addr_simple_2): Likeiwse.
* aarch64-dis.c (aarch64_ext_addr_simple_2): Likewise.
* aarch64-dis.h (ext_addr_simple_2): Likewise.
* aarch64-opc.c (operand_general_constraint_met_p): Remove
case for ldstgv_indexed.
(aarch64_print_operand): Remove case for AARCH64_OPND_ADDR_SIMPLE_2.
* aarch64-tbl.h (struct aarch64_opcode): Remove ldgv and stgv.
(AARCH64_OPERANDS): Remove ADDR_SIMPLE_2.
* aarch64-asm-2.c: Regenerated.
* aarch64-dis-2.c: Regenerated.
* aarch64-opc-2.c: Regenerated.

5 years agoPrevent a potential illegal memory access in readelf when parsing a note with a zero...
Nick Clifton [Fri, 25 Jan 2019 13:16:06 +0000 (13:16 +0000)]
Prevent a potential illegal memory access in readelf when parsing a note with a zero name size.

PR 24131
* readelf.c (process_notes_at): Prevent an illegal memory access
when the note's namesize is zero.
(decode_tic6x_unwind_bytecode): Add code to handle the case where
no registers are specified in a frame pop instruction.

5 years agoUpdated Bulgarian and Russian translations for some of the binutils sub-directories
Nick Clifton [Fri, 25 Jan 2019 11:48:55 +0000 (11:48 +0000)]
Updated Bulgarian and Russian translations for some of the binutils sub-directories

5 years agoPR23940, check bounds before using
Wu Heng [Fri, 25 Jan 2019 03:11:47 +0000 (13:41 +1030)]
PR23940, check bounds before using

PR gas/23940
* macro.c (getstring): Check array bound before accessing.

5 years agoAutomatic date update in version.in
GDB Administrator [Fri, 25 Jan 2019 00:00:37 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoPR24125, Assertion failure with embedded NULs in string
Alan Modra [Thu, 24 Jan 2019 23:04:14 +0000 (09:34 +1030)]
PR24125, Assertion failure with embedded NULs in string

An assertion that can be triggered by user input is wrong, so remove
it.  I believe the NUL would have been accepted before the PR20902
patch.

PR 20902
PR 24125
* read.c (stringer): Delete assertion.

5 years agotarget_pass_signals/target_program_signals: Use gdb::array_view
Pedro Alves [Thu, 24 Jan 2019 18:25:06 +0000 (18:25 +0000)]
target_pass_signals/target_program_signals: Use gdb::array_view

This replaces the pointer and length parameters of target_pass_signals
and target_program_signals with a gdb::array_view parameter, and fixes
the fallout.

In infrun.c, the signal_stop, signal_print, signal_program,
signal_catch, signal_pass globals are currently pointers to
heap-allocated memory.  I see no point in that, so I converted them to
arrays.  This allows simplifying the calls to
target_pass_signals/target_program_signals, since we can pass the
array directly, which can implicitly convert to gdb::array_view.

gdb/ChangeLog:
2019-01-24  Pedro Alves  <palves@redhat.com>

* infrun.c (signal_stop, signal_print, signal_program)
(signal_catch, signal_pass): Now arrays instead of pointers.
(update_signals_program_target, do_target_resume)
(signal_catch_update, handle_command, _initialize_infrun): Adjust.
* linux-nat.c (linux_nat_target::pass_signals)
(linux_nat_target::create_inferior, linux_nat_target::attach):
Adjust.
* linux-nat.h (linux_nat_target::pass_signals): Adjust.
* nto-procfs.c (nto_procfs_target::pass_signals): Adjust.
* procfs.c (procfs_target::pass_signals): Adjust.
* record-full.c (record_full_target::resume): Adjust.
* remote.c (remote_target::pass_signals)
(remote_target::program_signals): Adjust.
* target-debug.h (target_debug_print_signals): Now takes a
gdb::array_view as parameter.  Adjust.
* target.h (target_ops) <pass_signals, program_signals>: Replace
pointer and length parameters with gdb::array_view.
(target_pass_signals, target_program_signals): Likewise.
* target-delegates.c: Regenerate.

5 years agoFix clang/libc++ build
Pedro Alves [Thu, 24 Jan 2019 18:01:49 +0000 (18:01 +0000)]
Fix clang/libc++ build

This fixes the following build error with clang/libc++, reported at
<https://sourceware.org/ml/gdb-patches/2019-01/msg00537.html>:

  (...)
  In file included from breakpoint.c:34:
  In file included from ./inferior.h:54:
  ./common/forward-scope-exit.h:98:7: error: no matching constructor for
  initialization of 'decltype(std::bind(&delete_longjmp_breakpoint,
  std::declval<int>()))' (aka '__bind<void (*)(int), int>')
      : m_bind_function (std::bind (function, args...))
^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ./common/gdb_optional.h:155:19: note: in instantiation of member
  function 'detail::forward_scope_exit<void (int),
  &delete_longjmp_breakpoint, void (int)>::forward_scope_exit' requested
  here
      new (&m_item) T (std::forward<Args>(args)...);
    ^
  breakpoint.c:11127:18: note: in instantiation of function template
  specialization 'gdb::optional<detail::forward_scope_exit<void (int),
  &delete_longjmp_breakpoint, void (int)> >::emplace<int &>' requested
  here
lj_deleter.emplace (thread);
   ^
  /Applications/Xcode-10.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/functional:2220:7:
  note: candidate constructor (the implicit copy constructor) not
  viable: no known conversion from '__bind<[...], int &>' to 'const
  __bind<[...], int>' for 1st argument
  class __bind
^
  (...)

I don't really know why I ended up with a copy here.  We can just pass
the arguments directly to the being-constructed bind.

gdb/ChangeLog:
2019-01-24  Pedro Alves  <palves@redhat.com>

* common/forward-scope-exit.h
(forward_scope_exit::forward_scope_exit): Pass arguments to
m_bind_function directly, instead of creating a std::bind and
copying that.

5 years agoAArch64 AAPCS: Ignore static members
Alan Hayward [Thu, 24 Jan 2019 08:17:39 +0000 (08:17 +0000)]
AArch64 AAPCS: Ignore static members

Static members in C++ structs are global data and therefore not part of the
list of struct members considered for passing in registers.

Note the corresponding code in GCC (from which the GDB AAPCS code is based)
does not have any static member checks due to the static members not being
part of the struct type at that point.

Extend gdb.base/infcall-nested-structs.exp to test structs with static
members when compiled for C++.  XFAIL more cases for x86_64 (see gdb/24104).
For completeness, ensure some test cases have both empty structures and
static members.

Also fixes gdb.dwarf2/dw2-cp-infcall-ref-static.exp.

gdb/ChangeLog:

* aarch64-tdep.c (aapcs_is_vfp_call_or_return_candidate_1): Check
for static members.
(pass_in_v_vfp_candidate): Likewise.

gdb/testsuite/ChangeLog:

* gdb.base/infcall-nested-structs.c (struct struct_static_02_01):
New structure.
(struct struct_static_02_02): Likewise.
(struct struct_static_02_03): Likewise.
(struct struct_static_02_04): Likewise.
(struct struct_static_04_01): Likewise.
(struct struct_static_04_02): Likewise.
(struct struct_static_04_03): Likewise.
(struct struct_static_04_04): Likewise.
(struct struct_static_06_01): Likewise.
(struct struct_static_06_02): Likewise.
(struct struct_static_06_03): Likewise.
(struct struct_static_06_04): Likewise.
(cmp_struct_static_02_01): Likewise.
(cmp_struct_static_02_02): Likewise.
(cmp_struct_static_02_03): Likewise.
(cmp_struct_static_02_04): Likewise.
(cmp_struct_static_04_01): Likewise.
(cmp_struct_static_04_02): Likewise.
(cmp_struct_static_04_03): Likewise.
(cmp_struct_static_04_04): Likewise.
(cmp_struct_static_06_01): Likewise.
(cmp_struct_static_06_02): Likewise.
(cmp_struct_static_06_03): Likewise.
(cmp_struct_static_06_04): Likewise.
(call_all): Test new structs.
* gdb.base/infcall-nested-structs.exp: Likewise.

5 years agoAutomatic date update in version.in
GDB Administrator [Thu, 24 Jan 2019 00:00:48 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoUse scope_exit in regcache.c
Tom Tromey [Wed, 23 Jan 2019 18:58:37 +0000 (18:58 +0000)]
Use scope_exit in regcache.c

This removes the regcache_invalidator class in favor of a scope_exit.
This seems like an improvement (albeit a minor one) because
regcache_invalidator is only used in a single spot.

gdb/ChangeLog:
2019-01-23  Tom Tromey  <tom@tromey.com>
    Pedro Alves  <palves@redhat.com>

* regcache.c (class regcache_invalidator): Remove.
(regcache::raw_write): Use make_scope_exit.

5 years agoUpdate cleanup comment in ui-out.h
Tom Tromey [Wed, 23 Jan 2019 18:58:36 +0000 (18:58 +0000)]
Update cleanup comment in ui-out.h

ui-out.h refers to some cleanup functions that no longer exist.  This
updates the reference.

gdb/ChangeLog:
2019-01-23  Tom Tromey  <tom@tromey.com>

* ui-out.h (class ui_out_emit_type): Update comment.

5 years agoUpdate an obsolete cleanup comment
Tom Tromey [Wed, 23 Jan 2019 18:58:36 +0000 (18:58 +0000)]
Update an obsolete cleanup comment

This updates a comment in fetch_inferior_event.  The comment refers to
a cleanup that is now a scoped_restore_current_thread.

gdb/ChangeLog:
2019-01-23  Tom Tromey  <tom@tromey.com>

* infrun.c (fetch_inferior_event): Update comment.

5 years agoRemove remaining cleanup from fetch_inferior_event
Tom Tromey [Wed, 23 Jan 2019 18:58:35 +0000 (18:58 +0000)]
Remove remaining cleanup from fetch_inferior_event

This removes the remaining cleanup from fetch_inferior_event,
replacing it with a SCOPE_EXIT.  This required introducing a new scope
and reindenting.

gdb/ChangeLog:
2019-01-23  Tom Tromey  <tom@tromey.com>
    Pedro Alves  <palves@redhat.com>

* infrun.c (reinstall_readline_callback_handler_cleanup): Remove
parameter.
(fetch_inferior_event): Use SCOPE_EXIT.

5 years agoRemove cleanup from stop_all_threads
Tom Tromey [Wed, 23 Jan 2019 18:58:35 +0000 (18:58 +0000)]
Remove cleanup from stop_all_threads

This removes the cleanup from stop_all_threads, replacing it with a
scope_exit.

gdb/ChangeLog:
2019-01-23  Tom Tromey  <tom@tromey.com>
    Pedro Alves  <palves@redhat.com>

* infrun.c (disable_thread_events): Delete.
(stop_all_threads): Use SCOPE_EXIT.

5 years agoRemove clear_symtab_users_cleanup
Tom Tromey [Wed, 23 Jan 2019 18:58:34 +0000 (18:58 +0000)]
Remove clear_symtab_users_cleanup

This removes clear_symtab_users_cleanup, replacing it with uses of
forward_scope_exit.

gdb/ChangeLog:
2019-01-23  Tom Tromey  <tom@tromey.com>
    Pedro Alves  <palves@redhat.com>

* symfile.c: Include forward-scope-exit.h.
(clear_symtab_users_cleanup): Replace forward declaration with
a FORWARD_SCOPE_EXIT.
(syms_from_objfile_1): Use the forward_scope_exit and
gdb::optional instead of cleanup_function.
(reread_symbols): Use the forward_scope_exit instead of
cleanup_function.
(clear_symtab_users_cleanup): Remove function.

5 years agoRemove cleanup from linux-nat.c
Tom Tromey [Wed, 23 Jan 2019 18:58:34 +0000 (18:58 +0000)]
Remove cleanup from linux-nat.c

This removes a cleanup from linux-nat.c, replacing it with a
scope_exit.

gdb/ChangeLog:
2019-01-23  Tom Tromey  <tom@tromey.com>
    Pedro Alves  <palves@redhat.com>

* linux-nat.c: Include scope-exit.h.
(cleanup_target_stop): Remove.
(linux_nat_target::static_tracepoint_markers_by_strid): Use
SCOPE_EXIT.

5 years agoRemove cleanup_delete_std_terminate_breakpoint
Tom Tromey [Wed, 23 Jan 2019 18:58:33 +0000 (18:58 +0000)]
Remove cleanup_delete_std_terminate_breakpoint

This removes cleanup_delete_std_terminate_breakpoint, replacing it
with a use of SCOPE_EXIT.

gdb/ChangeLog:
2019-01-23  Tom Tromey  <tom@tromey.com>
    Pedro Alves  <palves@redhat.com>

* infcall.c (cleanup_delete_std_terminate_breakpoint): Remove.
(call_function_by_hand_dummy): Use SCOPE_EXIT.

5 years agoRemove make_bpstat_clear_actions_cleanup
Tom Tromey [Wed, 23 Jan 2019 18:58:33 +0000 (18:58 +0000)]
Remove make_bpstat_clear_actions_cleanup

This removes make_bpstat_clear_actions_cleanup, replacing it with uses
of scope_exit.

gdb/ChangeLog:
2019-01-23  Tom Tromey  <tom@tromey.com>
    Andrew Burgess  <andrew.burgess@embecosm.com>
    Pedro Alves  <palves@redhat.com>

* infrun.c (fetch_inferior_event): Use scope_exit.
* utils.h (make_bpstat_clear_actions_cleanup): Don't declare.
* top.c (execute_command): Use scope_exit.
* breakpoint.c (bpstat_do_actions): Use scope_exit.
* utils.c (do_bpstat_clear_actions_cleanup)
(make_bpstat_clear_actions_cleanup): Remove.

5 years agoRemove delete_just_stopped_threads_infrun_breakpoints_cleanup
Tom Tromey [Wed, 23 Jan 2019 18:58:32 +0000 (18:58 +0000)]
Remove delete_just_stopped_threads_infrun_breakpoints_cleanup

v3: sorted earlier in the series, and replaces the cleanup in
fetch_inferior_event here too instead of in some other patch.

This removes delete_just_stopped_threads_infrun_breakpoints_cleanup,
replacing it with uses of scope_exit.

gdb/ChangeLog:
2019-01-23  Tom Tromey  <tom@tromey.com>
    Pedro Alves  <palves@redhat.com>

* infrun.c: Include "common/scope-exit.h"
(delete_just_stopped_threads_infrun_breakpoints_cleanup): Remove.
(wait_for_inferior): Use SCOPE_EXIT.
(fetch_inferior_event): Use scope_exit.

5 years agoRemove remaining cleanup from gdb/breakpoint.c
Tom Tromey [Wed, 23 Jan 2019 18:58:31 +0000 (18:58 +0000)]
Remove remaining cleanup from gdb/breakpoint.c

In v3: remove the "have BKPT_CHAIN already discarded" comment too.

The remaining null cleanup in breakpoint.c does not seem to protect
anything, so remove it.

gdb/ChangeLog:
2019-01-23  Tom Tromey  <tom@tromey.com>
    Pedro Alves  <palves@redhat.com>

* breakpoint.c (create_breakpoint): Remove cleanup.

5 years agoReplace delete_longjmp_breakpoint_cleanup with a forward_scope_exit type
Tom Tromey [Wed, 23 Jan 2019 18:58:31 +0000 (18:58 +0000)]
Replace delete_longjmp_breakpoint_cleanup with a forward_scope_exit type

This removes delete_longjmp_breakpoint_cleanup in favor of forward_scope_exit.

gdb/ChangeLog:
2019-01-23  Tom Tromey  <tom@tromey.com>
    Andrew Burgess  <andrew.burgess@embecosm.com>
    Pedro Alves  <palves@redhat.com>

* breakpoint.c (until_break_command): Use
delete_longjmp_breakpoint_cleanup class.
* infcmd.c (delete_longjmp_breakpoint_cleanup): Remove function.
(until_next_command): Use delete_longjmp_breakpoint_cleanup class.
* inferior.h: Include forward-scope-exit.h.
(delete_longjmp_breakpoint_cleanup): Replace function declaration
with FORWARD_SCOPE_EXIT type.

5 years agoUse SCOPE_EXIT in gdbarch-selftest.c
Pedro Alves [Wed, 23 Jan 2019 18:58:30 +0000 (18:58 +0000)]
Use SCOPE_EXIT in gdbarch-selftest.c

Replace the custom local class with a SCOPE_EXIT.

gdb/ChangeLog:
2019-01-23  Pedro Alves  <palves@redhat.com>

* gdbarch-selftests.c (struct on_exit): Use SCOPE_EXIT.

5 years agoUse forward_scope_exit for scoped_finish_thread_state
Pedro Alves [Wed, 23 Jan 2019 18:58:30 +0000 (18:58 +0000)]
Use forward_scope_exit for scoped_finish_thread_state

This reimplements the manually-written scoped_finish_thread_state
class as a forward_scope_exit instantiation.  forward_scope_exit has
the same interface as scoped_finish_thread_state, so nothing else has
to change.

A forward_scope_exit is preferred over make_scope_exit here because
infrun.c:normal_stop needs to wrap scoped_finish_thread_state in a
gdb::optional.  Since we need the type there, might as well use it
everywhere.

gdb/ChangeLog:
2019-01-23  Pedro Alves  <palves@redhat.com>
    Andrew Burgess  <andrew.burgess@embecosm.com>

* gdbthread.h: Include "common/forward-scope-exit.h".
(scoped_finish_thread_state): Redefine custom class in terms of
forward_scope_exit.

5 years agoIntroduce forward_scope_exit
Pedro Alves [Wed, 23 Jan 2019 18:58:29 +0000 (18:58 +0000)]
Introduce forward_scope_exit

This adds a template that can be used to automatically instantiate
scope_exit-like types that wrap some cleanup function.  The
instantiated type has a ctor that has the same interface as the
wrapped function.  While the "magic" is just straight C++11, the
intended use is via the FORWARD_SCOPE_EXIT macro, which is a minimal
macro that avoids spelling out the wrapped function name more than
once:

 void some_function (int foo, object *bar);
 using some_function_fce = FORWARD_SCOPE_EXIT (some_function);
 some_function_fce cleanup (some_int, some_obj_ptr);

The above runs:
  some_function (some_int, some_obj_ptr);
at scope exit.

This is mainly useful as opposed to a simpler SCOPE_EXIT when you need
to:
  - cancel the scope_exit, in which case you need the object's name
  - wrap the scope_exit in a gdb::optional, in which case you need the
    scope_exit's type in advance.

More details in the code comments.

gdb/ChangeLog:
2019-01-23  Pedro Alves  <palves@redhat.com>
    Andrew Burgess  <andrew.burgess@embecosm.com>

* common/forward-scope-exit.h: New file.

5 years agoIntroduce scope_exit
Pedro Alves [Wed, 23 Jan 2019 18:58:29 +0000 (18:58 +0000)]
Introduce scope_exit

This add a new template class scope_exit.  scope_exit is a
general-purpose scope guard that calls its exit function at the end of
the current scope.  A scope_exit may be canceled by calling the
"release" method.  The API is modeled on P0052R5 - Generic Scope Guard
and RAII Wrapper for the Standard Library, which is itself based on
Andrej Alexandrescu's ScopeGuard/SCOPE_EXIT.

The main advantage of scope_exit is avoiding writing single-use RAII
classes and its boilerplate.  Following patches will remove a few of
such classes.

There are two forms available:

 - The "make_scope_exit" form allows canceling the scope guard.  Use
   it like this:

     auto cleanup = make_scope_exit ( <function, function object, lambda> );
     ...
     cleanup.release (); // cancel

 - If you don't need to cancel the guard, you can use the SCOPE_EXIT
   macro, like this:

     SCOPE_EXIT { /* any code you like here. */ }

Note: scope_exit instances do not allocate anything on the heap.

gdb/ChangeLog:
2019-01-23  Pedro Alves  <palves@redhat.com>
    Andrew Burgess  <andrew.burgess@embecosm.com>
    Tom Tromey  <tom@tromey.com>

* common/scope-exit.h: New file.

5 years agoRename ESC -> ESC_PARENS
Pedro Alves [Wed, 23 Jan 2019 18:58:28 +0000 (18:58 +0000)]
Rename ESC -> ESC_PARENS

A following patch will include common/preprocessor.h in some .c file
that also includes readline.h, and that revealed a conflict -- ESC is
defined by readline.h as well (actually readline's chardefs.h) with a
completely unrelated meaning:

 #define ESC CTRL('[')

Rename our version to avoid the conflict.

gdb/ChangeLog:
2019-01-23  Pedro Alves  <palves@redhat.com>

* common/preprocessor.h (ESC): Rename to ...
(ESC_PARENS): ... this.
* common/valid-expr.h (CHECK_VALID_EXPR_1, CHECK_VALID_EXPR_2)
(CHECK_VALID_EXPR_3, CHECK_VALID_EXPR_4): Adjust.

5 years agoRemove a warning from symtab.c
Tom Tromey [Fri, 18 Jan 2019 14:45:01 +0000 (07:45 -0700)]
Remove a warning from symtab.c

When building symtab.c, I get:

../../binutils-gdb/gdb/language.h: In function ‘void print_symbol_info(search_domain, symbol*, int, const char*)’:
../../binutils-gdb/gdb/language.h:738:20: warning: ‘*((void*)& l +4)’ may be used uninitialized in this function [-Wmaybe-uninitialized]
       set_language (m_lang);
       ~~~~~~~~~~~~~^~~~~~~~
../../binutils-gdb/gdb/symtab.c:4613:41: note: ‘*((void*)& l +4)’ was declared here
   scoped_switch_to_sym_language_if_auto l (sym);
                                         ^

This is another instance of the std::optional problem, see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635.

However, it seemed straightforward and inexpensive to me to silence
this one, which is what this patch does.

gdb/ChangeLog
2019-01-23  Tom Tromey  <tom@tromey.com>

* language.h (class scoped_switch_to_sym_language_if_auto):
Initialize m_lang in both cases.

5 years agoAArch64: Ensure lwp info is created zeroed
Alan Hayward [Wed, 23 Jan 2019 11:31:40 +0000 (11:31 +0000)]
AArch64: Ensure lwp info is created zeroed

The code to not set empty hardware BPs/WPs on new threads will only work
if the newly allocated struct is empty.

Ensure the structure is created zeroed.

This patch removes the remaining racy behaviour on gdb.threads tests
when run on AArch64 Ubuntu.

gdb/ChangeLog:

* nat/aarch64-linux.c (aarch64_linux_new_thread): Replace XNEW
with XCNEW.

5 years agoUpdated translations for some of the binutils subdirectory.
Nick Clifton [Wed, 23 Jan 2019 10:26:54 +0000 (10:26 +0000)]
Updated translations for some of the binutils subdirectory.

5 years agold: Add LTO warning to --wrap documentation
Sebastian Huber [Mon, 14 Jan 2019 07:30:19 +0000 (08:30 +0100)]
ld: Add LTO warning to --wrap documentation

ld/

* ld.texi (--wrap): Add warning that LTO may make this feature
ineffective.

5 years agocorelow.c does not need sys/file.h
Tom Tromey [Mon, 21 Jan 2019 22:18:50 +0000 (15:18 -0700)]
corelow.c does not need sys/file.h

I did not see any reason that corelow.c should include <sys/file.h>.
The provided explanatory comment seems to be wrong.  This patch
removes the include.

2019-01-22  Tom Tromey  <tom@tromey.com>

* corelow.c: Do not include sys/file.h.

5 years agoInclude coff/sym.h from coff/ecoff.h
Tom Tromey [Mon, 21 Jan 2019 21:50:24 +0000 (14:50 -0700)]
Include coff/sym.h from coff/ecoff.h

coff/ecoff.h refers to some names defined in coff/sym.h.  Include the
latter from the former, so that users of the header don't need to know
this detail.

2019-01-22  Tom Tromey  <tom@tromey.com>

* coff/ecoff.h: Include coff/sym.h.

5 years agoInclude gdb_curses.h in tui-wingeneral.h
Tom Tromey [Mon, 21 Jan 2019 21:18:25 +0000 (14:18 -0700)]
Include gdb_curses.h in tui-wingeneral.h

tui-wingeneral.h uses WINDOW, which is defined by curses.  So, include
gdb_curses.h from tui-wingeneral.h.

2019-01-22  Tom Tromey  <tom@tromey.com>

* tui/tui-wingeneral.h: Include gdb_curses.h.

5 years agoRename "lines" parameter in source-cache.h
Tom Tromey [Mon, 21 Jan 2019 21:17:32 +0000 (14:17 -0700)]
Rename "lines" parameter in source-cache.h

A compile in the TUI somehow had "lines" defined as a macro.  This
caused a compile error when including source-cache.h after whatever
header did that.  I tracked this down to a #define in
/usr/include/term.h, so I just changed source-cache.h to avoid the
clash.

gdb/ChangeLog
2019-01-22  Tom Tromey  <tom@tromey.com>

* source-cache.h (class source_cache) <get_source_lines,
get_plain_source_lines, extract_lines>: Rename "lines" parameter.

5 years agoDeclare remote_target in remote-fileio.h
Tom Tromey [Mon, 21 Jan 2019 21:08:59 +0000 (14:08 -0700)]
Declare remote_target in remote-fileio.h

remote-fileio.h refers to remote_target, so forward-declare it.

gdb/ChangeLog
2019-01-22  Tom Tromey  <tom@tromey.com>

* remote-fileio.h (struct remote_target): Declare.

5 years agoDo not include py-ref.h in most files
Tom Tromey [Mon, 21 Jan 2019 20:49:06 +0000 (13:49 -0700)]
Do not include py-ref.h in most files

py-ref.h can really only be included from a specific spot in
python-internal.h.  The other includes are not useful, and cause
compilation errors if the includes are ever sorted.  So, remove these
includes.

Arguably, py-ref.h should simply not be a separate header.

gdb/ChangeLog
2019-01-22  Tom Tromey  <tom@tromey.com>

* python/py-arch.c: Do not include py-ref.h.
* python/py-bpevent.c: Do not include py-ref.h.
* python/py-cmd.c: Do not include py-ref.h.
* python/py-continueevent.c: Do not include py-ref.h.
* python/py-event.h: Do not include py-ref.h.
* python/py-evtregistry.c: Do not include py-ref.h.
* python/py-finishbreakpoint.c: Do not include py-ref.h.
* python/py-frame.c: Do not include py-ref.h.
* python/py-framefilter.c: Do not include py-ref.h.
* python/py-function.c: Do not include py-ref.h.
* python/py-infevents.c: Do not include py-ref.h.
* python/py-linetable.c: Do not include py-ref.h.
* python/py-objfile.c: Do not include py-ref.h.
* python/py-param.c: Do not include py-ref.h.
* python/py-prettyprint.c: Do not include py-ref.h.
* python/py-progspace.c: Do not include py-ref.h.
* python/py-symbol.c: Do not include py-ref.h.
* python/py-symtab.c: Do not include py-ref.h.
* python/py-type.c: Do not include py-ref.h.
* python/py-unwind.c: Do not include py-ref.h.
* python/py-utils.c: Do not include py-ref.h.
* python/py-value.c: Do not include py-ref.h.
* python/py-varobj.c: Do not include py-ref.h.
* python/py-xmethods.c: Do not include py-ref.h.
* python/python.c: Do not include py-ref.h.
* varobj.c: Do not include py-ref.h.

5 years agoUse "struct bcache" in objfiles.h
Tom Tromey [Mon, 21 Jan 2019 20:45:00 +0000 (13:45 -0700)]
Use "struct bcache" in objfiles.h

If objfiles.h is included after bcache.h, then the "bcache" function
will cause a compiler error because "bcache" will be seen as a
function, not a type.  Fix this error by using the "struct" keyword.

gdb/ChangeLog
2019-01-22  Tom Tromey  <tom@tromey.com>

* objfiles.h (struct objfile_per_bfd_storage): Use "struct"
keyword for bcache.

5 years agoRemove a comment in compile/compile-cplus-types.c
Tom Tromey [Mon, 21 Jan 2019 20:43:16 +0000 (13:43 -0700)]
Remove a comment in compile/compile-cplus-types.c

The include sorter can't handle multi-line comments on the same line
as a #include.  This patch removes the only such comment.

In general I think these sorts of comments do not provide much value:
more often than not, I find that the comment is obsolete in one way or
another, and so the include sorter removes them in most cases.

gdb/ChangeLog
2019-01-22  Tom Tromey  <tom@tromey.com>

* compile/compile-cplus-types.c: Remove a comment by #include.

5 years agoInclude compile-internal.h in gcc-c-plugin.h
Tom Tromey [Mon, 21 Jan 2019 20:42:36 +0000 (13:42 -0700)]
Include compile-internal.h in gcc-c-plugin.h

gcc-c-plugin.h refers to some types defined in compile-internal.h.
This patch changes the former to include the latter.

gdb/ChangeLog
2019-01-22  Tom Tromey  <tom@tromey.com>

* compile/gcc-c-plugin.h: Include compile-internal.h.

5 years agoAutomatic date update in version.in
GDB Administrator [Wed, 23 Jan 2019 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoRemove the EXTERN define from stabsread.h
Tom Tromey [Tue, 22 Jan 2019 08:58:59 +0000 (01:58 -0700)]
Remove the EXTERN define from stabsread.h

This removes the EXTERN define from stabsread.h.  This is the only
spot that still uses this approach, and it interfered with sorting the
includes in stabsread.c.

Tested by rebuilding.

gdb/ChangeLog
2019-01-22  Tom Tromey  <tom@tromey.com>

* stabsread.c (EXTERN): Do not define.
(symnum, next_symbol_text_func, processing_gcc_compilation)
(within_function, global_sym_chain, global_stabs)
(previous_stab_code, this_object_header_files)
(n_this_object_header_files)
(n_allocated_this_object_header_files): Define.
* stabsread.h (EXTERN): Never define.  Use "extern".

5 years agoAutomatic date update in version.in
GDB Administrator [Tue, 22 Jan 2019 00:00:30 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoFix leak in event-top.c history expansion
Philippe Waroquiers [Sun, 20 Jan 2019 15:59:00 +0000 (16:59 +0100)]
Fix leak in event-top.c history expansion

E.g. in gdb.base/default.exp, valgrind detects leaks such as
==17663== 1,438 bytes in 101 blocks are definitely lost in loss record 2,804 of 2,884
==17663==    at 0x4C2BE6D: malloc (vg_replace_malloc.c:309)
==17663==    by 0x418A17: xmalloc (common-utils.c:44)
==17663==    by 0x4E6F19C: history_expand (histexpand.c:1061)
==17663==    by 0x4B4490: handle_line_of_input(buffer*, char const*, int, char const*) (event-top.c:685)
==17663==    by 0x4B4562: command_line_handler(std::unique_ptr<char, gdb::xfree_deleter<char> >&&) (event-top.c:753)
...

Fix the leak by using an unique_xmalloc_ptr for history_value.

gdb/ChangeLog
2019-01-22  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* event-top.c (handle_line_of_input): use unique_xmalloc_ptr for
history_value.

5 years agoRemove duplicate or commented-out #includes
Tom Tromey [Sat, 19 Jan 2019 21:08:48 +0000 (14:08 -0700)]
Remove duplicate or commented-out #includes

I wrote a little script to detect duplicate or commented-out #includes
and ran it on gdb.  This patch is the result.  Tested by rebuilding.

gdb/ChangeLog
2019-01-21  Tom Tromey  <tom@tromey.com>

* ui-out.c: Fix includes.
* tui/tui-source.c: Fix includes.
* target.c: Fix includes.
* remote.c: Fix includes.
* regcache.c: Fix includes.
* python/py-block.c: Fix includes.
* printcmd.c: Fix includes.
* or1k-tdep.c: Fix includes.
* mi/mi-main.c: Fix includes.
* m32r-tdep.c: Fix includes.
* csky-tdep.c: Fix includes.
* compile/compile-cplus-types.c: Fix includes.
* cli/cli-interp.c: Fix includes.

gdb/gdbserver/ChangeLog
2019-01-21  Tom Tromey  <tom@tromey.com>

* tracepoint.c: Fix includes.
* remote-utils.c: Fix includes.
* linux-x86-low.c: Fix includes.

gdb/stubs/ChangeLog
2019-01-21  Tom Tromey  <tom@tromey.com>

* ia64vms-stub.c: Fix includes.

5 years agoFix leak in splay-tree
Tom Tromey [Mon, 21 Jan 2019 15:41:28 +0000 (08:41 -0700)]
Fix leak in splay-tree

Philippe Waroquiers noticed a memory leak in gdb, which he tracked
down to a bug in splay-tree.  splay_tree_remove does not call the
`delete_key' function when it removes the old node; but it should.

I looked at every splay tree in GCC and there is only one that passes
a non-NULL delete function -- the one in lto.c.  That file does not
call splay_tree_remove.  So, I think this is safe to check in.

I re-ran the LTO tests to double check.

libiberty/
* splay-tree.c (splay_tree_remove): Delete the key if necessary.

5 years agoAArch64 AAPCS: Empty structs have non zero size in C++
Alan Hayward [Mon, 21 Jan 2019 15:51:49 +0000 (15:51 +0000)]
AArch64 AAPCS: Empty structs have non zero size in C++

When gdb.base/infcall-nested-structs.c is complied as C++, the compiler
will not pass structs containing empty structs via float arguments.
This is because structs in C++ have a minimum size of 1, causing padding
in the struct once compiled.  The AAPCS does not allow structs with
padding to be passed in float arguments.

Add padding checks to AArch64 and add C++ compile variant to the test.

Some of the tests fail on X86_64. This has been raised as bug gdb/24104.

gdb/ChangeLog:

* aarch64-tdep.c (aapcs_is_vfp_call_or_return_candidate_1): Check
for padding.

gdb/testsuite/ChangeLog:

* gdb.base/infcall-nested-structs.exp: Test C++ in addition to C.