This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Re: [PATCH] Replace ../include/wait.h with gdb_wait.h.
- To: ac131313 at cygnus dot com
- Subject: Re: [PATCH] Replace ../include/wait.h with gdb_wait.h.
- From: Mark Kettenis <kettenis at wins dot uva dot nl>
- Date: Wed, 9 Feb 2000 15:29:46 +0100
- CC: gdb-patches at sourceware dot cygnus dot com
- References: <38A12872.13D194C4@cygnus.com>
Date: Wed, 09 Feb 2000 19:42:26 +1100
From: Andrew Cagney <ac131313@cygnus.com>
FYI,
I've just checked in the attatched patch. It replaces the sometimes
convoluted sequence:
[snip]
Great!
So far this has only been verified on for the d10v-elf target. Please
report / submit patches for other targets.
There is a problem with `linux-thread.c', where `gdb_wait.h' is included
before config.h. This means that HAVE_SYS_WAIT_H and HAVE_WAIT_H are
still undefined and the system headers are never used.
Since `linux-thread.c' uses __W_STOPCODE, and `gdb_wait.h' doesn't
provide a fallback macro I get a linker failure. Moving up the
include for `defs.h' solves this problem.
The rest of GDB seems to be using WSETSTOP, so it seems appropriate to
use that macro instead of __W_STOPCODE in `linux-thread.c'. I changed
the definition of WSETSTOP and WSETEXIT in `gdb_wait.h' to use
W_STOPCODE and W_EXITCODE if they are available. All BSD-derived
systems and systems that try to be source-compatible with BSD (like
Linux and the Hurd) should have those macros. The change is merely
cosmetic but there might be systems out there that really use a
different way to store this information.
Feel free to do with this patch what you want as long as you make sure
that `gdb_wait.h' is included after `config.h' in `linux-thread.c' :-).
Mark
PS Andrew, concering coding-style, current practice in a lot of GNU
packages is to use extra whitespace after `#' like in the following
example:
#ifndef foobar
# ifdef foo
# define foobar foo
# else
# define foobar bar
# endif
#endif
This makes things a bit more readable. The patch below doesn't do
this, but is it OK to use this style in GDB in the future?
2000-02-09 Mark Kettenis <kettenis@gnu.org>
* linux-thread.c: Include defs.h before gdb_wait.h.
(linuxthreads_attach): Use WSETSTOP instead of __W_STOPCODE.
(linuxthreads_create_inferior): Likewise.
* gdb_wait.h (WSETEXIT): Define in terms of W_EXITCODE if defined.
(WSETSTOP): Define in terms of W_STOPCODE if defined.
Index: gdb/linux-thread.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-thread.c,v
retrieving revision 1.2
diff -u -r1.2 linux-thread.c
--- gdb/linux-thread.c 2000/02/09 08:52:46 1.2
+++ gdb/linux-thread.c 2000/02/09 14:23:02
@@ -47,13 +47,13 @@
linuxthreads package heavily relies on wait() synchronization to keep
them correct. */
+#include "defs.h"
#include <sys/types.h> /* for pid_t */
#include <sys/ptrace.h> /* for PT_* flags */
#include "gdb_wait.h" /* for WUNTRACED and __WCLONE flags */
#include <signal.h> /* for struct sigaction and NSIG */
#include <sys/utsname.h>
-#include "defs.h"
#include "target.h"
#include "inferior.h"
#include "gdbcore.h"
@@ -1129,7 +1129,7 @@
linuxthreads_breakpoints_inserted = 1;
linuxthreads_breakpoint_last = -1;
linuxthreads_wait_last = -1;
- linuxthreads_exit_status = __W_STOPCODE(0);
+ WSETSTOP (linuxthreads_exit_status, 0);
child_ops.to_attach (args, from_tty);
@@ -1189,7 +1189,7 @@
linuxthreads_find_trap (inferior_pid, 1);
linuxthreads_wait_last = -1;
- linuxthreads_exit_status = __W_STOPCODE(0);
+ WSETSTOP (linuxthreads_exit_status, 0);
}
linuxthreads_inferior_pid = 0;
@@ -1601,7 +1601,7 @@
linuxthreads_breakpoints_inserted = 1;
linuxthreads_breakpoint_last = -1;
linuxthreads_wait_last = -1;
- linuxthreads_exit_status = __W_STOPCODE(0);
+ WSETSTOP (linuxthreads_exit_status, 0);
if (linuxthreads_max)
linuxthreads_attach_pending = 1;
Index: gdb/gdb_wait.h
===================================================================
RCS file: /cvs/src/src/gdb/gdb_wait.h,v
retrieving revision 1.1
diff -u -r1.1 gdb_wait.h
--- gdb/gdb_wait.h 2000/02/09 08:52:45 1.1
+++ gdb/gdb_wait.h 2000/02/09 14:23:07
@@ -86,11 +86,19 @@
#endif
#ifndef WSETEXIT
+#ifdef W_EXITCODE
+#define WSETEXIT(w,status) ((w) = W_EXITCODE(status, 0))
+#else
#define WSETEXIT(w,status) ((w) = (0 | ((status) << 8)))
#endif
+#endif
#ifndef WSETSTOP
+#ifndef W_STOPCODE
+#define WSETSTOP(w,sig) ((w) = W_STOPCODE(sig))
+#else
#define WSETSTOP(w,sig) ((w) = (0177 | ((sig) << 8)))
+#endif
#endif
/*