diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-02-10 11:50:16 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-02-10 11:51:48 +0000 |
commit | 296866c38e1b88df42d66bdc32cfed2d5212914c (patch) | |
tree | f56631b4a7ed520ad4c7198c14a8746cc30cd01b | |
parent | d3d236b2bf2784d7454dcb7fce595b6aac6967cd (diff) | |
download | poky-296866c38e1b88df42d66bdc32cfed2d5212914c.tar.gz |
image-swab: Convert to attach strace to the process to obtain the required swabber data
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-x | bitbake/bin/bitbake-runtask-strace | 8 | ||||
-rw-r--r-- | meta/classes/image-swab.bbclass | 19 | ||||
-rwxr-xr-x | scripts/swabber-strace-attach | 30 |
3 files changed, 47 insertions, 10 deletions
diff --git a/bitbake/bin/bitbake-runtask-strace b/bitbake/bin/bitbake-runtask-strace deleted file mode 100755 index 1741a84de2..0000000000 --- a/bitbake/bin/bitbake-runtask-strace +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | STRACE=`which strace` | ||
3 | |||
4 | if [ ! -x "$STRACE" ]; then | ||
5 | bitbake-runtask $1 $2 $3 $4 | ||
6 | else | ||
7 | strace -f -o $TRACE_LOGFILE-$3.log -e trace=open,execve bitbake-runtask $1 $2 $3 $4 | ||
8 | fi | ||
diff --git a/meta/classes/image-swab.bbclass b/meta/classes/image-swab.bbclass index ec949ffe2e..b939ec4b45 100644 --- a/meta/classes/image-swab.bbclass +++ b/meta/classes/image-swab.bbclass | |||
@@ -2,7 +2,7 @@ HOST_DATA ?= "${TMPDIR}/host-contamination-data/" | |||
2 | SWABBER_REPORT ?= "${LOG_DIR}/swabber/" | 2 | SWABBER_REPORT ?= "${LOG_DIR}/swabber/" |
3 | SWABBER_LOGS ?= "${LOG_DIR}/contamination-logs" | 3 | SWABBER_LOGS ?= "${LOG_DIR}/contamination-logs" |
4 | TRACE_LOGDIR ?= "${SWABBER_LOGS}/${PACKAGE_ARCH}" | 4 | TRACE_LOGDIR ?= "${SWABBER_LOGS}/${PACKAGE_ARCH}" |
5 | export TRACE_LOGFILE = "${TRACE_LOGDIR}/${PN}-${PV}" | 5 | TRACE_LOGFILE = "${TRACE_LOGDIR}/${PN}-${PV}" |
6 | 6 | ||
7 | SWAB_ORIG_TASK := "${BB_DEFAULT_TASK}" | 7 | SWAB_ORIG_TASK := "${BB_DEFAULT_TASK}" |
8 | BB_DEFAULT_TASK = "generate_swabber_report" | 8 | BB_DEFAULT_TASK = "generate_swabber_report" |
@@ -56,7 +56,22 @@ python() { | |||
56 | bb.data.setVarFlag('do_setscene', 'depends', " ".join(deps), d) | 56 | bb.data.setVarFlag('do_setscene', 'depends', " ".join(deps), d) |
57 | logdir = bb.data.expand("${TRACE_LOGDIR}", d) | 57 | logdir = bb.data.expand("${TRACE_LOGDIR}", d) |
58 | bb.utils.mkdirhier(logdir) | 58 | bb.utils.mkdirhier(logdir) |
59 | bb.data.setVar('BB_RUNTASK', 'bitbake-runtask-strace', d) | 59 | else: |
60 | bb.data.setVar('STRACEFUNC', '', d) | ||
61 | } | ||
62 | |||
63 | STRACEPID = "${@os.getpid()}" | ||
64 | STRACEFUNC = "imageswab_attachstrace" | ||
65 | |||
66 | do_configure[prefuncs] += "${STRACEFUNC}" | ||
67 | do_compile[prefuncs] += "${STRACEFUNC}" | ||
68 | |||
69 | imageswab_attachstrace () { | ||
70 | STRACE=`which strace` | ||
71 | |||
72 | if [ -x "$STRACE" ]; then | ||
73 | swabber-strace-attach "$STRACE -f -o ${TRACE_LOGFILE}-${BB_CURRENTTASK}.log -e trace=open,execve -p ${STRACEPID}" "${TRACE_LOGFILE}-traceattach-${BB_CURRENTTASK}.log" | ||
74 | fi | ||
60 | } | 75 | } |
61 | 76 | ||
62 | do_generate_swabber_report () { | 77 | do_generate_swabber_report () { |
diff --git a/scripts/swabber-strace-attach b/scripts/swabber-strace-attach new file mode 100755 index 0000000000..d4f80e4e91 --- /dev/null +++ b/scripts/swabber-strace-attach | |||
@@ -0,0 +1,30 @@ | |||
1 | #!/usr/bin/env python | ||
2 | import os | ||
3 | import sys | ||
4 | |||
5 | # Detach from the controlling terminal and parent process by forking twice to daemonize ourselves, | ||
6 | # then run the command passed as argv[1]. Send log data to argv[2]. | ||
7 | |||
8 | pid = os.fork() | ||
9 | if (pid == 0): | ||
10 | os.setsid() | ||
11 | pid = os.fork() | ||
12 | if (pid != 0): | ||
13 | os._exit(0) | ||
14 | else: | ||
15 | sys.exit() | ||
16 | |||
17 | |||
18 | si = file(os.devnull, 'r') | ||
19 | so = file(sys.argv[2], 'w') | ||
20 | se = so | ||
21 | |||
22 | # Replace those fds with our own | ||
23 | os.dup2(si.fileno(), sys.stdin.fileno()) | ||
24 | os.dup2(so.fileno(), sys.stdout.fileno()) | ||
25 | os.dup2(se.fileno(), sys.stderr.fileno()) | ||
26 | |||
27 | ret = os.system(sys.argv[1]) | ||
28 | |||
29 | os._exit(ret) | ||
30 | |||