karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 1 | -- Copyright 2011 the V8 project authors. All rights reserved. |
| 2 | -- Redistribution and use in source and binary forms, with or without |
| 3 | -- modification, are permitted provided that the following conditions are |
| 4 | -- met: |
| 5 | -- |
| 6 | -- * Redistributions of source code must retain the above copyright |
| 7 | -- notice, this list of conditions and the following disclaimer. |
| 8 | -- * Redistributions in binary form must reproduce the above |
| 9 | -- copyright notice, this list of conditions and the following |
| 10 | -- disclaimer in the documentation and/or other materials provided |
| 11 | -- with the distribution. |
| 12 | -- * Neither the name of Google Inc. nor the names of its |
| 13 | -- contributors may be used to endorse or promote products derived |
| 14 | -- from this software without specific prior written permission. |
| 15 | -- |
| 16 | -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | -- This is main driver for gcmole tool. See README for more details. |
| 29 | -- Usage: CLANG_BIN=clang-bin-dir lua tools/gcmole/gcmole.lua [arm|ia32|x64] |
| 30 | |
| 31 | local DIR = arg[0]:match("^(.+)/[^/]+$") |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 32 | |
| 33 | local FLAGS = { |
| 34 | -- Do not build gcsuspects file and reuse previously generated one. |
| 35 | reuse_gcsuspects = false; |
| 36 | |
| 37 | -- Print commands to console before executing them. |
| 38 | verbose = false; |
| 39 | |
| 40 | -- Perform dead variable analysis (generates many false positives). |
| 41 | -- TODO add some sort of whiteliste to filter out false positives. |
| 42 | dead_vars = false; |
| 43 | |
| 44 | -- When building gcsuspects whitelist certain functions as if they |
| 45 | -- can be causing GC. Currently used to reduce number of false |
| 46 | -- positives in dead variables analysis. See TODO for WHITELIST |
| 47 | -- below. |
| 48 | whitelist = true; |
| 49 | } |
| 50 | local ARGS = {} |
| 51 | |
| 52 | for i = 1, #arg do |
| 53 | local flag = arg[i]:match "^%-%-([%w_-]+)$" |
| 54 | if flag then |
| 55 | local no, real_flag = flag:match "^(no)([%w_-]+)$" |
| 56 | if real_flag then flag = real_flag end |
| 57 | |
| 58 | flag = flag:gsub("%-", "_") |
| 59 | if FLAGS[flag] ~= nil then |
| 60 | FLAGS[flag] = (no ~= "no") |
| 61 | else |
| 62 | error("Unknown flag: " .. flag) |
| 63 | end |
| 64 | else |
| 65 | table.insert(ARGS, arg[i]) |
| 66 | end |
| 67 | end |
| 68 | |
| 69 | local ARCHS = ARGS[1] and { ARGS[1] } or { 'ia32', 'arm', 'x64' } |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 70 | |
| 71 | local io = require "io" |
| 72 | local os = require "os" |
| 73 | |
| 74 | function log(...) |
| 75 | io.stderr:write(string.format(...)) |
| 76 | io.stderr:write "\n" |
| 77 | end |
| 78 | |
| 79 | ------------------------------------------------------------------------------- |
| 80 | -- Clang invocation |
| 81 | |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 82 | local CLANG_BIN = os.getenv "CLANG_BIN" |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame^] | 83 | local CLANG_PLUGINS = os.getenv "CLANG_PLUGINS" |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 84 | |
| 85 | if not CLANG_BIN or CLANG_BIN == "" then |
| 86 | error "CLANG_BIN not set" |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 87 | end |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 88 | |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame^] | 89 | if not CLANG_PLUGINS or CLANG_PLUGINS == "" then |
| 90 | CLANG_PLUGINS = DIR |
| 91 | end |
| 92 | |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 93 | local function MakeClangCommandLine(plugin, plugin_args, triple, arch_define) |
| 94 | if plugin_args then |
| 95 | for i = 1, #plugin_args do |
| 96 | plugin_args[i] = "-plugin-arg-" .. plugin .. " " .. plugin_args[i] |
| 97 | end |
| 98 | plugin_args = " " .. table.concat(plugin_args, " ") |
| 99 | end |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame^] | 100 | return CLANG_BIN .. "/clang -cc1 -load " .. CLANG_PLUGINS .. "/libgcmole.so" |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 101 | .. " -plugin " .. plugin |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 102 | .. (plugin_args or "") |
| 103 | .. " -triple " .. triple |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 104 | .. " -D" .. arch_define |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 105 | .. " -DENABLE_DEBUGGER_SUPPORT" |
| 106 | .. " -Isrc" |
| 107 | end |
| 108 | |
| 109 | function InvokeClangPluginForEachFile(filenames, cfg, func) |
| 110 | local cmd_line = MakeClangCommandLine(cfg.plugin, |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 111 | cfg.plugin_args, |
| 112 | cfg.triple, |
| 113 | cfg.arch_define) |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 114 | for _, filename in ipairs(filenames) do |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 115 | log("-- %s", filename) |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 116 | local action = cmd_line .. " src/" .. filename .. " 2>&1" |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 117 | if FLAGS.verbose then print('popen ', action) end |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 118 | local pipe = io.popen(action) |
| 119 | func(filename, pipe:lines()) |
| 120 | pipe:close() |
| 121 | end |
| 122 | end |
| 123 | |
| 124 | ------------------------------------------------------------------------------- |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 125 | -- GYP file parsing |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 126 | |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 127 | local function ParseGYPFile() |
| 128 | local f = assert(io.open("tools/gyp/v8.gyp"), "failed to open GYP file") |
| 129 | local gyp = f:read('*a') |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 130 | f:close() |
| 131 | |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 132 | local result = {} |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 133 | |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 134 | for condition, sources in |
| 135 | gyp:gmatch "'sources': %[.-### gcmole%((.-)%) ###(.-)%]" do |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 136 | local files = {} |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 137 | for file in sources:gmatch "'%.%./%.%./src/([^']-%.cc)'" do |
| 138 | table.insert(files, file) |
| 139 | end |
| 140 | result[condition] = files |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 141 | end |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 142 | |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 143 | return result |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 144 | end |
| 145 | |
| 146 | local function EvaluateCondition(cond, props) |
| 147 | if cond == 'all' then return true end |
| 148 | |
| 149 | local p, v = cond:match "(%w+):(%w+)" |
| 150 | |
| 151 | assert(p and v, "failed to parse condition: " .. cond) |
| 152 | assert(props[p] ~= nil, "undefined configuration property: " .. p) |
| 153 | |
| 154 | return props[p] == v |
| 155 | end |
| 156 | |
| 157 | local function BuildFileList(sources, props) |
| 158 | local list = {} |
| 159 | for condition, files in pairs(sources) do |
| 160 | if EvaluateCondition(condition, props) then |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 161 | for i = 1, #files do table.insert(list, files[i]) end |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 162 | end |
| 163 | end |
| 164 | return list |
| 165 | end |
| 166 | |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 167 | local sources = ParseGYPFile() |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 168 | |
| 169 | local function FilesForArch(arch) |
| 170 | return BuildFileList(sources, { os = 'linux', |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 171 | arch = arch, |
| 172 | mode = 'debug', |
| 173 | simulator = ''}) |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 174 | end |
| 175 | |
| 176 | local mtConfig = {} |
| 177 | |
| 178 | mtConfig.__index = mtConfig |
| 179 | |
| 180 | local function config (t) return setmetatable(t, mtConfig) end |
| 181 | |
| 182 | function mtConfig:extend(t) |
| 183 | local e = {} |
| 184 | for k, v in pairs(self) do e[k] = v end |
| 185 | for k, v in pairs(t) do e[k] = v end |
| 186 | return config(e) |
| 187 | end |
| 188 | |
| 189 | local ARCHITECTURES = { |
| 190 | ia32 = config { triple = "i586-unknown-linux", |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 191 | arch_define = "V8_TARGET_ARCH_IA32" }, |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 192 | arm = config { triple = "i586-unknown-linux", |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 193 | arch_define = "V8_TARGET_ARCH_ARM" }, |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 194 | x64 = config { triple = "x86_64-unknown-linux", |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 195 | arch_define = "V8_TARGET_ARCH_X64" } |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | ------------------------------------------------------------------------------- |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 199 | -- GCSuspects Generation |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 200 | |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 201 | local gc, gc_caused, funcs |
| 202 | |
| 203 | local WHITELIST = { |
| 204 | -- The following functions call CEntryStub which is always present. |
| 205 | "MacroAssembler.*CallExternalReference", |
| 206 | "MacroAssembler.*CallRuntime", |
| 207 | "CompileCallLoadPropertyWithInterceptor", |
| 208 | "CallIC.*GenerateMiss", |
| 209 | |
| 210 | -- DirectCEntryStub is a special stub used on ARM. |
| 211 | -- It is pinned and always present. |
| 212 | "DirectCEntryStub.*GenerateCall", |
| 213 | |
| 214 | -- TODO GCMole currently is sensitive enough to understand that certain |
| 215 | -- functions only cause GC and return Failure simulataneously. |
| 216 | -- Callsites of such functions are safe as long as they are properly |
| 217 | -- check return value and propagate the Failure to the caller. |
| 218 | -- It should be possible to extend GCMole to understand this. |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 219 | "Heap.*AllocateFunctionPrototype", |
| 220 | |
| 221 | -- Ignore all StateTag methods. |
| 222 | "StateTag", |
| 223 | |
| 224 | -- Ignore printing of elements transition. |
| 225 | "PrintElementsTransition" |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 226 | }; |
| 227 | |
| 228 | local function AddCause(name, cause) |
| 229 | local t = gc_caused[name] |
| 230 | if not t then |
| 231 | t = {} |
| 232 | gc_caused[name] = t |
| 233 | end |
| 234 | table.insert(t, cause) |
| 235 | end |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 236 | |
| 237 | local function resolve(name) |
| 238 | local f = funcs[name] |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 239 | |
| 240 | if not f then |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 241 | f = {} |
| 242 | funcs[name] = f |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 243 | |
| 244 | if name:match "Collect.*Garbage" then |
| 245 | gc[name] = true |
| 246 | AddCause(name, "<GC>") |
| 247 | end |
| 248 | |
| 249 | if FLAGS.whitelist then |
| 250 | for i = 1, #WHITELIST do |
| 251 | if name:match(WHITELIST[i]) then |
| 252 | gc[name] = false |
| 253 | end |
| 254 | end |
| 255 | end |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 256 | end |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 257 | |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 258 | return f |
| 259 | end |
| 260 | |
| 261 | local function parse (filename, lines) |
| 262 | local scope |
| 263 | |
| 264 | for funcname in lines do |
| 265 | if funcname:sub(1, 1) ~= '\t' then |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 266 | resolve(funcname) |
| 267 | scope = funcname |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 268 | else |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 269 | local name = funcname:sub(2) |
| 270 | resolve(name)[scope] = true |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 271 | end |
| 272 | end |
| 273 | end |
| 274 | |
| 275 | local function propagate () |
| 276 | log "** Propagating GC information" |
| 277 | |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 278 | local function mark(from, callers) |
| 279 | for caller, _ in pairs(callers) do |
| 280 | if gc[caller] == nil then |
| 281 | gc[caller] = true |
| 282 | mark(caller, funcs[caller]) |
| 283 | end |
| 284 | AddCause(caller, from) |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 285 | end |
| 286 | end |
| 287 | |
| 288 | for funcname, callers in pairs(funcs) do |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 289 | if gc[funcname] then mark(funcname, callers) end |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 290 | end |
| 291 | end |
| 292 | |
| 293 | local function GenerateGCSuspects(arch, files, cfg) |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 294 | -- Reset the global state. |
| 295 | gc, gc_caused, funcs = {}, {}, {} |
| 296 | |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 297 | log ("** Building GC Suspects for %s", arch) |
| 298 | InvokeClangPluginForEachFile (files, |
| 299 | cfg:extend { plugin = "dump-callees" }, |
| 300 | parse) |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 301 | |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 302 | propagate() |
| 303 | |
| 304 | local out = assert(io.open("gcsuspects", "w")) |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 305 | for name, value in pairs(gc) do if value then out:write (name, '\n') end end |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 306 | out:close() |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 307 | |
| 308 | local out = assert(io.open("gccauses", "w")) |
| 309 | out:write "GC = {" |
| 310 | for name, causes in pairs(gc_caused) do |
| 311 | out:write("['", name, "'] = {") |
| 312 | for i = 1, #causes do out:write ("'", causes[i], "';") end |
| 313 | out:write("};\n") |
| 314 | end |
| 315 | out:write "}" |
| 316 | out:close() |
| 317 | |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 318 | log ("** GCSuspects generated for %s", arch) |
| 319 | end |
| 320 | |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 321 | -------------------------------------------------------------------------------- |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 322 | -- Analysis |
| 323 | |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 324 | local function CheckCorrectnessForArch(arch) |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 325 | local files = FilesForArch(arch) |
| 326 | local cfg = ARCHITECTURES[arch] |
| 327 | |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 328 | if not FLAGS.reuse_gcsuspects then |
| 329 | GenerateGCSuspects(arch, files, cfg) |
| 330 | end |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 331 | |
| 332 | local processed_files = 0 |
| 333 | local errors_found = false |
| 334 | local function SearchForErrors(filename, lines) |
| 335 | processed_files = processed_files + 1 |
| 336 | for l in lines do |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 337 | errors_found = errors_found or |
| 338 | l:match "^[^:]+:%d+:%d+:" or |
| 339 | l:match "error" or |
| 340 | l:match "warning" |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 341 | print(l) |
| 342 | end |
| 343 | end |
| 344 | |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 345 | log("** Searching for evaluation order problems%s for %s", |
| 346 | FLAGS.dead_vars and " and dead variables" or "", |
| 347 | arch) |
| 348 | local plugin_args |
| 349 | if FLAGS.dead_vars then plugin_args = { "--dead-vars" } end |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 350 | InvokeClangPluginForEachFile(files, |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 351 | cfg:extend { plugin = "find-problems", |
| 352 | plugin_args = plugin_args }, |
| 353 | SearchForErrors) |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 354 | log("** Done processing %d files. %s", |
| 355 | processed_files, |
| 356 | errors_found and "Errors found" or "No errors found") |
| 357 | |
| 358 | return errors_found |
| 359 | end |
| 360 | |
| 361 | local function SafeCheckCorrectnessForArch(arch) |
| 362 | local status, errors = pcall(CheckCorrectnessForArch, arch) |
| 363 | if not status then |
| 364 | print(string.format("There was an error: %s", errors)) |
| 365 | errors = true |
| 366 | end |
| 367 | return errors |
| 368 | end |
| 369 | |
| 370 | local errors = false |
| 371 | |
| 372 | for _, arch in ipairs(ARCHS) do |
| 373 | if not ARCHITECTURES[arch] then |
| 374 | error ("Unknown arch: " .. arch) |
| 375 | end |
| 376 | |
| 377 | errors = SafeCheckCorrectnessForArch(arch, report) or errors |
| 378 | end |
| 379 | |
| 380 | os.exit(errors and 1 or 0) |