public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* [PATCH] Fix strace -T
@ 2011-09-08 18:37 Jon TURNEY
  2011-09-08 19:10 ` Christopher Faylor
  0 siblings, 1 reply; 3+ messages in thread
From: Jon TURNEY @ 2011-09-08 18:37 UTC (permalink / raw)
  To: cygwin-patches

[-- Attachment #1: Type: text/plain, Size: 345 bytes --]


strace -T to toggle stracing of a process doesn't seem to work at the moment. 
Attached is a patch to make it work again.

2011-09-08  Jon TURNEY  <jon.turney@dronecode.org.uk>

	* include/sys/strace.h (strace): Add toggle() method
	* strace.cc (toggle): Implement toggle() method
	* sigproc.cc (wait_sig): Use strace.toggle() in __SIGSTRACE



[-- Attachment #2: strace_toggle.patch --]
[-- Type: text/plain, Size: 1187 bytes --]

Fix 'strace -T -pid=<pid>'

Index: cygwin/include/sys/strace.h
===================================================================
--- cygwin/include/sys/strace.h.orig
+++ cygwin/include/sys/strace.h
@@ -40,6 +40,7 @@ class strace
   unsigned char _active;
 public:
   void activate ();
+  void toggle ();
   strace () {activate ();}
   int microseconds ();
   int version;
Index: cygwin/sigproc.cc
===================================================================
--- cygwin/sigproc.cc.orig
+++ cygwin/sigproc.cc
@@ -1194,7 +1194,7 @@ wait_sig (VOID *)
 	  talktome (&pack.si);
 	  break;
 	case __SIGSTRACE:
-	  strace.activate ();
+	  strace.toggle ();
 	  strace.hello ();
 	  break;
 	case __SIGPENDING:
Index: cygwin/strace.cc
===================================================================
--- cygwin/strace.cc.orig
+++ cygwin/strace.cc
@@ -43,6 +43,21 @@ strace::activate ()
 }
 
 void
+strace::toggle()
+{
+  if (active())
+    {
+      /* turn off stracing */
+      _active ^= 1;
+    }
+  else
+    {
+      /* announcing _STRACE_INTERFACE_ACTIVATE_ADDR makes the stracer turn on stracing */
+      activate ();
+    }
+}
+
+void
 strace::hello ()
 {
   if (active ())

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix strace -T
  2011-09-08 18:37 [PATCH] Fix strace -T Jon TURNEY
@ 2011-09-08 19:10 ` Christopher Faylor
  2011-09-09 12:28   ` Jon TURNEY
  0 siblings, 1 reply; 3+ messages in thread
From: Christopher Faylor @ 2011-09-08 19:10 UTC (permalink / raw)
  To: cygwin-patches

On Thu, Sep 08, 2011 at 07:37:29PM +0100, Jon TURNEY wrote:
>
>strace -T to toggle stracing of a process doesn't seem to work at the moment. 
>Attached is a patch to make it work again.
>
>2011-09-08  Jon TURNEY  <jon.turney@dronecode.org.uk>
>
>	* include/sys/strace.h (strace): Add toggle() method
>	* strace.cc (toggle): Implement toggle() method
>	* sigproc.cc (wait_sig): Use strace.toggle() in __SIGSTRACE

IIRC, the intent was for hello() to toggle (in which case I guess it
should be hellogoodbye).  Why do you even need this functionality?
I'd just as soon remove it.

cgf

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix strace -T
  2011-09-08 19:10 ` Christopher Faylor
@ 2011-09-09 12:28   ` Jon TURNEY
  0 siblings, 0 replies; 3+ messages in thread
From: Jon TURNEY @ 2011-09-09 12:28 UTC (permalink / raw)
  To: cygwin-patches

On 08/09/2011 20:09, Christopher Faylor wrote:
> On Thu, Sep 08, 2011 at 07:37:29PM +0100, Jon TURNEY wrote:
>>
>> strace -T to toggle stracing of a process doesn't seem to work at the moment.
>> Attached is a patch to make it work again.
>>
>> 2011-09-08  Jon TURNEY<jon.turney@dronecode.org.uk>
>>
>> 	* include/sys/strace.h (strace): Add toggle() method
>> 	* strace.cc (toggle): Implement toggle() method
>> 	* sigproc.cc (wait_sig): Use strace.toggle() in __SIGSTRACE
>
> IIRC, the intent was for hello() to toggle (in which case I guess it
> should be hellogoodbye).  Why do you even need this functionality?
> I'd just as soon remove it.

I found it very helpful to have this working when I was looking at a problem 
which occurred when running the twisted testsuite ([1], I think), as running 
the entire testsuite with strace enabled greatly slowed it down and generated 
a vast amount of output, and the problem did not reproduce when running a 
single test.  Being able to disable strace output until close to the point of 
failure was useful.

I didn't want to touch strace::hello() as it's called from a few other places 
than __SIGSTRACE processing, and I don't understand them well enough to know 
if toggling in those places is correct.

[1] http://cygwin.com/ml/cygwin/2011-03/msg00437.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-09-09 12:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-08 18:37 [PATCH] Fix strace -T Jon TURNEY
2011-09-08 19:10 ` Christopher Faylor
2011-09-09 12:28   ` Jon TURNEY

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).