diff --git a/.devtoolset-3-strace.metadata b/.devtoolset-3-strace.metadata new file mode 100644 index 0000000..173e856 --- /dev/null +++ b/.devtoolset-3-strace.metadata @@ -0,0 +1 @@ +01e71ecb3e2113087194596bdf5ca39d7d054c4c SOURCES/strace-4.8.tar.gz diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1a272e4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/strace-4.8.tar.gz diff --git a/README.md b/README.md deleted file mode 100644 index 98f42b4..0000000 --- a/README.md +++ /dev/null @@ -1,4 +0,0 @@ -The master branch has no content - -Look at the c7 branch if you are working with CentOS-7, or the c4/c5/c6 branch for CentOS-4, 5 or 6 -If you find this file in a distro specific branch, it means that no content has been checked in yet diff --git a/SOURCES/strace-rh1044044.patch b/SOURCES/strace-rh1044044.patch new file mode 100644 index 0000000..2626411 --- /dev/null +++ b/SOURCES/strace-rh1044044.patch @@ -0,0 +1,20 @@ +diff -Nrup a/count.c b/count.c +--- a/count.c 2012-04-27 17:38:24.000000000 -0600 ++++ b/count.c 2013-12-18 09:23:32.823289640 -0700 +@@ -100,6 +100,16 @@ time_cmp(void *a, void *b) + static int + syscall_cmp(void *a, void *b) + { ++ const char *name_a = sysent[*((int *) a)].sys_name; ++ const char *name_b = sysent[*((int *) b)].sys_name; ++ ++ if (name_a == name_b) ++ return 0; ++ if (!name_a) ++ return -1; ++ if (!name_b) ++ return 1; ++ + return strcmp(sysent[*((int *) a)].sys_name, + sysent[*((int *) b)].sys_name); + } diff --git a/SOURCES/strace-rh851457.patch b/SOURCES/strace-rh851457.patch new file mode 100644 index 0000000..b234a10 --- /dev/null +++ b/SOURCES/strace-rh851457.patch @@ -0,0 +1,246 @@ +diff -Nrup a/defs.h b/defs.h +--- a/defs.h 2013-05-14 08:10:42.000000000 -0600 ++++ b/defs.h 2013-06-13 09:46:36.972244927 -0600 +@@ -398,6 +398,9 @@ struct tcb { + int pid; /* Process Id of this entry */ + int qual_flg; /* qual_flags[scno] or DEFAULT_QUAL_FLAGS + RAW */ + int u_error; /* Error code */ ++ int wait_status; /* Status from last wait() */ ++ struct tcb *next_need_service; ++ /* Linked list of tracees found by wait()s */ + long scno; /* System call number */ + long u_arg[MAX_ARGS]; /* System call arguments */ + #if defined(LINUX_MIPSN32) || defined(X32) +diff -Nrup a/strace.c b/strace.c +--- a/strace.c 2013-05-28 15:49:16.000000000 -0600 ++++ b/strace.c 2013-06-13 09:46:45.381217727 -0600 +@@ -1895,21 +1895,42 @@ interrupt(int sig) + interrupted = sig; + } + +-static int +-trace(void) ++static int remembered_pid; ++static int remembered_status; ++ ++static struct tcb * ++collect_stopped_tcbs(void) + { + struct rusage ru; + struct rusage *rup = cflag ? &ru : NULL; ++ struct tcb *found_tcps; ++ struct tcb **nextp; ++ int wnohang = 0; ++ int pid; ++ struct tcb *tcp; ++ + #ifdef __WALL + static int wait4_options = __WALL; + #endif + ++ if (remembered_pid) { ++ pid = remembered_pid; ++ remembered_pid = 0; ++ if (debug_flag) ++ fprintf(stderr, " [remembered wait(%#x) = %u]\n", ++ remembered_status, pid); ++ tcp = pid2tcb(pid); /* can't be NULL */ ++ tcp->wait_status = remembered_status; ++ tcp->next_need_service = NULL; ++ return tcp; ++ } ++ ++ nextp = &found_tcps; ++ found_tcps = NULL; ++ + while (nprocs != 0) { +- int pid; + int wait_errno; +- int status, sig; +- int stopped; +- struct tcb *tcp; ++ int status; + unsigned event; + + if (interrupted) +@@ -1917,26 +1938,36 @@ trace(void) + if (interactive) + sigprocmask(SIG_SETMASK, &empty_set, NULL); + #ifdef __WALL +- pid = wait4(-1, &status, wait4_options, rup); ++ pid = wait4(-1, &status, wait4_options | wnohang, rup); + if (pid < 0 && (wait4_options & __WALL) && errno == EINVAL) { + /* this kernel does not support __WALL */ + wait4_options &= ~__WALL; +- pid = wait4(-1, &status, wait4_options, rup); ++ pid = wait4(-1, &status, wait4_options | wnohang, rup); + } + if (pid < 0 && !(wait4_options & __WALL) && errno == ECHILD) { + /* most likely a "cloned" process */ +- pid = wait4(-1, &status, __WCLONE, rup); +- if (pid < 0) { ++ pid = wait4(-1, &status, __WCLONE | wnohang, rup); ++ if (pid < 0 && errno != ECHILD) { + perror_msg("wait4(__WCLONE) failed"); + } + } + #else +- pid = wait4(-1, &status, 0, rup); ++ pid = wait4(-1, &status, wnohang, rup); + #endif /* __WALL */ + wait_errno = errno; + if (interactive) + sigprocmask(SIG_BLOCK, &blocked_set, NULL); + ++ if (pid == 0 && wnohang) { ++ /* We had at least one successful ++ * wait() before. We waited ++ * with WNOHANG second time. ++ * Stop collecting more tracees, ++ * process what we already have. ++ */ ++ break; ++ } ++ + if (pid < 0) { + switch (wait_errno) { + case EINTR: +@@ -1948,11 +1979,11 @@ trace(void) + * version of SunOS sometimes reports + * ECHILD before sending us SIGCHILD. + */ +- return 0; ++ return found_tcps; + default: + errno = wait_errno; + perror_msg("wait"); +- return -1; ++ return (struct tcb *) -1; + } + } + if (pid == popen_pid) { +@@ -2092,14 +2123,68 @@ trace(void) + skip_one_b_execve = 0; + } + +- /* Set current output file */ +- current_tcp = tcp; +- + if (cflag) { + tv_sub(&tcp->dtime, &ru.ru_stime, &tcp->stime); + tcp->stime = ru.ru_stime; + } + ++ /* If we waited and got a stopped task notification, ++ * subsequent wait may return the same pid again, for example, ++ * with SIGKILL notification. SIGKILL kills even stopped tasks. ++ * We must not add it to the list ++ * (one task can't be inserted twice in the list). ++ */ ++ { ++ struct tcb *f = found_tcps; ++ while (f) { ++ if (f == tcp) { ++ remembered_pid = pid; ++ remembered_status = status; ++ return found_tcps; ++ } ++ f = f->next_need_service; ++ } ++ } ++ ++ /* It is important to not invert the order of tasks ++ * to process. For one, alloc_tcb() above picks newly forked ++ * threads in some order, processing of them and their parent ++ * should be in the same order, otherwise bad things happen ++ * (misinterpreted SIGSTOPs and such). ++ */ ++ tcp->wait_status = status; ++ *nextp = tcp; ++ nextp = &tcp->next_need_service; ++ *nextp = NULL; ++ wnohang = WNOHANG; ++ } ++ return found_tcps; ++} ++ ++static int ++handle_stopped_tcbs(struct tcb *tcp) ++{ ++ struct tcb *next; ++ ++ for (; tcp; tcp = next) { ++ int pid; ++ int status; ++ int sig; ++ int event; ++ int stopped; ++ ++ ++ /* If the child exits, the TCP will get dropped and ++ thus we can't use it to find the next TCP needing ++ service. So we save the next TCP needing service ++ and used the saved value when the loop iterates. */ ++ next = tcp->next_need_service; ++ ++ current_tcp = tcp; ++ status = tcp->wait_status; ++ pid = tcp->pid; ++ ++ event = ((unsigned)status >> 16); + if (WIFSIGNALED(status)) { + if (pid == strace_child) + exit_code = 0x100 | WTERMSIG(status); +@@ -2302,6 +2387,27 @@ trace(void) + return 0; + } + ++static int ++trace(void) ++{ ++ int rc; ++ struct tcb *tcbs; ++ ++ while (nprocs != 0) { ++ if (interrupted) ++ return 0; ++ tcbs = collect_stopped_tcbs(); ++ if (!tcbs) ++ break; ++ if (tcbs == (struct tcb *) -1) ++ return -1; ++ rc = handle_stopped_tcbs(tcbs); ++ if (rc) ++ return rc; ++ } ++ return 0; ++} ++ + int + main(int argc, char *argv[]) + { +diff -Nrup a/tests/Makefile.am b/tests/Makefile.am +--- a/tests/Makefile.am 2013-05-07 20:06:39.000000000 -0600 ++++ b/tests/Makefile.am 2013-06-13 10:01:52.103302835 -0600 +@@ -4,7 +4,8 @@ AM_CFLAGS = $(WARN_CFLAGS) + + check_PROGRAMS = net-accept-connect + +-TESTS = ptrace_setoptions strace-f qual_syscall stat net ++# "net" test disabled as it is highly dependent on timing issues ++TESTS = ptrace_setoptions strace-f qual_syscall stat + + EXTRA_DIST = init.sh $(TESTS) + +diff -Nrup a/tests/Makefile.in b/tests/Makefile.in +--- a/tests/Makefile.in 2013-06-04 18:02:45.000000000 -0600 ++++ b/tests/Makefile.in 2013-06-13 10:02:17.535221388 -0600 +@@ -201,7 +201,7 @@ top_build_prefix = @top_build_prefix@ + top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ + AM_CFLAGS = $(WARN_CFLAGS) +-TESTS = ptrace_setoptions strace-f qual_syscall stat net ++TESTS = ptrace_setoptions strace-f qual_syscall stat + EXTRA_DIST = init.sh $(TESTS) + CLEANFILES = check.log + all: all-am diff --git a/SOURCES/strace-rh921550.patch b/SOURCES/strace-rh921550.patch new file mode 100644 index 0000000..f531350 --- /dev/null +++ b/SOURCES/strace-rh921550.patch @@ -0,0 +1,19 @@ +diff -Nrup a/mem.c b/mem.c +--- a/mem.c 2013-05-23 07:40:34.000000000 -0600 ++++ b/mem.c 2014-05-21 10:14:34.958889425 -0600 +@@ -385,9 +385,15 @@ static const struct xlat madvise_cmds[] + #ifdef MADV_NOHUGEPAGE + { MADV_NOHUGEPAGE, "MADV_NOHUGEPAGE" }, + #endif ++#ifndef MADV_DONTDUMP ++#define MADV_DONTDUMP 16 ++#endif + #ifdef MADV_DONTDUMP + { MADV_DONTDUMP, "MADV_DONTDUMP" }, + #endif ++#ifndef MADV_DODUMP ++#define MADV_DODUMP 17 ++#endif + #ifdef MADV_DODUMP + { MADV_DODUMP, "MADV_DODUMP" }, + #endif diff --git a/SOURCES/strace-rh948577.patch b/SOURCES/strace-rh948577.patch new file mode 100644 index 0000000..1bc482c --- /dev/null +++ b/SOURCES/strace-rh948577.patch @@ -0,0 +1,46 @@ +diff -Nrup a/Makefile.am b/Makefile.am +--- a/Makefile.am 2012-04-18 09:27:25.000000000 -0600 ++++ b/Makefile.am 2013-04-15 15:05:43.907237228 -0600 +@@ -3,7 +3,7 @@ + SUBDIRS = tests + + bin_PROGRAMS = strace +-man_MANS = strace.1 ++man_MANS = strace.1 strace-log-merge.1 + bin_SCRIPTS = strace-graph strace-log-merge + + OS = linux +diff -Nrup a/Makefile.in b/Makefile.in +--- a/Makefile.in 2012-05-02 09:40:25.000000000 -0600 ++++ b/Makefile.in 2013-04-15 15:15:01.060139931 -0600 +@@ -302,7 +302,7 @@ top_build_prefix = @top_build_prefix@ + top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ + SUBDIRS = tests +-man_MANS = strace.1 ++man_MANS = strace.1 strace-log-merge.1 + bin_SCRIPTS = strace-graph strace-log-merge + OS = linux + # ARCH is `i386', `m68k', `sparc', etc. +diff -Nrup a/strace-log-merge.1 b/strace-log-merge.1 +--- a/strace-log-merge.1 1969-12-31 17:00:00.000000000 -0700 ++++ b/strace-log-merge.1 2013-04-15 15:05:13.235353408 -0600 +@@ -0,0 +1,18 @@ ++.TH strace-log-merge 1 "15 April 2013" ".1" "strace-log-merge" ++.SH NAME ++strace-log-merge ++.SH SYNOPSIS ++strace-log-merge STRACE_LOG ++.SH DESCRIPTION ++strace-log-merge finds all STRACE_LOG.PID files, adds PID prefix to every line, ++the combines and sorts them, and prints the result to standard output. ++ ++It is assumed that STRACE_LOGs were produced by strace with the -tt[t] ++option which prints timestamps (otherwise worting won't do any good). ++ ++.SH OPTIONS ++--help Show help ++ ++.SH SEE ALSO ++.SH BUGS ++ diff --git a/SOURCES/strace-rh971352.patch b/SOURCES/strace-rh971352.patch new file mode 100644 index 0000000..0d955a2 --- /dev/null +++ b/SOURCES/strace-rh971352.patch @@ -0,0 +1,15 @@ +diff -Nrup a/strace.c b/strace.c +--- a/strace.c 2013-07-17 14:39:50.603696069 -0600 ++++ b/strace.c 2013-07-17 14:43:27.625962443 -0600 +@@ -2184,6 +2184,11 @@ handle_stopped_tcbs(struct tcb *tcp) + status = tcp->wait_status; + pid = tcp->pid; + ++ /* we must re-fetch all registers for each pid in list */ ++ clear_regs(); ++ if (WIFSTOPPED(status)) ++ get_regs(pid); ++ + event = ((unsigned)status >> 16); + if (WIFSIGNALED(status)) { + if (pid == strace_child) diff --git a/SOURCES/strace-strict-aliasing.patch b/SOURCES/strace-strict-aliasing.patch new file mode 100644 index 0000000..f038dea --- /dev/null +++ b/SOURCES/strace-strict-aliasing.patch @@ -0,0 +1,40 @@ +diff -Nrup a/system.c b/system.c +--- a/system.c 2012-03-16 05:02:22.000000000 -0600 ++++ b/system.c 2013-02-18 15:17:23.651569983 -0700 +@@ -516,10 +516,14 @@ print_cap_header(struct tcb *tcp, unsign + umoven(tcp, addr, sizeof(*arg.p), arg.c) < 0) + tprintf("%#lx", addr); + else { ++ __u32 version; ++ int pid; + tprints("{"); +- printxval(cap_version, arg.p->version, ++ memcpy (&version, &arg.p->version, sizeof (__u32)); ++ printxval(cap_version, version, + "_LINUX_CAPABILITY_VERSION_???"); +- tprintf(", %d}", arg.p->pid); ++ memcpy (&pid, &arg.p->pid, sizeof (int)); ++ tprintf(", %d}", pid); + } + } + +@@ -537,12 +541,16 @@ print_cap_data(struct tcb *tcp, unsigned + umoven(tcp, addr, sizeof(*arg.p), arg.c) < 0) + tprintf("%#lx", addr); + else { ++ __u32 x; + tprints("{"); +- printflags(capabilities, arg.p->effective, "CAP_???"); ++ memcpy (&x, &arg.p->effective, sizeof (__u32)); ++ printflags(capabilities, x, "CAP_???"); + tprints(", "); +- printflags(capabilities, arg.p->permitted, "CAP_???"); ++ memcpy (&x, &arg.p->permitted, sizeof (__u32)); ++ printflags(capabilities, x, "CAP_???"); + tprints(", "); +- printflags(capabilities, arg.p->inheritable, "CAP_???"); ++ memcpy (&x, &arg.p->inheritable, sizeof (__u32)); ++ printflags(capabilities, x, "CAP_???"); + tprints("}"); + } + } diff --git a/SPECS/strace.spec b/SPECS/strace.spec new file mode 100644 index 0000000..57edd88 --- /dev/null +++ b/SPECS/strace.spec @@ -0,0 +1,122 @@ +%{?scl:%{?scl_package:%scl_package strace}} + +Summary: Tracks and displays system calls associated with a running process +Name: %{?scl_prefix}strace +Version: 4.8 +Release: 8%{?dist} +License: BSD +Group: Development/Debuggers +URL: http://sourceforge.net/projects/strace/ +# The upstream source really comes in .xz format. Unfortunately +# DTS builds using .xz seem to want to use /opt/rh/<...>/xz rather +# than the one in /usr/bin. Using the .gz extension seems to avoid +# this problem. This should be fixed at some point. +Source: http://downloads.sourceforge.net/strace/strace-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +%define alternatives_cmd %{!?scl:%{_sbindir}}%{?scl:%{_root_sbindir}}/alternatives +%define alternatives_cmdline %{alternatives_cmd}%{?scl: --altdir %{_sysconfdir}/alternatives --admindir %{_scl_root}/var/lib/alternatives} + +BuildRequires: libacl-devel, libaio-devel, time +%{?scl:Requires:%scl_runtime} + +Patch1000: strace-strict-aliasing.patch +Patch1001: strace-rh948577.patch +Patch1002: strace-rh851457.patch +Patch1003: strace-rh971352.patch +Patch1004: strace-rh1044044.patch + +# Hack as the RHEL 6 used for DTS is too old and doesn't define MADV_DODUMP +# and MADV_DONTDUMP. +Patch2000: strace-rh921550.patch + +# In the past we had a separate strace64 package, these days the +# stndard 64 bit build provides that functionality. For tracing +# 32 bit applications on ppc and s390 we still have strace32 +Obsoletes: strace64 + +%define strace32_arches ppc s390 + +%description +The strace program intercepts and records the system calls called and +received by a running process. Strace can print a record of each +system call, its arguments and its return value. Strace is useful for +diagnosing problems and debugging, as well as for instructional +purposes. + +Install strace if you need a tool to track the system calls made and +received by a process. + +%ifarch %{strace32_arches} +%package -n strace32 +Summary: Tracks and displays system calls associated with a running process. +Group: Development/Debuggers + +%description -n strace32 +The strace program intercepts and records the system calls called and +received by a running process. Strace can print a record of each +system call, its arguments and its return value. Strace is useful for +diagnosing problems and debugging, as well as for instructional +purposes. + +Install strace if you need a tool to track the system calls made and +received by a process. + +This package provides the `strace32' program to trace 32-bit processes on +64-bit IBM P and Z series platforms. +%endif + +%prep +%setup -q -n strace-%{version} +%patch1000 -p1 +%patch1001 -p1 +%patch1002 -p1 +%patch1003 -p1 +%patch1004 -p1 +%patch2000 -p1 + +%build +%configure +make %{?_smp_mflags} + +%install +rm -rf %{buildroot} +make DESTDIR=%{buildroot} install + +# remove unpackaged files from the buildroot +rm -f %{buildroot}%{_bindir}/strace-graph + +%define copy64 ln +%if 0%{?rhel} +%if 0%{?rhel} < 6 +%endif +%define copy64 cp -p +%endif + +%ifarch %{strace32_arches} +%{copy64} %{buildroot}%{_bindir}/strace %{buildroot}%{_bindir}/strace32 +%endif + +%check +make check + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root) +%doc CREDITS ChangeLog ChangeLog-CVS COPYING NEWS README +%{_bindir}/strace +%{_bindir}/strace-log-merge +%{_mandir}/man1/* + +%ifarch %{strace32_arches} +%files -n strace32 +%defattr(-,root,root) +%{_bindir}/strace32 +%endif + +%changelog +* Wed May 21 2014 Jeff Law - 4.8-8 +- Import from RHEL 7 and build +