[gm.py] Improve mksnapshot failure detection

Dynamically process the arguments instead of hardcoding them,
which is brittle when they change.

Change-Id: I08f603dc6df6e3ed34518326b67da15f6a6d6102
Reviewed-on: https://chromium-review.googlesource.com/c/1405312
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58733}
This commit is contained in:
Jakob Kummerow 2019-01-11 11:24:36 +01:00 committed by Commit Bot
parent fd49c8bb43
commit 0685745cf5

View File

@ -206,6 +206,16 @@ def GetPath(arch, mode):
subdir = "%s.%s" % (arch, mode)
return os.path.join(OUTDIR, subdir)
def PrepareMksnapshotCmdline(orig_cmdline, path):
result = "gdb --args %s/mksnapshot " % path
for w in orig_cmdline.split(" "):
if w.startswith("gen/") or w.startswith("snapshot_blob"):
result += ("%(path)s%(sep)s%(arg)s " %
{"path": path, "sep": os.sep, "arg": w})
else:
result += "%s " % w
return result
class Config(object):
def __init__(self, arch, mode, targets, tests=[]):
self.arch = arch
@ -266,32 +276,16 @@ class Config(object):
return_code, output = _CallWithOutput("autoninja -C %s %s" %
(path, targets))
if return_code != 0 and "FAILED: snapshot_blob.bin" in output:
if return_code != 0 and "FAILED:" in output and "snapshot_blob" in output:
csa_trap = re.compile("Specify option( --csa-trap-on-node=[^ ]*)")
match = csa_trap.search(output)
extra_opt = match.group(1) if match else ""
cmdline = re.compile("python ../../tools/run.py ./mksnapshot (.*)")
match = cmdline.search(output)
cmdline = PrepareMksnapshotCmdline(match.group(1), path) + extra_opt
_Notify("V8 build requires your attention",
"Detected mksnapshot failure, re-running in GDB...")
_Call("gdb -args %(path)s/mksnapshot "
"--startup_src %(path)s/gen/snapshot.cc "
"--random-seed 314159265 "
"--startup-blob %(path)s/snapshot_blob.bin"
"%(extra)s"% {"path": path, "extra": extra_opt})
if (return_code != 0 and
"FAILED: gen/embedded.cc snapshot_blob.bin" in output):
csa_trap = re.compile("Specify option( --csa-trap-on-node=[^ ]*)")
match = csa_trap.search(output)
extra_opt = match.group(1) if match else ""
_Notify("V8 build requires your attention",
"Detected mksnapshot failure, re-running in GDB...")
_Call("gdb -args %(path)s/mksnapshot "
"--turbo-instruction-scheduling "
"--embedded_src %(path)s/gen/embedded.cc "
"--embedded_variant Default "
"--startup_src %(path)s/gen/snapshot.cc "
"--random-seed 314159265 "
"--startup-blob %(path)s/snapshot_blob.bin"
"%(extra)s"% {"path": path, "extra": extra_opt})
_Call(cmdline)
return return_code
def RunTests(self):