~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/strace.py

  • Committer: Jelmer Vernooij
  • Date: 2011-12-18 15:28:38 UTC
  • mto: This revision was merged to the branch mainline in revision 6386.
  • Revision ID: jelmer@samba.org-20111218152838-5wxpfnugk2jd625k
UseĀ absolute_import.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
 
 
18
from __future__ import absolute_import
 
19
 
18
20
"""Support for running strace against the current process."""
19
21
 
20
 
import errno
21
22
import os
22
23
import signal
23
24
import subprocess
26
27
from bzrlib import errors
27
28
 
28
29
 
29
 
# this is currently test-focused, so importing bzrlib.tests is ok. We might
30
 
# want to move feature to its own module though.
31
 
from bzrlib.tests.features import Feature
32
 
 
33
 
 
34
30
def strace(function, *args, **kwargs):
35
31
    """Invoke strace on function.
36
32
 
54
50
    # start strace
55
51
    strace_cmd = ['strace', '-r', '-tt', '-p', str(pid), '-o', log_file.name]
56
52
    if follow_children:
57
 
        strace_args.append('-f')
 
53
        strace_cmd.append('-f')
58
54
    # need to catch both stdout and stderr to work around
59
55
    # bug 627208
60
56
    proc = subprocess.Popen(strace_cmd,