aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2007-01-03 02:32:09 +0000
committerMike Frysinger <vapier@gentoo.org>2007-01-03 02:32:09 +0000
commitcf63c3d7170030bfb09f4eb3288406ec052179a6 (patch)
treed11293a354855e1ed51639b03584ce58a5116271 /bin/check-implicit-pointer-usage.py
parentTry to create DISTDIR before disabling fetch due to it's nonexistence. Thank... (diff)
downloadportage-cf63c3d7170030bfb09f4eb3288406ec052179a6.tar.gz
portage-cf63c3d7170030bfb09f4eb3288406ec052179a6.tar.bz2
portage-cf63c3d7170030bfb09f4eb3288406ec052179a6.zip
add support for scanning of build logs for common issues #111436
svn path=/main/trunk/; revision=5449
Diffstat (limited to 'bin/check-implicit-pointer-usage.py')
-rwxr-xr-xbin/check-implicit-pointer-usage.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/bin/check-implicit-pointer-usage.py b/bin/check-implicit-pointer-usage.py
new file mode 100755
index 000000000..4afa8f24b
--- /dev/null
+++ b/bin/check-implicit-pointer-usage.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+
+# Ripped from HP and updated from Debian
+
+#
+# Copyright (c) 2004 Hewlett-Packard Development Company, L.P.
+# David Mosberger <davidm@hpl.hp.com>
+#
+# Scan standard input for GCC warning messages that are likely to
+# source of real 64-bit problems. In particular, see whether there
+# are any implicitly declared functions whose return values are later
+# interpreted as pointers. Those are almost guaranteed to cause
+# crashes.
+#
+import re
+import sys
+
+implicit_pattern = re.compile("([^:]*):(\d+): warning: implicit declaration "
+ + "of function [`']([^']*)'")
+pointer_pattern = re.compile(
+ "([^:]*):(\d+): warning: "
+ + "("
+ + "(assignment"
+ + "|initialization"
+ + "|return"
+ + "|passing arg \d+ of `[^']*'"
+ + "|passing arg \d+ of pointer to function"
+ + ") makes pointer from integer without a cast"
+ + "|"
+ + "cast to pointer from integer of different size)")
+last_implicit_filename = ""
+last_implicit_linenum = -1
+last_implicit_func = ""
+
+while True:
+ line = sys.stdin.readline()
+ if line == '':
+ break
+ m = implicit_pattern.match(line)
+ if m:
+ last_implicit_filename = m.group(1)
+ last_implicit_linenum = int(m.group(2))
+ last_implicit_func = m.group(3)
+ else:
+ m = pointer_pattern.match(line)
+ if m:
+ pointer_filename = m.group(1)
+ pointer_linenum = int(m.group(2))
+ if (last_implicit_filename == pointer_filename
+ and last_implicit_linenum == pointer_linenum):
+ print "Function `%s' implicitly converted to pointer at " \
+ "%s:%d" % (last_implicit_func, last_implicit_filename,
+ last_implicit_linenum)