Commit Graph

231 Commits

Author SHA1 Message Date
Markus Metzger c56ccc05b2 config, btrace: check for pt_insn_event in libipt
Version 2 of libipt adds an event system to instruction flow decoders and
deprecates indicating events via flags in struct pt_insn.  Add configuration
checks to determine which version we have.

gdb/
	* configure.ac: Check for pt_insn_event, struct pt_insn.enabled,
	and struct pt_insn.resynced.
	* configure: Regenerated.
	* config.in: Regenerated.
2017-05-31 10:44:32 +02:00
Maciej W. Rozycki c50730217d Remove IRIX 5 <sys/proc.h> _KMEMUSER workaround
Complement commit 3831839c08 ("Delete IRIX support") and remove the
IRIX 5 <sys/proc.h> _KMEMUSER workaround from the `configure' script, as
IRIX is no longer a supported host configuration.

	gdb/
	* configure.ac <mips-sgi-irix5*>: Remove <sys/proc.h> _KMEMUSER
	workaround.
	* configure: Regenerate.
	* config.in: Regenerate.
2016-10-31 17:06:24 +00: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 f77a9b4860 Regen gdb/config.in
gdb/ChangeLog:
2016-10-19  Pedro Alves  <palves@redhat.com>

	* config.in: Regenerate.
2016-10-19 14:35:06 +01:00
John Baldwin e6cdd38e8f Add support for catching system calls to native FreeBSD targets.
All platforms on FreeBSD use a shared system call table, so use a
single XML file to describe the system calls available on each FreeBSD
platform.

Recent versions of FreeBSD include the identifier of the current
system call when reporting a system call entry or exit event in the
ptrace_lwpinfo structure obtained via PT_LWPINFO in fbsd_wait.  As
such, FreeBSD native targets do not use the gdbarch method to fetch
the system call code.  In addition, FreeBSD register sets fetched via
ptrace do not include an equivalent of 'orig_rax' (on amd64 for
example), so the system call code cannot be extracted from the
available registers during a system call exit.  However, GDB assumes
that system call catch points are not supported if the gdbarch method
is not present.  As a workaround, FreeBSD ABIs install a dummy gdbarch
method that throws an internal_error if it is ever invoked.

gdb/ChangeLog:

	* configure.ac: Check for support for system call LWP fields on
	FreeBSD.
	* config.in, configure: Rebuild.
	* data-directory/Makefile.in (SYSCALLS_FILES): Add freebsd.xml.
	* fbsd-nat.c (fbsd_wait) [HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE]:
	Report system call events.
	[HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE]
	(fbsd_set_syscall_catchpoint): New function.
	(fbsd_nat_add_target) [HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE]:
	Set "to_set_syscall_catchpoint" to "fbsd_set_syscall_catchpoint".
	* fbsd-tdep.c: Include xml-syscall.h
	(fbsd_get_syscall_number): New function.
	(fbsd_init_abi): Set XML system call file name.
	Add "get_syscall_number" gdbarch method.
	* syscalls/freebsd.xml: New file.
2016-06-24 10:46:03 -07:00
Tom Tromey dcd1f97951 Add self-test framework to gdb
I wanted to unit test the Rust lexer, so I added a simple unit testing
command to gdb.

The intent is that self tests will only be compiled into gdb in
development mode.  In release mode they simply won't exist.  So, this
exposes $development to C code as GDB_SELF_TEST.

In development mode, test functions are registered with the self test
module.  A test function is just a function that does some checks, and
throws an exception on failure.

Then this adds a new "maint selftest" command which invokes the test
functions, and a new dejagnu test case that invokes it.

2016-05-17  Tom Tromey  <tom@tromey.com>

	* NEWS: Add "maint selftest" entry.
	* selftest.h: New file.
	* selftest.c: New file.
	* maint.c: Include selftest.h.
	(maintenance_selftest): New function.
	(_initialize_maint_cmds): Add "maint selftest" command.
	* configure.ac (GDB_SELF_TEST): Maybe define.
	* config.in, configure: Rebuild.
	* Makefile.in (SFILES): Add selftest.c.
	(COMMON_OBS): Add selftest.o.

2016-05-17  Tom Tromey  <tom@tromey.com>

	* gdb.texinfo (Maintenance Commands): Document "maint selftest".

2016-05-17  Tom Tromey  <tom@tromey.com>

	* gdb.gdb/unittest.exp: New file.
2016-05-17 12:01:59 -06:00
John Baldwin 6e9567fe2a Add support for LWP-based threads on FreeBSD.
Older versions of FreeBSD supported userland threading via a pure
user-space threading library (N threads scheduled on 1 process) and
a N:M model (N threads scheduled on M LWPs).  However, modern FreeBSD
versions only support a M:M threading model where each user thread is
backed by a dedicated LWP.  This thread target only supports this
threading model.  It also uses ptrace to query and alter LWP state
directly rather than using libthread_db to simplify the implementation.

FreeBSD recently gained support for reporting LWP events (birth and death
of LWPs).  GDB will use LWP events when present.  For older systems it
fetches the list of LWPs in the to_update_thread_list target op to update
the list of threads on each stop.

This target supports scheduler locking by using ptrace to suspend
individual LWPs as necessary before resuming a process.

gdb/ChangeLog:

	* configure.ac: Check for support for LWP names on FreeBSD.
	* fbsd-nat.c [PT_LWPINFO] New variable debug_fbsd_lwp.
	[TDP_RFPPWAIT || HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME]
	(fbsd_fetch_kinfo_proc): Move function earlier.
	[PT_LWPINFO] (fbsd_thread_alive): New function.
	[PT_LWPINFO] (fbsd_pid_to_str): New function.
	[HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME] (fbsd_thread_name): New function.
	[PT_LWP_EVENTS] (fbsd_enable_lwp_events): New function.
	[PT_LWPINFO] (fbsd_add_threads): New function.
	[PT_LWPINFO] (fbsd_update_thread_list): New function.
	[PT_LWPINFO] New variable super_resume.
	[PT_LWPINFO] (resume_one_thread_cb): New function.
	[PT_LWPINFO] (resume_all_threads_cb): New function.
	[PT_LWPINFO] (fbsd_resume): New function.
	(fbsd_remember_child): Save full ptid instead of plain pid.
	(fbsd_is_child_pending): Return ptid of saved child process.
	(fbsd_wait): Include lwp in returned ptid and switch to LWP ptid on
	first stop.
	[PT_LWP_EVENTS] Handle LWP events.
	[TDP_RFPPWAIT] Include LWP in child ptid.
	(fbsd_post_startup_inferior) [PT_LWP_EVENTS]: Enable LWP events.
	(fbsd_post_attach) [PT_LWP_EVENTS]: Enable LWP events.
	Add threads for existing processes.
	(fbsd_nat_add_target) [PT_LWPINFO]: Set "to_thread_alive" to
	"fbsd_thread_alive".
	Set "to_pid_to_str" to "fbsd_pid_to_str".
	[HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME]: Set "to_thread_name" to
	"fbsd_thread_name".
	[PT_LWPINFO]: Set "to_update_thread_list" to "fbsd_update_thread_list".
	Set "to_has_thread_control" to "tc_schedlock".
	Set "to_resume" to "fbsd_resume".
	(_initialize_fbsd_nat): New function.
	* configure: Regenerate.
	* config.in: Regenerate.

gdb/doc/ChangeLog:

	* gdb.texinfo (Debugging Output): Document "set/show debug fbsd-lwp".
2016-01-19 08:19:00 -08:00
Pedro Alves 976102cd17 Fix PR sim/13418: building with --enable-targets=all fails
Multitarget builds currently fail when:

 (1) simulator support is enabled (the main --target supports target sim)
 (2) powerpc is included in the --enable-targets list
 (3) powerpc is not the main/default target (--target)

This is because the powerpc sim provides a non-standard API function
sim_spr_register_name which gdb/rs6000-tdep.c utilizes.  Since the sim
does not yet support multitarget, only the sim (if one exists) for the
main target is built.  When that target isn't powerpc, this function
is not available leading to linking errors:

	rs6000-tdep.c:(.text+0x1e34d): undefined reference to
	`sim_spr_register_name'

Fix this by only using that API if the sim linked in is the powerpc
sim.

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

	PR sim/13418
	* configure.ac: Define WITH_PPC_SIM when linking in the sim and
	the target is powerpc*.
	* configure: Regenerate.
	* config.in: Regenerate.
2016-01-05 11:03:40 +00:00
Pedro Alves 4a6ed09b0f Remove support for LinuxThreads and vendor 2.4 kernels w/ backported NPTL
Since we now rely on PTRACE_EVENT_CLONE being available (added in
Linux 2.5.46), we're relying on NPTL.

This commit removes the support for older LinuxThreads, as well as the
workarounds for vendor 2.4 kernels with NPTL backported.

 - Rely on tkill being available.

 - Assume gdb doesn't get cancel signals.

 - Remove code that checks the LinuxThreads restart and cancel signals
   in the inferior.

 - Assume that __WALL is available.

 - Assume that non-leader threads report WIFEXITED.

 - Thus, no longer need to send signal 0 to check whether threads are
   still alive.

 - Update comments throughout.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/ChangeLog:

	* configure.ac: Remove tkill checks.
	* configure, config.in: Regenerate.
	* linux-nat.c: Remove HAVE_TKILL_SYSCALL check.  Update top level
	comments.
	(linux_nat_post_attach_wait): Remove 'cloned' parameter.  Use
	__WALL.
	(attach_proc_task_lwp_callback): Don't set the cloned flag.
	(linux_nat_attach): Adjust.
	(kill_lwp): Remove HAVE_TKILL_SYSCALL check.  No longer fall back
	to 'kill'.
	(linux_handle_extended_wait): Use __WALL.  Don't set the cloned
	flag.
	(wait_lwp): Use __WALL.  Update comments.
	(running_callback, stop_and_resume_callback): Delete.
	(linux_nat_filter_event): Don't stop and resume all lwps. Don't
	check if the event LWP has previously exited.
	(check_zombie_leaders): Update comments.
	(linux_nat_wait_1): Use __WALL.
	(kill_wait_callback): Don't handle clone processes separately.
	Use __WALL instead.
	(linux_thread_alive): Delete.
	(linux_nat_thread_alive): Return true as long as the LWP is in the
	LWP list.
	(linux_nat_update_thread_list): Assume the kernel supports
	PTRACE_EVENT_CLONE.
	(get_signo): Delete.
	(lin_thread_get_thread_signals): Remove LinuxThreads references.
	No longer check __pthread_sig_restart / __pthread_sig_cancel in
	the inferior.
	* linux-nat.h (struct lwp_info) <cloned>: Delete field.
	* linux-thread-db.c: Update comments.
	(_initialize_thread_db): Remove LinuxThreads references.
	* nat/linux-waitpid.c (my_waitpid): No longer emulate __WALL.
	Pass down flags unmodified.
	* linux-waitpid.h (my_waitpid): Update documentation.

gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_kill_one_lwp): Remove references to
	LinuxThreads.
	(kill_lwp): Remove HAVE_TKILL_SYSCALL check.  No longer fall back
	to 'kill'.
	(linux_init_signals): Delete.
	(initialize_low): Adjust.
	* thread-db.c (thread_db_init): Remove LinuxThreads reference.
2015-12-17 14:20:51 +00:00
Pedro Alves 14d8814778 gdb: Drop use of obsolete AC_TYPE_SIGNAL
Since we're using sighandler_t, nothing else refers to RETSIGTYPE in
gdb.

(Actually, given gdb/remote.c has been assuming signal handlers return
void for a long time, we could have gotten get rid of this even
without gnulib's sighandler_t.)

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

	* configure.ac: Remove AC_TYPE_SIGNAL call.
	* configure, config.in: Regenerate.
2015-08-27 13:26:23 +01: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
Markus Metzger 58bfce9343 configure: check for libipt
Check for libipt, an Intel(R) Processor Trace decoder library.  The sources
can be found on github at:

    https://github.com/01org/processor-trace

gdb/
	* configure.ac: Check for libipt
	* configure: Regenerate.
	* config.in: Regenerate.
	* Makefile.in (LIBIPT): New.
	(CLIBS): Add $LIBIPT.
	* NEWS: document new configure options
2015-07-02 12:45:50 +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
H.J. Lu 711a72d3d6 Add --with-system-zlib in gdb
This patch adds --with-system-zlib and removes --with-zlib in gdb.

	* Makefile.in (ZLIB): New.
	(ZLIBINC): Likewise.
	(INTERNAL_CFLAGS_BASE): Add $(ZLIBINC).
	(CLIBS): Add $(ZLIB).
	* acinclude.m4: (GDB_AC_CHECK_BFD): Add $zlibdir to LDFLAGS.
	Add -lz to LIBS.
	* gdb_bfd.c: Don't check HAVE_ZLIB_H to include <zlib.h>.
	* top.c (print_gdb_configuration): Remove --with-zlib and
	--without-zlib.
	* config.in: Regenerated.
	* configure: Likewise.
2015-03-31 08:24:18 -07:00
John Baldwin 25268153a1 Use kinfo_getvmmap on FreeBSD to enumerate memory regions.
Use kinfo_getvmmap from libutil on FreeBSD to enumerate memory
regions in a running process instead of /proc/<pid>/map.  FreeBSD systems
do not mount procfs by default, but kinfo_getvmmap uses a sysctl that
is always available.

Skip memory regions for devices as well as regions an application has
requested to not be dumped via the MAP_NOCORE flag to mmap or
MADV_NOCORE advice to madvise.

gdb/ChangeLog:

	* configure.ac: AC_CHECK_LIB(util, kinfo_getvmmap).
	* configure: Regenerate.
	* config.in: Regenerate.
	* fbsd-nat.c [!HAVE_KINFO_GETVMMAP] (fbsd_read_mapping): Don't
        define.
	(fbsd_find_memory_regions): Use kinfo_getvmmap to
	enumerate memory regions if present.
2015-03-13 14:08:15 -04:00
Andy Wingo 92fab5a617 [guile] Run finalizers from GDB thread
gdb/ChangeLog:

	* guile/guile.c (_initialize_guile): Disable automatic
	finalization, if Guile offers us that possibility.
	* guile/guile.c (call_initialize_gdb_module):
	* guile/scm-safe-call.c (gdbscm_with_catch): Arrange to run
	finalizers in appropriate places.
	* config.in (HAVE_GUILE_MANUAL_FINALIZATION): New definition.
	* configure.ac (AC_TRY_LIBGUILE): Add a check for
	scm_set_automatic_finalization_enabled.
	* configure: Regenerated.
2015-03-11 13:07:53 +01: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
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
Jan Kratochvil 1bc1068a0c Fix MinGW compilation
On Sun, 14 Dec 2014 07:00:28 +0100, Yao Qi wrote:
The build on mingw host is broken because mingw has no mkdtemp.

../../../git/gdb/compile/compile.c: In function 'get_compile_file_tempdir':
../../../git/gdb/compile/compile.c:194:3: error: implicit declaration of function 'mkdtemp' [-Werror=implicit-function-declaration]
   tempdir_name = mkdtemp (tname);
   ^
../../../git/gdb/compile/compile.c:194:16: error: assignment makes pointer from integer without a cast [-Werror]
   tempdir_name = mkdtemp (tname);
                ^
cc1: all warnings being treated as errors

In the end I have managed to test it by Wine myself:

$ wine build_win32/gdb/gdb.exe -q build_win32/gdb/gdb.exe -ex start -ex 'compile code 1' -ex 'set confirm no' -ex quit
[...]
Temporary breakpoint 1, main (argc=1, argv=0x241418) at ../../gdb/gdb.c:29
29        args.argc = argc;
Could not load libcc1.so: Module not found.

Even if it managed to load libcc1.so (it needs host-dependent name libcc1.dll)
then it would soon end up at least on:

default_infcall_mmap:
  error (_("This target does not support inferior memory allocation by mmap."));

As currently there is only:

linux-tdep.c:
  set_gdbarch_infcall_mmap (gdbarch, linux_infcall_mmap);

While one could debug Linux targets from MS-Windows host I find it somehow
overcomplicated now when we are trying to get it running at least on native
Linux x86*.

The 'compile' project needs a larger port effort to run on MS-Windows.

gdb/ChangeLog
2014-12-17  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix MinGW compilation.
	* compile/compile.c (get_compile_file_tempdir): Call error if
	!HAVE_MKDTEMP.
	* config.in: Regenerate.
	* configure: Regenerate.
	* configure.ac (AC_CHECK_FUNCS): Add mkdtemp.

gdb/testsuite/ChangeLog
2014-12-17  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix MinGW compilation.
	* gdb.compile/compile-ops.exp: Update untested message if
	!skip_compile_feature_tests.
	* gdb.compile/compile-setjmp.exp: Likewise.
	* gdb.compile/compile-tls.exp: Likewise.
	* gdb.compile/compile.exp: Likewise.
	* lib/gdb.exp (skip_compile_feature_tests): Check also "Command not
	supported on this host".
2014-12-17 20:09:02 +01:00
Yao Qi abbffc8924 Use canonicalize_file_name unconditionally
gdb:

2014-11-28  Yao Qi  <yao@codesourcery.com>

	* configure.ac (AC_CHECK_FUNCS): Remove canonicalize_file_name
	and realpath.
	* config.in: Re-generated.
	* configure: Re-generated.
	* utils.c (gdb_realpath): Remove code calling realpath,
	canonicalize_file_name and pathconf.
	[!_WIN32]: Call canonicalize_file_name.
2014-11-28 18:38:16 +08:00
Yao Qi 3332aaf289 Use lstat unconditionally
Since lstat gnulib module is imported, we can use it unconditionally.
lstat usage was introduced by this patch

https://sourceware.org/ml/gdb-patches/2012-01/msg00390.html

during the review, it was suggested to import gnulib lstat module, but
we didn't do that.

gdb:

2014-11-28  Yao Qi  <yao@codesourcery.com>

	* configure.ac (AC_CHECK_FUNCS): Remove lstat.
	* config.in, configure: Regenerate.
	* symfile.c (find_separate_debug_file_by_debuglink): Remove
	code checking HAVE_LSTAT is defined.
2014-11-28 18:38:02 +08:00
Yao Qi bdca27a2f5 Use readlink unconditionally
Since readlink module is imported, we can use it unconditionally.
This patch is to remove configure checks and HAVE_READLINK checks in
code.  It was mentioned in the patch below

  [RFA/commit] gdbserver: return ENOSYS if readlink not supported.
  https://sourceware.org/ml/gdb-patches/2012-02/msg00148.html

to use readlink in gdbserver, but we chose something simple at that
moment.

gdb:

2014-11-28  Yao Qi  <yao@codesourcery.com>

	* configure.ac (AC_CHECK_FUNCS): Remove readlink.
	* config.in, configure: Re-generate.
	* inf-child.c (inf_child_fileio_readlink): Don't check
	HAVE_READLINK is defined.

gdb/gdbserver:

2014-11-28  Yao Qi  <yao@codesourcery.com>

	* configure.ac(AC_CHECK_FUNCS): Remove readlink.
	* config.in, configure: Re-generate.
	* hostio.c (handle_unlink): Remove code checking HAVE_READLINK
	is defined.
2014-11-28 18:37:52 +08:00
Doug Evans 92d8d229d9 Fix for PR 17247: Block SIGCHLD while initializing Guile.
The problem here is that if a thread other than gdb's main thread
gets a SIGCHLD (it's an asynchronous signal so the kernel will
essentially pick a random thread) then gdb will hang if it is
in sigsuspend when the SIGCHLD is delivered.  The other thread
will see the signal and the sigsuspend won't "wake up".

Guile and libgc should be blocking SIGCHLD in their threads,
but we need to work with Guile 2.0 and libgc 7.4.
The problem first shows up in libgc 7.4 because it is the first
release that enables multiple marker threads by default.

gdb/ChangeLog:

	PR 17247
	* guile.c: #include <signal.h>.
	(_initialize_guile): Block SIGCHLD while initializing Guile.

	Replaces the following, which is reverted.

	2014-07-26  Doug Evans  <xdje42@gmail.com>

	PR 17185
	* configure.ac: Add check for header gc/gc.h.
	Add check for function setenv.
	* configure: Regenerate.
	* config.in: Regenerate.
	* guile/guile.c (_initialize_guile): Add workaround for libgc 7.4.0.
2014-09-08 22:45:34 -07:00
Alan Modra 2974be626b Fix --diable-shared --enable-plugins build breakage
Directories that don't use libtool need to add -ldl (on most *nix
hosts) to provide dlopen for libbfd.

config/
	* plugins.m4 (AC_PLUGINS): If plugins are enabled, add -ldl to
	LIBS via AC_SEARCH_LIBS.
gdb/
	* acinclude.m4 (GDB_AC_CHECK_BFD): Don't add -ldl.
	* config.in: Regenerate.
sim/ppc/
	* configure.ac: Invoke AC_PLUGINS.
	* config.in: Regenerate.

and regen lots of configure files.
2014-08-19 21:59:56 +09:30
Doug Evans 74edf51613 PR 17185
PR 17185 describes a problem with using gdb+guile with libgc 7.4.0.
The symptom is a hang in sigsuspend.
[The thread referenced in the PR has the details.]
It's not clear what the right fix is, or even where the bug is yet.
This patch applies the same workaround Guile has applied.
There is no functionality or real performance loss with this,
and Guile has been using it for awhile.

	* configure.ac: Add check for header gc/gc.h.
	Add check for function setenv.
	* configure: Regenerate.
	* config.in: Regenerate.
	* guile/guile.c (_initialize_guile): Add workaround for libgc 7.4.0.
2014-07-26 14:49:04 -07:00
Gary Benson 992c7d700f Demangler crash handler
This commit wraps calls to the demangler with a segmentation fault
handler.  The first time a segmentation fault is caught a core file
is generated and the user is prompted to file a bug and offered the
choice to exit or to continue their GDB session.  A maintainence
option is provided to allow the user to disable the crash handler
if required.

gdb/
2014-06-19  Gary Benson  <gbenson@redhat.com>

	* configure.ac [AC_CHECK_FUNCS] <sigaltstack>: New check.
	* configure: Regenerate.
	* config.in: Likewise.
	* main.c (signal.h): New include.
	(setup_alternate_signal_stack): New function.
	(captured_main): Call the above.
	* cp-support.c (signal.h): New include.
	(catch_demangler_crashes): New flag.
	(SIGJMP_BUF): New define.
	(SIGSETJMP): Likewise.
	(SIGLONGJMP): Likewise.
	(gdb_demangle_jmp_buf): New static global.
	(gdb_demangle_attempt_core_dump): Likewise.
	(gdb_demangle_signal_handler): New function.
	(gdb_demangle): If catch_demangler_crashes is set, install the
	above signal handler before calling bfd_demangle, and restore
	the original signal handler afterwards.  Display the offending
	symbol and call demangler_warning the first time a segmentation
	fault is caught.
	(_initialize_cp_support): New maint set/show command.

gdb/doc/
2014-06-19  Gary Benson  <gbenson@redhat.com>

	* gdb.texinfo (Maintenance Commands): Document new
	"maint set/show catch-demangler-crashes" option.
2014-06-19 09:13:57 +01:00
Ludovic Courtès 16954d5d9d guile: Allow compilation with Guile <= 2.0.5.
gdb/
2014-06-01  Ludovic Courtès  <ludo@gnu.org>

	* configure.ac: When Guile is available, check for the
	availability of 'scm_new_smob'.
	* configure, config.h.in: Regenerate.
	* guile/guile-internal.h (scm_new_smob) [!HAVE_SCM_NEW_SMOB]: New
	function.
2014-06-01 22:26:55 +02:00
Doug Evans ed3ef33944 Add Guile as an extension language.
* NEWS: Mention Guile scripting.
	* Makefile.in (SUBDIR_GUILE_OBS): New variable.
	(SUBDIR_GUILE_SRCS, SUBDIR_GUILE_DEPS): New variables
	(SUBDIR_GUILE_LDFLAGS, SUBDIR_GUILE_CFLAGS): New variables.
	(INTERNAL_CPPFLAGS): Add GUILE_CPPFLAGS.
	(CLIBS): Add GUILE_LIBS.
	(install-guile): New rule.
	(guile.o): New rule.
	(scm-arch.o, scm-auto-load.o, scm-block.o): New rules.
	(scm-breakpoint.o, scm-disasm.o, scm-exception.o): New rules.
	(scm-frame.o, scm-iterator.o, scm-lazy-string.o): New rules.
	(scm-math.o, scm-objfile.o, scm-ports.o): New rules.
	(scm-pretty-print.o, scm-safe-call.o, scm-gsmob.o): New rules.
	(scm-string.o, scm-symbol.o, scm-symtab.o): New rules.
	(scm-type.o, scm-utils.o, scm-value.o): New rules.
	* configure.ac: New option --with-guile.
	* configure: Regenerate.
	* config.in: Regenerate.
	* auto-load.c: Remove #include "python/python.h".  Add #include
	"gdb/section-scripts.h".
	(source_section_scripts): Handle Guile scripts.
	(_initialize_auto_load): Add name of Guile objfile script to
	scripts-directory help text.
	* breakpoint.c (condition_command): Tweak comment to include Scheme.
	* breakpoint.h (gdbscm_breakpoint_object): Add forward decl.
	(struct breakpoint): New member scm_bp_object.
	* defs.h (enum command_control_type): New value guile_control.
	* cli/cli-cmds.c: Remove #include "python/python.h".  Add #include
	"extension.h".
	(show_user): Update comment.
	(_initialize_cli_cmds): Update help text for "show user".  Update help
	text for max-user-call-depth.
	* cli/cli-script.c: Remove #include "python/python.h".  Add #include
	"extension.h".
	(multi_line_command_p): Add guile_control.
	(print_command_lines): Handle guile_control.
	(execute_control_command, recurse_read_control_structure): Ditto.
	(process_next_line): Recognize "guile" commands.
	* disasm.c (gdb_disassemble_info): Make non-static.
	* disasm.h: #include "dis-asm.h".
	(struct gdbarch): Add forward decl.
	(gdb_disassemble_info): Declare.
	* extension.c: #include "guile/guile.h".
	(extension_languages): Add guile.
	(get_ext_lang_defn): Handle EXT_LANG_GDB.
	* extension.h (enum extension_language): New value EXT_LANG_GUILE.
	* gdbtypes.c (get_unsigned_type_max): New function.
	(get_signed_type_minmax): New function.
	* gdbtypes.h (get_unsigned_type_max): Declare.
	(get_signed_type_minmax): Declare.
	* guile/README: New file.
	* guile/guile-internal.h: New file.
	* guile/guile.c: New file.
	* guile/guile.h: New file.
	* guile/scm-arch.c: New file.
	* guile/scm-auto-load.c: New file.
	* guile/scm-block.c: New file.
	* guile/scm-breakpoint.c: New file.
	* guile/scm-disasm.c: New file.
	* guile/scm-exception.c: New file.
	* guile/scm-frame.c: New file.
	* guile/scm-gsmob.c: New file.
	* guile/scm-iterator.c: New file.
	* guile/scm-lazy-string.c: New file.
	* guile/scm-math.c: New file.
	* guile/scm-objfile.c: New file.
	* guile/scm-ports.c: New file.
	* guile/scm-pretty-print.c: New file.
	* guile/scm-safe-call.c: New file.
	* guile/scm-string.c: New file.
	* guile/scm-symbol.c: New file.
	* guile/scm-symtab.c: New file.
	* guile/scm-type.c: New file.
	* guile/scm-utils.c: New file.
	* guile/scm-value.c: New file.
	* guile/lib/gdb.scm: New file.
	* guile/lib/gdb/boot.scm: New file.
	* guile/lib/gdb/experimental.scm: New file.
	* guile/lib/gdb/init.scm: New file.
	* guile/lib/gdb/iterator.scm: New file.
	* guile/lib/gdb/printing.scm: New file.
	* guile/lib/gdb/types.scm: New file.
	* data-directory/Makefile.in (GUILE_SRCDIR): New variable.
	(VPATH): Add $(GUILE_SRCDIR).
	(GUILE_DIR): New variable.
	(GUILE_INSTALL_DIR, GUILE_FILES): New variables.
	(all): Add stamp-guile dependency.
	(stamp-guile): New rule.
	(clean-guile, install-guile, uninstall-guile): New rules.
	(install-only): Add install-guile dependency.
	(uninstall): Add uninstall-guile dependency.
	(clean): Add clean-guile dependency.

	doc/
	* Makefile.in (GDB_DOC_FILES): Add guile.texi.
	* gdb.texinfo (Auto-loading): Add set/show auto-load guile-scripts.
	(Extending GDB): New menu entries Guile, Multiple Extension Languages.
	(Guile docs): Include guile.texi.
	(objfile-gdbdotext file): Add objfile-gdb.scm.
	(dotdebug_gdb_scripts section): Mention Guile scripts.
	(Multiple Extension Languages): New node.
	* guile.texi: New file.

	testsuite/
	* configure.ac (AC_OUTPUT): Add gdb.guile.
	* configure: Regenerate.
	* lib/gdb-guile.exp: New file.
	* lib/gdb.exp (get_target_charset): New function.
	* gdb.base/help.exp: Update expected output from "apropos apropos".
	* gdb.guile/Makefile.in: New file.
	* gdb.guile/guile.exp: New file.
	* gdb.guile/scm-arch.c: New file.
	* gdb.guile/scm-arch.exp: New file.
	* gdb.guile/scm-block.c: New file.
	* gdb.guile/scm-block.exp: New file.
	* gdb.guile/scm-breakpoint.c: New file.
	* gdb.guile/scm-breakpoint.exp: New file.
	* gdb.guile/scm-disasm.c: New file.
	* gdb.guile/scm-disasm.exp: New file.
	* gdb.guile/scm-equal.c: New file.
	* gdb.guile/scm-equal.exp: New file.
	* gdb.guile/scm-error.exp: New file.
	* gdb.guile/scm-error.scm: New file.
	* gdb.guile/scm-frame-args.c: New file.
	* gdb.guile/scm-frame-args.exp: New file.
	* gdb.guile/scm-frame-args.scm: New file.
	* gdb.guile/scm-frame-inline.c: New file.
	* gdb.guile/scm-frame-inline.exp: New file.
	* gdb.guile/scm-frame.c: New file.
	* gdb.guile/scm-frame.exp: New file.
	* gdb.guile/scm-generics.exp: New file.
	* gdb.guile/scm-gsmob.exp: New file.
	* gdb.guile/scm-iterator.c: New file.
	* gdb.guile/scm-iterator.exp: New file.
	* gdb.guile/scm-math.c: New file.
	* gdb.guile/scm-math.exp: New file.
	* gdb.guile/scm-objfile-script-gdb.in: New file.
	* gdb.guile/scm-objfile-script.c: New file.
	* gdb.guile/scm-objfile-script.exp: New file.
	* gdb.guile/scm-objfile.c: New file.
	* gdb.guile/scm-objfile.exp: New file.
	* gdb.guile/scm-ports.exp: New file.
	* gdb.guile/scm-pretty-print.c: New file.
	* gdb.guile/scm-pretty-print.exp: New file.
	* gdb.guile/scm-pretty-print.scm: New file.
	* gdb.guile/scm-section-script.c: New file.
	* gdb.guile/scm-section-script.exp: New file.
	* gdb.guile/scm-section-script.scm: New file.
	* gdb.guile/scm-symbol.c: New file.
	* gdb.guile/scm-symbol.exp: New file.
	* gdb.guile/scm-symtab-2.c: New file.
	* gdb.guile/scm-symtab.c: New file.
	* gdb.guile/scm-symtab.exp: New file.
	* gdb.guile/scm-type.c: New file.
	* gdb.guile/scm-type.exp: New file.
	* gdb.guile/scm-value-cc.cc: New file.
	* gdb.guile/scm-value-cc.exp: New file.
	* gdb.guile/scm-value.c: New file.
	* gdb.guile/scm-value.exp: New file.
	* gdb.guile/source2.scm: New file.
	* gdb.guile/types-module.cc: New file.
	* gdb.guile/types-module.exp: New file.
2014-02-09 19:40:01 -08:00
Tom Tromey 161d1bec16 don't check for stddef.h
gdb already unconditionally includes stddef.h in many places.
I think there is no reason to check for its existence.

Also, Zack Weinberg's header file survey agrees:

    http://hacks.owlfolio.org/header-survey/

This patch removes the configure check and the inclusion guards.
It also removes a redundant inclusion that I noticed in defs.h.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* config.in: Rebuild.
	* configure: Rebuild.
	* configure.ac: Don't check for stddef.h.
	* defs.h: Unconditionally include stddef.h.  Remove duplicate
	inclusion.
2013-11-18 13:29:01 -07:00
Tom Tromey 2978b11100 remove gdb_dirent.h
This removes gdb_dirent.h and updates the code to use dirent.h
instead.  It also removes the now-useless configure checks.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* common/common.m4 (GDB_AC_COMMON): Don't use AC_HEADER_DIRENT.
	* common/gdb_dirent.h: Remove.
	* common/filestuff.c: Use dirent.h.
	* common/linux-osdata.c: Use dirent.h.
	(NAMELEN): Define.
	* config.in: Rebuild.
	* configure: Rebuild.
	* configure.ac: Don't use AC_HEADER_DIRENT.
	* linux-fork.c: Use dirent.h
	* linux-nat.c: Use dirent.h.
	* nto-procfs.c: Use dirent.h.
	* procfs.c: Use dirent.h.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* config.in: Rebuild.
	* configure: Rebuild.
	* configure.ac: Don't use AC_HEADER_DIRENT.
2013-11-18 13:29:01 -07:00
Tom Tromey a18d8f10c0 fix a comment in configure.ac
My grepping around showed that HAVE_MULTIPLE_PROC_FDS is only ever
mentioned in a comment in configure.ac.  Since the macro is long dead,
let's remove the last mention.

2013-11-08  Tom Tromey  <tromey@redhat.com>

	* configure: Rebuild.
	* configure.ac: Remove mentions of HAVE_MULTIPLE_PROC_FDS.
2013-11-08 12:30:07 -07:00
Tom Tromey 9467110bae gdb configure updates
Now that the configury needed for the "common" and "target"
directories is in common.m4, some code in gdb's configure.ac is
redundant.

I ran this script after making an "ID" file using mkid:

   sed -n 's/^.*\(HAVE_[A-Z0-9_]*\).*$/\1/p' config.in |
   while read x; do
     echo ===== $x
     gid $x | egrep -v '^(testsuite|gnulib|common|target|gdbserver)/'
   done

This finds all the spots using HAVE_ defines, and, more importantly,
makes it clear which defines aren't used in the main parts of gdb.

From this I came up with this patch to remove all the unused bits.

There are a few that are subtly used -- for example the configure
script sometimes checks internal configure cache variables, meaning
some checks cannot be removed.

2013-11-08  Tom Tromey  <tromey@redhat.com>

	* configure, config.in: Rebuild.
	* configure.ac: Remove unused configury.
2013-11-08 12:30:02 -07:00
Tom Tromey 9b4bea7218 remove link.h checks
The removal of solib-sunos.c also removed the last user of various
macros defined by configure.

This patch removes the corresponding configure code.

2013-11-08  Tom Tromey  <tromey@redhat.com>

	* configure, config.in: Rebuild.
	* configure.ac: Remove all link.h-related checks.
2013-11-08 12:29:42 -07:00
Luis Machado 96d7229d2a Unify ptrace options discovery code and make both GDB and
gdbserver use it.

	gdb/
	* Makefile.in (HFILES_NO_SRCDIR): Add nat/linux-nat.h and
	nat/linux-waitpid.h.
	(linux-waitpid.o): New object file rule.
	* common/linux-ptrace.c: Include nat/linux-waitpid.h.
	(current_ptrace_options): Moved from linux-nat.c.
	(linux_ptrace_test_ret_to_nx): Use type casts for ptrace
	parameters.
	(linux_fork_to_function): New function.
	(linux_grandchild_function): Likewise.
	(linux_child_function): Likewise.
	(linux_check_ptrace_features): New function, heavily
	based on linux-nat.c:linux_test_for_tracefork.
	(linux_enable_event_reporting): New function.
	(ptrace_supports_feature): Likewise.
	(linux_supports_tracefork): Likewise.
	(linux_supports_traceclone): Likewise.
	(linux_supports_tracevforkdone): Likewise.
	(linux_supports_tracesysgood): Likewise.
	* common/linux-ptrace.h (HAS_NOMMU): Moved from
	gdbserver/linux-low.c.
	(linux_enable_event_reporting): New declaration.
	(linux_supports_tracefork): Likewise.
	(linux_supports_traceclone): Likewise.
	(linux_supports_tracevforkdone): Likewise.
	(linux_supports_tracesysgood): Likewise.
	* config.in (PTRACE_TYPE_ARG4): Regenerate.
	* config/aarch64/linux.mh (NATDEPFILES): Add linux-waitpid.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/sparc/linux.mh (NATDEPFILES): Likewise.
	* config/sparc/linux64.mh (NATDEPFILES): Likewise.
	* config/tilegx/linux.mh (NATDEPFILES): Likewise.
	* config/xtensa/linux.mh (NATDEPFILES): Likewise.
	* configure.ac (AC_CACHE_CHECK): Add void * to the list of
	ptrace's 4th argument's types.
	Check the type of PTRACE_TYPE_ARG4.
	* configure: Regenerate.
	* linux-nat.c: Include nat/linux-nat.h and nat/linux-waitpid.h.
	(SYSCALL_SIGTRAP): Moved to nat/linux-nat.h.
	(linux_supports_tracefork_flag): Remove.
	(linux_supports_tracesysgood_flag): Likewise.
	(linux_supports_tracevforkdone_flag): Likewise.
	(current_ptrace_options): Moved to
	common/linux-ptrace.c.
	(linux_tracefork_child): Remove.
	(my_waitpid): Remove.
	(linux_test_for_tracefork): Renamed to
	linux_check_ptrace_features and moved to common/linux-ptrace.c.
	(linux_test_for_tracesysgood): Remove.
	(linux_supports_tracesysgood): Remove.
	(linux_supports_tracefork): Remove.
	(linux_supports_tracevforkdone): Remove.
	(linux_enable_tracesysgood): Remove.
	(linux_enable_event_reporting): Remove.
	(linux_init_ptrace): New function.
	(linux_child_post_attach): Call linux_init_ptrace.
	(linux_child_post_startup_inferior): Call linux_init_ptrace.
	(linux_child_follow_fork): Call linux_supports_tracefork
	and linux_supports_tracevforkdone.
	(linux_child_insert_fork_catchpoint): Call
	linux_supports_tracefork.
	(linux_child_insert_vfork_catchpoint): Likewise.
	(linux_child_set_syscall_catchpoint): Call
	linux_supports_tracesysgood.
	(lin_lwp_attach_lwp): Call linux_supports_tracefork.
	* nat/linux-nat.h: New file.
	* nat/linux-waitpid.c: New file.
	* nat/linux-waitpid.h: New file.

	gdb/gdbserver/
	* Makefile.in: Explain why ../target and ../nat are not
	listed as include file search paths.
	(linux-waitpid.o): New object file rule.
	* configure.srv (srv_native_linux_obj): New variable.
	Replace all occurrences of linux native object files with
	$srv_native_linux_obj.
	* linux-low.c: Include nat/linux-nat.h and nat/linux-waitpid.h.
	(HAS_NOMMU): Move defining logic to common/linux-ptrace.c.
	(linux_enable_event_reporting): Remove declaration.
	(my_waitpid): Moved to common/linux-waitpid.c.
	(linux_wait_for_event): Pass ptid when calling
	linux_enable_event_reporting.
	(linux_supports_tracefork_flag): Remove.
	(linux_enable_event_reporting): Likewise.
	(linux_tracefork_grandchild): Remove.
	(STACK_SIZE): Moved to common/linux-ptrace.c.
	(linux_tracefork_child): Remove.
	(linux_test_for_tracefork): Remove.
	(linux_look_up_symbols): Call linux_supports_traceclone.
	(initialize_low): Remove call to linux_test_for_tracefork.
	* linux-low.h (PTRACE_TYPE_ARG3): Move to
	common/linux-ptrace.h.
	(PTRACE_TYPE_ARG4): Likewise.
	Include linux-ptrace.h.
2013-08-22 23:46:30 +00:00
Ulrich Weigand b08ee99f15 2013-08-07 Raunaq Bathija <raunaq12@in.ibm.com>
Ulrich Weigand  <uweigand@de.ibm.com>

	* gdb_ptrace.h: Use ptrace64 instead of ptrace if HAVE_PTRACE64
	is defined.
	* rs6000-nat.c: Check for __ld_info64_ if compiling 64 BIT gdb.
	(rs6000_ptrace32): Call ptrace64 instead of ptrace if present.
	(rs6000_ptrace64): Call ptace64 instead of ptracex if present.
	* configure.ac: Check for ptrace64.
	* configure, config.in: Regenerate.
2013-08-07 14:39:57 +00:00
Pedro Alves e655c1a2f5 Reimplement DJGPP's .gdbinit -> gdb.ini renaming.
This simplifies the .gdbinit filename selection logic.

We have a GDBINIT_FILENAME define that supposedly configurations would
override, but none do so.  Instead, the only configuration that wants
a different file name instead of ".gdbinit", djgpp, does a strcpy over
the gdbinit global array.  This means the array needs to be sized, and
the code that does that is doing the usual
'PATH_MAX/FILENAME_MAX/fallback constant/etc.' mess.

Instead of all that, it's much simpler to have configure specificy the
.gdbinit filename.  As bonus, we can then make the "gdbinit" global
array const.

gdb/
2013-07-01  Pedro Alves  <palves@redhat.com>

	* configure.ac (GDBINIT): Define, depending on host.
	* go32-nat.c (init_go32_ops): Don't override gdbinit here.
	* top.c (PATH_MAX): Delete fallback definition.
	(GDBINIT_FILENAME): Delete.
	(gdbinit): Reimplement as const char array set to the GDBINIT
	string constant.
	* top.h (gdbinit): Make const.
2013-07-01 11:24:17 +00:00
Pedro Alves 8658d16d9d common/filestuff.c: No sockets on DJGPP.
Building gdb with --host=i586-pc-msdosdjgpp ends up with:

 i586-pc-msdosdjgpp-gcc -g -O2 -I../../src/gdb/config/djgpp  -I. -I../../src/gdb -I../../src/gdb/common -I../../src/gdb/config -DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H -I../../src/gdb/../include/opcode -I../../src/gdb/../opcodes/.. -I../../src/gdb/../readline/.. -I../bfd -I../../src/gdb/../bfd -I../../src/gdb/../include -I../libdecnumber -I../../src/gdb/../libdecnumber -I./../intl -I../../src/gdb/gnulib/import -Ibuild-gnulib/import    -Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral -Wpointer-sign -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wmissing-prototypes -Wdeclaration-after-statement -Wempty-body -Werror -c -o filestuff.o -MT filestuff.o -MMD -MP -MF .deps/filestuff.Tpo ../../src/gdb/common/filestuff.c
 ../../src/gdb/common/filestuff.c:38:24: fatal error: sys/socket.h: No such file or directory

There are no sockets on djgpp.  This #ifdef's out the bits in the file
that use sockets, depending on whether winsock or sys/socket.h is
available.

As alternative approach, given ser-tcp.c, ser-pipe.c, etc. are split
into separate files, and which to use is selected by configure.ac:

 dnl Figure out which of the many generic ser-*.c files the _host_ supports.
 SER_HARDWIRE="ser-base.o ser-unix.o ser-pipe.o ser-tcp.o"
 case ${host} in
  *go32* ) SER_HARDWIRE=ser-go32.o ;;
  *djgpp* ) SER_HARDWIRE=ser-go32.o ;;
  *mingw32*) SER_HARDWIRE="ser-base.o ser-tcp.o ser-mingw.o" ;;
 esac
 AC_SUBST(SER_HARDWIRE)

... I considered splitting filestuff.c similarly.  But I quickly gave
up on the idea, as it looked like a lot more complication over this
approach, for no real gain.  Plus, there are uses of these functions
outside the ser*.c framework.

gdbserver's configure.ac is already checking for sys/socket.h.

gdb/
2013-05-23  Pedro Alves  <palves@redhat.com>

	* common/filestuff.c [USE_WIN32API]: Define HAVE_SOCKETS.
	[HAVE_SYS_SOCKET_H]: Define HAVE_SOCKETS.
	(socket_mark_cloexec, gdb_socketpair_cloexec, gdb_socket_cloexec):
	Only define if HAVE_SOCKETS is defined.
	* configure.ac: Check for sys/socket.h.
	* config.in, configure: Regenerate.
2013-05-23 18:37:00 +00:00
Tom Tromey 614c279dda PR gdb/7912:
* Makefile.in (SFILES): Add filestuff.c
	(COMMON_OBS): Add filestuff.o.
	(filestuff.o): New target.
	* auto-load.c (auto_load_objfile_script_1): Use
	gdb_fopen_cloexec.
	* auxv.c (procfs_xfer_auxv): Use gdb_open_cloexec.
	* cli/cli-cmds.c (shell_escape): Call close_most_fds.
	* cli/cli-dump.c (fopen_with_cleanup): Use gdb_fopen_cloexec.
	* common/agent.c (gdb_connect_sync_socket): Use
	gdb_socket_cloexec.
	* common/filestuff.c: New file.
	* common/filestuff.h: New file.
	* common/linux-osdata.c (linux_common_core_of_thread)
	(command_from_pid, commandline_from_pid, print_source_lines)
	(linux_xfer_osdata_shm, linux_xfer_osdata_sem)
	(linux_xfer_osdata_msg, linux_xfer_osdata_modules): Use
	gdb_fopen_cloexec.
	* common/linux-procfs.c (linux_proc_get_int)
	(linux_proc_pid_has_state): Use gdb_fopen_cloexec.
	* config.in, configure: Rebuild.
	* configure.ac: Don't check for sys/socket.h.  Check for
	fdwalk, pipe2.
	* corelow.c (core_open): Use gdb_open_cloexec.
	* dwarf2read.c (write_psymtabs_to_index): Use gdb_fopen_cloexec.
	* fork-child.c (fork_inferior): Call close_most_fds.
	* gdb_bfd.c (gdb_bfd_open): Use gdb_open_cloexec.
	* inf-child.c (inf_child_fileio_readlink): Use gdb_open_cloexec.
	* linux-nat.c (linux_nat_thread_name, linux_proc_pending_signals):
	Use gdb_fopen_cloexec.
	(linux_proc_xfer_partial, linux_proc_xfer_spu): Use
	gdb_open_cloexec.
	(linux_async_pipe): Use gdb_pipe_cloexec.
	* remote-fileio.c (remote_fileio_func_open): Use
	gdb_open_cloexec.
	* remote.c (remote_file_put, remote_file_get): Use
	gdb_fopen_cloexec.
	* ser-pipe.c (pipe_open): Use gdb_socketpair_cloexec,
	close_most_fds.
	* ser-tcp.c (net_open): Use gdb_socket_cloexec.
	* ser-unix.c (hardwire_open): Use gdb_open_cloexec.
	* solib.c (solib_find): Use gdb_open_cloexec.
	* source.c (openp, find_and_open_source): Use gdb_open_cloexec.
	* tracepoint.c (tfile_start): Use gdb_fopen_cloexec.
	(tfile_open): Use gdb_open_cloexec.
	* tui/tui-io.c (tui_initialize_io): Use gdb_pipe_cloexec.
	* ui-file.c (gdb_fopen): Use gdb_fopen_cloexec.
	* xml-support.c (xml_fetch_content_from_file): Use
	gdb_fopen_cloexec.
	* main.c (captured_main): Call notice_open_fds.
gdbserver
	* Makefile.in (SFILES): Add filestuff.c.
	(OBS): Add filestuff.o.
	(filestuff.o): New target.
	* config.in, configure: Rebuild.
	* configure.ac: Check for fdwalk, pipe2.
2013-04-22 16:46:15 +00:00
Jan Kratochvil 4936921797 gdb/
* config.in: Regenerate.
2013-04-12 16:02:29 +00:00
Yao Qi 393fd4c376 gdb/
2013-04-10  Hui Zhu  <hui@codesourcery.com>
	    Yao Qi  <yao@codesourcery.com>

	* configure.ac: Check libbabeltrace is installed.
	* config.in: Regenerate.
	* configure: Regenerate.
	* Makefile.in (LIBBABELTRACE): New.
	(CLIBS): Add LIBBABELTRACE.
	* ctf.c: Include "exec.h".
	(CTF_EVENT_ID_STATUS, CTF_EVENT_ID_TSV_DEF): New macros.
	(CTF_EVENT_ID_TP_DEF, ctf_save_write_int32): New macros.
	(ctf_save_metadata_header): Define new type aliases in
	metadata.
	(ctf_write_header): Define event type "tsv_def" and "tp_def"
	in metadata.  Start a new faked packet for trace status.
	(ctf_write_status): Write trace status to CTF.
	(ctf_write_uploaded_tsv): Write TSV to CTF.
	(ctf_write_uploaded_tp): Write tracepoint definition to CTF.
	(ctf_write_definition_end): End the faked packet.

	(ctx, ctf_iter, trace_dirname): New.
	(start_pos): New variable.
	(ctf_destroy, ctf_open_dir, ctf_open): New.
	(SET_INT32_FIELD, SET_ARRAY_FIELD, SET_STRING_FIELD): New
	macros.
	(ctf_read_tsv, ctf_read_tp, ctf_close, ctf_files_info): New.
	(ctf_fetch_registers, ctf_xfer_partial): New.
	(ctf_get_trace_state_variable_value): New.
	(ctf_get_tpnum_from_frame_event): New.
	(ctf_get_traceframe_address): New.
	(ctf_trace_find, ctf_has_stack): New.
	(ctf_has_registers, ctf_traceframe_info, init_ctf_ops): New.
	(ctf_get_trace_status, ctf_read_status): New.
	(_initialize_ctf): New.
	* tracepoint.c (get_tracepoint_number): New
	(get_uploaded_tsv): Remove 'static'.
 	(struct traceframe_info, trace_regblock_size): Move it to ...
	* tracepoint.h: ... here.
	(get_tracepoint_number): Declare it.
	(get_uploaded_tsv): Declare it.

	* NEWS: Mention new configure option.

gdb/doc/

2013-04-10  Yao Qi  <yao@codesourcery.com>

	* gdb.texinfo (Trace Files): Add "target ctf".

gdb/testsuite/

2013-04-10  Yao Qi  <yao@codesourcery.com>

	* gdb.trace/actions.exp: Save trace data to CTF.
	Change to ctf target if GDB supports, read CTF data in ctf
	target, and check the actions of tracepoints.
	* gdb.trace/while-stepping.exp: Likewise.
	* gdb.trace/report.exp: Test GDB saves trace data to CTF
	format and read CTF trace file if GDB supports.
	* gdb.trace/tstatus.exp: Save trace data to CTF.  If ctf
	target is supported, change to ctf target, read trace data and
	check output of command "tstatus".
	* gdb.trace/tsv.exp: Save trace frame to CTF.  If GDB supports,
	read CTF data by target ctf and call check_tsv.
2013-04-10 09:42:57 +00:00
Jan Kratochvil 74a0d9f6a5 gdb/
* configure.ac (CC_HAS_LONG_LONG): Replace by AC_MSG_ERROR.
	* defs.h (LONGEST, ULONGEST): Remove conditionalization for
	CC_HAS_LONG_LONG.
	* dwarf2-frame.c (DW64_CIE_ID): Likewise.
	* dwarf2read.c (extract_cu_value): Remove the function.
	(create_cus_from_index_list): Make the return type void, inline the
	extract_cu_value caller, include new gdb_static_assert.
	(create_cus_from_index): Make the return type void, update the function
	comment, update the create_cus_from_index_list caller.
	(create_signatured_type_table_from_index): Make the return type void,
	inline the extract_cu_value caller, include new gdb_static_assert.
	(dwarf2_read_index): Update the create_cus_from_index and
	create_signatured_type_table_from_index caller.
	* printcmd.c (ui_printf): Remove conditionalizations for
	CC_HAS_LONG_LONG.
	* config.in: Regenerate.
	* configure: Regenerate.

gdb/doc/
	* gdbint.texinfo (Host Definition): Remove CC_HAS_LONG_LONG.
2012-12-09 18:39:59 +00:00
Markus Metzger 945bf71318 2012-11-28 Markus Metzger <markus.t.metzger@intel.com>
gdb/
	* configure.ac: Check for linux/perf_event.h.
	* config.in: Regenerated.
	* configure: Regenerated.

gdb/gdbserver/
	* configure.ac: Check for linux/perf_event.h.
	* config.in: Regenerated.
	* configure: Regenerated.
2012-11-28 16:21:58 +00:00
Tom Tromey 608e2dbbfe 2012-11-26 Alexander Larsson <alexl@redhat.com>
Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Tom Tromey  <tromey@redhat.com>

	* NEWS: Mention mini debuginfo feature.
	* minidebug.c: New file.
	* configure.ac: Check for lzma.
	* configure, config.in: Rebuild.
	* Makefile.in (LIBLZMA): New variable.
	(CLIBS): Include LIBLZMA.
	(SFILES): Mention minidebug.c.
	(COMMON_OBS): Mention minidebug.o.
	* symfile.c (read_symbols): New function.
	(syms_from_objfile, reread_symbols): Call it.
	* symfile.h (find_separate_debug_file_in_section): Declare.
doc
	* gdb.texinfo (MiniDebugInfo): New node.
	(GDB Files): Update.
testsuite
	* gdb.base/gnu-debugdata.exp: New file.
	* gdb.base/gnu-debugdata.c: New file.
	* lib/gdb.exp (gdb_file_cmd): Handle LZMA warning.
	(gdb_unload): Return 0 on success.
2012-11-26 19:23:56 +00:00
Pierre Muller 3a731e0fc7 * configure.ac (AC_HEADER_STAT): Remove.
* gdb_stat.h (STAT_MACROS_BROKEN): Remove macro use
	and corresponding code.
	* configure: Regenerate.
	* config.in: Regenerate.
2012-11-15 14:48:26 +00:00
Tom Tromey e68227b907 * configure, config.in: Rebuild.
* configure.ac: Don't check for ctype.h, time.h.
	* expprint.c: Don't use HAVE_CTYPE_H.
2012-11-14 19:16:04 +00:00
Jan Kratochvil 8775fd2d8d gdb/
* config.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Remove check for gnu/libc-version.h.
	* linux-thread-db.c <HAVE_GNU_LIBC_VERSION_H>: Remove include of
	gnu/libc-version.h.
	(enable_thread_event_reporting) <HAVE_GNU_LIBC_VERSION_H>: Remove
	variables libc_version, libc_major and libc_minor.  Replace sscanf by
	inferior_has_bug.  Extend the comment.
2012-07-02 20:31:09 +00:00
H.J. Lu 6fea9e186c Use PTRACE_PEEKUSER to get fs_base/gs_base
* amd64-linux-nat.c: Include <sys/user.h>.
	(ps_get_thread_area): Use PTRACE_PEEKUSER to get fs_base/gs_base
	if HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE or
	HAVE_STRUCT_USER_REGS_STRUCT_GS_BASE is defined.

	* configure.ac: Check if the fs_base and gs_base members of
	`struct user_regs_struct' exist.
	* config.in: Regenerated.
	* configure: Likewise.
2012-06-26 14:43:01 +00:00
Jan Kratochvil a68ffae9e6 gdb/
* configure.ac (development): Define new variable.
	Call AC_CHECK_LIB for mcheck if $development.
	(ERROR_ON_WARNING): Enable it by default only if $development.
	* config.in: Regenerate.
	* configure: Regenerate.
2012-06-01 18:20:18 +00:00
Jan Kratochvil 7349ff92c2 gdb/
Implement multi-component --with-auto-load-dir.
	* NEWS (set auto-load scripts-directory, --with-auto-load-dir): New
	entries.
	(--with-auto-load-safe-path): Update the default value description.
	* auto-load.c (auto_load_dir, set_auto_load_dir, show_auto_load_dir):
	New.
	(auto_load_objfile_script): Add DEBUG_AUTO_LOAD output.  Remove
	GDB_DATADIR NULL check.  Replace GDB_DATADIR/auto-load by
	AUTO_LOAD_DIR.  Support $ddir and multiple components in it.
	(_initialize_auto_load): Initialize also auto_load_dir.  Install new
	"set auto-load scripts-directory".
	* config.in: Regenerate.
	* configure: Regenerate.
	* configure.ac (--with-auto-load-dir): New configure option.
	(--auto-load-safe-path): Change the default to --with-auto-load-dir.

gdb/doc/
	Implement multi-component --with-auto-load-dir.
	* gdb.texinfo (Auto-loading): New references
	for 'set auto-load scripts-directory'
	and 'show auto-load scripts-directory'.
	(Auto-loading safe path): Describe the new default.  Move $ddir
	substituation reference to 'objfile-gdb.py file'.
	(objfile-gdb.py file): Describe script-name alias.  Change real-name to
	script-name.  Describe new 'set auto-load scripts-directory'
	and 'show auto-load scripts-directory'.
2012-05-11 18:20:26 +00:00
Jan Kratochvil 6dea1fbd79 gdb/
Provide $ddir substitution for --with-auto-load-safe-path.
	* NEWS (--with-auto-load-safe-path, --without-auto-load-safe-path): New
	entries.
	* auto-load.c: Include observer.h.
	(auto_load_safe_path_vec_update): Call substitute_path_component for
	each component.  New variable ddir_subst.
	(auto_load_gdb_datadir_changed): New function.
	(set_auto_load_safe_path): Rename DEFAULT_AUTO_LOAD_SAFE_PATH to
	AUTO_LOAD_SAFE_PATH.  New comment.
	(_initialize_auto_load): Rename DEFAULT_AUTO_LOAD_SAFE_PATH to
	AUTO_LOAD_SAFE_PATH.  Install auto_load_gdb_datadir_changed.
	* config.in: Regenerate.
	* configure: Regenerate.
	* configure.ac (--auto-load-safe-path): Rename
	DEFAULT_AUTO_LOAD_SAFE_PATH to AUTO_LOAD_SAFE_PATH.  Default to
	GDB_DATADIR/auto-load.
	* defs.h (substitute_path_component): New declaration.
	* top.c: Include observer.h.
	(set_gdb_datadir): New function.
	(init_main): Install it for "set data-directory".
	* utils.c (substitute_path_component): New function.

gdb/doc/
	Provide $ddir substitution for --with-auto-load-safe-path.
	* gdb.texinfo (Auto-loading): Replace /usr/local by $ddir/auto-load.
	(Auto-loading safe path): Likewise.  Mention the default value,
	$ddir substitution, --with-auto-load-safe-path and
	--without-auto-load-safe-path.
	* observer.texi (gdb_datadir_changed): New.
2012-05-11 18:13:26 +00:00