Commit Graph

152 Commits

Author SHA1 Message Date
Simon Marchi d0ac1c4488 Bump to autoconf 2.69 and automake 1.15.1
When trying to run the update-gnulib.sh script in gdb, I get this:

Error: Wrong automake version (Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\${ <-- HERE ([^      =:+{}]+)}/ at /opt/automake/1.11.1/bin/automake line 4113.), we need 1.11.1.
Aborting.

Apparently, it's an issue with a regex in automake that triggers a
warning starting with Perl 5.22.  It has been fixed in automake 1.15.1.
So I think it's a good excuse to bump the versions of autoconf and
automake used in the gnulib import.  And to avoid requiring multiple
builds of autoconf/automake, it was suggested that we bump the required
version of those tools for all binutils-gdb.

For autoconf, the 2.69 version is universally available, so it's an easy
choice.  For automake, different distros and distro versions have
different automake versions.  But 1.15.1 seems to be the most readily
available as a package.  In any case, it's easy to build it from source.

I removed the version checks from AUTOMAKE_OPTIONS and AC_PREREQ,
because I don't think they are useful in our case.  They only specify a
lower bound for the acceptable version of automake/autoconf.  That's
useful if you let the user choose the version of the tool they want to
use, but want to set a minimum version (because you use a feature that
was introduced in that version).  In our case, we force people to use a
specific version anyway.  For the autoconf version, we have the check in
config/override.m4 that enforces the version we want.  It will be one
less thing to update next time we change autotools version.

I hit a few categories of problems that required some changes.  They are
described below along with the chosen solutions.

Problem 1:

  configure.ac:17: warning: AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated.  For more info, see:
  configure.ac:17: http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation

Solution 1:

  Adjust the code based on the example at that URL.

Problem 2 (in zlib/):

  Makefile.am: error: required file './INSTALL' not found
  Makefile.am:   'automake --add-missing' can install 'INSTALL'
  Makefile.am: error: required file './NEWS' not found
  Makefile.am: error: required file './AUTHORS' not found
  Makefile.am: error: required file './COPYING' not found
  Makefile.am:   'automake --add-missing' can install 'COPYING'

Solution 2:

  Add the foreign option to AUTOMAKE_OPTIONS.

Problem 3:

  doc/Makefile.am:20: error: support for Cygnus-style trees has been removed

Solution 3:

  Remove the cygnus options.

Problem 4:

  Makefile.am:656: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')

Solution 4:

  Rename "INCLUDES = " to "AM_CPPFLAGS += " (because AM_CPPFLAGS is
  already defined earlier).

Problem 5:

  doc/Makefile.am:71: warning: suffix '.texinfo' for Texinfo files is discouraged; use '.texi' instead
  doc/Makefile.am: warning: Oops!
  doc/Makefile.am:     It appears this file (or files included by it) are triggering
  doc/Makefile.am:     an undocumented, soon-to-be-removed automake hack.
  doc/Makefile.am:     Future automake versions will no longer place in the builddir
  doc/Makefile.am:     (rather than in the srcdir) the generated '.info' files that
  doc/Makefile.am:     appear to be cleaned, by e.g. being listed in CLEANFILES or
  doc/Makefile.am:     DISTCLEANFILES.
  doc/Makefile.am:     If you want your '.info' files to be placed in the builddir
  doc/Makefile.am:     rather than in the srcdir, you have to use the shiny new
  doc/Makefile.am:     'info-in-builddir' automake option.

Solution 5:

  Rename .texinfo files to .texi.

Problem 6:

  doc/Makefile.am: warning: Oops!
  doc/Makefile.am:     It appears this file (or files included by it) are triggering
  doc/Makefile.am:     an undocumented, soon-to-be-removed automake hack.
  doc/Makefile.am:     Future automake versions will no longer place in the builddir
  doc/Makefile.am:     (rather than in the srcdir) the generated '.info' files that
  doc/Makefile.am:     appear to be cleaned, by e.g. being listed in CLEANFILES or
  doc/Makefile.am:     DISTCLEANFILES.
  doc/Makefile.am:     If you want your '.info' files to be placed in the builddir
  doc/Makefile.am:     rather than in the srcdir, you have to use the shiny new
  doc/Makefile.am:     'info-in-builddir' automake option.

Solution 6:

  Remove the hack at the bottom of doc/Makefile.am and use
  the info-in-builddir automake option.

Problem 7:

  doc/Makefile.am:35: error: required file '../texinfo.tex' not found
  doc/Makefile.am:35:   'automake --add-missing' can install 'texinfo.tex'

Solution 7:

  Use the no-texinfo.tex automake option.  We also have one in
  texinfo/texinfo.tex, not sure if we should point to that, or move it
  (or a newer version of it added with automake --add-missing) to
  top-level.

Problem 8:

  Makefile.am:131: warning: source file 'config/tc-aarch64.c' is in a subdirectory,
  Makefile.am:131: but option 'subdir-objects' is disabled
  automake: warning: possible forward-incompatibility.
  automake: At least a source file is in a subdirectory, but the 'subdir-objects'
  automake: automake option hasn't been enabled.  For now, the corresponding output
  automake: object file(s) will be placed in the top-level directory.  However,
  automake: this behaviour will change in future Automake versions: they will
  automake: unconditionally cause object files to be placed in the same subdirectory
  automake: of the corresponding sources.
  automake: You are advised to start using 'subdir-objects' option throughout your
  automake: project, to avoid future incompatibilities.

Solution 8:

  Use subdir-objects, that means adjusting references to some .o that will now
  be in config/.

Problem 9:

  configure.ac:375: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
  ../../lib/autoconf/lang.m4:193: AC_LANG_CONFTEST is expanded from...
  ../../lib/autoconf/general.m4:2601: _AC_COMPILE_IFELSE is expanded from...
  ../../lib/autoconf/general.m4:2617: AC_COMPILE_IFELSE is expanded from...
  ../../lib/m4sugar/m4sh.m4:639: AS_IF is expanded from...
  ../../lib/autoconf/general.m4:2042: AC_CACHE_VAL is expanded from...
  ../../lib/autoconf/general.m4:2063: AC_CACHE_CHECK is expanded from...
  configure.ac:375: the top level

Solution 9:

  Use AC_LANG_SOURCE, or use proper quoting.

Problem 10 (in intl/):

  configure.ac:7: warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
  /usr/share/aclocal/threadlib.m4:36: gl_THREADLIB_EARLY_BODY is expanded from...
  /usr/share/aclocal/threadlib.m4:29: gl_THREADLIB_EARLY is expanded from...
  /usr/share/aclocal/threadlib.m4:318: gl_THREADLIB is expanded from...
  /usr/share/aclocal/lock.m4:9: gl_LOCK is expanded from...
  /usr/share/aclocal/intl.m4:211: gt_INTL_SUBDIR_CORE is expanded from...
  /usr/share/aclocal/intl.m4:25: AM_INTL_SUBDIR is expanded from...
  /usr/share/aclocal/gettext.m4:57: AM_GNU_GETTEXT is expanded from...
  configure.ac:7: the top level

Solution 10:

  Add AC_USE_SYSTEM_EXTENSIONS in configure.ac.

ChangeLog:

	* libtool.m4: Use AC_LANG_SOURCE.
	* configure.ac: Remove AC_PREREQ, use AC_LANG_SOURCE.
	* README-maintainer-mode: Update version requirements.
	* ar-lib: New file.
	* test-driver: New file.
	* configure: Re-generate.

bfd/ChangeLog:

	* Makefile.am (AUTOMAKE_OPTIONS): Remove 1.11.
	(INCLUDES): Rename to ...
	(AM_CPPFLAGS): ... this.
	* configure.ac: Remove AC_PREREQ.
	* doc/Makefile.am (AUTOMAKE_OPTIONS): Remove 1.9, cygnus, add
	info-in-builddir no-texinfo.tex.
	(info_TEXINFOS): Rename bfd.texinfo to bfd.texi.
	* doc/bfd.texinfo: Rename to ...
	* doc/bfd.texi: ... this.
	* Makefile.in: Re-generate.
	* aclocal.m4: Re-generate.
	* config.in: Re-generate.
	* configure: Re-generate.
	* doc/Makefile.in: Re-generate.

binutils/ChangeLog:

	* configure.ac: Remove AC_PREREQ.
	* doc/Makefile.am (AUTOMAKE_OPTIONS): Remove cygnus, add
	info-in-builddir no-texinfo.tex.
	* Makefile.in: Re-generate.
	* aclocal.m4: Re-generate.
	* config.in: Re-generate.
	* configure: Re-generate.
	* doc/Makefile.in: Re-generate.

config/ChangeLog:

	* override.m4 (_GCC_AUTOCONF_VERSION): Bump from 2.64 to 2.69.

etc/ChangeLog:

	* configure.in: Remove AC_PREREQ.
	* configure: Re-generate.

gas/ChangeLog:

	* Makefile.am (AUTOMAKE_OPTIONS): Remove 1.11, add subdir-objects.
	(TARG_CPU_O, OBJ_FORMAT_O, ATOF_TARG_O): Add config/ prefix.
	* configure.ac (TARG_CPU_O, OBJ_FORMAT_O, ATOF_TARG_O, emfiles,
	extra_objects): Add config/ prefix.
	* doc/as.texinfo: Rename to...
	* doc/as.texi: ... this.
	* doc/Makefile.am: Rename as.texinfo to as.texi throughout.
	Remove DISTCLEANFILES hack.
	(AUTOMAKE_OPTIONS): Remove 1.8, cygnus, add no-texinfo.tex and
	info-in-builddir.
	* Makefile.in: Re-generate.
	* aclocal.m4: Re-generate.
	* config.in: Re-generate.
	* configure: Re-generate.
	* doc/Makefile.in: Re-generate.

gdb/ChangeLog:

	* common/common-defs.h (PACKAGE_NAME, PACKAGE_VERSION,
	PACKAGE_STRING, PACKAGE_TARNAME): Undefine.
	* configure.ac: Remove AC_PREREQ, add missing quoting.
	* gnulib/configure.ac: Modernize usage of
	AC_INIT/AM_INIT_AUTOMAKE.  Remove AC_PREREQ.
	* gnulib/update-gnulib.sh (AUTOCONF_VERSION): Bump to 2.69.
	(AUTOMAKE_VERSION): Bump to 1.15.1.
	* configure: Re-generate.
	* config.in: Re-generate.
	* aclocal.m4: Re-generate.
	* gnulib/aclocal.m4: Re-generate.
	* gnulib/config.in: Re-generate.
	* gnulib/configure: Re-generate.
	* gnulib/import/Makefile.in: Re-generate.

gdb/gdbserver/ChangeLog:

	* configure.ac: Remove AC_PREREQ, add missing quoting.
	* configure: Re-generate.
	* config.in: Re-generate.
	* aclocal.m4: Re-generate.

gdb/testsuite/ChangeLog:

	* configure.ac: Remove AC_PREREQ.
	* configure: Re-generate.

gold/ChangeLog:

	* configure.ac: Remove AC_PREREQ, add missing quoting and usage
	of AC_LANG_SOURCE.
	* Makefile.in: Re-generate.
	* aclocal.m4: Re-generate.
	* configure: Re-generate.
	* testsuite/Makefile.in: Re-generate.

gprof/ChangeLog:

	* configure.ac: Remove AC_PREREQ.
	* Makefile.am: Remove DISTCLEANFILES hack.
	(AUTOMAKE_OPTIONS): Remove 1.11, add info-in-builddir.
	* Makefile.in: Re-generate.
	* aclocal.m4: Re-generate.
	* configure: Re-generate.
	* gconfig.in: Re-generate.

intl/ChangeLog:

	* configure.ac: Add AC_USE_SYSTEM_EXTENSIONS, remove AC_PREREQ.
	* configure: Re-generate.
	* config.h.in: Re-generate.
	* aclocal.m4: Re-generate.

ld/ChangeLog:

	* configure.ac: Remove AC_PREREQ.
	* Makefile.am: Remove DISTCLEANFILES hack, rename ld.texinfo to
	ld.texi, ldint.texinfo to ldint.texi throughout.
	(AUTOMAKE_OPTIONS): Add info-in-builddir.
	* README: Rename ld.texinfo to ld.texi, ldint.texinfo to
	ldint.texi throughout.
	* gen-doc.texi: Likewise.
	* h8-doc.texi: Likewise.
	* ld.texinfo: Rename to ...
	* ld.texi: ... this.
	* ldint.texinfo: Rename to ...
	* ldint.texi: ... this.
	* Makefile.in: Re-generate.
	* aclocal.m4: Re-generate.
	* config.in: Re-generate.
	* configure: Re-generate.

libdecnumber/ChangeLog:

	* configure.ac: Remove AC_PREREQ.
	* configure: Re-generate.
	* aclocal.m4.

libiberty/ChangeLog:

	* configure.ac: Remove AC_PREREQ.
	* configure: Re-generate.
	* config.in: Re-generate.

opcodes/ChangeLog:

	* Makefile.am (AUTOMAKE_OPTIONS): Remove 1.11.
	* configure.ac: Remove AC_PREREQ.
	* Makefile.in: Re-generate.
	* aclocal.m4: Re-generate.
	* configure: Re-generate.

readline/ChangeLog.gdb:

	* configure: Re-generate.
	* examples/rlfe/configure: Re-generate.

sim/ChangeLog:

	* All configure.ac: Remove AC_PREREQ.
	* All configure: Re-generate.

zlib/ChangeLog.bin-gdb:

	* configure.ac: Modernize AC_INIT call, remove AC_PREREQ.
	* Makefile.am (AUTOMAKE_OPTIONS): Remove 1.8, cygnus, add
	foreign.
	* Makefile.in: Re-generate.
	* aclocal.m4: Re-generate.
	* configure: Re-generate.
2018-06-19 16:55:06 -04:00
Tom Tromey 1a34f210bb Fix the clang build
Simon pointed out that gdb would not build with clang, due to the
addition of -Wimplicit-fallthrough.  This patch fixes the problem by
using -Wimplicit-fallthrough=3 -- this does not work with clang,
bypassing the issue.

Tested by rebuilding with both gcc and clang; and also by verifying
that -Wimplicit-fallthrough=3 is used in the gcc build.

I will file a follow-up bug to convert the fall-through comments to a
form that can be used by both clang and gcc.

gdb/ChangeLog
2018-05-10  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* warning.m4 (AM_GDB_WARNINGS): Use -Wimplicit-fallthrough=3.

gdb/gdbserver/ChangeLog
2018-05-10  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
2018-05-10 10:05:35 -06:00
Tom Tromey aff689d36d Add -Wduplicated-cond
This adds -Wduplicated-cond to warnings.m4.  This caught one bug.

I tried adding -Wduplicated-branches as well, but it results in some
spurious failures from code like this in cgen.h:

    #define CGEN_ATTR_TYPE(n) \
    struct { unsigned int bool_; \
	     CGEN_ATTR_VALUE_TYPE nonbool[(n) ? (n) : 1]; }

This will trigger a warning if passed n==1, which seems like a
perfectly valid thing to do; and there were other issues like this as
well.

ChangeLog
2018-05-07  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* warning.m4 (AM_GDB_WARNINGS): Add -Wduplicated-cond.

gdbserver/ChangeLog
2018-05-07  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
2018-05-07 08:47:38 -06:00
Tom Tromey 85e26832a0 Add -Wimplicit-fallthrough
This adds -Wimplicit-fallthrough to the set of default warnings.

2018-05-04  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* warning.m4 (AM_GDB_WARNINGS): Add -Wimplicit-fallthrough.

gdbserver/ChangeLog
2018-05-04  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
2018-05-04 22:04:46 -06:00
Tom Tromey 632e107b32 Enable -Wsuggest-override
I noticed the existence of -Wsuggest-override and so this patch
enables it for gdb.  It found a few spots that could use "override".
Also I went ahead and removed all uses of the "OVERRIDE" macro.

Using override is beneficial because it makes it harder to change a
base class and then forget to change a derived class.

Tested by the buildbot.

ChangeLog
2018-04-27  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* warning.m4 (AM_GDB_WARNINGS): Add -Wsuggest-override.
	* dwarf2loc.c (class dwarf_evaluate_loc_desc): Use "override", not
	"OVERRIDE".
	(class symbol_needs_eval_context): Likewise.
	* dwarf2read.c (mock_mapped_index::symbol_name_count)
	(mock_mapped_index::symbol_name_at): Use "override".  Remove
	"virtual".
	* dwarf2-frame.c (dwarf_expr_executor::get_addr_index): Use
	"override".
	(class dwarf_expr_executor): Use "override", not "OVERRIDE".
	* aarch64-tdep.c (instruction_reader::read): Use "override".
	(instruction_reader_test::read): Likewise.
	* arm-tdep.c (instruction_reader::read): Use "override".
	(instruction_reader_thumb::read): Likewise.

gdbserver/ChangeLog
2018-04-27  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
2018-04-27 12:53:14 -06:00
Tom Tromey 458412c368 Regenerate gdb/configure and gdbserver/configure
Pedro pointed out that gdb/configure and gdbserver/configure weren't
updated after some recent *.m4 changes.

This patch rebuilds those files.  Tested by rebuilding.  Pedro
approved this in the thread where he raised this issue, so I'm pushing
it in.

ChangeLog
2018-04-23  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

gdbserver/ChangeLog
2018-04-23  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
2018-04-23 09:29:41 -06: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
Eldar Abusalimov f517c1805a configure: Fix test for fs_base/gs_base in <sys/user.h>
Make <sys/types.h> be included prior to including <sys/user.h>.

glibc versions older than 2.14 use __uintNN_t types within certain
structures defined in <sys/user.h> probably assuming these types are
defined prior to including the header. This results in the following
`configure` feature test compilation error that makes it think that
`struct user_regs_struct` doesn't have `fs_base`/`gs_base` fields,
althouh it does.

    configure:13617: checking for struct user_regs_struct.fs_base
    configure:13617: gcc -c -g -O2 -I/linux/include conftest.c >&5
    In file included from conftest.c:158:0:
    /usr/include/sys/user.h:32:3: error: unknown type name '__uint16_t'
       __uint16_t  cwd;
       ^
    /usr/include/sys/user.h:33:3: error: unknown type name '__uint16_t'
       __uint16_t  swd;
       ^
    /usr/include/sys/user.h:34:3: error: unknown type name '__uint16_t'
       __uint16_t  ftw;
       ^
    /usr/include/sys/user.h:35:3: error: unknown type name '__uint16_t'
       __uint16_t  fop;
       ^
    /usr/include/sys/user.h:36:3: error: unknown type name '__uint64_t'
       __uint64_t  rip;
       ^
    /usr/include/sys/user.h:37:3: error: unknown type name '__uint64_t'
       __uint64_t  rdp;
       ^
    /usr/include/sys/user.h:38:3: error: unknown type name '__uint32_t'
       __uint32_t  mxcsr;
       ^
    /usr/include/sys/user.h:39:3: error: unknown type name '__uint32_t'
       __uint32_t  mxcr_mask;
       ^
    /usr/include/sys/user.h:40:3: error: unknown type name '__uint32_t'
       __uint32_t  st_space[32];   /* 8*16 bytes for each FP-reg = 128 bytes */
       ^
    /usr/include/sys/user.h:41:3: error: unknown type name '__uint32_t'
       __uint32_t  xmm_space[64];  /* 16*16 bytes for each XMM-reg = 256 bytes */
       ^
    /usr/include/sys/user.h:42:3: error: unknown type name '__uint32_t'
       __uint32_t  padding[24];
       ^
    configure:13617: $? = 1
    configure: failed program was:
    | /* confdefs.h */
    ...
    | /* end confdefs.h.  */
    | #include <sys/user.h>
    |
    | int
    | main ()
    | {
    | static struct user_regs_struct ac_aggr;
    | if (ac_aggr.fs_base)
    | return 0;
    |   ;
    |   return 0;
    | }

Recent glibc versions don't use typedef'ed int types in <sys/user.h>,
thus allowing it to be included as is
(glibc commit d79a9c949c84e7f0ba33e87447c47af833e9f11a).
However there're still some distros alive that use older glibc,
for instance, RHEL/CentOS 6 package glibc 2.12.

Also affects PR gdb/21559:

    ../../gdb/regcache.c:1087: internal-error: void regcache_raw_supply(regcache, int, const void): Assertion `regnum >= 0 && regnum < regcache->descr->nr_raw_registers' failed.

As noted by Andrew Paprocki, who submitted the PR
(https://sourceware.org/bugzilla/show_bug.cgi?id=21559#c3):

    > It should be noted that modifying `configure` to force on
    > `HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE` and
    > `HAVE_STRUCT_USER_REGS_STRUCT_GS_BASE` fixes this issue. For some
    > reason the `configure` tests for `fs_base` and `gs_base` fail
    > even though `sys/user.h` on RHEL5 has the fields defined in
    > `user_regs_struct`.

Note that this patch does NOT fix the root cause of PR gdb/21559,
although now that `configure` properly detects the presence of the
fields and sets HAVE_XXX accordingly, the execution takes another
path, which doesn't lead to the assertion failure in question.

gdb/ChangeLog:
2018-01-17  Eldar Abusalimov  <eldar.abusalimov@jetbrains.com>

	PR gdb/21559
	* configure.ac: Include <sys/types.h> prior to <sys/user.h> when
	checking for fs_base/gs_base fields in struct user_regs_struct.
	* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2018-01-17  Eldar Abusalimov  <eldar.abusalimov@jetbrains.com>

	PR gdb/21559
	* configure.ac: Include <sys/types.h> prior to <sys/user.h> when
	checking for fs_base/gs_base fields in struct user_regs_struct.
	* configure: Regenerate.
2018-01-17 13:02:19 +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
Rainer Orth 44122162ae Remove ioctl-based procfs support on Solaris
This is the previously mentioned patch to get rid of
unstructured/ioctl-based procfs support in procfs.c.  Given that support
for structured procfs was introduced in Solaris 2.6 back in 1997 and
we're just removing support for Solaris < 10, there's no point in
carrying that baggage (and tons of support for IRIX and OSF/1 as well)
around any longer.

Most of the patch should be straightforward (removing support for
!NEW_PROC_API, non-Solaris OSes and pre-Solaris 10 quirks).

Only a few points need explanations:

* <sys/syscall.h> was already included unconditionally in most places,
  so there's no need to have guards in a few remaining ones.

* configure.host already obsoletes i?86-*-sysv4.2, i?86-*-sysv5, so
  NEW_PROC_API detection for those in configure.ac can go.

* I'm still including <sys/procfs.h> with #define _STRUCTURED_PROC 1.
  Theoretically, it would be better to include <procfs.h> on Solaris
  (which includes that define), but that breaks the build over
  <procfs.h> vs. gdb's "procfs.h", and doesn't exist on Linux.

* I've regenerated syscall_table[] in proc-events.c with a small script
  from Solaris 10, 11.3, 11.4 <sys/syscall.h>, so there should be no
  traces of older Solaris versions and other OSes left.

* prsysent_t and DYNAMIC_SYSCALLS was only used for AIX 5, but AIX
  doesn't use procfs.c any longer, so all related code can go.

The patch was generated with diff -w so one can easier see changes
without being distracted by simple reindentations.

So far, it has only been compiled and smoke-tested on
amd64-pc-solaris2.1[01], sparcv9-sun-solaris2.1[01], and
x86_64-pc-linux-gnu.  Certainly needs more testing (Solaris 11.3
vs. 11.4, 32-bit gdb, testsuite once I've figured out what's wrong on
Solaris 10 etc.), but it's enough to get a first impression how much
cleanup is possible here.

	* configure.ac Don't check for sys/fault.h, sys/syscall.h,
	sys/proc.h.
	(NEW_PROC_API): Remove.
	(prsysent_t, pr_sigset_t, pr_sigaction64_t, pr_siginfo64_t):
	Likewise.
	* common/common.m4 (GDB_AC_COMMON): Don't check for sys/syscall.h.
	* configure: Regenerate.
	* config.in: Regenerate.
	* gdbserver/configure: Regenerate.
	* gdbserver/config.in: Regenerate.

	* i386-sol2-nat.c (_initialize_amd64_sol2_nat): Remove
	NEW_PROC_API test.
	* sparc-sol2-nat.c (_initialize_sparc_sol2_nat): Likewise.

	* linux-btrace.c: Remove HAVE_SYS_SYSCALL_H test.

	* proc-api.c: Remove !NEW_PROC_API support.
	Remove HAVE_SYS_PROC_H and HAVE_SYS_USER_H tests.
	Remove tests for macros always defined on Solaris.
	* proc-events.c: Remove !NEW_PROC_API support.
	Remove Remove HAVE_SYS_SYSCALL_H, HAVE_SYS_PROC_H and
	HAVE_SYS_USER_H tests.
	(init_syscall_table): Remove non-Solaris syscalls.
	Remove tests for syscalls present on all Solaris versions.
	Add missing Solaris 10+ syscalls.
	(signal_table): Remove non-Solaris signals.
	Remove tests for signals present on all Solaris versions.
	(fault_table): Remove non-Solaris faults.
	Remove tests for faults present on all Solaris versions.
	* proc-flags.c: Remove !NEW_PROC_API support.
	(pr_flag_table): Remove non-Solaris and pre-Solaris 7 comments.
	Remove non-Solaris flags.
	* proc-why.c: Remove !NEW_PROC_API support.
	(pr_why_table): Remove meaningless comments.
	Remove tests for reasons present on all Solaris versions.
	Remove OSF/1 cases.
	(proc_prettyfprint_why): Likewise.

	* procfs.c: Remove !NEW_PROC_API and DYNAMIC_SYSCALLS support.
	Remove HAVE_SYS_FAULT_H and HAVE_SYS_SYSCALL_H tests.
	Remove WA_READ test, IRIX watchpoint support.
	(gdb_sigset_t, gdb_sigaction_t, gdb_siginfo_t): Replace by base
	types.  Change users.
	(gdb_praddset, gdb_prdelset, gdb_premptysysset, gdb_praddsysset)
	(gdb_prdelset, gdb_pr_issyssetmember): Replace by base macros.
	Change callers.
	Remove CTL_PROC_NAME_FMT tests.
	(gdb_prstatus_t, gdb_lwpstatus_t): Replace by base types.  Change
	users.
	(sysset_t_size): Remove.  Use sizeof (sysset_t) in callers.
	Remove PROCFS_DONT_PIOCSSIG_CURSIG support.
	(proc_modify_flag): Replace GDBRESET by PCUNSET.
	Remove PR_ASYNC, PR_KLC tests.
	(proc_unset_inherit_on_fork): Remove PR_ASYNC test.
	(proc_parent_pid): Remove PCWATCH etc. tests.
	(proc_set_watchpoint): Remove !PCWATCH && !PIOCSWATCH support.
	Remove PCAGENT test.
	(proc_get_nthreads) [PIOCNTHR && PIOCTLIST]: Remove.
	Remove SYS_lwpcreate || SYS_lwp_create test.
	(proc_get_current_thread): Likewise.
	[PIOCNTHR && PIOCTLIST]: Remove.
	[PIOCLSTATUS]: Remove.
	(procfs_debug_inferior): Remove non-Solaris cases, conditionals.
	[PRFS_STOPEXEC]: Remove.
	(syscall_is_lwp_exit): Remove non-Solaris cases, conditionals.
	(syscall_is_exit): Likewise.
	(syscall_is_exec): Likewise.
	(syscall_is_lwp_create): Likewise.
	Remove SYS_syssgi support.
	(procfs_wait): Remove PR_ASYNC, !PIOCSSPCACT tests.
	[SYS_syssgi]: Remove.
	Remove non-Solaris cases, conditionals.
	(unconditionally_kill_inferior) [PROCFS_NEED_PIOCSSIG_FOR_KILL]:
	Remove.
	(procfs_init_inferior) [SYS_syssgi]: Remove.
	(procfs_set_exec_trap) [PRFS_STOPEXEC]: Remove.
	(procfs_inferior_created) [SYS_syssgi]: Remove.
	(procfs_set_watchpoint): Remove !AIX5 test.
	(procfs_stopped_by_watchpoint): Remove FLTWATCH test, FLTKWATCH
	case.
	(mappingflags) [MA_PHYS]: Remove.
	(info_mappings_callback): Remove PCAGENT test.
	Remove PIOCOPENLWP || PCAGENT test.
2017-11-30 16:05:30 +01:00
Pedro Alves d1928160a3 Don't check termio.h and sgtty.h in common/common.m4 either
common/common.m4 still had checks for termio.h/sgtty.h that are stale
now.  Remove them.

gdb/ChangeLog:
2017-11-06  Pedro Alves  <palves@redhat.com>

	* common/common.m4 (GDB_AC_COMMON): No longer check termio.h nor
	sgtty.h.
	* config.in, configure: Regenerate.

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

	* config.in, configure: Regenerate.
2017-11-06 16:19:12 +00:00
Pedro Alves 726e13564b Assume termios is available, remove support for termio and sgtty
This commit garbage collects the termio and sgtty support.

GDB's terminal handling code still has support for the old termio and
sgtty interfaces in addition to termios.  However, I think it's pretty
safe to assume that for a long, long time, Unix-like systems provide
termios.  GNU/Linux, Solaris, Cygwin, AIX, DJGPP, macOS and the BSDs
all have had termios.h for many years.  Looking around the web, I
found discussions about FreeBSD folks trying to get rid of old sgtty.h
a decade ago:

  https://lists.freebsd.org/pipermail/freebsd-hackers/2007-March/019983.html

So I think support for termio and sgtty in GDB is just dead code that
is never compiled anywhere and is just getting in the way.  For
example, serial_noflush_set_tty_state and the raw<->cooked concerns
mentioned in inflow.c only exist because of sgtty (see
hardwire_noflush_set_tty_state).

Regtested on GNU/Linux.

Confirmed that I can still build Solaris, DJGPP and AIX GDB and that
the resulting GDBs still include the termios.h-guarded code.
Confirmed mingw-w64 GDB still builds and skips the termios.h-guarded
code.

gdb/ChangeLog:
2017-11-06  Pedro Alves  <palves@redhat.com>

	* Makefile.in (SER_HARDWIRE): Update comment.
	(HFILES_NO_SRCDIR): Remove gdb_termios.h.
	* common/gdb_termios.h: Delete file.
	* common/job-control.c: Include termios.h and unistd.h instead of
	gdb_termios.h.
	(gdb_setpgid): Remove HAVE_TERMIOS || TIOCGPGRP preprocessor
	check.
	(have_job_control): Check HAVE_TERMIOS_H instead of HAVE_TERMIOS.
	Remove sgtty code.
	* configure.ac: No longer check for termio.h and sgtty.h.
	* configure: Regenerate.
	* inflow.c: Include termios.h instead of gdb_termios.h.  Replace
	PROCESS_GROUP_TYPE checks with HAVE_TERMIOS_H checks throughout.
	Replace PROCESS_GROUP_TYPE references with pid_t references
	throughout.
	(gdb_getpgrp): Delete.
	(set_initial_gdb_ttystate): Use tcgetpgrp instead of gdb_getpgrp.
	(child_terminal_inferior): Remove comment.  Remove sgtty code.
	(child_terminal_ours_1): Use tcgetpgrp directly instead of
	gdb_getpgrp.  Use serial_set_tty_state instead aof
	serial_noflush_set_tty_state.  Remove sgtty code.
	* inflow.h: Include unistd.h instead of gdb_termios.h.  Replace
	PROCESS_GROUP_TYPE check with HAVE_TERMIOS_H check.
	(inferior_process_group): Now returns pid_t.
	* ser-base.c (ser_base_noflush_set_tty_state): Delete.
	* ser-base.h (ser_base_noflush_set_tty_state): Delete.
	* ser-event.c (serial_event_ops): Update.
	* ser-go32.c (dos_noflush_set_tty_state): Delete.
	(dos_ops): Update.
	* ser-mingw.c (hardwire_ops, tty_ops, pipe_ops, tcp_ops): Update.
	* ser-pipe.c (pipe_ops): Update.
	* ser-tcp.c (tcp_ops): Update.
	* ser-unix.c: Include termios.h instead of gdb_termios.h.  Remove
	HAVE_TERMIOS checks.
	[HAVE_TERMIO] (struct hardwire_ttystate): Delete.
	[HAVE_SGTTY] (struct hardwire_ttystate): Delete.
	(get_tty_state, set_tty_state): Drop termio and sgtty code, and
	assume termios.
	(hardwire_noflush_set_tty_state): Delete.
	(hardwire_print_tty_state, hardwire_drain_output)
	(hardwire_flush_output, hardwire_flush_input)
	(hardwire_send_break, hardwire_raw, hardwire_setbaudrate)
	(hardwire_setstopbits, hardwire_setparity): Drop termio and sgtty
	code, and assume termios.
	(hardwire_ops): Update.
	(_initialize_ser_hardwire): Remove HAVE_TERMIOS check.
	* serial.c (serial_noflush_set_tty_state): Delete.
	* serial.h (serial_noflush_set_tty_state): Delete.
	(serial_ops::noflush_set_tty_state): Delete.

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

	* configure.ac: No longer check for termio.h and sgtty.h.
	* configure: Regenerate.
	* remote-utils.c: Include termios.h instead of gdb_termios.h.
	(remote_open): Check HAVE_TERMIOS_H instead of HAVE_TERMIOS.
	Remove termio and sgtty code.
2017-11-06 15:36:46 +00: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
Yao Qi 5bfda25568 Regenerate gdbserver/configure
4fa7574 (Fix gdb 8.1 Solaris compilation) changes warning.m4 and updates
configure, but gdbserver/configure is not updated.

gdb/gdbserver:

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

	* configure: Regenerated.
2017-10-16 11:26:38 +01: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 8465943af6 gdb: Add -Wno-mismatched-tags
clang complains that for some types, we use both the class and struct
keywords in different places.  It's not really a problem, so I think we
can safely turn this warning off.

gdb/ChangeLog:

	* configure: Re-generate.
	* warning.m4 (build_warnings): Add -Wno-mismatched-tags.

gdb/gdbserver/ChangeLog:

	* configure: Re-generate.
2017-06-17 23:18:49 +02:00
Simon Marchi 3e019bdc20 gdb: Use -Werror when checking for (un)supported warning flags
In warning.m4, we pass all the warning flags one by one to the compiler
to test if they are supported by this particular compiler.  If the
compiler exits with an error, we conclude that this warning flag is not
supported and exclude it.  This allows us to use warning flags without
having to worry about which versions of which compilers support each
flag.

clang, by default, only emits a warning if an unknown flag is passed:

  warning: unknown warning option '-Wfoo' [-Wunknown-warning-option]

The result is that we think that all the warning flags we use are
supported by clang (they are not), and the compilation fails later when
building with -Werror, since the aforementioned warning becomes an
error.  The fix is to also pass -Werror when probing for supported
flags, then we'll correctly get an error when using an unknown warning,
and we'll exclude it:

  error: unknown warning option '-Wfoo' [-Werror,-Wunknown-warning-option]

I am not sure why there is a change in a random comment in
gdbserver/configure, but I suppose it's a leftfover from a previous
patch, so I included it.

gdb/ChangeLog:

	* configure: Re-generate.
	* warning.m4: Pass -Werror to compiler when checking for
	supported warning flags.

gdb/gdbserver/ChangeLog:

	* configure: Re-generate.
2017-06-17 23:18:20 +02:00
Pedro Alves e13cb306f0 gdb: Disable -Werror for -Wmaybe-uninitialized
Newer GCCs are triggering false-positive -Wmaybe-uninitialized
warnings around code that uses gdb::optional:
  https://sourceware.org/ml/gdb-patches/2017-05/msg00118.html

Using std::optional wouldn't help, it triggers the same warnings:
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635

Initializing the variables to quiet the warning would defeat the
purpose of gdb::optional.  Making the optional ctor memset its storage
would be a pessimization.  Wrapping gdb::optional's internals with
"#pragma GCC diagnostic push/ignored/pop" doesn't work, we'd have to
wrap uses of gdb::optional instead, which I think would get unwieldy
and ugly as we start using gdb::optional more and more.

The -Wmaybe-uninitialized warning is documented as producing false
positives (unlike -Wuninialized), so until we find a better
workaround, disable -Werror for this warning.  You'll still see the
warning when building gdb, but it won't cause a build failure.

Tested by building with gcc 4.8.5, 5.3.1, and gcc trunk (20170428).

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

	* warning.m4 (build_warnings): Add -Wno-error=maybe-uninitialized.
	* configure: Regenerate.

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

	* configure: Regenerate.
2017-05-05 01:03:28 +01:00
Sergio Durigan Junior c94fee56f5 Regenerate gdb/{,gdbserver/}configure (for commit be628ab814)
On commit be628ab814, both
common/common.m4 was modified in order to check for the presence of
'termios.h', 'termio.h' and 'sgtty.h'.  However, I forgot to
regenerate both gdb/configure and gdb/gdbserver/configure.  This
commit does that.

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

	* configure: Regenerate.

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

	* configure: Regenerate.
2017-05-03 09:17:12 -04:00
Pedro Alves 9bf2a70066 -Wwrite-strings: Remove -Wno-write-strings
AFAIK GDB is now free from -Wwrite-strings warnings.  A few warnings may
be left behind in some host-specific code, but those should be few and
easy to fix.

gdb/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

	* warning.m4 (build_warnings): Remove -Wno-write-strings.
	* configure: Regenerate.

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

	* configure: Regenerate.
2017-04-05 19:21:37 +01:00
Walfred Tedeschi 239b6d1095 gdbserver-amd64: add HAVE_STRUCT_USER_REGS_STRUCT_(GS|FS)_BASE for gdbserver.
The macros mentioned in the title were set only for GDB. In gdbserver they
were not set until now.  To align the code in GDB and gdbserver these macros
are also added into gdbserver, enabling read and write of gs_base and fs_base
registers from the system in new and old kernels.

2017-01-27  Walfred Tedeschi  <walfred.tedeschi@intel.com>

gdb/gdbserver/ChangeLog:

    	* configure.ac: Check if the fs_base and gs_base members of
    	`struct user_regs_struct' exist.
    	* config.in: Regenerated.
    	* configure: Likewise.
2017-01-27 15:20:11 +01: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
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
Pedro Alves 201506dadd x32 Fast tracepoints: IPA target descriptions
Building GDB for x32 fails building the IPA, with:

   .../src/gdb/gdbserver/linux-amd64-ipa.c: In function ‘const target_desc* get_ipa_tdesc(int)’:
   .../src/gdb/gdbserver/linux-amd64-ipa.c:182:14: error: ‘tdesc_amd64_avx_linux’ was not declared in this scope
	  return tdesc_amd64_avx_linux;
		 ^
   .../src/gdb/gdbserver/linux-amd64-ipa.c:184:14: error: ‘tdesc_amd64_mpx_linux’ was not declared in this scope
	  return tdesc_amd64_mpx_linux;
		 ^
   .../src/gdb/gdbserver/linux-amd64-ipa.c:186:14: error: ‘tdesc_amd64_avx_mpx_linux’ was not declared in this scope
	  return tdesc_amd64_avx_mpx_linux;
		 ^
  [...]

The problem is that the IPA is trying to use the 64-bit descriptions,
when it should be using the x32 ones.

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

	PR gdb/20415
	* Makefile.in (x32-linux-ipa.o, x32-avx-linux-ipa.o)
	(x32-avx512-linux-ipa.o): New rules.
	* configure.ac (x86_64-*-linux*): New x32 check.
	* configure.srv (ipa_x32_linux_regobj): New.
	(x86_64-*-linux*): Use $ipa_x32_linux_regobj if building for x32.
	* linux-amd64-ipa.c (get_ipa_tdesc) [__ILP32__]: Return x32
	descriptions.
	(initialize_low_tracepoint) [__ILP32__]: Initialize x32
	descriptions.
	* configure: Regenerate.
2016-08-19 12:07:44 +01:00
Pedro Alves f348d89aec Fix PR gdb/18653: gdb disturbs inferior's inherited signal dispositions
gdb's (or gdbserver's) own signal handling should not interfere with
the signal dispositions their spawned children inherit.  However, it
currently does.  For example, some paths in gdb cause SIGPIPE to be
set to SIG_IGN, and as consequence, the child starts with SIGPIPE to
set to SIG_IGN too, even though gdb was started with SIGPIPE set to
SIG_DFL.

This is because the exec family of functions does not reset the signal
disposition of signals that are set to SIG_IGN:

  http://pubs.opengroup.org/onlinepubs/7908799/xsh/execve.html

  Signals set to the default action (SIG_DFL) in the calling process
  image are set to the default action in the new process
  image. Signals set to be ignored (SIG_IGN) by the calling process
  image are set to be ignored by the new process image. Signals set to
  be caught by the calling process image are set to the default action
  in the new process image (see <signal.h>).

And neither does it reset signal masks or flags.

In order to be transparent, when spawning new child processes to debug
(with "run", etc.), reset signal actions and mask back to what was
originally inherited from gdb/gdbserver's parent, just before execing
the target program to debug.

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

	PR gdb/18653
	* Makefile.in (SFILES): Add
	common/signals-state-save-restore.c.
	(HFILES_NO_SRCDIR): Add common/signals-state-save-restore.h.
	(COMMON_OBS): Add signals-state-save-restore.o.
	(signals-state-save-restore.o): New rule.
	* configure: Regenerate.
	* fork-child.c: Include "signals-state-save-restore.h".
	(fork_inferior): Call restore_original_signals_state.
	* main.c: Include "signals-state-save-restore.h".
	(captured_main): Call save_original_signals_state.
	* common/common.m4: Add sigaction to AC_CHECK_FUNCS checks.
	* common/signals-state-save-restore.c: New file.
	* common/signals-state-save-restore.h: New file.

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

	PR gdb/18653
	* Makefile.in (OBS): Add signals-state-save-restore.o.
	(signals-state-save-restore.o): New rule.
	* config.in: Regenerate.
	* configure: Regenerate.
	* linux-low.c: Include "signals-state-save-restore.h".
	(linux_create_inferior): Call
	restore_original_signals_state.
	* server.c: Include "dispositions-save-restore.h".
	(captured_main): Call save_original_signals_state.

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

	PR gdb/18653
	* gdb.base/signals-state-child.c: New file.
	* gdb.base/signals-state-child.exp: New file.
	* gdb.gdb/selftest.exp (do_steps_and_nexts): Add new pattern.
2016-08-09 20:16:20 +01:00
Pedro Alves 1baf514936 gdb/configure --help: suggest --disable-build-with-cxx instead of --enable...
We build by default with a C++ compiler, but "configure --help" still
says "--enable-build-with-cxx", which hints that it is by default
disabled.  Update the --help text.

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

	* build-with-cxx.m4: Change help string to be in terms of
	--disable-build-with-cxx.
	* configure: Regenerate.

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

	* configure: Regenerate.
2016-08-05 16:54:29 +01:00
Tom Tromey 305450edd3 Add -Wunused-but-set-* to build
This adds -Wunused-but-set-variable and -Wunused-but-set-parameter to
configure.

2016-07-21  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* warning.m4 (AM_GDB_WARNINGS) <build_warnings>: Add
	-Wunused-but-set-parameter, -Wunused-but-set-variable.

2016-07-21  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
2016-07-21 13:07:23 -06:00
Pedro Alves a23585089d Build GDB as a C++ program by default
This makes --enable-build-with-cxx be "yes" by default.

One must now configure with --enable-build-with-cxx=no in order to
build with a C compiler.

gdb/ChangeLog:
2016-04-20  Pedro Alves  <palves@redhat.com>

	* build-with-cxx.m4 (GDB_AC_BUILD_WITH_CXX): Default to yes.
	* configure: Renegerate.

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

	* configure: Renegerate.
2016-04-20 23:20:15 +01:00
Pedro Alves 9b30624b65 Fix PR gdb/19250: ptrace prototype is not detected properly in C++ mode
The ptrace args/return types detection doesn't work properly in C++
mode, on non-GNU/Linux hosts.  For example, on gcc70 (NetBSD 5.1),
where the prototype is:

 int ptrace(int, __pid_t, void*, int);

configure misdetects it as:

 $ grep PTRACE_TYPE config.h
 #define PTRACE_TYPE_ARG1 int
 #define PTRACE_TYPE_ARG3 int *
 #define PTRACE_TYPE_ARG4 int
 /* #undef PTRACE_TYPE_ARG5 */
 #define PTRACE_TYPE_RET int

resulting in:

 ../../src/gdb/amd64bsd-nat.c: In function 'void amd64bsd_fetch_inferior_registers(target_ops*, regcache*, int)':
 ../../src/gdb/amd64bsd-nat.c:56: warning: dereferencing type-punned pointer will break strict-aliasing rules
 ../../src/gdb/amd64bsd-nat.c: In function 'void amd64bsd_store_inferior_registers(target_ops*, regcache*, int)':
 ../../src/gdb/amd64bsd-nat.c:104: warning: dereferencing type-punned pointer will break strict-aliasing rules
 ../../src/gdb/amd64bsd-nat.c:110: warning: dereferencing type-punned pointer will break strict-aliasing rules

We could address this [1], however despite ptrace.m4's claim:

 # Needs to be tested in C++ mode, to detect whether we need to cast
 # the first argument to enum __ptrace_request.

it appears that there's actually no need to test in C++ mode.  Always
running the ptrace tests in C mode works just the same on GNU/Linux.

I remember experimenting with several different ways to handle the
original issue back then, and maybe that was needed in some other
attempt and then I didn't realize it ended up not really necessary.

Confirmed that this fixes the NetBSD 5.1 C++ build, and confirmed that
C and C++ builds on Fedora 23 are unaffected.

[1] - https://sourceware.org/ml/gdb-patches/2016-04/msg00374.html

gdb/ChangeLog:
2016-04-18  Pedro Alves  <palves@redhat.com>

	* ptrace.m4 (GDB_AC_PTRACE): Don't run tests in C++ mode.
	* configure: Regenerate.

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

	* configure: Regenerate.
2016-04-18 17:42:50 +01:00
Simon Marchi 1e94266c4d Modernize configure.ac's
Using AC_OUTPUT with arguments has been deprecated for some time in
autoconf, even in version 2.64, which we are using.  This change should
not affect functionality.

I also removed the "exit 0"'s, they shouldn't be necessary.

gdb/ChangeLog:

	* configure.ac: Use AC_CONFIG_FILES instead of passing arguments
	to AC_OUTPUT.  Remove "exit 0" at the end.
	* configure: Regenerate.

gdb/testsuite/ChangeLog:

	* configure.ac: Use AC_CONFIG_FILES instead of passing arguments
	to AC_OUTPUT.
	* configure: Regenerate.

gdb/gdbserver/ChangeLog:

	* configure.ac: Use AC_CONFIG_FILES instead of passing arguments
	to AC_OUTPUT.
	* configure: Regenerate.
2016-02-09 09:01:58 -05:00
Pedro Alves a994041db3 gdb: Respect CXXFLAGS when building with C++ compiler
Currently, even when built with --enable-build-with-cxx, gdb uses
CFLAGS instead of CXXFLAGS.  This commit fixes it.

CXXFLAGS set in the environment when configure was run is now honored
in the generated gdb/Makefile, and you can also override CXXFLAGS in
the command like at make time, with the usual 'make CXXFLAGS="..."'

Objects built with a C compiler (e.g., gnulib) still honor CFLAGS
instead.

gdb/ChangeLog:
2016-01-21  Pedro Alves  <palves@redhat.com>

	* Makefile.in (COMPILER_CFLAGS): New.
	(CXXFLAGS): Get it from configure.
	(INTERNAL_CFLAGS_BASE, INTERNAL_LDFLAGS): Use COMPILER_CFLAGS
	instead of CFLAGS.
	* build-with-cxx.m4 (GDB_AC_BUILD_WITH_CXX): Set and AC_SUBST
	COMPILER_CFLAGS.
	* configure: Regenerate.

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

	* Makefile.in (COMPILER_CFLAGS, CXXFLAGS): New.
	(INTERNAL_CFLAGS_BASE): Use COMPILER_CFLAGS instead of CFLAGS.
	* configure: Regenerate.
2016-01-21 11:18:45 +00:00
Gary Benson eb0edac83f Fix gdbserver build failure on targets without fork
This commit fixes nat/linux-namespaces.c to build correctly on
targets without fork.

gdb/ChangeLog:

	* nat/linux-namespaces.c (do_fork): New function.
	(linux_mntns_get_helper): Use the above.

gdb/gdbserver/ChangeLog:

	* configure.ac (AC_FUNC_FORK): New check.
	* config.in: Regenerate.
	* configure: Likewise.
2016-01-18 11:39:42 +00:00
Mike Frysinger 8f13a3ce8a gdbserver: use the new gdb warning helpers
We need to use -Wno-missing-prototypes for now as much of the code
sticks externs in local files and not in common headers.

2016-01-11  Mike Frysinger  <vapier@gentoo.org>

	* acinclude.m4: Include new ../warning.m4 file.
	* configure: Regenerated.
	* configure.ac: Replace all warning logic with AM_GDB_WARNINGS.
2016-01-12 10:34:57 -05:00
Pedro Alves 7544db951a Fix -Wno-unknown-warning support detection
Ref: https://sourceware.org/ml/gdb/2015-12/msg00024.html

We have code in configure.ac that tries to detect whether the compiler
supports each warning and suppress it if not, but that doesn't work
with "-Wno-" options, because gcc doesn't error out for
-Wno-unknown-warning unless other diagnostics are being produced.

See https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html.

Handle this by checking whether -Wfoo works when we actually want
-Wno-foo.

gdb/ChangeLog:
2015-12-16  Pedro Alves  <palves@redhat.com>

	* configure.ac (compiler warning flags): When testing a
	-Wno-foo option, check whether -Wfoo works instead.
	* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2015-12-16  Pedro Alves  <palves@redhat.com>

	* configure.ac (compiler warning flags): When testing a
	-Wno-foo option, check whether -Wfoo works instead.
	* configure: Regenerate.
2015-12-16 22:56:49 +00:00
Joel Brobecker 64da5dd5ea [gdbserver] disable Elf32_auxv_t/Elf64_auxv_t AC_CHECK_TYPES check on Android
See the comment added in configure.ac for more details behind
this change.

gdb/gdbserver/ChangeLog:

        * configure.ac: Do not call AC_CHECK_TYPES for Elf32_auxv_t
        and Elf64_auxv_t if the target is Android.
2015-11-23 09:48:16 -08:00
Pedro Alves 9a0847060d [C++] Default to -Werror in C++ mode too
Both x86_64 GNU/Linux and x86_64 mingw-w64 build cleanly with
--enable-targets=all.  This enables -Werror by default in C++ mode
too, in order to let the buildbot catch C++ build regressions for us.

gdb/ChangeLog:
2015-11-19  Pedro Alves  <palves@redhat.com>

	* configure.ac (ERROR_ON_WARNING): Don't check whether in C++
	mode.
	* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2015-11-19  Pedro Alves  <palves@redhat.com>

	* configure.ac (ERROR_ON_WARNING): Don't check whether in C++
	mode.
	* configure: Regenerate.
2015-11-19 14:32:54 +00:00
Pedro Alves dad44a1fba [C++] Drop -fpermissive hack
Both x86_64 GNU/Linux and x86_64 mingw-w64 build cleanly with
--enable-targets=all.  Let's drop the -fpermissive hack, in order to
let the buildbot catch C++ build regressions for us.

gdb/ChangeLog:
2015-11-19  Pedro Alves  <palves@redhat.com>

	* build-with-cxx.m4 (GDB_AC_BUILD_WITH_CXX): Remove -fpermissive.
	* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2015-11-19  Pedro Alves  <palves@redhat.com>

	* configure: Regenerate.
2015-11-19 14:32:54 +00:00
Pedro Alves 5401971915 C++: handle glibc's ptrace(enum __ptrace_request, ...)
Building in C++ mode issues ~40 warnings like this:

 ../../src/gdb/linux-nat.c: In function ‘int linux_handle_extended_wait(lwp_info*, int, int)’:
 ../../src/gdb/linux-nat.c:2016:51: warning: invalid conversion from ‘int’ to ‘__ptrace_request’ [-fpermissive]
	ptrace (PTRACE_GETEVENTMSG, pid, 0, &new_pid);

The issue is that in glibc, ptrace's first parameter is an enum.
That's not a problem if we pick the PTRACE_XXX requests from
sys/ptrace.h, as those will be values of the corresponding enum.
However, we have fallback definitions for PTRACE_XXX symbols when the
system headers miss them (such as PTRACE_GETEVENTMSG above), and those
are plain integer constants.  E.g., nat/linux-ptrace.h:

 #define PTRACE_GETEVENTMSG	0x4201

One idea would be to fix this by defining those fallbacks like:

 -#define PTRACE_GETEVENTMSG	0x4201
 +#define PTRACE_GETEVENTMSG	((enum __ptrace_request) 0x4201)

However, while glibc's ptrace uses enum __ptrace_request for first
parameter:

  extern long int ptrace (enum __ptrace_request __request, ...) __THROW;

other libc's, like e.g., Android's bionic do not -- in that case, the
first parameter is int:

  long ptrace(int request, pid_t pid, void * addr, void * data);

So the fix I came up is to make configure/ptrace.m4 also detect the
type of the ptrace's first parameter and defin PTRACE_TYPE_ARG1, as
already does the for parameters 3-4, and then simply wrap ptrace with
a macro that casts the first argument to the detected type.  (I'm
leaving adding a nicer wrapper for when we drop building in C).

While this adds the wrapper, GNU/Linux files won't use it until the
next patch, which makes all native GNU/Linux files include
gdb_ptrace.h.

gdb/ChangeLog:
2015-07-24  Pedro Alves  <palves@redhat.com>

	* ptrace.m4 (ptrace tests): Test in C++ mode.  Try with 'enum
	__ptrace_request as first parameter type instead of int.
	(PTRACE_TYPE_ARG1): Define.
	* nat/gdb_ptrace.h [!PTRACE_TYPE_ARG5] (ptrace): Define as wrapper
	that casts first argument to PTRACE_TYPE_ARG1.
	* config.in: Regenerate.
	* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2015-07-24  Pedro Alves  <palves@redhat.com>

	* config.in: Regenerate.
	* configure: Regenerate.
2015-07-24 15:12:15 +01:00
Pedro Alves eb7aa56163 make gdbserver use the same ptrace autoconf checks as gdb
This factors the ptrace checks out of gdb's configure.ac to a new
ptrace.m4 file, and then makes gdbserver's configure.ac source it too.

gdb/ChangeLog:
2015-07-24  Pedro Alves  <palves@redhat.com>

	* acinclude.m4: Include ptrace.m4.
	* configure.ac: Call GDB_AC_PTRACE and move ptrace checks ...
	* ptrace.m4: ... to this new file.

gdb/gdbserver/ChangeLog:
2015-07-24  Pedro Alves  <palves@redhat.com>

	* acinclude.m4: Include ../ptrace.m4.
	* configure.ac: Call GDB_AC_PTRACE.
	* config.in, configure: Regenerate.
2015-07-24 14:57:19 +01:00
Jan Kratochvil db1ff28b60 Revert the previous 7 commits of: Validate binary before use
ddc98fbf2f Create empty nat/linux-maps.[ch] and common/target-utils.[ch]
6e5b4429db Move gdb_regex* to common/
f7af1fcd75 Prepare linux_find_memory_regions_full & co. for move
9904185cfd Move linux_find_memory_regions_full & co.
700ca40f6f gdbserver build-id attribute generator
ca5268b6be Validate symbol file using build-id
0a94970d66 Tests for validate symbol file using build-id

gdb/ChangeLog
2015-07-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Revert the previous 6 commits:
	Create empty nat/linux-maps.[ch] and common/target-utils.[ch].
	Move gdb_regex* to common/
	Prepare linux_find_memory_regions_full & co. for move
	Move linux_find_memory_regions_full & co.
	gdbserver build-id attribute generator
	Validate symbol file using build-id

gdb/gdbserver/ChangeLog
2015-07-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Revert the previous 3 commits:
	Move gdb_regex* to common/
	Move linux_find_memory_regions_full & co.
	gdbserver build-id attribute generator

gdb/doc/ChangeLog
2015-07-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Revert the previous 2 commits:
	gdbserver build-id attribute generator
	Validate symbol file using build-id

gdb/testsuite/ChangeLog
2015-07-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Revert the previous commit:
	Tests for validate symbol file using build-id.
2015-07-15 20:27:32 +02:00
Jan Kratochvil 6e5b4429db Move gdb_regex* to common/
Later patches need regex support also in gdbserver.

gdb/ChangeLog
2015-07-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (HFILES_NO_SRCDIR): Change gdb_regex.h to
	common/gdb_regex.h.
	(COMMON_OBS): Add gdb_regex.o.
	(gdb_regex.o): New.
	* common/common.m4 (GDB_AC_COMMON): Add gdb_use_included_regex,
	--without-included-regex and USE_INCLUDED_REGEX.
	* common/gdb_regex.c: New file from utils.c functions.
	* common/gdb_regex.h: Move it here from gdb_regex.h, update include
	file wrapping define name.
	* configure: Rebuilt.
	* configure.ac (gdb_use_included_regex, --without-included-regex)
	(USE_INCLUDED_REGEX): Move them to common/common.m4.
	* gdb_regex.h: Move it to common/gdb_regex.h.
	* utils.c: Remove include gdb_regex.h.
	(do_regfree_cleanup, make_regfree_cleanup, get_regcomp_error)
	(compile_rx_or_error): Move them to common/gdb_regex.c.

gdb/gdbserver/ChangeLog
2015-07-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (OBS): Add gdb_regex.o.
	(gdb_regex.o): New.
	* config.in: Rebuilt.
	* configure: Rebuilt.
2015-07-15 17:39:17 +02:00
Gary Benson 4b8b5e7245 Introduce nat/linux-namespaces.[ch]
This commit introduces new shared files nat/linux-namespaces.[ch]
containing code to support Linux namespaces that will be used by
both GDB and gdbserver.

gdb/ChangeLog:

	* configure.ac (AC_CHECK_FUNCS): Add setns.
	* config.in: Regenerate.
	* configure: Likewise.
	* nat/linux-namespaces.h: New file.
	* nat/linux-namespaces.c: Likewise.
	* Makefile.in (HFILES_NO_SRCDIR): Add nat/linux-namespaces.h.
	(linux-namespaces.o): New rule.
	* config/aarch64/linux.mh (NATDEPFILES): Add linux-namespaces.o.
	* config/alpha/alpha-linux.mh (NATDEPFILES): Likewise.
	* config/arm/linux.mh (NATDEPFILES): Likewise.
	* config/i386/linux.mh (NATDEPFILES): Likewise.
	* config/i386/linux64.mh (NATDEPFILES): Likewise.
	* config/ia64/linux.mh (NATDEPFILES): Likewise.
	* config/m32r/linux.mh (NATDEPFILES): Likewise.
	* config/m68k/linux.mh (NATDEPFILES): Likewise.
	* config/mips/linux.mh (NATDEPFILES): Likewise.
	* config/pa/linux.mh (NATDEPFILES): Likewise.
	* config/powerpc/linux.mh (NATDEPFILES): Likewise.
	* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
	* config/powerpc/spu-linux.mh (NATDEPFILES): Likewise.
	* config/s390/linux.mh (NATDEPFILES): Likewise.
	* config/sparc/linux.mh (NATDEPFILES): Likewise.
	* config/sparc/linux64.mh (NATDEPFILES): Likewise.
	* config/tilegx/linux.mh (NATDEPFILES): Likewise.
	* config/xtensa/linux.mh (NATDEPFILES): Likewise.

gdb/gdbserver/ChangeLog:

	* configure.ac (AC_CHECK_FUNCS): Add setns.
	* config.in: Regenerate.
	* configure: Likewise.
	* Makefile.in (SFILES): Add nat/linux-namespaces.c.
	(linux-namespaces.o): New rule.
	* configure.srv (srv_linux_obj): Add linux-namespaces.o.
2015-06-10 14:28:43 +01:00
Joel Brobecker 1041a03c1b Fix gdbserver build failure on arm-android.
The following patch...

| proc-service, extern "C"
|
| libthread_db.so calls symbols in the client (GDB), through the
| proc-service interface.  These routines must have extern "C" linkage
| so their symbol names are not mangled when GDB is built as a C++
| program.  On the GDBserver side, we were missing fallback declarations for
| all these symbols.
|
| gdb/ChangeLog:
|
|     * gdb_proc_service.h: Wrap with EXTERN_C_PUSH/EXTERN_C_POP.
|
| gdb/gdbserver/ChangeLog:
| 2015-02-27  Pedro Alves  <palves@redhat.com>
|
|     * gdb_proc_service.h: Wrap with EXTERN_C_PUSH/EXTERN_C_POP.
|     [!HAVE_PROC_SERVICE_H] (struct ps_prochandle): Forward declare.
|     [!HAVE_PROC_SERVICE_H] (ps_pdread, ps_pdwrite, ps_ptread)
|     ps_ptwrite, ps_lgetregs, ps_lsetregs, ps_lgetfpregs)
|     (ps_lsetfpregs, ps_getpid)
|     (ps_get_thread_area, ps_pglobal_lookup, ps_pstop, ps_pcontinue)
|     (ps_lstop, ps_lcontinue, ps_lgetxregsize, ps_lgetxregs)
|     (ps_lsetxregs, ps_plog): Declare.

... added a number of declarations which do not compile when cross-
compiling GDBserver on arm-android. The problem comes from type
prfpregset_t not being declared:

    /[...]/gdbserver/gdb_proc_service.h:98:47:
    error: unknown type name 'prfpregset_t'

After searching through the includes of the install we have,
I could not find that type being declared anywhere. So I did
the same as for prgregset_t, and created the typedef if the
type isn't declared.

gdb/gdbserver/ChangeLog:

        * configure.ac: Add prfpregset_t BFD_HAVE_SYS_PROCFS_TYPE check.
        * configure, config.in: Regenerate.
        * gdb_proc_service.h [HAVE_PRFPREGSET_T] (prfpregset_t):
        Declare typedef.
2015-05-14 07:13:16 -07:00
Gary Benson 791c00567a Move remote_fileio_to_fio_stat to gdb/common
This commit moves remote_fileio_to_fio_stat and its supporting
functions into new files common/common-remote-fileio.[ch].

gdb/ChangeLog:

	* common/common-remote-fileio.h: New file.
	* common/common-remote-fileio.c: Likewise.
	* Makefile.in (SFILES): Add common/common-remote-fileio.c.
	(HFILES_NO_SRCDIR): Add common/common-remote-fileio.h.
	(COMMON_OBS): Add common-remote-fileio.o.
	(common-remote-fileio.o): New rule.
	* remote-fileio.h (common-remote-fileio.h): New include.
	* remote-fileio.c (gdb/fileio.h): Do not include.
	(remote_fileio_to_be): Moved to common-remote-fileio.h.
	(remote_fileio_to_fio_uint): Likewise.
	(remote_fileio_to_fio_time): Likewise.
	(remote_fileio_mode_to_target): Moved to common-remote-fileio.c.
	(remote_fileio_to_fio_mode): Likewise.
	(remote_fileio_to_fio_ulong): Likewise.
	(remote_fileio_to_fio_stat): Likewise.

gdb/gdbserver/ChangeLog:

	* configure.ac (AC_CHECK_MEMBERS): Add checks for
	struct stat.st_blocks and struct stat.st_blksize.
	* configure: Regenerate.
	* config.in: Likewise.
	* Makefile.in (SFILES): Add common/common-remote-fileio.c.
	(OBS): Add common-remote-fileio.o.
	(common-remote-fileio.o): New rule.
2015-03-11 17:53:57 +00:00
Pedro Alves aac331e484 Remove C-specific warnings from common warning set
Whoops, these are C specific, but I somehow missed the warnings before:

  cc1plus: warning: command line option ‘-Wmissing-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
  cc1plus: warning: command line option ‘-Wdeclaration-after-statement’ is valid for C/ObjC but not for C++ [enabled by default]
  cc1plus: warning: command line option ‘-Wmissing-parameter-type’ is valid for C/ObjC but not for C++ [enabled by default]
  cc1plus: warning: command line option ‘-Wold-style-declaration’ is valid for C/ObjC but not for C++ [enabled by default]
  cc1plus: warning: command line option ‘-Wold-style-definition’ is valid for C/ObjC but not for C++ [enabled by default]

gdb/ChangeLog:
2015-03-07  Pedro Alves  <palves@redhat.com>

	* configure.ac (build_warnings): Move -Wmissing-prototypes
	-Wdeclaration-after-statement -Wmissing-parameter-type
	-Wold-style-declaration -Wold-style-definition to the C-specific
	set.
	* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2015-03-07  Pedro Alves  <palves@redhat.com>

	* configure.ac (build_warnings): Move
	-Wdeclaration-after-statement to the C-specific set.
	* configure: Regenerate.
2015-03-07 18:00:15 +00:00
Pedro Alves 3bc3d82a00 Add --enable-build-with-cxx configure switch
This new option, disabled by default for now, allows specifying
whether to build GDB, GDBserver, and friends with a C++ (98/03)
compiler.

The name of the switch should be familiar to those who followed GCC's
own C++ conversion process.

. Adding -fpermissive to COMPILER in C++ mode (see the new
build-with-cxx.m4 file) makes errors like these be warnings instead:

  gdb/infrun.c:6597:1: error:   initializing argument 1 of ‘void sig_print_info(gdb_signal)’ [-fpermissive]
   sig_print_info (enum gdb_signal oursig)
   ^
  gdb/infrun.c: In function ‘void do_restore_infcall_suspend_state_cleanup(void*)’:
  gdb/infrun.c:7164:39: error: invalid conversion from ‘void*’ to ‘infcall_suspend_state*’ [-fpermissive]
     restore_infcall_suspend_state (state);
				 ^

so that the compiler carries on compiling the file.  -Werror still
catches the warnings, so nothing is lost, only our lifes are made
easier by concentrating on getting other more important things out of
the way first.

There's no way to quiet those warnings.  Until they're all fixed, when
building in C++ mode, -Werror is disabled by default.

. Adding -Wno-narrowing suppresses thousands of instances of this warning:

  gdb/arm-linux-tdep.c:439:1: error: narrowing conversion of ‘-1’ from ‘int’ to ‘ULONGEST {aka long unsigned int}’ inside { } is ill-formed in C++11 [-Werror=narrowing]
  gdb/arm-linux-tdep.c:439:1: error: narrowing conversion of ‘-1l’ from ‘LONGEST {aka long int}’ to ‘ULONGEST {aka long unsigned int}’ inside { } is ill-formed in C++11 [-Werror=narrowing]
  gdb/arm-linux-tdep.c:450:1: error: narrowing conversion of ‘-1’ from ‘int’ to ‘ULONGEST {aka long unsigned int}’ inside { } is ill-formed in C++11 [-Werror=narrowing]

We can defer handling those until we target C++11.


. Adding -Wno-sign-compare suppresses thousands of instances of this warning:

  gdb/linux-record.c:1763:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
	 if (tmpulongest == tdep->fcntl_F_GETLK64)
				  ^


. Adding -Wno-write-strings suppresses thousands of instances of this warning:

  gdb/mi/mi-cmd-var.c: In function ‘void mi_cmd_var_show_attributes(char*, char**, int)’:
  gdb/mi/mi-cmd-var.c:514:12: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
       attstr = "editable";
	      ^
  gdb/mi/mi-cmd-var.c:516:12: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
       attstr = "noneditable";
	      ^

For now, it's best to hide these warnings from view until we're
'-fpermissive'-clean, and can thus start building with -Werror.
The C compiler has always managed to build working GDBs with these
issues in the code, so a C++ compiler should too.

gdb/ChangeLog:
2015-02-27  Pedro Alves  <palves@redhat.com>

	* Makefile.in (COMPILER): New, get it from autoconf.
	(COMPILE.pre, CC_LD): Use COMPILER.
	(CXX): Get from autoconf instead.
	(CXX_FOR_TARGET): Default to g++ instead of gcc.
	* acinclude.m4: Include build-with-cxx.m4.
	* build-with-cxx.m4: New file.
	* configure.ac: Call AC_PROG_CXX and GDB_AC_BUILD_WITH_CXX.
	Disable -Werror by default if building in C++ mode.
	(build_warnings): Add -Wno-sign-compare, -Wno-write-strings and
	-Wno-narrowing in C++ mode.  Only enable -Wpointer-sign in C mode.
	Run supported-warning-flags tests with the C++ compiler.
	Save/restore CXXFLAGS too.
	* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2015-02-27  Pedro Alves  <palves@redhat.com>

	* Makefile.in (COMPILER): New, get it from autoconf.
	(CXX): Get from autoconf instead.
	(COMPILE.pre): Use COMPILER.
	(CC-LD): Rename to ...
	(CC_LD): ... this.  Use COMPILER.
	(gdbserver$(EXEEXT), gdbreplay$(EXEEXT), $(IPA_LIB)): Adjust.
	(CXX_FOR_TARGET): Default to g++ instead of gcc.
	* acinclude.m4: Include build-with-cxx.m4.
	* configure.ac: Call AC_PROG_CXX and GDB_AC_BUILD_WITH_CXX.
	Disable -Werror by default if building in C++ mode.
	(build_warnings): Add -Wno-sign-compare, -Wno-write-strings and
	-Wno-narrowing in C++ mode. Run supported-warning-flags tests with
	the C++ compiler.  Save/restore CXXFLAGS too.
	* configure: Regenerate.
2015-02-27 16:24:02 +00:00
Pedro Alves 07697489f4 Create libiberty.m4, have GDB and GDBserver use it
Converting GDB to be a C++ program, I stumbled on 'basename' issues,
like:

 src/gdb/../include/ansidecl.h:169:64: error: new declaration ‘char* basename(const char*)’
 /usr/include/string.h:597:26: error: ambiguates old declaration ‘const char* basename(const char*)’

which I believe led to this bit in gold's configure.ac:

 dnl We have to check these in C, not C++, because autoconf generates
 dnl tests which have no type information, and current glibc provides
 dnl multiple declarations of functions like basename when compiling
 dnl with C++.
 AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp])

These checks IIUC intend to generate all the HAVE_DECL_FOO symbols
that libiberty.h and ansidecl.h check.

GDB is missing these checks currently, which results in the conflict
shown above.

This adds an m4 file that both GDB and GDBserver's configury use to
pull in the autoconf checks that libiberty clients needs done in order
to use these libiberty.h/ansidecl.h.

gdb/ChangeLog:
2015-02-27  Pedro Alves  <palves@redhat.com>

	* libiberty.m4: New file.
	* acinclude.m4: Include libiberty.m4.
	* configure.ac: Call libiberty_INIT.
	* config.in, configure: Regenerate.

gdb/gdbserver/
2015-02-27  Pedro Alves  <palves@redhat.com>

	* acinclude.m4: Include libiberty.m4.
	* configure.ac: Call libiberty_INIT.
	* config.in, configure: Regenerate.
2015-02-27 15:52:02 +00:00
Sergio Durigan Junior fb23d55442 Move safe_strerror to common/
This patch moves safe_strerror from the gdb/{posix,mingw}-hdep.c files
to the respective common/{posix,mingw}-strerror.c files.  This is a
preparation for the next patch, which shares a common code (to disable
address space randomization when creating a new inferior).

The patch has been regtested on Fedora 20 x86_64, and no regressions
were found.

gdb/ChangeLog
2015-01-15  Sergio Durigan Junior  <sergiodj@redhat.com>

	* Makefile.in (ALLDEPFILES): Including common/mingw-strerror.c and
	common/posix-strerror.c.
	(posix-strerror.o): New rule.
	(mingw-strerror.o): Likewise.
	* common/common-utils.h (safe_strerror): Move prototype to here,
	from utils.h.
	* common/common.host: New file.
	* common/mingw-strerror.c: Likewise.
	* common/posix-strerror.c: Likewise.
	* configure: Regenerated.
	* configure.ac: Source common/common.host.  Add variable
	common_host_obs to gdb_host_obs.
	* contrib/ari/gdb_ari.sh: Mention gdb/common/mingw-strerror.c and
	gdb/common/posix-strerror.c when warning about the use of
	strerror.
	* mingw-hdep.c (safe_strerror): Remove definition; move it to
	common/mingw-strerror.c.
	* posix-hdep.c (safe_strerror): Remove definition; move it to
	common/posix-hdep.c.
	* utils.h (safe_strerror): Remove prototype; move to
	common/common-utils.h.

gdb/gdbserver/ChangeLog
2015-01-15  Sergio Durigan Junior  <sergiodj@redhat.com>

	* Makefile.in (posix-strerror.o): New rule.
	(mingw-strerror.o): Likewise.
	* configure: Regenerated.
	* configure.ac: Source file ../common/common.host.  Initialize new
	variable srv_host_obs.  Add srv_host_obs to GDBSERVER_DEPFILES.
2015-01-15 15:09:15 -05:00
Yao Qi cdf436294f Detect 64-bit-ness in PowerPC Book III-E
This patch is to teach both GDB and GDBServer to detect 64-bit inferior
correctly.  We find a problem that GDBServer is unable to detect on a
e5500 core processor.  Current GDBServer assumes that MSR is a 64-bit
register, but MSR is a 32-bit register in Book III-E.  This patch is
to fix this problem by checking the right bit in MSR, in order to handle
both Book III-S and Book III-E.  In order to detect Book III-S and
Book III-E, we check the PPC_FEATURE_BOOKE from the host's HWCAP (by
getauxval on glibc >= 2.16.  If getauxval doesn't exist, we implement
the fallback by parsing /proc/self/auxv), because it should an invariant
on the same machine cross different processes.

In order to share code, I add nat/ppc-linux.c for both GDB and
GDBserver side.

gdb:

2015-01-14  Yao Qi  <yao@codesourcery.com>

	* Makefile.in (ppc-linux.o): New rule.
	* config/powerpc/ppc64-linux.mh (NATDEPFILES): Add ppc-linux.o.
	* configure.ac: AC_CHECK_FUNCS(getauxval).
	* config.in: Re-generated.
	* configure: Re-generated.
	* nat/ppc-linux.h [__powerpc64__] (ppc64_64bit_inferior_p):
	Declare.
	* nat/ppc-linux.c: New file.
	* ppc-linux-nat.c (ppc_linux_target_wordsize) [__powerpc64__]:
	Call ppc64_64bit_inferior_p.

gdb/gdbserver:

2015-01-14  Yao Qi  <yao@codesourcery.com>

	* Makefile.in (SFILES): Add nat/ppc-linux.c.
	(ppc-linux.o): New rule.
	* configure.srv (powerpc*-*-linux*): Add ppc-linux.o.
	* configure.ac: AC_CHECK_FUNCS(getauxval).
	* config.in: Re-generated.
	* configure: Re-generated.
	* linux-ppc-low.c (ppc_arch_setup) [__powerpc64__]: Call
	ppc64_64bit_inferior_p
2015-01-14 22:28:27 +08:00