[SCM] strace branch, master, updated. v4.5.20-103-g7b6847b

Denys Vlasenko dvlasenk at redhat.com
Thu Mar 10 11:26:08 UTC 2011


On Thu, 2011-03-10 at 00:59 +0300, Dmitry V. Levin wrote:
> On Wed, Mar 09, 2011 at 05:15:30PM +0000, Denys Vlasenko wrote:
> > --- a/strace.c
> > +++ b/strace.c
> > @@ -2637,6 +2637,8 @@ Process %d attached (waiting for parent)\n",
> >  			}
> >  			if (cflag != CFLAG_ONLY_STATS
> >  			    && (qual_flags[WSTOPSIG(status)] & QUAL_SIGNAL)) {
> > +				siginfo_t si;
> > +				int entered_stopped_state;
> >  				unsigned long addr = 0;
> >  				long pc = 0;
> >  #if defined(PT_CR_IPSR) && defined(PT_CR_IIP) && defined(PT_GETSIGINFO)
> > @@ -2653,15 +2655,30 @@ Process %d attached (waiting for parent)\n",
> >  #elif defined PTRACE_GETSIGINFO
> >  				if (WSTOPSIG(status) == SIGSEGV ||
> >  				    WSTOPSIG(status) == SIGBUS) {
> > -					siginfo_t si;
> >  					if (ptrace(PTRACE_GETSIGINFO, pid,
> >  						   0, &si) == 0)
> >  						addr = (unsigned long)
> 
> Missing ChangeLog entry is not the only problem with this commit.
> The PT_CR_IPSR && PT_CR_IIP && PT_GETSIGINFO case won't compile.

My apologies, I did not notice that there is another variable named 'si'
in the same scope.

It is easy to just use additional "siginfo_t si" in the added if () {}
block and hope gcc is smart enough to reuse the same slot for both
structs instead of doing this optimization by hand...

Here is it. Please take a look at this fixed version.

-- 
vda


Show job control stop differently from signal notification

* strace.c (trace): Query PTRACE_GETSIGINFO on stop signals,
if it fails, show "--- stopped by SIGFOO ---"
to indicate that tracee is in job control stop now.


diff -d -urpN strace.0/strace.c strace.1/strace.c
--- strace.0/strace.c	2011-02-14 20:11:45.690110153 +0100
+++ strace.1/strace.c	2011-03-10 12:15:14.259222703 +0100
@@ -2626,6 +2626,7 @@ Process %d attached (waiting for parent)
 			}
 			if (cflag != CFLAG_ONLY_STATS
 			    && (qual_flags[WSTOPSIG(status)] & QUAL_SIGNAL)) {
+				int in_job_control_stop;
 				unsigned long addr = 0;
 				long pc = 0;
 #if defined(PT_CR_IPSR) && defined(PT_CR_IIP) && defined(PT_GETSIGINFO)
@@ -2649,8 +2650,25 @@ Process %d attached (waiting for parent)
 							si.si_addr;
 				}
 #endif
+				in_job_control_stop = 0;
+				if (WSTOPSIG(status) == SIGSTOP ||
+				    WSTOPSIG(status) == SIGTSTP ||
+				    WSTOPSIG(status) == SIGTTIN ||
+				    WSTOPSIG(status) == SIGTTOU) {
+					/*
+					 * PTRACE_GETSIGINFO fails if this is
+					 * genuine *stop* notification,
+					 * not *signal* notification
+					 */
+					siginfo_t si;
+					if (ptrace(PTRACE_GETSIGINFO, pid,
+						    0, &si) != 0)
+						in_job_control_stop = 1;
+				}
 				printleader(tcp);
-				tprintf("--- %s (%s) @ %lx (%lx) ---",
+				tprintf(in_job_control_stop
+					? "--- stopped by %s ---"
+					: "--- %s (%s) @ %lx (%lx) ---",
 					signame(WSTOPSIG(status)),
 					strsignal(WSTOPSIG(status)), pc, addr);
 				printtrailer();






More information about the Strace-devel mailing list