[PATCH] Fix strace -T

2011-09-08 Thread Jon TURNEY


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.tur...@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


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 ())


Re: [PATCH] Fix strace -T

2011-09-08 Thread Christopher Faylor
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.tur...@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