Commit Graph

281 Commits

Author SHA1 Message Date
Simon Marchi a1cd91dc2f gdbserver/Makefile.in: Remove ADD_DEPS
ADD_DEPS is defined nowhere, so I presume it's not useful.  If I'm wrong
and this is actually used, there should be a comment explaining where it
comes from.

gdb/gdbserver/ChangeLog:

	* Makefile.in: Remove references to $(ADD_DEPS).
2018-09-16 20:34:56 -04:00
Sergio Durigan Junior c7ab0aef11 Implement IPv6 support for GDB/gdbserver
This patch implements IPv6 support for both GDB and gdbserver.  Based
on my research, it is the fourth attempt to do that since 2006.  Since
I used ideas from all of the previous patches, I also added their
authors's names on the ChangeLogs as a way to recognize their
efforts.  For reference sake, you can find the previous attempts at:

  https://sourceware.org/ml/gdb-patches/2006-09/msg00192.html

  https://sourceware.org/ml/gdb-patches/2014-02/msg00248.html

  https://sourceware.org/ml/gdb-patches/2016-02/msg00226.html

The basic idea behind the patch is to start using the new
'getaddrinfo'/'getnameinfo' calls, which are responsible for
translating names and addresses in a protocol-independent way.  This
means that if we ever have a new version of the IP protocol, we won't
need to change the code again (or, at least, won't have to change the
majority of the code).

The function 'getaddrinfo' returns a linked list of possible addresses
to connect to.  Dealing with multiple addresses proved to be a hard
task with the current TCP auto-retry mechanism implemented on
ser-tcp:net_open.  For example, when gdbserver listened only on an
IPv4 socket:

  $ ./gdbserver --once 127.0.0.1:1234 ./a.out

and GDB was instructed to try to connect to both IPv6 and IPv4
sockets:

  $ ./gdb -ex 'target extended-remote localhost:1234' ./a.out

the user would notice a somewhat big delay before GDB was able to
connect to the IPv4 socket.  This happened because GDB was trying to
connect to the IPv6 socket first, and had to wait until the connection
timed out before it tried to connect to the IPv4 socket.

For that reason, I had to rewrite the main loop and implement a new
method for handling multiple connections.  After some discussion,
Pedro and I agreed on the following algorithm:

  1) For each entry returned by 'getaddrinfo', we try to open a socket
  and connect to it.

  2.a) If we have a successful 'connect', we just use that connection.

  2.b) If we don't have a successfull 'connect', but if we've got a
  ECONNREFUSED (meaning the the connection was refused), we keep track
  of this fact by using a flag.

  2.c) If we don't have a successfull 'connect', but if we've got a
  EINPROGRESS (meaning that the connection is in progress), we perform
  a 'select' call on the socket until we have a result (either a
  successful connection, or an error on the socket).

  3) If tcp_auto_retry is true, and we haven't gotten a successful
  connection, and at least one of our attempts failed with
  ECONNREFUSED, then we wait a little bit (i.e., call
  'wait_for_connect'), check to see if there was a
  timeout/interruption (in which case we bail out), and then go back
  to (1).

After multiple tests, I was able to connect without delay on the
scenario described above, and was also able to connect in all other
types of scenarios.

I also implemented some hostname parsing functions (along with their
corresponding unit tests) which are used to help GDB and gdbserver to
parse hostname strings provided by the user.  These new functions are
living inside common/netstuff.[ch].  I've had to do that since IPv6
introduces a new URL scheme, which defines that square brackets can be
used to enclose the host part and differentiate it from the
port (e.g., "[::1]:1234" means "host ::1, port 1234").  I spent some
time thinking about a reasonable way to interpret what the user wants,
and I came up with the following:

  - If the user has provided a prefix that doesn't specify the protocol
    version (i.e., "tcp:" or "udp:"), or if the user has not provided
    any prefix, don't make any assumptions (i.e., assume AF_UNSPEC when
    dealing with 'getaddrinfo') *unless* the host starts with "[" (in
    which case, assume it's an IPv6 host).

  - If the user has provided a prefix that does specify the protocol
    version (i.e., "tcp4:", "tcp6:", "udp4:" or "udp6:"), then respect
    that.

This method doesn't follow strictly what RFC 2732 proposes (that
literal IPv6 addresses should be provided enclosed in "[" and "]")
because IPv6 addresses still can be provided without square brackets
in our case, but since we have prefixes to specify protocol versions I
think this is not an issue.

Another thing worth mentioning is the new 'GDB_TEST_SOCKETHOST'
testcase parameter, which makes it possible to specify the
hostname (without the port) to be used when testing GDB and
gdbserver.  For example, to run IPv6 tests:

  $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp6:[::1]'

Or, to run IPv4 tests:

  $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp4:127.0.0.1'

This required a few changes on the gdbserver-base.exp, and also a
minimal adjustment on gdb.server/run-without-local-binary.exp.

Finally, I've implemented a new testcase,
gdb.server/server-connect.exp, which is supposed to run on the native
host and perform various "smoke tests" using different connection
methods.

This patch has been regression-tested on BuildBot and locally, and
also built using a x86_64-w64-mingw32 GCC, and no problems were found.

gdb/ChangeLog:
2018-07-11  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Paul Fertser  <fercerpav@gmail.com>
	    Tsutomu Seki  <sekiriki@gmail.com>
	    Pedro Alves  <palves@redhat.com>

	* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
	'unittests/parse-connection-spec-selftests.c'.
	(COMMON_SFILES): Add 'common/netstuff.c'.
	(HFILES_NO_SRCDIR): Add 'common/netstuff.h'.
	* NEWS (Changes since GDB 8.2): Mention IPv6 support.
	* common/netstuff.c: New file.
	* common/netstuff.h: New file.
	* ser-tcp.c: Include 'netstuff.h' and 'wspiapi.h'.
	(wait_for_connect): Update comment.  New parameter
	'gdb::optional<int> sock' instead of 'struct serial *scb'.
	Use 'sock' directly instead of 'scb->fd'.
	(try_connect): New function, with code from 'net_open'.
	(net_open): Rewrite main loop to deal with multiple
	sockets/addresses.  Handle IPv6-style hostnames; implement
	support for IPv6 connections.
	* unittests/parse-connection-spec-selftests.c: New file.

gdb/gdbserver/ChangeLog:
2018-07-11  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Paul Fertser  <fercerpav@gmail.com>
	    Tsutomu Seki  <sekiriki@gmail.com>

	* Makefile.in (SFILES): Add '$(srcdir)/common/netstuff.c'.
	(OBS): Add 'common/netstuff.o'.
	(GDBREPLAY_OBS): Likewise.
	* gdbreplay.c: Include 'wspiapi.h' and 'netstuff.h'.
	(remote_open): Implement support for IPv6
	connections.
	* remote-utils.c: Include 'netstuff.h', 'filestuff.h'
	and 'wspiapi.h'.
	(handle_accept_event): Accept connections from IPv6 sources.
	(remote_prepare): Handle IPv6-style hostnames; implement
	support for IPv6 connections.
	(remote_open): Implement support for printing connections from
	IPv6 sources.

gdb/testsuite/ChangeLog:
2018-07-11  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Paul Fertser  <fercerpav@gmail.com>
	    Tsutomu Seki  <sekiriki@gmail.com>

	* README (Testsuite Parameters): Mention new 'GDB_TEST_SOCKETHOST'
	parameter.
	* boards/native-extended-gdbserver.exp: Do not set 'sockethost'
	by default.
	* boards/native-gdbserver.exp: Likewise.
	* gdb.server/run-without-local-binary.exp: Improve regexp used
	for detecting when a remote debugging connection succeeds.
	* gdb.server/server-connect.exp: New file.
	* lib/gdbserver-support.exp (gdbserver_default_get_comm_port):
	Do not prefix the port number with ":".
	(gdbserver_start): New global GDB_TEST_SOCKETHOST.  Implement
	support for detecting and using it.  Add '$debughost_gdbserver'
	to the list of arguments used to start gdbserver.  Handle case
	when gdbserver cannot resolve a network name.

gdb/doc/ChangeLog:
2018-07-11  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Paul Fertser  <fercerpav@gmail.com>
	    Tsutomu Seki  <sekiriki@gmail.com>

	* gdb.texinfo (Remote Connection Commands): Add explanation
	about new IPv6 support.  Add new connection prefixes.
2018-07-11 19:41:31 -04:00
Alan Hayward e9902bfc28 Ptrace support for Aarch64 SVE
Add support for reading and writing registers for Aarch64 SVE.

We need to support the cases where the kernel only gives us a
fpsimd structure. This occurs when there is no active SVE state
in the kernel (for example, after starting a new process).

Added checks to make sure the vector length has not changed whilst
the process is running.

gdb/
	* aarch64-linux-nat.c (fetch_sveregs_from_thread): New function.
	(store_sveregs_to_thread): Likewise.
	(aarch64_linux_fetch_inferior_registers): Check for SVE.
	(aarch64_linux_store_inferior_registers): Likewise.
	* nat/aarch64-sve-linux-ptrace.c (aarch64_sve_get_sveregs): New
	function.
	(aarch64_sve_regs_copy_to_regcache): Likewise.
	(aarch64_sve_regs_copy_from_regcache): Likewise.
	* nat/aarch64-sve-linux-ptrace.h (aarch64_sve_get_sveregs): New
	declaration.
	(aarch64_sve_regs_copy_to_regcache): Likewise.
	(aarch64_sve_regs_copy_from_regcache): Likewise.
	(sve_context): Structure from Linux headers.
	(SVE_SIG_ZREGS_SIZE): Define from Linux headers.
	(SVE_SIG_ZREG_SIZE): Likewise.
	(SVE_SIG_PREG_SIZE): Likewise.
	(SVE_SIG_FFR_SIZE): Likewise.
	(SVE_SIG_REGS_OFFSET): Likewise.
	(SVE_SIG_ZREGS_OFFSET): Likewise.
	(SVE_SIG_ZREG_OFFSET): Likewise.
	(SVE_SIG_ZREGS_SIZE): Likewise.
	(SVE_SIG_PREGS_OFFSET): Likewise.
	(SVE_SIG_PREG_OFFSET): Likewise.
	(SVE_SIG_PREGS_SIZE): Likewise.
	(SVE_SIG_FFR_OFFSET): Likewise.
	(SVE_SIG_REGS_SIZE): Likewise.
	(SVE_SIG_CONTEXT_SIZE): Likewise.
	(SVE_PT_REGS_MASK): Likewise.
	(SVE_PT_REGS_FPSIMD): Likewise.
	(SVE_PT_REGS_SVE): Likewise.
	(SVE_PT_VL_INHERIT): Likewise.
	(SVE_PT_VL_ONEXEC): Likewise.
	(SVE_PT_REGS_OFFSET): Likewise.
	(SVE_PT_FPSIMD_OFFSET): Likewise.
	(SVE_PT_FPSIMD_SIZE): Likewise.
	(SVE_PT_SVE_ZREG_SIZE): Likewise.
	(SVE_PT_SVE_PREG_SIZE): Likewise.
	(SVE_PT_SVE_FFR_SIZE): Likewise.
	(SVE_PT_SVE_FPSR_SIZE): Likewise.
	(SVE_PT_SVE_FPCR_SIZE): Likewise.
	(__SVE_SIG_TO_PT): Likewise.
	(SVE_PT_SVE_OFFSET): Likewise.
	(SVE_PT_SVE_ZREGS_OFFSET): Likewise.
	(SVE_PT_SVE_ZREG_OFFSET): Likewise.
	(SVE_PT_SVE_ZREGS_SIZE): Likewise.
	(SVE_PT_SVE_PREGS_OFFSET): Likewise.
	(SVE_PT_SVE_PREG_OFFSET): Likewise.
	(SVE_PT_SVE_PREGS_SIZE): Likewise.
	(SVE_PT_SVE_FFR_OFFSET): Likewise.
	(SVE_PT_SVE_FPSR_OFFSET): Likewise.
	(SVE_PT_SVE_FPCR_OFFSET): Likewise.
	(SVE_PT_SVE_SIZE): Likewise.
	(SVE_PT_SIZE): Likewise.
	(HAS_SVE_STATE): New define.

gdbserver/
	* Makefile.in: Add aarch64-sve-linux-ptrace.c.
2018-06-18 10:06:53 +01:00
Pedro Alves 03349c9345 Make gdbreplay use more common routines
This makes gdbreplay share a bit more code with gdbserver, and paves
the way to share more in future.  Including common-defs.h pulls in
defines and headers that gdb and gdbserver assume are always
defined/available too, such as for example _(), ansidecl.h or a set of
system headers.  Including that revealed (static vs extern conflict)
gdbreplay had a local copy of perror_with_name (which exited directly
instead of throwing an error).  So I removed gdbreplay's local copy,
and then added enough .o files until gdbreplay linked successfully.

Also, use xstrdup instead of strdup.

gdb/gdbserver/ChangeLog:
2018-06-08  Pedro Alves  <palves@redhat.com>

	* Makefile.in (GDBREPLAY_OBS): Add common/cleanups.o,
	common/common-exceptions.o, common/common-utils.o,
	common/errors.o, common/print-utils.o and utils.o.
	* gdbreplay.c: Include "common-defs.h" instead of the two
	'config.h's here.  Don't include stdio.h, errno.h, stdlib.h,
	string.h or alloca.h.
	(perror_with_name): Delete.
	(remote_open): Use xstrdup instead of strdup.
	(main): Rename to ...
	(captured_main): ... this.
	(main): New.
2018-06-08 20:48:28 +01:00
Pedro Franco de Carvalho bd64614eb7 [PowerPC] Consolidate linux target description selection
Share target description declarations and selection among ppc linux
native targets, core files, gdbserver and IPA.

To avoid complicated define guards, gdbserver and IPA now have
declarations for all descriptions, including 64-bit generated
descriptions when compiled in 32-bit mode. These have always been
linked into the gdbserver and IPA binaries. Because they might be
uninitialized, the selection function checks that the selected
description is initialized.

gdb/ChangeLog:
2018-05-22  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

	* arch/ppc-linux-common.c: New file.
	* arch/ppc-linux-common.h: New file.
	* arch/ppc-linux-tdesc.h: New file.
	* configure.tgt (powerpc*-*-linux*): Add arch/ppc-linux-common.o.
	* Makefile.in (ALL_TARGET_OBS): Add arch/ppc-linux-common.o.
	(HFILES_NO_SRCDIR): Add arch/ppc-linux-common.h and
	arch/ppc-linux-tdesc.h.
	* ppc-linux-nat.c: Include arch/ppc-linux-common.h and
	arch/ppc-linux-tdesc.h.
	(ppc_linux_nat_target::read_description): Remove target
	description matching code. Fill a ppc_linux_features struct and
	call ppc_linux_match_description with it. Move comment about ISA
	2.05 to ppc-linux-common.c.
	* ppc-linux-tdep.c: Include arch/ppc-linux-common.h and
	arch/ppc-linux-tdesc.h.
	(ppc_linux_core_read_description): Remove target description
	matching code. Fill a ppc_linux_features struct and call
	ppc_linux_match_description with it.
	* ppc-linux-tdep.h (tdesc_powerpc_32l, tdesc_powerpc_64l)
	(tdesc_powerpc_altivec32l, tdesc_powerpc_altivec64l)
	(tdesc_powerpc_cell32l, tdesc_powerpc_cell64l)
	(tdesc_powerpc_vsx32l, tdesc_powerpc_vsx64l)
	(tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_64l)
	(tdesc_powerpc_isa205_altivec32l, tdesc_powerpc_isa205_altivec64l)
	(tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_isa205_vsx64l)
	(tdesc_powerpc_e500l): Remove.

gdb/gdbserver/ChangeLog:
2018-05-22  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

	* configure.srv (srv_tgtobj): Add arch/ppc-linux-common.o.
	* Makefile.in (SFILES): Add arch/ppc-linux-common.c.
	* linux-ppc-tdesc.h: Rename to linux-ppc-tdesc-init.h.
	* linux-ppc-tdesc-init.h (tdesc_powerpc_32l, tdesc_powerpc_64l)
	(tdesc_powerpc_altivec32l, tdesc_powerpc_altivec64l)
	(tdesc_powerpc_cell32l, tdesc_powerpc_cell64l)
	(tdesc_powerpc_vsx32l, tdesc_powerpc_vsx64l)
	(tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_64l)
	(tdesc_powerpc_isa205_altivec32l, tdesc_powerpc_isa205_altivec64l)
	(tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_isa205_vsx64l)
	(tdesc_powerpc_e500l): Remove.
	* linux-ppc-ipa.c: Include arch/ppc-linux-tdesc.h and
	linux-ppc-tdesc-init.h. Don't include linux-ppc-tdesc.h.
	* linux-ppc-low.c: Include arch/ppc-linux-common.h,
	arch/ppc-linux-tdesc.h, and linux-ppc-tdesc-init.h. Don't include
	linux-ppc-tdesc.h.
	(ppc_arch_setup): Remove target description matching code. Fill a
	ppc_linux_features struct and call ppc_linux_match_description
	with it.
2018-05-22 11:52:02 -03:00
Simon Marchi f31c089e78 Fix dependency tracking in gdbserver subdirectories
The dependency tracking (the thing that knows which source file included
which other source file during last build to know what to rebuild when
an included file changes) is broken for gdbserver subdirectories (arch
and common).

The dependency tracking files are created in the form

  arch/.deps/i386.Po

but we try to include

  .deps/arch/i386.Po

An easy smoke test is too "touch" the gdb/features/i386/32bit-core.c
file in the source directory and try to rebuild gdbserver.  This file is
included by gdb/arch/i386.c, so it should cause
gdb/gdbserver/arch/i386.o in the build directory to be rebuilt.  It
currently isn't rebuilt, but is with this patch applied.

This patch copies the technique used in GDB to transform the dep file
paths to the proper form.

Also, while testing using the depcomp method of dependency tracking (by
just hacking the condition), I noticed that depcomp was not found.  The
path to depcomp seems to be missing a "..".

gdb/gdbserver/ChangeLog:

	* Makefile.in (depcomp): Add "..".
	(all_deps_files): New and use it.
2018-04-19 13:23:32 -04:00
Alan Hayward ea3e7d7179 Commonise tdesc_reg and makes use of it in gdbserver tdesc
gdb/
	* Makefile.in: Add arch/tdesc.c
	* common/tdesc.c: New file.
	* common/tdesc.h (tdesc_element_visitor): Move to here.
	(tdesc_element): Likewise.
	(tdesc_reg): Likewise.
	(tdesc_reg_up): Likewise.
	* regformats/regdef.h (reg): Add offset to constructors.
	* target-descriptions.c (tdesc_element_visitor): Move from here.
	(tdesc_element): Likewise.
	(tdesc_reg): Likewise.
	(tdesc_reg_up): Likewise.

gdbserver/
	* Makefile.in: Add common/tdesc.c
	* tdesc.c (init_target_desc): init all reg_defs from register vector.
	(tdesc_create_reg): Create tdesc_reg.
	* tdesc.h (tdesc_feature): Add register vector.
2018-04-18 14:00:30 +01:00
Simon Marchi 39be3c7e98 Add silent Makefile rules
Many projects (e.g. the Linux kernel) and build systems use "silent"
rules, which means that they'll only print a summary of what's being
done instead of printing all the detailed command lines.  While chatting
on the #gdb IRC channel, I realized a few people (including me) thought
it would be nice to have it in GDB too.

The idea is that too much text is not useful, the important information
gets lost.  If there's only the essential information, it's more likely
to be useful.  Most of the time, when I look at the build output, it's
to see how it's progressing.  By just printing a brief summary of each
operation, I can easily spot what's currently being compiled and
therefore how the build progresses (with time you know the order in
which files are compiled almost by heart).

As with other projects (Linux, automake-based things, probably others),
it's possible to print the complete command lines by passing V=1 to make
(or any other non-zero value).

I had one hesitation about this: when people report build failures, we
are more likely to miss the full compile command line.  We'll probably
sometimes need to ask people to include the build log with "make V=1".
I don't think it's a big downside, if other projects the size of the
Linux kernel can live with it, I'm sure we can too.

gdb/ChangeLog:

	* silent-rules.mk: New.
	* Makefile.in: Include silent-rules.mk
	(srcdir, VPATH, top_srcdir): Move up.
	(COMPILE): Add ECHO_CXX.
	(test-cp-name-parser$(EXEEXT)): Add ECHO_CXXLD.
	(init.c): Add ECHO_INIT_C.
	(gdb$(EXEEXT)): Add SILENCE and ECHO_CXXLD.
	(version.c): Add ECHO_GEN.
	(printcmd.o): Add ECHO_CXX.
	(target-float.o): Add ECHO_CXX.
	(ada-exp.o): Add ECHO_CXX.
	(stamp-xml): Add SILENCE and ECHO_GEN_XML_BUILTIN.
	(insight$(EXEEXT)): Add ECHO_CXXLD.
	* gnulib/configure.ac: Add AM_SILENT_RULES.
	* gnulib/aclocal.m4: Re-generate.
	* gnulib/configure: Re-generate.
	* gnulib/import/Makefile.in: Re-generate.

gdb/gdbserver/ChangeLog:

	* Makefile.in: Include silent-rules.mk.
	(srcdir, abs_top_srcdir, abs_srcdir, VPATH): Move up.
	(COMPILE): Add ECHO_CXX.
	(gdbserver$(EXEEXT)): Add SILENCE and ECHO_CXXLD.
	(gdbreplay$(EXEEXT)): Add SILENCE and ECHO_CXXLD.
	($(IPA_LIB)): Add SILENCE and ECHO_CXXLD.
	(version-generated.c): Add ECHO_GEN.
	(stamp-xml): Add SILENCE and ECHO_GEN_XML_BUILTIN_GENERATED.
	(IPAGENT_COMPILE): Add ECHO_CXX.
	(%-generated.c): Add ECHO_REGDAT.
2018-03-16 16:30:25 -04:00
Sergio Durigan Junior b4987c956d Create new common/pathstuff.[ch]
This commit moves the path manipulation routines found on utils.c to a
new common/pathstuff.c, and updates the Makefile.in's accordingly.
The routines moved are "gdb_realpath", "gdb_realpath_keepfile" and
"gdb_abspath".

This will be needed because gdbserver will have to call "gdb_abspath"
on my next patch, which implements a way to expand the path of the
inferior provided by the user in order to allow specifying just the
binary name when starting gdbserver, like:

  $ gdbserver :1234 a.out

With the recent addition of the startup-with-shell feature on
gdbserver, this scenario doesn't work anymore if the user doesn't have
the current directory listed in the PATH variable.

I had to do a minor adjustment on "gdb_abspath" because we don't have
access to "tilde_expand" on gdbserver, so now the function is using
"gdb_tilde_expand" instead.  Otherwise, the code is the same.

Regression tested on the BuildBot, without regressions.

gdb/ChangeLog:
2018-02-28  Sergio Durigan Junior  <sergiodj@redhat.com>

	* Makefile.in (COMMON_SFILES): Add "common/pathstuff.c".
	(HFILES_NO_SRCDIR): Add "common/pathstuff.h".
	* auto-load.c: Include "common/pathstuff.h".
	* common/common-def.h (current_directory): Move here.
	* common/gdb_tilde_expand.c (gdb_tilde_expand_up): New
	function.
	* common/gdb_tilde_expand.h (gdb_tilde_expand_up): New
	prototype.
	* common/pathstuff.c: New file.
	* common/pathstuff.h: New file.
	* compile/compile.c: Include "common/pathstuff.h".
	* defs.h (current_directory): Move to "common/common-defs.h".
	* dwarf2read.c: Include "common/pathstuff.h".
	* exec.c: Likewise.
	* guile/scm-safe-call.c: Likewise.
	* linux-thread-db.c: Likewise.
	* main.c: Likewise.
	* nto-tdep.c: Likewise.
	* objfiles.c: Likewise.
	* source.c: Likewise.
	* symtab.c: Likewise.
	* utils.c: Include "common/pathstuff.h".
	(gdb_realpath): Move to "common/pathstuff.c".
	(gdb_realpath_keepfile): Likewise.
	(gdb_abspath): Likewise.
	* utils.h (gdb_realpath): Move to "common/pathstuff.h".
	(gdb_realpath_keepfile): Likewise.
	(gdb_abspath): Likewise.

gdb/gdbserver/ChangeLog:
2018-02-28  Sergio Durigan Junior  <sergiodj@redhat.com>

	* Makefile.in (SFILES): Add "$(srcdir)/common/pathstuff.c".
	(OBJS): Add "pathstuff.o".
	* server.c (current_directory): New global variable.
	(captured_main): Initialize "current_directory".
2018-02-28 11:34:39 -05:00
Alan Hayward a543c5ca7c Fix make 3.81 build errors
gdbserver/
	* Makefile.in: Switch order of make rules.
2018-02-20 10:04:30 +00:00
Alan Hayward b5884fa710 Add common/ dir in build directories
gdb/
	* Makefile.in: (COMMON_SFILES): Add common/*.c files.
	(SFILES): Remove common/*.c files.
	(COMMON_OBS): Remove some *.o files built from common/*.c files.
	* common/common.host: Add common reference.
	* configure.ac: Likewise.
	* configure: Regenerate.

gdbserver/
	* Makefile.in: Add common directory in build.
	* configure.ac: Add common reference.
	* configure: Regenerate.
2018-02-19 09:37:24 +00:00
Yao Qi 605fd3c659 Fix GDBserver build failure when $development is false
When we set bfd/development.sh:$development to false, GDBserver failed to
build,

selftest.o: In function `selftests::run_tests(char const*)':
binutils-gdb/gdb/gdbserver/../common/selftest.c:97:undefined reference to `selftests::reset()'
collect2: error: ld returned 1 exit status

selftest.o shouldn't be compiled and linked when $development is false.
With this patch, in release mode, GDBserver doesn't nothing with option
--selftest,

$ ./gdbserver --selftest=foo
Selftests are not available in a non-development build.
$ ./gdbserver --selftest
Selftests are not available in a non-development build.

gdb/gdbserver:

2018-01-08  Yao Qi  <yao.qi@linaro.org>
	    Simon Marchi  <simon.marchi@ericsson.com>

	* Makefile.in (OBS): Remove selftest.o.
	* configure.ac: Set srv_selftest_objs if $development is true.
	(GDBSERVER_DEPFILES): Append $srv_selftest_objs.
	* configure: Re-generated.
	* server.c (captured_main): Wrap variable selftest_filter with
	GDB_SELF_TEST.

gdb/testsuite:

2018-01-08  Simon Marchi  <simon.marchi@ericsson.com>

	* gdb.server/unittest.exp: Match the output in non-development
	mode.
2018-01-08 10:09:33 +00:00
Joel Brobecker e2882c8578 Update copyright year range in all GDB files
gdb/ChangeLog:

        Update copyright year range in all GDB files
2018-01-02 07:38:06 +04:00
Alan Hayward a602f924c8 Better make rule for arch/ files built for IPA
gdbserver/
	* Makefile.in: Update arch rules.
	* configure.srv: Explicitly mark arch/ files.
2017-11-15 09:59:12 +00:00
Yao Qi 7a7cdfa04b [GDBserver] Move aarch64-insn.o to arch/ and remove one Makefile rule
gdb/gdbserver:

2017-10-17  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in: Remove one rule.
	* configure.srv: Rename aarch64-insn.o with arch/aarch64-insn.o.
2017-10-17 12:12:04 +01:00
Yao Qi 60d6cfc99e [GDBserver] Replicate src dir in build dir
Similar to f38307f5 (Replicate src dir in build dir), this patch change
configure and Makefile to generate object files in arch/ directory.

gdb/gdbserver:

2017-10-17  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (CONFIG_SRC_SUBDIR): New variable.
	(clean): Remove .o files in CONFIG_SRC_SUBDIR.
	(distclean): Remove DEPDIR in CONFIG_SRC_SUBDIR.
	(arch-i386.o, arch-amd64.o): Remove rules.
	(arch/%.o): New rule.
	Update POSTCOMPILE and COMPILE.pre.
	* configure.ac: Invoke AC_CONFIG_COMMANDS.
	* configure: Re-generated.
	* configure.srv: Replace arch-i386.o with arch/i386.o.
	Replace arch-amd64.o with arch/amd64.o.
2017-10-17 12:12:04 +01:00
Sergio Durigan Junior 7da0a88674 Introduce gdb_tilde_expand
Currently, whenever we want to handle paths provided by the user and
perform tilde expansion on GDB, we rely on "tilde_expand", which comes
from readline.  This was enough for our use cases so far, but the
situation will change when we start dealing with paths on gdbserver as
well, which is what the next patches implement.

Unfortunately it is not possible to use "tilde_expand" in this case
because gdbserver doesn't use readline.  For that reason I decided to
implement a new "gdb_tilde_expand" function, which is basically a
wrapper for "glob" and its GNU extension, GLOB_TILDE_CHECK.  With the
import of the "glob" module from gnulib, we're sure that "glob" always
supports this extension.

gdb/ChangeLog:
2017-10-04  Sergio Durigan Junior  <sergiodj@redhat.com>

	* Makefile.in (SFILES): Add gdb_tilde_expand.c.
	(HFILES_NO_SRCDIR): Add gdb_tilde_expand.h.
	(COMMON_OBS): Add gdb_tilde_expand.o.
	* common/gdb_tilde_expand.c: New file.
	* common/gdb_tilde_expand.h: Likewise.

gdb/gdbserver/ChangeLog:
2017-10-04  Sergio Durigan Junior  <sergiodj@redhat.com>

	* Makefile.in (SFILES): Add $(srcdir)/common/gdb_tilde_expand.c.
	(OBS): Add gdb_tilde_expand.o.
2017-10-04 01:57:29 -04:00
Yao Qi b4570e4b30 Convert amd64-linux target descriptions
This patch changes amd64-linux target descriptions so that they can be
dynamically generated in both GDB and GDBserver.

gdb/gdbserver:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (arch-amd64.o): New rule.
	* configure.srv: Append arch-amd64.o.
	* linux-amd64-ipa.c: Include common/x86-xstate.h.
	(get_ipa_tdesc): Call amd64_linux_read_description.
	(initialize_low_tracepoint): Don't call init_registers_x32_XXX
	and init_registers_amd64_XXX.
	* linux-x86-low.c (x86_linux_read_description): Call
	amd64_linux_read_description.
	(x86_get_ipa_tdesc_idx): Call amd64_get_ipa_tdesc_idx.
	(initialize_low_arch): Don't call init_registers_x32_XXX and
	init_registers_amd64_XXX.
	* linux-x86-tdesc-selftest.c: Declare init_registers_amd64_XXX
	and tdesc_amd64_XXX.
	[__x86_64__] (amd64_tdesc_test): New function.
	(initialize_low_tdesc) [__x86_64__]: Call init_registers_x32_XXX
	and init_registers_amd64_XXX.
	* linux-x86-tdesc.c: Include arch/amd64.h.
	(xcr0_to_tdesc_idx): New function.
	(i386_linux_read_description): New function.
	(amd64_get_ipa_tdesc_idx): New function.
	* linux-x86-tdesc.h (amd64_get_ipa_tdesc_idx): Declare.
	(amd64_get_ipa_tdesc): Declare.

gdb:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* amd64-linux-tdep.c: Include arch/amd64.h.  Don't include
	features/i386/*.c.
	(amd64_linux_read_description): Call
	amd64_create_target_description.
	* arch/amd64.c: New file.
	* arch/amd64.h: New file.
	* configure.tgt (x86_64-*-linux*): Append amd64.o.
	* Makefile.in (ALL_64_TARGET_OBS): Append amd64.o.
2017-09-05 09:54:54 +01:00
Yao Qi 5f035c0716 Share i386-linux target description between GDB and GDBserver
The code on creating i386-linux target descriptions are quite similar
between GDB and GDBserver, so this patch moves them into a shared file
arch/i386.c.  I didn't name it as i386-linux.c, because I want to reuse it
to create other i386 non-linux target descriptions later.

gdb:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (ALL_TARGET_OBS): Add i386.o.
	(SFILES): Add arch/i386.c.
	(HFILES_NO_SRCDIR): Add arch/i386.h.
	* arch/i386.c: New file.
	* arch/i386.h: New file.
	* arch/tdesc.h (allocate_target_description): Declare.
	(set_tdesc_architecture): Declare.
	(set_tdesc_osabi): Declare.
	* configure.tgt (i[34567]86-*-linux*): Add i386.o.
	* i386-linux-tdep.c: Don't include ../features/i386/32bit-XXX.c.
	include arch/i386.h.
	(i386_linux_read_description): Remove code and call
	i386_create_target_description.
	(set_tdesc_architecture): New function.
	(set_tdesc_osabi): New function.
	* target-descriptions.h (allocate_target_description): Remove.

gdb/gdbserver:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (arch-i386.o): New rule.
	* configure.srv (i[34567]86-*-linux*): Add arch-i386.o.
	(x86_64-*-linux*): Likewise.
	* linux-x86-tdesc.c: Don't include ../features/i386/32bit-XXX.c,
	include arch/i386.h.
	(i386_linux_read_description): Remove code and call
	i386_create_target_description.
	* tdesc.c (allocate_target_description): New function.
	* tdesc.h (set_tdesc_architecture): Remove declaration.
	(set_tdesc_osabi): Likewise.
2017-09-05 09:54:53 +01:00
Yao Qi f7000548a2 Use VEC for target_desc.reg_defs
Nowadays, target_desc.reg_defs is a pointer points to a pre-generated
array, which is not flexible.  This patch changes it from an array
to a VEC so that GDBserver can create target descriptions dynamically
later.  Instead of using pre-generated array, the -generated.c calls
VEC_safe_push to add each register to vector.

Since target_desc.reg_defs is used in IPA, we need to build common/vec.c
for IPA too.

gdb/gdbserver:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (IPA_OBJS): Add vec-ipa.o
	* regcache.c (get_thread_regcache): Use VEC_length.
	(init_register_cache): Likewise.
	(regcache_cpy): Likewise.
	(registers_to_string): Iterate reg_defs via VEC_iterate.
	(find_regno): Likewise.
	(find_register_by_number): Use VEC_index.
	(register_size): Call find_register_by_number.
	(register_data): Call find_register_by_number.
	(supply_regblock): Use VEC_length.
	(regcache_raw_read_unsigned): Likewise.
	* tdesc.c (init_target_desc): Iterate reg_defs via
	VEC_iterate.
	(default_description): Update initializer.
	(copy_target_description): Don't update field num_registers.
	* tdesc.h (struct target_desc) <reg_defs>: Change it to VEC.
	<num_registers>: Remove.

gdb:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* regformats/regdat.sh: Update generated code.
2017-09-05 09:54:52 +01:00
Simon Marchi 50a421ac3a gdbserver Makefile: don't delete intermediary files
If you "make" from scratch in gdbserver/, you'll notice that make
deletes the files it considers as intermediary at the end:

  $ make clean && make
  ...
  rm i386-mmx-linux-generated.c x32-avx-avx512-linux-generated.c ...

Then, if you type make again, make will rebuild these files and rebuild
gdbserver.  To avoid this, we can add the .SECONDARY special target.  If
it has no pre-requisites, all intermediary files will be kept.

gdb/gdbserver/ChangeLog:

	* Makefile.in (.SECONDARY): Define target.
2017-09-04 19:02:56 +02:00
Yao Qi 6d580b635f GDBserver self tests
This patch uses GDB self test in GDBserver.  The self tests are run if
GDBserver is started with option --selftest.

gdb:

2017-08-18  Yao Qi  <yao.qi@linaro.org>

	* NEWS: Mention GDBserver's new option "--selftest".
	* Makefile.in (SFILES): Remove selftest.c, add common/selftest.c.
	* selftest.c: Move it to common/selftest.c.
	* selftest.h: Move it to common/selftest.h.
	* selftest-arch.c (reset): New function.
	(tests_with_arch): Call reset.

gdb/gdbserver:

2017-08-18  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (OBS): Add selftest.o.
	* configure.ac: AC_DEFINE GDB_SELF_TEST if $development.
	* configure, config.in: Re-generated.
	* server.c: Include common/sefltest.h.
	(captured_main): Handle option --selftest.

gdb/testsuite:

2017-08-18  Yao Qi  <yao.qi@linaro.org>

	* gdb.server/unittest.exp: New.

gdb/doc:

2017-08-18  Yao Qi  <yao.qi@linaro.org>

	* gdb.texinfo (Server): Document "--selftest".
2017-08-18 09:20:43 +01:00
Simon Marchi a206891ad1 gdbserver/Makefile.in: Sort IPA_OBJS
gdb/gdbserver/ChangeLog:

	* Makefile.in (IPA_OBJS): Sort and format one item per line.
2017-06-20 16:59:03 +02:00
Simon Marchi cf0dd6f02c gdb: Pass -x c++ to the compiler
Because we are compiling .c files containing C++ code, clang++ complains
with:

  clang: error: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated

If renaming all the source files to .cpp is out of the question, an
alternative is to pass "-x c++" to convince the compiler that we are
really compiling C++.  It works fine with GCC too.

gdb/ChangeLog:

	* Makefile.in (COMPILE.pre): Add "-x c++".

gdb/gdbserver/ChangeLog:

	* Makefile.in (COMPILE.pre): Add "-x c++".
2017-06-17 23:17:00 +02:00
Sergio Durigan Junior 2090129c36 Share fork_inferior et al with gdbserver
This is the most important (and the biggest, sorry) patch of the
series.  It moves fork_inferior from gdb/fork-child.c to
nat/fork-inferior.c and makes all the necessary adjustments to both
GDB and gdbserver to make sure everything works OK.

There is no "most important change" with this patch; all changes are
made in a progressive way, making sure that gdbserver had the
necessary features while not breaking GDB at the same time.

I decided to go ahead and implement a partial support for starting the
inferior with a shell on gdbserver, although the full feature comes in
the next patch.  The user won't have the option to disable the
startup-with-shell, and also won't be able to change which shell
gdbserver will use (other than setting the $SHELL environment
variable, that is).

Everything is working as expected, and no regressions were present
during the tests.

gdb/ChangeLog:
2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* Makefile.in (HFILES_NO_SRCDIR): Add "common/common-inferior.h"
	and "nat/fork-inferior.h".
	* common/common-inferior.h: New file, with contents from
	"gdb/inferior.h".
	* commom/common-utils.c: Include "common-utils.h".
	(stringify_argv): New function.
	* common/common-utils.h (stringify_argv): New prototype.
	* configure.nat: Add "fork-inferior.o" as a dependency for
	"*linux*", "fbsd*" and "nbsd*" hosts.
	* corefile.c (get_exec_file): Update comment.
	* darwin-nat.c (darwin_ptrace_him): Call "gdb_startup_inferior"
	instead of "startup_inferior".
	(darwin_create_inferior): Call "add_thread_silent" after
	"fork_inferior".
	* fork-child.c: Cleanup unnecessary includes.
	(SHELL_FILE): Move to "common/common-fork-child.c".
	(environ): Likewise.
	(exec_wrapper): Initialize.
	(get_exec_wrapper): New function.
	(breakup_args): Move to "common/common-fork-child.c"; rename to
	"breakup_args_for_exec".
	(escape_bang_in_quoted_argument): Move to
	"common/common-fork-child.c".
	(saved_ui): New variable.
	(prefork_hook): New function.
	(postfork_hook): Likewise.
	(postfork_child_hook): Likewise.
	(gdb_startup_inferior): Likewise.
	(fork_inferior): Move to "common/common-fork-child.c".  Update
	function to support gdbserver.
	(startup_inferior): Likewise.
	* gdbcore.h (get_exec_file): Remove declaration.
	* gnu-nat.c (gnu_create_inferior): Call "gdb_startup_inferior"
	instead of "startup_inferior".  Call "add_thread_silent" after
	"fork_inferior".
	* inf-ptrace.c: Include "nat/fork-inferior.h" and "utils.h".
	(inf_ptrace_create_inferior): Call "gdb_startup_inferior"
	instead of "startup_inferior".  Call "add_thread_silent" after
	"fork_inferior".
	* inferior.h: Include "common-inferior.h".
	(trace_start_error): Move to "common/common-utils.h".
	(trace_start_error_with_name): Likewise.
	(fork_inferior): Move prototype to "nat/fork-inferior.h".
	(startup_inferior): Likewise.
	(gdb_startup_inferior): New prototype.
	* nat/fork-inferior.c: New file, with contents from "fork-child.c".
	* nat/fork-inferior.h: New file.
	* procfs.c (procfs_init_inferior): Call "gdb_startup_inferior"
	instead of "startup_inferior".  Call "add_thread_silent" after
	"fork_inferior".
	* target.h (target_terminal_init): Move prototype to
	"target/target.h".
	(target_terminal_inferior): Likewise.
	(target_terminal_ours): Likewise.
	* target/target.h (target_terminal_init): New prototype, moved
	from "target.h".
	(target_terminal_inferior): Likewise.
	(target_terminal_ours): Likewise.
	* utils.c (gdb_flush_out_err): New function.

gdb/gdbserver/ChangeLog:
2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* Makefile.in (SFILES): Add "nat/fork-inferior.o".
	* configure: Regenerate.
	* configure.srv (srv_linux_obj): Add "fork-child.o" and
	"fork-inferior.o".
	(i[34567]86-*-lynxos*): Likewise.
	(spu*-*-*): Likewise.
	* fork-child.c: New file.
	* linux-low.c: Include "common-inferior.h", "nat/fork-inferior.h"
	and "environ.h".
	(linux_ptrace_fun): New function.
	(linux_create_inferior): Adjust function prototype to reflect
	change on "target.h".  Adjust function code to use
	"fork_inferior".
	(linux_request_interrupt): Delete "signal_pid".
	* lynx-low.c: Include "common-inferior.h" and "nat/fork-inferior.h".
	(lynx_ptrace_fun): New function.
	(lynx_create_inferior): Adjust function prototype to reflect
	change on "target.h".  Adjust function code to use
	"fork_inferior".
	* nto-low.c (nto_create_inferior): Adjust function prototype and
	code to reflect change on "target.h".  Update comments.
	* server.c: Include "common-inferior.h", "nat/fork-inferior.h",
	"common-terminal.h" and "environ.h".
	(terminal_fd): Moved to fork-child.c.
	(old_foreground_pgrp): Likewise.
	(restore_old_foreground_pgrp): Likewise.
	(last_status): Make it global.
	(last_ptid): Likewise.
	(our_environ): New variable.
	(startup_with_shell): Likewise.
	(program_name): Likewise.
	(program_argv): Rename to...
	(program_args): ...this.
	(wrapper_argv): New variable.
	(start_inferior): Delete function.
	(get_exec_wrapper): New function.
	(get_exec_file): Likewise.
	(get_environ): Likewise.
	(prefork_hook): Likewise.
	(post_fork_inferior): Likewise.
	(postfork_hook): Likewise.
	(postfork_child_hook): Likewise.
	(handle_v_run): Update code to deal with arguments coming from the
	remote host.  Update calls from "start_inferior" to
	"create_inferior".
	(captured_main): Likewise.  Initialize environment variable.  Call
	"have_job_control".
	* server.h (post_fork_inferior): New prototype.
	(get_environ): Likewise.
	(last_status): Declare.
	(last_ptid): Likewise.
	(signal_pid): Likewise.
	* spu-low.c: Include "common-inferior.h" and "nat/fork-inferior.h".
	(spu_ptrace_fun): New function.
	(spu_create_inferior): Adjust function prototype to reflect change
	on "target.h".  Adjust function code to use "fork_inferior".
	* target.c (target_terminal_init): New function.
	(target_terminal_inferior): Likewise.
	(target_terminal_ours): Likewise.
	* target.h: Include <vector>.
	(struct target_ops) <create_inferior>: Update prototype.
	(create_inferior): Update macro.
	* utils.c (gdb_flush_out_err): New function.
	* win32-low.c (win32_create_inferior): Adjust function prototype
	and code to reflect change on "target.h".

gdb/testsuite/ChangeLog:
2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.server/non-existing-program.exp: Update regex in order to
	reflect the fact that gdbserver is now using fork_inferior (with a
	shell) to startup the inferior.
2017-06-07 19:56:09 -04:00
Sergio Durigan Junior 156525114c Move parts of inferior job control to common/
This commit moves a few bits responsible for dealing with inferior job
control from GDB to common/, which makes them available to gdbserver.
This is necessary for the upcoming patches that will share
fork_inferior et al between GDB and gdbserver.

We move some parts of gdb/terminal.h to gdb/common/common-terminal.h,
especifically the code that checks terminal features and that are used
to set job_control accordingly.

After sharing parts of gdb/terminal.h, we also to share the two
functions on gdb/inflow.c that are going to be needed by the
fork_inferior rework.  They are 'gdb_setpgid' and the new
'have_job_control'.  I've also taken the opportunity to give a more
meaningful name to "inflow.c" on common/.  Now it is called
"job-control.c" (thanks Pedro for the suggestion).

gdb/ChangeLog:
2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>

	* Makefile.in (SFILES): Add "common/job-control.c".
	(HFILES_NO_SRCDIR): Add "common/job-control.h".
	(COMMON_OBS): Add "job-control.o".
	* common/job-control.c: New file, with contents from
	"gdb/inflow.c".
	* common/job-control.h: New file, with contents from "terminal.h".
	* fork-child.c: Include "job-control.h".
	* inflow.c: Include "job-control.h".
	(gdb_setpgid): Move to "common/common-inflow.c".
	(_initialize_inflow): Move setting of "job_control" to
	"handle_job_control".
	* terminal.h (job_control): Moved to "common/common-terminal.h".
	(gdb_setpgid): Likewise.
	* top.c: Include "job_control.h".
	* utils.c: Likewise.
	(job_control): Moved to "job-control.c".

gdb/gdbserver/ChangeLog:
2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>

	* Makefile.in (SFILE): Add "common/job-control.c".
	(OBS): Add "job-control.o".
2017-06-07 19:52:56 -04:00
Simon Marchi 65dd1e590e gdbserver: Clear .deps on clean
In some situations, the dependency tracking files in .deps can refer to
source files that were removed or renamed, leading to errors like:

  make: *** No rule to make target `version.c', needed by `version.o'. Stop.

This patch makes the clean target clear the .deps directory, which gives
the user a chance to recover from the error wihtout knowing about the
internals of the build system.

It is already done for GDB.  See here for more details:

  https://sourceware.org/ml/gdb-patches/2009-03/msg00000.html

gdb/gdbserver/ChangeLog:

	* Makefile.in (clean): Clear .deps.
2017-04-04 10:50:01 -04:00
Simon Marchi 8fa5b77748 gdbserver: Suffix generated C files with -generated
I noticed that there were some missing files in gdbserver's gitignore
(some generated register format .c files).  Of course the easy fix would
be to add those files to .gitignore, but I think we can do a better job,
so that we don't have to worry about adding generated files to
.gitignore or the clean Makefile target.

I suggest naming all generated source files -generated.c.  This way, we
can use a single rule in .gitignore and do a "rm -f *-generated.c" to
clean them up.

New in v2:

  - Don't rename version.o and xml-builtin.o

gdb/gdbserver/ChangeLog:

	* .gitignore: Remove generated files, replace with wildcard.
	* (clean): Replace removal of generated files with wildcard.
	(version.c): Replace with...
	(version-generated.c): ...this.
	(xml-builtin.c): Replace with...
	(xml-builtin-generated.c): ...this.
	(%-ipa.o: %-generated.c, %.o: %-generated.c): New rules.
	(%.c: *regformats*): Replace with...
	(%-generated.c: *regformats*): ...this.
2017-03-31 11:19:44 -04:00
Simon Marchi 1a01e7c6b0 gdbserver: Use pattern rule for the remaining %-ipa.o objects
gdb/gdbserver/ChangeLog:

	* Makefile.in (%-ipa.o: %-ipa.c): New rule.
	(ax-ipa.o: ax.c): Remove.
	(linux-i386-ipa.o: linux-i386-ipa.c): Remove.
	(linux-amd64-ipa.o: linux-amd64-ipa.c): Remove.
	(linux-aarch64-ipa.o: linux-aarch64-ipa.c): Remove.
	(linux-s390-ipa.o: linux-s390-ipa.c): Remove.
	(linux-ppc-ipa.o: linux-ppc-ipa.c): Remove.
2017-03-13 18:44:05 -04:00
Simon Marchi 36bc18a810 gdbserver: Use pattern rule for IPA objects from common/
gdb/gdbserver/ChangeLog:

	* Makefile.in (%-ipa.o: ../common/%.c): New rule.
	(print-utils-ipa.o: ../common/print-utils.c): Remove.
	(rsp-low-ipa.o: ../common/rsp-low.c): Remove.
	(errors-ipa.o: ../common/errors.c): Remove.
	(format-ipa.o: ../common/format.c): Remove.
	(common-utils-ipa.o: ../common/common-utils.c): Remove.
2017-03-13 18:44:05 -04:00
Simon Marchi a8ebe3d5f1 gdbserver: Use pattern rule for IPA objects from gdbserver/
gdb/gdbserver/ChangeLog:

	* Makefile.in (%-ipa.o: %.c): New rule.
	(tracepoint-ipa.o: tracepoint.c): Remove.
	(utils-ipa.o: utils.c): Remove.
	(remote-utils-ipa.o: remote-utils.c): Remove.
	(regcache-ipa.o: regcache.c): Remove.
	(i386-linux-ipa.o: i386-linux.c): Remove.
	(i386-mmx-linux-ipa.o: i386-mmx-linux.c): Remove.
	(i386-avx-linux-ipa.o: i386-avx-linux.c): Remove.
	(i386-mpx-linux-ipa.o: i386-mpx-linux.c): Remove.
	(i386-avx-mpx-linux-ipa.o: i386-avx-mpx-linux.c): Remove.
	(i386-avx-avx512-linux-ipa.o: i386-avx-avx512-linux.c): Remove.
	(i386-avx-mpx-avx512-pku-linux-ipa.o: i386-avx-mpx-avx512-pku-linux.c): Remove.
	(amd64-linux-ipa.o: amd64-linux.c): Remove.
	(amd64-avx-linux-ipa.o: amd64-avx-linux.c): Remove.
	(amd64-mpx-linux-ipa.o: amd64-mpx-linux.c): Remove.
	(amd64-avx-mpx-linux-ipa.o: amd64-avx-mpx-linux.c): Remove.
	(amd64-avx-avx512-linux-ipa.o: amd64-avx-avx512-linux.c): Remove.
	(amd64-avx-mpx-avx512-pku-linux-ipa.o: amd64-avx-mpx-avx512-pku-linux.c): Remove.
	(aarch64-ipa.o: aarch64.c): Remove.
	(s390-linux32-ipa.o: s390-linux32.c): Remove.
	(s390-linux32v1-ipa.o: s390-linux32v1.c): Remove.
	(s390-linux32v2-ipa.o: s390-linux32v2.c): Remove.
	(s390-linux64-ipa.o: s390-linux64.c): Remove.
	(s390-linux64v1-ipa.o: s390-linux64v1.c): Remove.
	(s390-linux64v2-ipa.o: s390-linux64v2.c): Remove.
	(s390-te-linux64-ipa.o: s390-te-linux64.c): Remove.
	(s390-vx-linux64-ipa.o: s390-vx-linux64.c): Remove.
	(s390-tevx-linux64-ipa.o: s390-tevx-linux64.c): Remove.
	(s390x-linux64-ipa.o: s390x-linux64.c): Remove.
	(s390x-linux64v1-ipa.o: s390x-linux64v1.c): Remove.
	(s390x-linux64v2-ipa.o: s390x-linux64v2.c): Remove.
	(s390x-te-linux64-ipa.o: s390x-te-linux64.c): Remove.
	(s390x-vx-linux64-ipa.o: s390x-vx-linux64.c): Remove.
	(s390x-tevx-linux64-ipa.o: s390x-tevx-linux64.c): Remove.
	(powerpc-32l-ipa.o: powerpc-32l.c): Remove.
	(powerpc-altivec32l-ipa.o: powerpc-altivec32l.c): Remove.
	(powerpc-cell32l-ipa.o: powerpc-cell32l.c): Remove.
	(powerpc-vsx32l-ipa.o: powerpc-vsx32l.c): Remove.
	(powerpc-isa205-32l-ipa.o: powerpc-isa205-32l.c): Remove.
	(powerpc-isa205-altivec32l-ipa.o: powerpc-isa205-altivec32l.c): Remove.
	(powerpc-isa205-vsx32l-ipa.o: powerpc-isa205-vsx32l.c): Remove.
	(powerpc-e500l-ipa.o: powerpc-e500l.c): Remove.
	(powerpc-64l-ipa.o: powerpc-64l.c): Remove.
	(powerpc-altivec64l-ipa.o: powerpc-altivec64l.c): Remove.
	(powerpc-cell64l-ipa.o: powerpc-cell64l.c): Remove.
	(powerpc-vsx64l-ipa.o: powerpc-vsx64l.c): Remove.
	(powerpc-isa205-64l-ipa.o: powerpc-isa205-64l.c): Remove.
	(powerpc-isa205-altivec64l-ipa.o: powerpc-isa205-altivec64l.c): Remove.
	(powerpc-isa205-vsx64l-ipa.o: powerpc-isa205-vsx64l.c): Remove.
	(tdesc-ipa.o: tdesc.c): Remove.
	(x32-linux-ipa.o: x32-linux.c): Remove.
	(x32-avx-linux-ipa.o: x32-avx-linux.c): Remove.
	(x32-avx512-linux-ipa.o: x32-avx512-linux.c): Remove.
2017-03-13 18:44:04 -04:00
Simon Marchi 50cfacb78f gdbserver: Use pattern rule for objects from arch/
gdb/gdbserver/ChangeLog:

	* Makefile.in (%.o: ../arch/%.c): New rule.
	(arm.o: ../arch/arm.c): Remove.
	(arm-linux.o: ../arch/arm-linux.c): Remove.
	(arm-get-next-pcs.o: ../arch/arm-get-next-pcs.c): Remove.
	(aarch64-insn.o: ../arch/aarch64-insn.c): Remove.
2017-03-13 18:44:03 -04:00
Simon Marchi c5a22423d0 gdbserver: Use pattern rule for objects from nat/
gdb/gdbserver/ChangeLog:

	* Makefile.in (%.o: ../nat/%.c): New rule.
	(x86-dregs.o: ../nat/x86-dregs.c): Remove.
	(amd64-linux-siginfo.o: ../nat/amd64-linux-siginfo.c): Remove.
	(linux-btrace.o: ../nat/linux-btrace.c): Remove.
	(linux-osdata.o: ../nat/linux-osdata.c): Remove.
	(linux-procfs.o: ../nat/linux-procfs.c): Remove.
	(linux-ptrace.o: ../nat/linux-ptrace.c): Remove.
	(linux-waitpid.o: ../nat/linux-waitpid.c): Remove.
	(mips-linux-watch.o: ../nat/mips-linux-watch.c): Remove.
	(ppc-linux.o: ../nat/ppc-linux.c): Remove.
	(linux-personality.o: ../nat/linux-personality.c): Remove.
	(aarch64-linux-hw-point.o: ../nat/aarch64-linux-hw-point.c): Remove.
	(aarch64-linux.o: ../nat/aarch64-linux.c): Remove.
	(x86-linux.o: ../nat/x86-linux.c): Remove.
	(x86-linux-dregs.o: ../nat/x86-linux-dregs.c): Remove.
	(linux-namespaces.o: ../nat/linux-namespaces.c): Remove.
2017-03-13 18:44:03 -04:00
Simon Marchi 6bda016bec gdbserver: Use pattern rule for objects from common/
gdb/gdbserver/ChangeLog:

	* Makefile.in (%.o: ../common/%.c): New rule.
	(signals.o: ../common/signals.c): Remove.
	(print-utils.o: ../common/print-utils.c): Remove.
	(rsp-low.o: ../common/rsp-low.c): Remove.
	(common-utils.o: ../common/common-utils.c): Remove.
	(posix-strerror.o: ../common/posix-strerror.c): Remove.
	(mingw-strerror.o: ../common/mingw-strerror.c): Remove.
	(vec.o: ../common/vec.c): Remove.
	(gdb_vecs.o: ../common/gdb_vecs.c): Remove.
	(xml-utils.o: ../common/xml-utils.c): Remove.
	(ptid.o: ../common/ptid.c): Remove.
	(buffer.o: ../common/buffer.c): Remove.
	(format.o: ../common/format.c): Remove.
	(filestuff.o: ../common/filestuff.c): Remove.
	(agent.o: ../common/agent.c): Remove.
	(errors.o: ../common/errors.c): Remove.
	(environ.o: ../common/environ.c): Remove.
	(common-debug.o: ../common/common-debug.c): Remove.
	(cleanups.o: ../common/cleanups.c): Remove.
	(common-exceptions.o: ../common/common-exceptions.c): Remove.
	(fileio.o: ../common/fileio.c): Remove.
	(common-regcache.o: ../common/common-regcache.c): Remove.
	(signals-state-save-restore.o: ../common/signals-state-save-restore.c): Remove.
	(new-op.o: ../common/new-op.c): Remove.
	(btrace-common.o: ../common/btrace-common.c): Remove.
2017-03-13 18:44:02 -04:00
Simon Marchi 21122961ec gdbserver: Use pattern rule for objects from target/
gdb/gdbserver/ChangeLog:

	* Makefile.in (%.o: ../target/%.c): New rule.
	(waitstatus.o: ../target/waitstatus.c): Remove.
2017-03-13 18:44:02 -04:00
Simon Marchi c362e6217b gdbserver: Use pattern rule for regformats source file generation
gdb/gdbserver/ChangeLog:

	* Makefile.in
	(%.c: ../regformats/%.dat,
	(%.c: ../regformats/arm/%.dat,
	(%.c: ../regformats/i386/%.dat,
	(%.c: ../regformats/rs6000/%.dat): New rules.
	(aarch64.c): Remove.
	(reg-arm.c): Remove.
	(arm-with-iwmmxt.c): Remove.
	(arm-with-vfpv2.c): Remove.
	(arm-with-vfpv3.c): Remove.
	(arm-with-neon.c): Remove.
	(reg-bfin.c): Remove.
	(reg-cris.c): Remove.
	(reg-crisv32.c): Remove.
	(i386.c): Remove.
	(i386-linux.c): Remove.
	(i386-avx.c): Remove.
	(i386-avx-linux.c): Remove.
	(i386-avx-avx512.c): Remove.
	(i386-avx-avx512-linux.c): Remove.
	(i386-mpx.c): Remove.
	(i386-mpx-linux.c): Remove.
	(i386-avx-mpx-avx512-pku.c): Remove.
	(i386-avx-mpx-avx512-pku-linux.c): Remove.
	(i386-avx-mpx.c): Remove.
	(i386-avx-mpx-linux.c): Remove.
	(i386-mmx.c): Remove.
	(i386-mmx-linux.c): Remove.
	(reg-ia64.c): Remove.
	(reg-m32r.c): Remove.
	(reg-m68k.c): Remove.
	(reg-cf.c): Remove.
	(mips-linux.c): Remove.
	(mips-dsp-linux.c): Remove.
	(mips64-linux.c): Remove.
	(mips64-dsp-linux.c): Remove.
	(nios2-linux.c): Remove.
	(powerpc-32.c): Remove.
	(powerpc-32l.c): Remove.
	(powerpc-altivec32l.c): Remove.
	(powerpc-cell32l.c): Remove.
	(powerpc-vsx32l.c): Remove.
	(powerpc-isa205-32l.c): Remove.
	(powerpc-isa205-altivec32l.c): Remove.
	(powerpc-isa205-vsx32l.c): Remove.
	(powerpc-e500l.c): Remove.
	(powerpc-64l.c): Remove.
	(powerpc-altivec64l.c): Remove.
	(powerpc-cell64l.c): Remove.
	(powerpc-vsx64l.c): Remove.
	(powerpc-isa205-64l.c): Remove.
	(powerpc-isa205-altivec64l.c): Remove.
	(powerpc-isa205-vsx64l.c): Remove.
	(s390-linux32.c): Remove.
	(s390-linux32v1.c): Remove.
	(s390-linux32v2.c): Remove.
	(s390-linux64.c): Remove.
	(s390-linux64v1.c): Remove.
	(s390-linux64v2.c): Remove.
	(s390-te-linux64.c): Remove.
	(s390-vx-linux64.c): Remove.
	(s390-tevx-linux64.c): Remove.
	(s390x-linux64.c): Remove.
	(s390x-linux64v1.c): Remove.
	(s390x-linux64v2.c): Remove.
	(s390x-te-linux64.c): Remove.
	(s390x-vx-linux64.c): Remove.
	(s390x-tevx-linux64.c): Remove.
	(tic6x-c64xp-linux.c): Remove.
	(tic6x-c64x-linux.c): Remove.
	(tic6x-c62x-linux.c): Remove.
	(reg-sh.c): Remove.
	(reg-sparc64.c): Remove.
	(reg-spu.c): Remove.
	(amd64.c): Remove.
	(amd64-linux.c): Remove.
	(amd64-avx.c): Remove.
	(amd64-avx-linux.c): Remove.
	(amd64-avx-avx512.c): Remove.
	(amd64-avx-avx512-linux.c): Remove.
	(amd64-mpx.c): Remove.
	(amd64-mpx-linux.c): Remove.
	(amd64-avx-mpx-avx512-pku.c): Remove.
	(amd64-avx-mpx-avx512-pku-linux.c): Remove.
	(amd64-avx-mpx.c): Remove.
	(amd64-avx-mpx-linux.c): Remove.
	(x32.c): Remove.
	(x32-linux.c): Remove.
	(x32-avx.c): Remove.
	(x32-avx-linux.c): Remove.
	(x32-avx-avx512.c): Remove.
	(x32-avx-avx512-linux.c): Remove.
	(reg-xtensa.c): Remove.
	(reg-tilegx.c): Remove.
	(reg-tilegx32.c): Remove.
2017-03-13 18:44:01 -04:00
Sergio Durigan Junior 1672e0d98d Share gdb/environ.[ch] with gdbserver
We will need access to the environment functions when we share
fork_inferior between GDB and gdbserver, therefore we simply make the
API on gdb/environ.[ch] available on common/.  No extra adjustments
are needed to make it compile on gdbserver.

gdb/ChangeLog:
2017-03-07  Sergio Durigan Junior  <sergiodj@redhat.com>

	* Makefile.in (SFILES): Replace "environ.c" with
	"common/environ.c".
	(HFILES_NO_SRCDIR): Likewise, for "environ.h".
	* environ.c: Include "common-defs.h" instead of "defs.h.  Moved
	to...
	* common/environ.c: ... here.
	* environ.h: Moved to...
	* common/environ.h: ... here.

gdb/gdbserver/ChangeLog:
2017-03-07  Sergio Durigan Junior  <sergiodj@redhat.com>

	* Makefile.in (SFILES): Add "common/environ.c".
	(OBJS): Add "common/environ.h".
2017-03-07 15:39:35 -05:00
Michael Sturm 51547df62c Add support for Intel PKRU register to GDB and GDBserver.
This patch adds support for the registers added by the
Memory Protection Keys for Userspace (PKU aka PKEYs) feature.
Native and remote debugging are covered by this patch.

The XSAVE area is extended with a new state containing
the 32-bit wide PKRU register. The new register is added to
amd64-avx-mpx_avx512-* tdesc, thus it is renamed accordingly. Also,
respective xstate mask X86_XSTATE_AVX_MPX_AVX512_MASK is renamed to
X86_XSTATE_AVX_MPX_AVX512_PKU_MASK to reflect the new feature set
it supports.

For more information, please refer to the
Intel(R) 64 and IA-32 Architectures Software Developer's
Manual - Septemper 2015
http://www.intel.com/content/dam/www/public/us/en/documents/
manuals/64-ia-32-architectures-software-developer-manual-325462.pdf

gdb/Changelog:
2015-12-08  Michael Sturm  <michael.sturm@intel.com>

     * NEWS: Mention addition of PKU feature.
     * amd64-linux-nat.c (amd64_linux_gregset32_reg_offset): Add PKRU register.
     * amd64-linux-tdep.c (features/i386/amd64-avx-mpx-avx512-linux.c): Rename
       to...
     (features/i386/amd64-avx-mpx-avx512-pku-linux.c): ...this.
     (amd64_linux_gregset_reg_offset): Add PKRU register.
     (amd64_linux_core_read_description): Rename
     X86_XSTATE_AVX_MPX_AVX512_MASK,
     rename tdesc_amd64_avx_mpx_avx512_pku_linux.
     (_initialize_amd64_linux_tdep): Rename
     initialize_tdesc_amd64_avx_mpx_avx512_linux.
     * amd64-linux-tdep.h (AMD64_LINUX_ORIG_RAX_REGNUM): Adjust regnum
     calculation.
     (tdesc_amd64_avx_mpx_avx512_linux): Rename to...
     (tdesc_amd64_avx_mpx_avx512_pku_linux): ...this.
     * amd64-tdep.c (features/i386/amd64-avx-mpx-avx512-pku.c): Rename to...
     (features/i386/amd64-avx-mpx-avx512-pku.c): ...this.
     (amd64_pkeys_names): New register name for raw register PKRU.
     (amd64_init_abi): Add code to initialize PKRU tdep variables if feature
     is present.
     (amd64_target_description): Rename X86_XSTATE_AVX_MPX_AVX512_MASK,
     rename tdesc_amd64_avx_mpx_avx512.
     (_initialize_amd64_tdep): Rename initialize_tdesc_amd64_avx_mpx_avx512.
     * amd64-tdep.h (enum amd64_regnum): Add PKRU register.
     (AMD64_NUM_REGS): Adjust regnum calculation.
     * i386-linux.nat.c (GETXSTATEREGS_SUPPLIES): Extend range of
     registers supplied via XSTATE by PKRU register.
     * common/x86-xstate.h (X86_XSTATE_PKRU): New macro.
     (X86_XSTATE_AVX_MPX_AVX512_MASK): Add PKRU and renamed mask.
     (X86_XSTATE_ALL_MASK): Rename X86_XSTATE_AVX_MPX_AVX512_MASK.
     (X86_XSTATE_PKRU_SIZE): New macro.
     (X86_XSTATE_MAX_SIZE): Adjust size.
     (HAS_PKRU(XCR0)): New macro.
     (X86_XSTATE_SIZE): Add checkfor PKRU.
     * features/Makefile (WHICH): Rename i386/i386-avx-mpx-avx512,
     i386/i386-avx-mpx-avx512-linux, i386/amd64-avx-mpx-avx512,
     i386/amd64-avx-mpx-avx512-linux.
     (i386/i386-avx-mpx-avx512-expedite): Rename expedite.
     (i386/i386-avx-mpx-avx512-linux-expedite): Likewise.
     (i386/amd64-avx-mpx-avx512-expedite): Likewise.
     (i386/amd64-avx-mpx-avx512-linux-expedite): Likewise.
     (XMLTOC): Rename i386/amd64-avx-mpx-avx512-linux.xml,
     i386/amd64-avx-mpx-avx512.xml, i386/i386-avx-mpx-avx512-linux.xml,
     i386/i386-avx-mpx-avx512.xml.
     ((outdir)/i386/i386-avx-mpx-avx512.dat): Rename rule, add
     i386/32bit-pkeys.xml.
     ((outdir)/i386/i386-avx-mpx-avx512-pku-linux.dat): Likewise.
     ((outdir)/i386/amd64-avx-mpx-avx512.dat): Rename rule, add
     i386/64bit-pkeys.xml.
     ((outdir)/i386/amd64-avx-mpx-avx512-linux.dat): Likewise.
     * features/i386/32bit-pkeys.xml: New file.
     * features/i386/64bit-pkeys.xml: Likewise.
     * features/i386/amd64-avx-mpx-avx512-linux-pku.c: Regenerate from
     renamed XML file.
     * features/i386/amd64-avx-mpx-avx512-linux.xml: Rename to
     amd64-avx-mpx-avx512-pku-linux.xml, add 64bit-pkeys.xml
     * features/i386/amd64-avx-mpx-avx512.c: Regenerate from
     renamed XML file.
     * features/i386/amd64-avx-mpx-avx512.xml: Rename to
     amd64-avx-mpx-avx512-pku.xml, add 64bit-pkeys.xml.
     * features/i386/i386-avx-mpx-avx512-linux.c: Regenerate from
     renamed XML file.
     * features/i386/i386-avx-mpx-avx512-linux.xml: Rename to
     i386-avx-mpx-avx512-pku-linux.xml, add 32bit-pkeys.xml.
     * features/i386/i386-avx-mpx-avx512.c: Regenerate from
     renamed XML file.
     * features/i386/i386-avx-mpx-avx512.xml: Rename to
     i386-avx-mpx-avx512-pku.xml, add 32bit-pkeys.xml.
     * i386-linux-nat.c (GETXSTATEREGS_SUPPLIES): Change to use
     I386_PKEYS_NUM_REGS.
     * i386-linux-tdep.c (features/i386/i386-avx-mpx-avx512-linux.c): Rename
     include.
     (i386_linux_gregset_reg_offset): Add PKRU register.
     (i386_linux_core_read_description): Rename xstate mask and returned
     tdesc for X86_XSTATE_AVX_MPX_AVX512_PKU_MASK.
     (_initialize_i386_linux_tdep): Rename
     initialize_tdesc_i386_avx_mpx_avx512_linux.
     * i386-linux-tdep.h (I386_LINUX_ORIG_EAX_REGNUM): Adjuste regnum
     calculation.
     (tdesc_i386_avx_mpx_avx512_linux): Rename prototype.
     (/* Format of XSAVE...): Add pkru register.
     * i386-tdep.c (i386-avx-mpx-avx512.c): Rename include.
     (i386_pkeys_names): New register name for raw register PKRU.
     (i386_pkru_regnum_p): Add function to look up register number of
     PKRU raw register.
     (i386_register_reggroup_p): Add code to exclude PKRU from general
     register group.
     (i386_validate_tdesc_p): Add code to handle PKRU feature, add PKRU
     registers if feature is present in xcr0.
     (i386_gdbarch_init): Adjust number of registers in architecture. Add code
     to initialize PKRU feature variables in tdep structure.
     (i386_target_description): Rename xstate mask and returned
     tdesc for X86_XSTATE_AVX_MPX_AVX512_PKU_MASK.
     (_initialize_i386_tdep): Rename initialize_tdesc_i386_avx_mpx_avx512.
     * i386-tdep.h (struct gdbarch_tdep): Add feature variables to tdep
     structure.
     (enum i386_regnum): Add PKRU register.
     (I386_PKEYS_NUM_REGS): New define for number of registers in PKRU feature.
     (i386_pkru_regnum_p): New prototype.
     * i387-tdep.c (xsave_pkeys_offset): New table for PKRU offsets in
     XSAVE buffer.
     (XSAVE_PKEYS_ADDR): New macro.
     (i387_supply_xsave): Add code to handle PKRU register.
     (i387_collect_xsave): Likewise.
     * i387-tdep.h (I387_NUM_PKEYS_REGS): New define for number of registers
     in PKRU feature.
     (I387_PKRU_REGNUM): New macro.
     (I387_PKEYSEND_REGNUM): Likewise.
     * regformats/i386/amd64_avx_mpx_avx512_pku_linux.dat: Regenerate from
     renamed XML file.
     * regformats/i386/amd64_avx_mpx_avx512_pku.dat: Likewise.
     * regformats/i386/i386/amd64-avx-mpx-avx512-pku.dat: Likewise.
     * regformats/i386/i386_avx_mpx_avx512_pku_linux.dat: Likewise.

testsuite/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * gdb.arch/i386-pkru.c: New file.
     * gdb.arch/i386-pkru.exp: Likewise.

gdbserver/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * Makefile.in (clean): Rename i386-avx-mpx-avx512.c,
     i386-avx-mpx-avx512-linux.c, amd64-avx-mpx-avx512.c,
     amd64-avx-mpx-avx512-linux.c.
     (i386-avx-mpx-avx512-linux-ipa.o:): Rename rule and source file.
     (amd64-avx-mpx-avx512-linux-ipa.o:): Likewise.
     (i386-avx-mpx-avx512.c :): Rename rule, source files and dat files.
     (i386-avx-mpx-avx512-linux.c :): Likewise.
     (amd64-avx-mpx-avx512.c :): Likewise.
     (amd64-avx-mpx-avx512-linux.c :): Likewise.
     * configure.srv (srv_i386_regobj): Rename i386-avx-mpx-avx512.o.
     (srv_i386_linux_regobj): Rename i386-avx-mpx-avx512-linux.o.
     (srv_amd64_regobj): Rename amd64-avx-mpx-avx512.o.
     (srv_amd64_linux_regobj): Rename amd64-avx-mpx-avx512-linux.o.
     (ipa_i386_linux_regobj): Rename i386-avx-mpx-avx512-linux-ipa.o.
     (ipa_amd64_linux_regobj): Rename amd64-avx-mpx-avx512-pku-linux-ipa.o.
     (srv_i386_32bit_xmlfiles): Add 32bit-pkeys.xml.
     (srv_i386_64bit_xmlfiles): Add 64bit-pkeys.xml.
     (srv_i386_xmlfiles): Rename i386/i386-avx-mpx-avx512.xml.
     (srv_amd64_xmlfiles): Rename i386/amd64-avx-mpx-avx512.xml.
     (srv_i386_linux_xmlfiles): Rename i386/i386-avx-mpx-avx512-linux.xml.
     (srv_amd64_linux_xmlfiles): Rename di386/amd64-avx-mpx-avx512-linux.xml.
     * i387-fp.c (num_pkeys_registers): New variable.
     (struct i387_xsave): Add space for pkru values.
     (i387_cache_to_fsave): Add code to handle PKRU register.
     (i387_xsave_to_cache): Likewise.
     * linux-amd64-ipa.c (get_ipa_tdesc): Rename
     tdesc_amd64_avx_mpx_avx512_linux.
     (initialize_low_tracepoint): Rename
     init_registers_amd64_avx_mpx_avx512_linux.
     * linux-i386-ipa.c (get_ipa_desc): Rename
     tdesc_i386_avx_mpx_avx512_linux.
     (initialize_low_tracepoint): Rename
     init_registers_i386_avx_mpx_avx512_linux.
     * linux-x86-low.c (x86_64_regmap[]): Add PKRU register.
     (x86_linux_read_description): Rename X86_XSTATE_AVX_MPX_AVX512_MASK,
     rename tdesc_amd64_avx_mpx_avx512_linux, rename
     tdesc_i386_avx_mpx_avx512_linux.
     (x86_get_ipa_tdesc_idx): Rename tdesc_amd64_avx_mpx_avx512_linux,
     rename tdesc_i386_avx_mpx_avx512_linux.
     (initialize_low_arch): Rename init_registers_amd64_avx_mpx_avx512_linux,
     rename init_registers_i386_avx_mpx_avx512_linux.
     * linux-x86-tdesc.h (init_registers_amd64_avx_mpx_avx512_linux): Renamed
     prototype.
     (tdesc_amd64_avx_mpx_avx512_linux): Likewise.
     (init_registers_i386_avx_mpx_avx512_linux): Likewise.
     (tdesc_i386_avx_mpx_avx512_linux): Likewise.

doc/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * gdb.texinfo (i386 Features): Add description of PKRU register.

Change-Id: If75ce5aba7dfd33fdbe3d8b47f04ef3f550c52be
Signed-off-by: Michael Sturm <michael.sturm@intel.com>
2017-02-17 11:44:48 +01:00
Michael Sturm a1fa17ee15 Add target description for avx-avx512.
Add a dedicated target description for the feature combination
avx-avx512 as implemented by certain IA CPU models.

The corresponding X86_XSTATE_AVX_AVX512_MASK already exists, but shared
the tdesc with X86_XSTATE_AVX_MPX_AVX512_MASK. This caused MPX registers
displayed as undefined on CPUs that only implemented
X86_XSTATE_AVX_AVX512_MASK, which is undesired. This patch solves this issue.

This patch also corrects the wrong usage of x32-avx-mpx-avx512, which is
replaced by x32-avx-avx512. The MPX feature is not implemented in x32 mode.

gdb/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * amd64-linux-tdep.c (features/i386/amd64-avx-avx512-linux.c):
     New include.
     (features/i386/x32-avx-mpx-avx512-linux.c): Rename to...
     (features/i386/x32-avx-avx512-linux.c): ...this.
     (amd64_linux_core_read_description): Add dedicated cases for
     X86_XSTATE_AVX_AVX512_MASK and return appropriate tdesc.
     (_initialize_amd64_linux_tdep): Add calls to
     initialize_tdesc_amd64_avx_avx512_linux and
     initialize_tdesc_x32_avx_avx512_linux.
     * amd64-linux.tdep.h (tdesc_amd64_avx_avx512_linux): New prototype.
     (tdesc_x32_avx_mpx_avx512_linux): Rename to...
     (tdesc_x32_avx_avx512_linu): ...this.
     * amd64-tdep.c (features/i386/amd64-avx-avx512.c): New include.
     (features/i386/x32-avx-mpx-avx512.c): Rename to...
     (features/i386/x32-avx-avx512.c): ...this.
     (amd64_target_description): Add dedicated case for
     X86_XSTATE_AVX_AVX512_MASK and return appropriate tdesc.
     (_initialize_amd64_tdep): Add call to
     initialize_tdesc_amd64_avx_avx512.
     (initialize_tdesc_x32_avx_mpx_avx512): Rename to...
     (initialize_tdesc_x32_avx_avx512): ...this.
     * features/Makefile (WHICH): New tdescs i386/i386-avx-avx512,
     i386/i386-avx-avx512-linux, i386/amd64-avx-avx512,
     i386/amd64-avx-avx512-linux.
     (i386/x32-avx-mpx-avx512): Rename to...
     (i386/x32-avx-avx512): ...this.
     (i386/x32-avx-mpx-avx512-linux): Rename to...
     (i386/x32-avx-avx512-linux): ...this.
     (i386/i386-avx-avx512-expedite, i386/i386-avx-avx512-linux-expedite,
     i386/amd64-avx-avx512-expedite, i386/amd64-avx-avx512-linux-expedite):
     New expedites.
     (i386/x32-avx-mpx-avx512-expedite): Rename to...
     (i386/x32-avx-avx512-expedite): ...this.
     (i386/x32-avx-mpx-avx512-linux-expedite): Rename to...
     (i386/x32-avx-avx512-linux-expedite): ...this.
     (XMLTOC): New XML files i386/amd64-avx-avx512-linux.xml,
     i386/amd64-avx-avx512.xml, i386/i386-avx-avx512-linux.xml,
     i386/i386-avx-avx512.xml.
     (i386/x32-avx-mpx-avx512-linux.xml): Rename to...
     (i386/x32-avx-avx512-linux.xml): ...this.
     (i386/x32-avx-mpx-avx512.xml): Rename to...
     (i386/x32-avx-avx512.xml): ...this.
     ($(outdir)/i386/i386-avx-avx512.dat): New rule.
     ($(outdir)/i386/i386-avx-avx512-linux.dat): Likewise.
     ($(outdir)/i386/amd64-avx-avx512.dat): Likewise.
     ($(outdir)/i386/amd64-avx-avx512-linux.dat): Likewise.
     ($(outdir)/i386/x32-avx-mpx-avx512.dat):  Rename to...
     ($(outdir)/i386/x32-avx-avx512.dat): ...this.
     ($(outdir)/i386/x32-avx-mpx-avx512-linux.dat): Rename to...
     ($(outdir)/i386/x32-avx-avx512-linux.dat): ...this.
     * features/i386/amd64-avx-avx512-linux.c: New file.
     * features/i386/amd64-avx-avx512-linux.xml: Likewise.
     * features/i386/amd64-avx-avx512.c: Likewise.
     * features/i386/amd64-avx-avx512.xml: Likewise.
     * features/i386/i386-avx-avx512-linux.c: Likewise.
     * features/i386/i386-avx-avx512-linux.xml: Likewise.
     * features/i386/i386-avx-avx512.c: Likewise.
     * features/i386/i386-avx-avx512.xml: Likewise.
     * features/i386/x32-avx-mpx-avx512-linux.c: Deleted.
     * features/i386/x32-avx-avx512-linux.c: New file.
     * features/i386/x32-avx-mpx-avx512-linux.xml: Deleted.
     * features/i386/x32-avx-avx512-linux.xml: New file.
     * features/i386/x32-avx-mpx-avx512.c: Deleted.
     * features/i386/x32-avx-avx512.c: New file.
     * features/i386/x32-avx-mpx-avx512.xml: Deleted.
     * features/i386/x32-avx-avx512.xml: New file.
     * i386-linux-tdep.c (features/i386/i386-avx-avx512-linux.c): New include.
     (i386_linux_core_read_description): Add dedicated case for
     X86_XSTATE_AVX_AVX512_MASK and return appropriate tdesc.
     (_initialize_i386_linux_tdep): Add call to
     initialize_tdesc_i386_avx_avx512_linux.
     * i386-linux-tdep.h (tdesc_i386_avx_avx512_linux): New prototype.
     * i386-tdep.c (features/i386/i386-avx-avx512.c): New include.
     (i386_validate_tdesc_p): Correct XSTATE mask used for feature_avx512.
     (i386_target_description): Add dedicated case for
     X86_XSTATE_AVX_AVX512_MASK and return appropriate tdesc.
     (_initialize_i386_tdep): Add call to initialize_tdesc_i386_avx_avx512.
     * regformats/i386/amd64-avx-avx512-linux.dat: New file
     * regformats/i386/amd64-avx-avx512.dat: Likewise.
     * regformats/i386/i386-avx-avx512-linux.dat: Likewise.
     * regformats/i386/i386-avx-avx512.dat: Likewise.
     * regformats/i386/x32-avx-mpx-avx512-linux.dat: Deleted.
     * regformats/i386/x32-avx-avx512-linux.dat: New file.
     * regformats/i386/x32-avx-mpx-avx512.dat: Deleted.
     * regformats/i386/x32-avx-avx512.dat: New file.
     * x86-linux-nat.c (x86_linux_read_description): Add dedidated case for
     X86_XSTATE_AVX_AVX512_MASK and return appropriate description.

gdbserver/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * Makefile.in  (clean): Add handling of new source files
     i386-avx-avx512.c, i386-avx-avx512-linux.c, amd64-avx-avx512.c,
     amd64-avx-avx512-linux.c.
     (x32-avx-mpx-avx512.c): Rename to...
     (x32-avx-avx512.c): ...this.
     (x32-avx-mpx-avx512-linux.c): Rename to...
     (x32-avx-avx512-linux.c): ...this.
     (i386-avx-avx512-linux-ipa.o): New rule.
     (amd64-avx-avx512-linux-ipa.o): Likewise.
     (i386-avx-avx512.c): Likewise.
     (i386-avx-avx512-linux.c): Likewise.
     (amd64-avx-avx512.c): Likewise.
     (amd64-avx-avx512-linux.c): Likewise.
     (x32-avx-avx512.c): Rename rule, source files, dat files from
     x32-avx-mpx-avx512.*) to this.
     (x32-avx-avx512-linux.c): Rename rule, source files, dat files from
     x32-avx-mpx-avx512-linux.*) to this.
     * configure.srv (srv_i386_regobj): Add i386-avx-avx512.o.
     (srv_i386_linux_regobj): Add i386-avx-avx512-linux.o.
     (srv_amd64_regobj): Add amd64-avx-avx512.o, rename
     x32-avx-mpx-avx512.o to x32-avx-avx512.o.
     (srv_amd64_linux_regobj): Add amd64-avx-avx512-linux.o, rename
     x32-avx-mpx-avx512-linux.o to x32-avx-avx512-linux.o.
     (ipa_i386_linux_regobj): Add i386-avx-avx512-linux-ipa.o.
     (ipa_amd64_linux_regobj): Add amd64-avx-avx512-linux-ipa.o.
     (srv_i386_xmlfiles): Add i386/i386-avx-avx512.xml.
     (srv_amd64_xmlfiles): Add i386/amd64-avx-avx512.xml, rename
     x32-avx-mpx-avx512.xml to x32-avx-avx512.xml.
     (srv_i386_linux_xmlfiles): Add i386/i386-avx-avx512-linux.xml.
     (srv_amd64_linux_xmlfiles): Add i386/amd64-avx-avx512-linux.xml,
     rename x32-avx-mpx-avx512-linux.xml to x32-avx-avx512-linux.xml.
     * linux-amd64-ipa.c (get_ipa_tdesc): Add dedicated case for
     X86_TDESC_AVX_AVX512 and return appropriate tdesc.
     (initialize_low_tracepoint): Add init_registers_amd64_avx_avx512_linux.
     * linux-i386-ipa.c (get_ipa_tdesc): Add dedicated case for
     X86_TDESC_AVX_AVX512 and return appropriate tdesc.
     (initialize_low_tracepoint): Add init_registers_i386_avx_avx512_linux.
     * linux-x86-low.c (x86_linux_read_description): Add dedicated cases for
     X86_XSTATE_AVX_AVX512_MASK and return appropriate tdesc.
     (x86_get_ipa_tdesc_idx): Rename tdesc_x32_avx_mpx_avx512_linux to
     tdesc_x32_avx_avx512_linux, add dedicated if-clause for
     tdesc_amd64_avx_avx512_linux and return appropriate mask.
     Add dedicated clause for tdesc_i386_avx_avx512_linux
     and return appropriate mask.
     (initialize_low_arch): Add init_registers_amd64_avx_avx512_linux,
     rename init_registers_x32_avx_mpx_avx512_linux, add
     init_registers_i386_avx_avx512_linux.
     * linux-x86-tdesc.h (enum x86_linux_tdesc): Add new value for
     X86_TDESC_AVX_AVX512.
     (init_registers_amd64_avx_avx512_linux): New prototype.
     (tdesc_amd64_avx_avx512_linux): Likewise.
     (init_registers_x32_avx_mpx_avx512_linux): Rename to...
     (init_registers_x32_avx_avx512_linux): ...this.
     (tdesc_x32_avx_mpx_avx512_linux): Rename to...
     (tdesc_x32_avx_avx512_linux): ...this.
     (init_registers_i386_avx_avx512_linux): New prototype.
     (tdesc_i386_avx_avx512_linux): Likewise.

Change-Id: I01359fab56c961a39568df50af39714ec7b31706
Signed-off-by: Michael Sturm <michael.sturm@intel.com>
2017-02-17 11:44:36 +01:00
Michael Sturm 22049425ce Rename target descriptions to reflect actual content of description.
To better reflect the actual feature set covered by the IA target
descriptions, the existing descriptions are renamed. Each feature of
the extended state is added to the name of a description or xstate mask
starting from AVX.
For example, amd64-mpx-avx512-linux becomes amd64-avx-mpx-avx512-linux,
while amd64-avx-linux remains unchanged.
Likewise, the corresponding xstate masks are changed, e.g. from
X86_XSTATE_MPX_AVX512_MASK to X86_XSTATE_AVX_MPX_AVX512_MASK.

gdb/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * amd64-linux-tdep.c (features/i386/amd64-avx512-linux.c): Rename
     include to...
     (features/i386/amd64-avx-mpx-avx512-linux.c): ...this.
     (features/i386/x32-avx512-linux.c): Rename include to...
     (features/i386/x32-avx-mpx-avx512-linux.c): ...this.
     (amd64_linux_core_read_description): Rename X86_XSTATE_MPX_AVX512_MASK,
     X86_XSTATE_AVX512_MASK, desc_x32_avx512_linux, tdesc_amd64_avx512_linux.
     (_initialize_amd64_linux_tdep): Rename
     initialize_tdesc_amd64_avx512_linux, initialize_tdesc_x32_avx512_linux.
     * amd64-linux-tdep.h (tdesc_amd64_avx512_linux): Rename to...
     (tdesc_amd64_avx_mpx_avx512_linux): ...this.
     (tdesc_x32_avx512_linux): Rename to...
     (tdesc_x32_avx_mpx_avx512_linux): ...this.
     * amd64-tdep.c (features/i386/amd64-avx512.c): Rename include to...
     (features/i386/amd64-avx-mpx-avx512.c): ...this.
     (features/i386/x32-avx512.c): Rename include to...
     (features/i386/x32-avx-mpx-avx512.c): ...this.
     (amd64_target_description): Rename X86_XSTATE_MPX_AVX512_MASK,
     X86_XSTATE_AVX512_MASK, tdesc_amd64_avx512.
     (_initialize_amd64_tdep): Rename initialize_tdesc_amd64_avx512. Rename
     initialize_tdesc_x32_avx512.
     * common/x86-xstate.h (X86_XSTATE_AVX512_MASK): Rename to...
     (X86_XSTATE_AVX_AVX512_MASK): ...this.
     (86_XSTATE_MPX_AVX512_MASK): Rename to...
     (X86_XSTATE_AVX_MPX_AVX512_MASK): ...this.
     (X86_XSTATE_ALL_MASK): Rename X86_XSTATE_MPX_AVX512_MASK to
     X86_XSTATE_AVX_MPX_AVX512_MASK.
     * features/Makefile (WHICH): Rename i386/i386-avx512,
     i386/i386-avx512-linux, i386/amd64-avx512, i386/amd64-avx512-linux,
     i386/x32-avx512, i386/x32-avx512-linux.
     (i386/i386-avx512-expedite, i386/i386-avx512-linux-expedite,
     i386/amd64-avx512-expedite, i386/amd64-avx512-linux-expedite,
     i386/x32-avx512-expedite, i386/x32-avx512-linux-expedite): Rename
     expedites.
     (XMLTOC): Rename i386/amd64-avx512-linux.xml, i386/amd64-avx512.xml,
     i386/i386-avx512-linux.xml, i386/i386-avx512.xml,
     i386/x32-avx512-linux.xml, i386/x32-avx512.xml.
     ($(outdir)/i386/i386-avx512.dat): Rename dat file in rule.
     ($(outdir)/i386/i386-avx512-linux.dat): Likewise.
     ($(outdir)/i386/amd64-avx512.dat): Likewise.
     ($(outdir)/i386/amd64-avx512-linux.dat): Likewise.
     ($(outdir)/i386/x32-avx512.dat): Likewise.
     ($(outdir)/i386/x32-avx512-linux.dat): Likewise.
     * features/i386/amd64-avx512-linux.c: Regenerate from renamed XML file.
     * features/i386/amd64-avx512-linux.xml: Rename XML file.
     * features/i386/amd64-avx512.c: Regenerate from renamed XML file.
     * features/i386/amd64-avx512.xml: Rename XML file.
     * features/i386/i386-avx512-linux.c: Regenerate from renamed XML file.
     * features/i386/i386-avx512-linux.xml: Rename XML file.
     * features/i386/i386-avx512.c: Regenerate from renamed XML file.
     * features/i386/i386-avx512.xml: Rename XML file.
     * features/i386/x32-avx512-linux.c: Regenerate from renamed XML file.
     * features/i386/x32-avx512-linux.xml: Rename XML file.
     * features/i386/x32-avx512.c: Regenerate from renamed XML file.
     * features/i386/x32-avx512.xml: Rename XML file.
     * i386-linux-tdep.c (features/i386/i386-avx512-linux.c): Rename to...
     (features/i386/i386-avx-mpx-avx512-linux.c): ...this.
     (i386_linux_core_read_description): Rename X86_XSTATE_MPX_AVX512_MASK,
     X86_XSTATE_AVX512_MASK, tdesc_i386_avx512_linux.
     (_initialize_i386_linux_tdep): Rename initialize_tdesc_i386_avx512_linux.
     * i386-linux-tdep.h (tdesc_i386_avx512_linux): Rename to...
     (tdesc_i386_avx_mpx_avx512_linux): ...this.
     * i386-tdep.c (features/i386/i386-avx512.c): Rename to...
     (features/i386/i386-avx-mpx-avx512.c): ...this.
     (i386_register_reggroup_p): Rename X86_XSTATE_AVX512_MASK.
     (i386_validate_tdesc_p): Likewise.
     (i386_target_description): Rename X86_XSTATE_MPX_AVX512_MASK,
     tdesc_i386_avx512.
     (_initialize_i386_tdep): Rename initialize_tdesc_i386_avx512.
     * regformats/i386/amd64-avx512-linux.dat: Regenerate from renamed XML
     file.
     * regformats/i386/amd64-avx512.dat: Likewise.
     * regformats/i386/i386-avx512-linux.dat: Likewise.
     * regformats/i386/i386-avx512.dat: Likewise.
     * regformats/i386/x32-avx512-linux.dat: Likewise.
     * regformats/i386/x32-avx512.dat: Likewise.
     * x86-Linux-nat.c (x86_linux_read_description): Rename
     X86_XSTATE_MPX_AVX512_MASK, X86_XSTATE_AVX512_MASK,
     tdesc_x32_avx512_linux, tdesc_amd64_avx512_linux, tdesc_i386_avx512_linux.

gdbserver/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * Makefile.in (clean): Rename i386-avx512.c, i386-avx512-linux.c,
     amd64-avx512.c, amd64-avx512-linux.c, x32-avx512.c, x32-avx512-linux.c.
     (i386-avx512-linux-ipa.o): Rename rule and source files.
     (amd64-avx512-linux-ipa.o): Likewise.
     (i386-avx512.c): Rename rule, source fils and dat files.
     (i386-avx512-linux.c): Likewise.
     (amd64-avx512.c): Likewise.
     (amd64-avx512-linux.c): Likewise.
     (x32-avx512.c): Likewise.
     (x32-avx512-linux.c): Likewise.
     * configfure.srv (srv_i386_regobj): Rename i386-avx512.o.
     (i386_linux_regobj): Rename i386-avx512-linux.o.
     (srv_amd64_regobj): Rename amd64-avx512.o, x32-avx512.o.
     (srv_amd64_linux_regobj): Rename amd64-avx512-linux.o,
     x32-avx512-linux.o.
     (ipa_i386_linux_regobj): Rename i386-avx512-linux-ipa.o.
     (ipa_amd64_linux_regobj): Rename amd64-avx512-linux-ipa.o.
     (srv_i386_xmlfiles): Rename i386/i386-avx512.xml.
     (srv_amd64_xmlfiles): Rename i386/amd64-avx512.xml, i386/x32-avx512.xml.
     (srv_i386_linux_xmlfiles): Rename i386/i386-avx512-linux.xml.
     (srv_amd64_linux_xmlfiles): Rename i386/amd64-avx512-linux.xml,
     i386/x32-avx512-linux.xml).
     * linux-amd64-ipa.c (get_ipa_tdesc): Rename X86_TDESC_AVX512 and returned
     tdesc for that case.
     (initialize_low_tracepoint): Rename init_registers_amd64_avx512_linux.
     * linux-i386-ipa.c (get_ipa_tdesc): Rename X86_TDESC_AVX512 and tdesc
     returned for that case.
     (initialize_low_tracepoint): Rename init_registers_i386_avx512_linux.
     * linux-x86-low.c (x86_linux_read_description): Rename
     X86_XSTATE_AVX512_MASK and tdesc returned for that case.
     (x86_get_ipa_tdesc_idx): Rename tdesc_amd64_avx512_linux,
     tdesc_x32_avx512_linux and mask returned for these descriptions.
     Rename tdesc_i386_avx512_linux and mask returned for that description.
     (initialize_low_arch): Rename init_registers_amd64_avx512_linux,
     init_registers_x32_avx512_linux, init_registers_i386_avx512_linux.
     * linux-x86-tdesc.h (enum x86_linux_tdesc): Rename X86_TDESC_AVX512.
     (init_registers_amd64_avx512_linux): Rename to...
     (init_registers_amd64_avx_mpx_avx512_linux): ...this.
     (tdesc_amd64_avx512_linux): Rename to...
     (tdesc_amd64_avx_mpx_avx512_linux): ...this.
     (init_registers_x32_avx512_linux): Rename to...
     (init_registers_x32_avx_mpx_avx512_linux): ...this.
     (tdesc_x32_avx512_linux): Rename to...
     (tdesc_x32_avx_mpx_avx512_linux): ...this.
     (init_registers_i386_avx512_linux): Rename to...
     (init_registers_i386_avx_mpx_avx512_linux): ...this.
     (tdesc_i386_avx512_linux): Rename to...
     (tdesc_i386_avx_mpx_avx512_linux): ...this.

Change-Id: Idb83be3b3b72d5487542d4b568193df2777a3d9d
Signed-off-by: Michael Sturm <michael.sturm@intel.com>
2017-02-17 11:44:24 +01:00
Joel Brobecker 61baf725ec update copyright year range in GDB files
This applies the second part of GDB's End of Year Procedure, which
updates the copyright year range in all of GDB's files.

gdb/ChangeLog:

        Update copyright year range in all GDB files.
2017-01-01 10:52:34 +04:00
Simon Marchi ad02e4fe87 Makefiles: Disable suffix rules and implicit rules
Since we don't use suffix rules nor implicit rules in gdb, we can
disable them.  The advantage is a slightly faster make [1].

Here are some numbers about the speedup.  I ran this on my trusty old
Intel Q6600, so the time numbers are probably higher than what you'd get
on any recent hardware.  I ran "make" in the gdb/ directory of an
already built repository (configured with --enable-targets=all).  I
recorded the time of execution (average of 5).  I then ran "make -d" and
recorded the number of printed lines, which gives a rough idea of the
number of operations done.

I compared the following configurations, to see the impact of both the
empty .SUFFIXES target and the empty pattern rules, as well as running
"make -r", which can be considered the "ideal" case.

 A - baseline
 B - baseline + .SUFFIXES
 C - baseline + pattern rules
 D - baseline + .SUFFIXES + pattern rules
 E - baseline + make -r

 config | time (s) | "make -d"
 -----------------------------
    A   |   5.74   |  2396643
    B   |   1.19   |   298469
    C   |   2.81   |  1266573
    D   |   1.13   |   245489
    E   |   1.01   |   163914

We can see that the empty .SUFFIXES target has a bigger impact than the
empty pattern rules, but still it doesn't hurt to disable the implicit
pattern rules as well.

There are still some mentions of implicit rules I can't get rid of in
the "make -d" output.  For example, it's trying to build .c files from
.w files:

  Looking for an implicit rule for '/home/simark/src/binutils-gdb/gdb/infrun.c'.
  Trying pattern rule with stem 'infrun'.
  Trying implicit prerequisite '/home/simark/src/binutils-gdb/gdb/infrun.w'.

and trying to build Makefile.in from a bunch of extensions:

  Looking for an implicit rule for 'Makefile.in'.
  Trying pattern rule with stem 'Makefile.in'.
  Trying implicit prerequisite 'Makefile.in.o'.
  Trying pattern rule with stem 'Makefile.in'.
  Trying implicit prerequisite 'Makefile.in.c'.
  Trying pattern rule with stem 'Makefile.in'.
  Trying implicit prerequisite 'Makefile.in.cc'.
  ... many more ...

If somebody knows how to disable them, we can do it, but at this point
the returns are minimal, so it is not that important.

I verified that both in-tree and out-of-tree builds work.

[1] Switching from explicit rules to pattern rules for files in
    subdirectories actually made it slower, so this is kind of a way to
    redeem myself.  But it the end it's faster than it was previously,
    so it was all worth it. :)

gdb/ChangeLog:

	* disable-implicit-rules.mk: New file.
	* Makefile.in: Include disable-implicit-rules.mk.
	* data-directory/Makefile.in: Likewise.
	* gnulib/Makefile.in: Likewise.

gdb/doc/ChangeLog:

	* Makefile.in: Likewise.

gdb/gdbserver/ChangeLog:

	* Makefile.in: Include disable-implicit-rules.mk.

gdb/testsuite/ChangeLog:

	* Makefile.in: Include disable-implicit-rules.mk.
2016-11-30 16:23:59 -05:00
Simon Marchi 8629c02c0d Minor formatting fixups in Makefiles
Mostly some whitespace changes to make things a bit more consistent.

gdb/ChangeLog:

	* Makefile.in: Fix whitespace formatting.

gdb/gdbserver/ChangeLog:

	* Makefile.in: Fix whitespace formatting.
2016-11-23 09:45:23 -05:00
Simon Marchi b593ecca85 Makefiles: Flatten and sort file lists
I find the big file lists in the Makefiles a bit ugly and not very
practical.  Since there are multiple filenames on each line (as much as
fits in 80 columns), it's not easy to add, remove or change a name in
the middle.  As a result, we have a mix of long and short lines in no
particular order (ALL_TARGET_OBS is a good example).

I therefore suggest flattening the lists (one name per line) and keeping
them in alphabetical order.  The diffs will be much clearer and merge
conflicts will be easier to resolve.

A nice (IMO) side-effect I observed is that the files are compiled
alphabetically by make, so it gives a rough idea of the progress of the
build.

I added a comment in gdb/Makefile.in to mention to keep the file lists
ordered, and gave the general guidelines on what order to respect.  I
added a comment in other Makefiles which refers to gdb/Makefile.in, to
avoid duplication.

Running the patch through the buildbot found that gdb.base/default.exp
started to fail.  The languages in the error message shown when typing
"set language" have changed order.  We could probably improve gdb so
that it prints them in a stable order, regardless of the order of the
object list passed to the linked, but just fixing the test is easier for
now.

New in v2:

 - Change ordering style, directories go at the end.
 - Cleanup gdbserver's and data-directory's Makefile as well.
 - Add comments at top of Makefiles about the ordering.
 - Remove wrong trailing backslahes.
 - Fix test gdb.base/default.exp.

gdb/ChangeLog:

	* Makefile.in: Add comment about file lists ordering.
	(SUBDIR_CLI_OBS, SUBDIR_CLI_SRCS, SUBDIR_MI_OBS, SUBDIR_MI_SRCS,
	SUBDIR_TUI_OBS, SUBDIR_TUI_SRCS, SUBDIR_GCC_COMPILE_OBS,
	SUBDIR_GCC_COMPILE_SRCS, SUBDIR_GUILE_OBS, SUBDIR_GUILE_SRCS,
	SUBDIR_PYTHON_OBS, SUBDIR_PYTHON_SRCS, SUBDIR_GDBTK_OBS,
	SUBDIR_GDBTK_SRCS, XMLFILES, REMOTE_OBS, ALL_64_TARGET_OBS,
	ALL_TARGET_OBS, SFILES, HFILES_NO_SRCDIR, HFILES_WITH_SRCDIR,
	COMMON_OBS, YYFILES, YYOBJ, generated_files, ALLDEPFILES):
	Flatten list and order alphabetically.
	* data-directory/Makefile.in: Add comment about file lists
	ordering.
	(GEN_SYSCALLS_FILES, PYTHON_FILE_LIST): Flatten list and order
	alphabetically.

gdb/gdbserver/ChangeLog:

	* Makefile.in (SFILES, OBS): Flatten list and order
	alphabetically.

gdb/testsuite/ChangeLog:

	* gdb.base/default.exp: Fix output of "set language".
2016-11-23 09:45:22 -05:00
Simon Marchi 5443506ee4 Makefile: Replace old suffix rules with pattern rules
As mentioned here [1], suffix rules are obsolete and have been
superseeded with pattern rules.  People (myself included, before writing
this patch) are more likely to know what pattern rules are than suffix
rules.

AFAIK, .SUFFIXES targets are only used for those rules, and can be
removed as well.

New in v2:

  - Replace rule in gdbserver/Makefile.in as well.

[1] https://www.gnu.org/software/make/manual/html_node/Suffix-Rules.html

gdb/ChangeLog:

	* Makefile.in (.c.o): Replace rule with ...
	(%.o: %.c): ... this one.
	(.po.gmo): Replace rule with ...
	(%.gmo: %.po): ... this one.
	(.po.pox): Replace rule with ...
	(%.pox: %.po): ... this one.
	(.y.c): Replace rule with ...
	(%.c: %.y): ... this one.
	(.l.c): Replace rule with ...
	(%.c: %.l): ... this one.
	(.SUFFIXES): Remove all instances.

gdb/gdbserver/ChangeLog:

	* Makefile.in (.c.o): Replace rule with ...
	(%.o: %.c): ... this one.
2016-11-17 12:02:13 -05:00
Simon Marchi 3b165252e8 Remove code that checks for GNU/non-GNU make
Since GNU make is now required to build GDB, we can remove everything
that checks whether the current make implemention is the GNU one or
not.  I simply removed the @GMAKE_TRUE@ prefixes and removed the whole
lines that were prefixed with @GMAKE_FALSE@.

I removed the code in the configure scripts that set those variables.

I also removed the following bits from the configure scripts:

  AC_CHECK_PROGS(MAKE, make): GNU make already defines a MAKE variable
    internally to be used when invoking Makefiles recursively.  I don't see
    this variable being used anywhere else (in scripts for example), so I
    think it's safe for removal.

  AC_PROG_MAKE_SET: This macro defines a SET_MAKE output variable, which
    is meant to be used in Makefiles to define the MAKE variable when
    using an implementation of make that doesn't already define it.
    Since we are now requiring GNU make, we don't need it anymore.
    Plus, I don't see SET_MAKE being used anywhere, so I don't think it
    was actually doing anything...

gdb/ChangeLog:

	* Makefile.in: Remove @GMAKE_TRUE@ prefixes and removes lines
	prefixed with @GMAKE_FALSE@.  Update comment related to non-GNU
	make.
	* configure.ac: Remove checks for the make program.
	* configure: Re-generate.

gdb/gdbserver/ChangeLog:

	* Makefile.in: Remove @GMAKE_TRUE@ prefixes and removes lines
	prefixed with @GMAKE_FALSE@.  Update comment related to non-GNU
	make.
	* configure.ac: Remove checks for the make program.
	* configure: Re-generate.

gdb/testsuite/ChangeLog:

	* Makefile.in: Remove @GMAKE_TRUE@ prefixes and removes lines
	prefixed with @GMAKE_FALSE@.  Update comment related to non-GNU
	make.
	* configure.ac: Remove checks for the make program.
	* configure: Re-generate.
2016-11-17 12:00:10 -05:00
Pedro Alves 0bcda68539 gdb: Require C++11
Use AX_CXX_COMPILE_STDCXX to detect if the compiler supports C++11,
and if -std=xxx switches are necessary to enable C++11.

We need to tweak AX_CXX_COMPILE_STDCXX a bit though.  Pristine
upstream AX_CXX_COMPILE_STDCXX appends -std=gnu++11 to CXX directly.
That doesn't work for us, because the top level Makefile passes CXX
down to subdirs, and that overrides whatever gdb/Makefile may set CXX
to.  The result would be that a make invocation from the build/gdb/
directory would use "g++ -std=gnu++11" as expected, while a make
invocation at the top level would not.

So instead of having AX_CXX_COMPILE_STDCXX set CXX directly, tweak it
to AC_SUBST a separate variable -- CXX_DIALECT -- and use '$(CXX)
(CXX_DIALECT)' to compile/link.

Confirmed that this enables C++11 starting with gcc 4.8, the first gcc
release with full C++11 support.

Also confirmed that configure errors out gracefully with older GCC
releases:

  checking whether /opt/gcc-4.7/bin/g++ supports C++11 features by default... no
  checking whether /opt/gcc-4.7/bin/g++ supports C++11 features with -std=gnu++11... no
  checking whether /opt/gcc-4.7/bin/g++ supports C++11 features with -std=gnu++0x... no
  checking whether /opt/gcc-4.7/bin/g++ supports C++11 features with -std=c++11... no
  checking whether /opt/gcc-4.7/bin/g++ supports C++11 features with -std=c++0x... no
  checking whether /opt/gcc-4.7/bin/g++ supports C++11 features with +std=c++11... no
  checking whether /opt/gcc-4.7/bin/g++ supports C++11 features with -h std=c++11... no
  configure: error: *** A compiler with support for C++11 language features is required.
  Makefile:9451: recipe for target 'configure-gdb' failed
  make[1]: *** [configure-gdb] Error 1
  make[1]: Leaving directory '/home/pedro/brno/pedro/gdb/mygit/cxx-convertion/build-gcc-4.7'

If we need to revert back to making C++11 optional, all that's
necessary is to change the "mandatory" to "optional" in configure.ac
and regenerate configure (both gdb and gdbserver).

gdb/ChangeLog:
2016-10-28  Pedro Alves  <palves@redhat.com>

	* Makefile.in (CXX_DIALECT): Get from configure.
	(COMPILE.pre, CC_LD): Append $(CXX_DIALECT).
	(FLAGS_TO_PASS): Pass CXX_DIALECT.
	* acinclude.m4: Include ax_cxx_compile_stdcxx.m4.
	* ax_cxx_compile_stdcxx.m4: Add FSF copyright header.  Set and
	AC_SUBST CXX_DIALECT instead of changing CXX/CXXCPP.
	* configure.ac: Call AX_CXX_COMPILE_STDCXX.
	* config.in: Regenerate.
	* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2016-10-28  Pedro Alves  <palves@redhat.com>

	* Makefile.in (CXX_DIALECT): Get from configure.
	(COMPILE.pre, CC_LD): Append $(CXX_DIALECT).
	* acinclude.m4: Include ../ax_cxx_compile_stdcxx.m4.
	* configure.ac: Call AX_CXX_COMPILE_STDCXX.
	* config.in: Regenerate.
	* configure: Regenerate.
2016-10-28 16:03:19 +01:00
Yao Qi 0a69eedb6d Clean up the XML files for ARM
This patch is move features/arm-*.xml to features/arm/, and it is based
on Terry's patch posted here
https://sourceware.org/ml/gdb-patches/2014-06/msg00794.html

One comment to Terry's patch is about losing "arm" prefix, and the new
patch fixes this problem.

gdb:

2016-10-05  Terry Guo  <terry.guo@arm.com>
	    Yao Qi  <yao.qi@linaro.org>

	* arm-tdep.c: Adjust includes.
	* features/Makefile (WHICH): Add "arm/" directory to arm
	target descriptions.
	(XMLTOC): Likewise.
	(arm/arm-with-iwmmxt.dat): Adjust the path for
	dependencies.
	* features/arm-core.xml: Moved to ...
	* features/arm/arm-core.xml: ... it.
	* features/arm-fpa.xml: Moved to ...
	* features/arm/arm-fpa.xml: ... it.
	* features/arm-m-profile.xml: Moved to ...
	* features/arm/arm-m-profile.xm: ... it.
	* features/arm-vfpv2.xml: Moved to ...
	* features/arm/arm-vfpv2.xm: ... it.
	* features/arm-vfpv3.xml: Moved to ...
	* features/arm/arm-vfpv3.xml: ... it.
	* features/arm-with-iwmmxt.c: Moved to ...
	* features/arm/arm-with-iwmmxt.c: ... it.
	* features/arm-with-iwmmxt.xml: Moved to ...
	* features/arm/arm-with-iwmmxt.xml: ... it.
	* features/arm-with-m-fpa-layout.c: Moved to ...
	* features/arm/arm-with-m-fpa-layout.c: ... it.
	* features/arm-with-m-fpa-layout.xml: Moved to ...
	* features/arm/arm-with-m-fpa-layout.xml: ... it.
	* features/arm-with-m-vfp-d16.c: Moved to ...
	* features/arm/arm-with-m-vfp-d16.c: ... it.
	* features/arm-with-m-vfp-d16.xml: Moved to ...
	* features/arm/arm-with-m-vfp-d16.xml: ... it.
	* features/arm-with-m.c: Moved to ...
	* features/arm/arm-with-m.c: ... it.
	* features/arm-with-m.xml: Moved to ...
	* features/arm/arm-with-m.xm: ... it.
	* features/arm-with-neon.c: Moved to ...
	* features/arm/arm-with-neon.c: ... it.
	* features/arm-with-neon.xml: Moved to ...
	* features/arm/arm-with-neon.xml: ... it.
	* features/arm-with-vfpv2.c: Moved to ...
	* features/arm/arm-with-vfpv2.c: ... it.
	* features/arm-with-vfpv2.xml: Moved to ...
	* features/arm/arm-with-vfpv2.xml: ... it.
	* features/arm-with-vfpv3.c: Moved to ...
	* features/arm/arm-with-vfpv3.c: ... it.
	* features/arm-with-vfpv3.xml: Moved to ...
	* features/arm/arm-with-vfpv3.xml: ... it.
	* features/xscale-iwmmxt.xml: Moved to ...
	* features/arm/xscale-iwmmxt.xml: ... it.

gdb/gdbserver:

2016-10-05  Terry Guo  <terry.guo@arm.com>
	    Yao Qi  <yao.qi@linaro.org>

	* Makefile.in: Adjust the path of rules.
	* configure.srv: Update the path of xml files.
	* regformats/arm-with-iwmmxt.dat: Regenerated.
	* regformats/arm-with-neon.dat: Likewise.
	* regformats/arm-with-vfpv2.dat: Likewise.
	* regformats/arm-with-vfpv3.dat Likewise.
2016-10-05 09:31:13 +01:00
Pedro Alves 503b1c39dc gdb: Replace operator new / operator new[]
If xmalloc fails allocating memory, usually because something tried a
huge allocation, like xmalloc(-1) or some such, GDB asks the user what
to do:

  .../src/gdb/utils.c:1079: internal-error: virtual memory exhausted.
  A problem internal to GDB has been detected,
  further debugging may prove unreliable.
  Quit this debugging session? (y or n)

If the user says "n", that throws a QUIT exception, which is caught by
one of the multiple CATCH(RETURN_MASK_ALL) blocks somewhere up the
stack.

The default implementations of operator new / operator new[] call
malloc directly, and on memory allocation failure throw
std::bad_alloc.  Currently, if that happens, since nothing catches it,
the exception escapes out of main, and GDB aborts from unhandled
exception.

This patch replaces the default operator new variants with versions
that, just like xmalloc:

 #1 - Raise an internal-error on memory allocation failure.

 #2 - Throw a QUIT gdb_exception, so that the exact same CATCH blocks
      continue handling memory allocation problems.

A minor complication of #2 is that operator new can _only_ throw
std::bad_alloc, or something that extends it:

  void* operator new (std::size_t size) throw (std::bad_alloc);

That means that if we let a gdb QUIT exception escape from within
operator new, the C++ runtime aborts due to unexpected exception
thrown.

So to bridge the gap, this patch adds a new gdb_quit_bad_alloc
exception type that inherits both std::bad_alloc and gdb_exception,
and throws _that_.

If we decide that we should be catching memory allocation errors in
fewer places than all the places we currently catch them (everywhere
we use RETURN_MASK_ALL currently), then we could change operator new
to throw plain std::bad_alloc then.  But I'm considering such a change
as separate matter from this one -- it'd make sense to do the same to
xmalloc at the same time, for instance.

Meanwhile, this allows using new/new[] instead of xmalloc/XNEW/etc.
without losing the "virtual memory exhausted" internal-error
safeguard.

Tested on x86_64 Fedora 23.

gdb/ChangeLog:
2016-09-23  Pedro Alves  <palves@redhat.com>

	* Makefile.in (SFILES): Add common/new-op.c.
	(COMMON_OBS): Add common/new-op.o.
	(new-op.o): New rule.
	* common/common-exceptions.h: Include <new>.
	(struct gdb_quit_bad_alloc): New type.
	* common/new-op.c: New file.

gdb/gdbserver/ChangeLog:
2016-09-23  Pedro Alves  <palves@redhat.com>

	* Makefile.in (SFILES): Add common/new-op.c.
	(OBS): Add common/new-op.o.
	(new-op.o): New rule.
2016-09-23 16:42:24 +01:00
Pedro Alves cf6de44d75 gdb/: Require a C++ compiler
This removes all support for building gdb & gdbserver with a C
compiler from gdb & gdbserver's build machinery.

gdb/ChangeLog:
2016-09-05  Pedro Alves  <palves@redhat.com>

	* NEWS: Mention that a C++ compiler is now required.
	* Makefile.in (COMPILER, COMPILER_CFLAGS): Remove.
	(COMPILE.pre, CC_LD): Use CXX directly.
	(INTERNAL_CFLAGS_BASE): Use CXXFLAGS directly.
	* acinclude.m4: Don't include build-with-cxx.m4.
	* build-with-cxx.m4: Delete file.
	* configure.ac: Remove GDB_AC_BUILD_WITH_CXX call.
	* warning.m4: Assume $enable_build_with_cxx is yes.
	* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2016-09-05  Pedro Alves  <palves@redhat.com>

	* Makefile.in (COMPILER, COMPILER_CFLAGS): Remove.
	(COMPILE.pre, CC_LD): Use CXX directly.
	(INTERNAL_CFLAGS_BASE): Use CXXFLAGS directly.
	* acinclude.m4: Don't include build-with-cxx.m4.
	* configure.ac: Remove GDB_AC_BUILD_WITH_CXX call.
	* configure: Regenerate.
2016-09-05 19:10:44 +01:00