summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-07 18:53:23 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-07 18:53:23 +0000
commit7bb860aa9310e178431f0cb83696b7d2a5856f37 (patch)
tree8cab952a0b1f1236b3f66eb6f8e7d49fd6f383be /tools
parent34dc5d9713620a3859d4b12cf400d0314d68a043 (diff)
downloadchromium_src-7bb860aa9310e178431f0cb83696b7d2a5856f37.zip
chromium_src-7bb860aa9310e178431f0cb83696b7d2a5856f37.tar.gz
chromium_src-7bb860aa9310e178431f0cb83696b7d2a5856f37.tar.bz2
Fix a xml parser crash in the valgrind analyze script.
I.e. http://build.chromium.org/buildbot/waterfall/builders/Modules%20Mac%20(valgrind)/builds/477/steps/valgrind%20test%3A%20ui/logs/stdio Review URL: http://codereview.chromium.org/115093 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15563 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rwxr-xr-xtools/valgrind/valgrind_analyze.py31
1 files changed, 25 insertions, 6 deletions
diff --git a/tools/valgrind/valgrind_analyze.py b/tools/valgrind/valgrind_analyze.py
index e4eb187..9fa0f12 100755
--- a/tools/valgrind/valgrind_analyze.py
+++ b/tools/valgrind/valgrind_analyze.py
@@ -13,6 +13,7 @@ import os
import sys
import time
from xml.dom.minidom import parse
+from xml.parsers.expat import ExpatError
# These are functions (using C++ mangled names) that we look for in stack
# traces. We don't show stack frames while pretty printing when they are below
@@ -208,12 +209,30 @@ class ValgrindAnalyze:
if not found:
badfiles.add(file)
else:
- raw_errors = parse(file).getElementsByTagName("error")
- for raw_error in raw_errors:
- # Ignore "possible" leaks for now by default.
- if (show_all_leaks or
- getTextOf(raw_error, "kind") != "Leak_PossiblyLost"):
- self._errors.add(ValgrindError(source_dir, raw_error))
+ try:
+ raw_errors = parse(file).getElementsByTagName("error")
+ for raw_error in raw_errors:
+ # Ignore "possible" leaks for now by default.
+ if (show_all_leaks or
+ getTextOf(raw_error, "kind") != "Leak_PossiblyLost"):
+ self._errors.add(ValgrindError(source_dir, raw_error))
+ except ExpatError, e:
+ logging.warn("could not parse %s: %s" % (file, e))
+ lineno = e.lineno - 1
+ context_lines = 5
+ context_start = max(0, lineno - context_lines)
+ context_end = lineno + context_lines + 1
+ context_file = open(file, "r")
+ for i in range(0, context_start):
+ context_file.readline()
+ for i in range(context_start, context_end):
+ context_data = context_file.readline().rstrip()
+ if i != lineno:
+ logging.warn(" %s" % context_data)
+ else:
+ logging.warn("> %s" % context_data)
+ context_file.close()
+ continue
if len(badfiles) > 0:
logging.warn("valgrind didn't finish writing %d files?!" % len(badfiles))