summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbitbake/bin/bitbake-worker36
-rw-r--r--bitbake/lib/bb/runqueue.py7
2 files changed, 37 insertions, 6 deletions
diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker
index d1ff5b36c5..c7992f7e82 100755
--- a/bitbake/bin/bitbake-worker
+++ b/bitbake/bin/bitbake-worker
@@ -12,10 +12,18 @@ import errno
12import signal 12import signal
13 13
14# Users shouldn't be running this code directly 14# Users shouldn't be running this code directly
15if len(sys.argv) != 2 or sys.argv[1] != "decafbad": 15if len(sys.argv) != 2 or not sys.argv[1].startswith("decafbad"):
16 print("bitbake-worker is meant for internal execution by bitbake itself, please don't use it standalone.") 16 print("bitbake-worker is meant for internal execution by bitbake itself, please don't use it standalone.")
17 sys.exit(1) 17 sys.exit(1)
18 18
19profiling = False
20if sys.argv[1] == "decafbadbad":
21 profiling = True
22 try:
23 import cProfile as profile
24 except:
25 import profile
26
19logger = logging.getLogger("BitBake") 27logger = logging.getLogger("BitBake")
20 28
21try: 29try:
@@ -134,6 +142,7 @@ def fork_off_task(cfg, data, workerdata, fn, task, taskname, appends, taskdepdat
134 bb.msg.fatal("RunQueue", "fork failed: %d (%s)" % (e.errno, e.strerror)) 142 bb.msg.fatal("RunQueue", "fork failed: %d (%s)" % (e.errno, e.strerror))
135 143
136 if pid == 0: 144 if pid == 0:
145 def child():
137 global worker_pipe 146 global worker_pipe
138 pipein.close() 147 pipein.close()
139 148
@@ -185,10 +194,20 @@ def fork_off_task(cfg, data, workerdata, fn, task, taskname, appends, taskdepdat
185 os._exit(1) 194 os._exit(1)
186 try: 195 try:
187 if not cfg.dry_run: 196 if not cfg.dry_run:
188 ret = bb.build.exec_task(fn, taskname, the_data, cfg.profile) 197 return bb.build.exec_task(fn, taskname, the_data, cfg.profile)
189 os._exit(ret)
190 except: 198 except:
191 os._exit(1) 199 os._exit(1)
200 if not profiling:
201 os._exit(child())
202 else:
203 profname = "profile-%s.log" % (fn.replace("/", "-") + "-" + taskname)
204 prof = profile.Profile()
205 try:
206 ret = profile.Profile.runcall(prof, child)
207 finally:
208 prof.dump_stats(profname)
209 bb.utils.process_profilelog(profname)
210 os._exit(ret)
192 else: 211 else:
193 for key, value in envbackup.iteritems(): 212 for key, value in envbackup.iteritems():
194 if value is None: 213 if value is None:
@@ -363,7 +382,16 @@ class BitbakeWorker(object):
363 382
364try: 383try:
365 worker = BitbakeWorker(sys.stdin) 384 worker = BitbakeWorker(sys.stdin)
366 worker.serve() 385 if not profiling:
386 worker.serve()
387 else:
388 profname = "profile-worker.log"
389 prof = profile.Profile()
390 try:
391 profile.Profile.runcall(prof, worker.serve)
392 finally:
393 prof.dump_stats(profname)
394 bb.utils.process_profilelog(profname)
367except BaseException as e: 395except BaseException as e:
368 if not normalexit: 396 if not normalexit:
369 import traceback 397 import traceback
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index e32f81a165..39df79473e 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -859,15 +859,18 @@ class RunQueue:
859 859
860 def _start_worker(self, fakeroot = False, rqexec = None): 860 def _start_worker(self, fakeroot = False, rqexec = None):
861 logger.debug(1, "Starting bitbake-worker") 861 logger.debug(1, "Starting bitbake-worker")
862 magic = "decafbad"
863 if self.cooker.configuration.profile:
864 magic = "decafbadbad"
862 if fakeroot: 865 if fakeroot:
863 fakerootcmd = self.cfgData.getVar("FAKEROOTCMD", True) 866 fakerootcmd = self.cfgData.getVar("FAKEROOTCMD", True)
864 fakerootenv = (self.cfgData.getVar("FAKEROOTBASEENV", True) or "").split() 867 fakerootenv = (self.cfgData.getVar("FAKEROOTBASEENV", True) or "").split()
865 env = os.environ.copy() 868 env = os.environ.copy()
866 for key, value in (var.split('=') for var in fakerootenv): 869 for key, value in (var.split('=') for var in fakerootenv):
867 env[key] = value 870 env[key] = value
868 worker = subprocess.Popen([fakerootcmd, "bitbake-worker", "decafbad"], stdout=subprocess.PIPE, stdin=subprocess.PIPE, env=env) 871 worker = subprocess.Popen([fakerootcmd, "bitbake-worker", magic], stdout=subprocess.PIPE, stdin=subprocess.PIPE, env=env)
869 else: 872 else:
870 worker = subprocess.Popen(["bitbake-worker", "decafbad"], stdout=subprocess.PIPE, stdin=subprocess.PIPE) 873 worker = subprocess.Popen(["bitbake-worker", magic], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
871 bb.utils.nonblockingfd(worker.stdout) 874 bb.utils.nonblockingfd(worker.stdout)
872 workerpipe = runQueuePipe(worker.stdout, None, self.cfgData, self, rqexec) 875 workerpipe = runQueuePipe(worker.stdout, None, self.cfgData, self, rqexec)
873 876