strace: always define WCOREDUMP

wait.c does it already.

* strace.c: Remove <sys/wait.h> include, add "wait.h" include.
[!WCOREDUMP]: Remove.
* wait.c: Remove <sys/wait.h> include, add "wait.h" include.
[!WCOREFLAG] (WCOREFLAG), [!WCOREDUMP] (WCOREDUMP): Move to wait.h,
rework.
[!W_STOPCODE] (W_STOPCODE), [!W_EXITCODE] (W_EXITCODE),
[!W_CONTINUED] (W_CONTINUED): Move to wait.h.
This commit is contained in:
Eugene Syromyatnikov 2018-10-03 10:31:30 +02:00
parent 0e58b178e5
commit 81c9974f11
3 changed files with 37 additions and 32 deletions

View File

@ -36,7 +36,6 @@
#include "ptrace.h"
#include <signal.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <sys/stat.h>
#ifdef HAVE_PATHS_H
# include <paths.h>
@ -59,6 +58,7 @@
#include "trace_event.h"
#include "xstring.h"
#include "delay.h"
#include "wait.h"
/* In some libc, these aren't declared. Do it ourself: */
extern char **environ;
@ -2033,14 +2033,9 @@ print_debug_info(const int pid, int status)
strcpy(buf, "???");
if (WIFSIGNALED(status))
#ifdef WCOREDUMP
xsprintf(buf, "WIFSIGNALED,%ssig=%s",
WCOREDUMP(status) ? "core," : "",
signame(WTERMSIG(status)));
#else
xsprintf(buf, "WIFSIGNALED,sig=%s",
signame(WTERMSIG(status)));
#endif
if (WIFEXITED(status))
xsprintf(buf, "WIFEXITED,exitcode=%u", WEXITSTATUS(status));
if (WIFSTOPPED(status))
@ -2172,14 +2167,9 @@ print_signalled(struct tcb *tcp, const int pid, int status)
&& is_number_in_set(WTERMSIG(status), signal_set)) {
if (tcp)
printleader(tcp);
#ifdef WCOREDUMP
printer("%skilled by %s%s%s",
prefix, signame(WTERMSIG(status)),
WCOREDUMP(status) ? " (core dumped)" : "", suffix);
#else
printer("%skilled by %s%s",
prefix, signame(WTERMSIG(status)), suffix);
#endif
line_ended();
}
}

22
wait.c
View File

@ -36,29 +36,9 @@
#include "defs.h"
#include "ptrace.h"
#include <sys/wait.h>
#include "wait.h"
#include "xlat/wait4_options.h"
#if !defined WCOREFLAG && defined WCOREFLG
# define WCOREFLAG WCOREFLG
#endif
#ifndef WCOREFLAG
# define WCOREFLAG 0x80
#endif
#ifndef WCOREDUMP
# define WCOREDUMP(status) ((status) & 0200)
#endif
#ifndef W_STOPCODE
# define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
#endif
#ifndef W_EXITCODE
# define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
#endif
#ifndef W_CONTINUED
# define W_CONTINUED 0xffff
#endif
#include "xlat/ptrace_events.h"
static int

35
wait.h Normal file
View File

@ -0,0 +1,35 @@
#ifndef STRACE_WAIT_H
#define STRACE_WAIT_H
#include "defs.h"
#include <sys/wait.h>
#include "static_assert.h"
/*
* on Linux, the "core dumped" flag is hard-coded to 0x80:
* fs/coredump.c:coredump_finish() after v3.10-rc1~143^2~41,
* fs/coredump.c:do_coredump() between v3.7-rc1~134^2~4 and v3.10-rc1~143^2~41,
* or fs/exec.c:do_coredump() before v3.7-rc1~134^2~4
*/
#ifndef WCOREFLAG
# define WCOREFLAG 0x80
#else
static_assert((WCOREFLAG) == 0x80, "WCOREFLAG != 0x80");
#endif
#ifndef WCOREDUMP
# define WCOREDUMP(status) ((status) & (WCOREFLAG))
#endif
#ifndef W_STOPCODE
# define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
#endif
#ifndef W_EXITCODE
# define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
#endif
#ifndef W_CONTINUED
# define W_CONTINUED 0xffff
#endif
#endif /* STRACE_WAIT_H */