diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-02-09 15:37:10 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-02-09 15:37:10 +0100 |
commit | b280acef5e151c0d32e828cf04b0cc8c644e2552 (patch) | |
tree | 86c8179bb20f99234e5b23029b1fb26635066d06 | |
parent | 2b6d0fc5c8e4472bc88db4075d2e63b4f01fbbe5 (diff) | |
parent | 8990f74eb66570c82bb67f98bdf8f514143c8650 (diff) | |
download | abrt-b280acef5e151c0d32e828cf04b0cc8c644e2552.tar.gz abrt-b280acef5e151c0d32e828cf04b0cc8c644e2552.tar.xz abrt-b280acef5e151c0d32e828cf04b0cc8c644e2552.zip |
Merge branch 'master' into rhel6
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | lib/Plugins/Python_hash.cpp | 17 | ||||
-rwxr-xr-x | scripts/abrt-bz-ratingfixer | 74 | ||||
-rwxr-xr-x | src/Backtrace/abrt-bz-dupchecker | 79 |
4 files changed, 119 insertions, 52 deletions
@@ -40,6 +40,7 @@ po/remove-potcdate.sed po/remove-potcdate.sin po/stamp-po py-compile +scripts/*.bt src/Applet/abrt-applet src/CLI/abrt-cli src/Backtrace/abrt-backtrace diff --git a/lib/Plugins/Python_hash.cpp b/lib/Plugins/Python_hash.cpp index ae246b38..36ddacdc 100644 --- a/lib/Plugins/Python_hash.cpp +++ b/lib/Plugins/Python_hash.cpp @@ -14,6 +14,7 @@ */ #include "abrtlib.h" #include "Python_hash.h" +#include <byteswap.h> #if defined(__BIG_ENDIAN__) && __BIG_ENDIAN__ # define MD5_BIG_ENDIAN 1 @@ -28,6 +29,16 @@ # error "Can't determine endianness" #endif +/* SWAP_LEnn means "convert CPU<->little_endian if needed (by swapping bytes)" */ +#if MD5_BIG_ENDIAN +# define SWAP_BE32(x) (x) +# define SWAP_LE32(x) bswap_32(x) +#else +# define SWAP_BE32(x) bswap_32(x) +# define SWAP_LE32(x) (x) +#endif + + /* 0: fastest, 3: smallest */ #define MD5_SIZE_VS_SPEED 3 @@ -123,11 +134,7 @@ static void md5_hash_block(const void *buffer, md5_ctx_t *ctx) uint32_t temp; for (i = 0; i < 16; i++) { -#if MD5_BIG_ENDIAN - cwp[i] = bswap_32(words[i]); -#else - cwp[i] = words[i]; -#endif + cwp[i] = SWAP_LE32(words[i]); } words += 16; diff --git a/scripts/abrt-bz-ratingfixer b/scripts/abrt-bz-ratingfixer index 86f4c0c7..82393329 100755 --- a/scripts/abrt-bz-ratingfixer +++ b/scripts/abrt-bz-ratingfixer @@ -1,6 +1,9 @@ #!/usr/bin/python # -*- mode:python -*- # +# Finds bugs with incomplete backtraces in Buzilla. +# Incomplete backtraces are caused by missing debuginfo. +# # Please do not run this script unless it's neccessary to do so. # It forces Bugzilla to send data related to thousands of bug reports. @@ -10,7 +13,13 @@ import sys import os.path import subprocess import cPickle +import urllib +import json +# +# Parse command line options. +# Exit if mandatory options are missing. +# parser = OptionParser(version="%prog 1.0") parser.add_option("-u", "--user", dest="user", help="Bugzilla user name (REQUIRED)", metavar="USERNAME") @@ -20,7 +29,6 @@ parser.add_option("-b", "--bugzilla", dest="bugzilla", help="Bugzilla URL (defaults to Red Hat Bugzilla)", metavar="URL") parser.add_option("-i", "--wiki", help="Generate output in wiki syntax", action="store_true", default=False, dest="wiki") - (options, args) = parser.parse_args() if not options.user or len(options.user) == 0: @@ -32,16 +40,18 @@ if not options.password or len(options.password) == 0: if not options.bugzilla or len(options.bugzilla) == 0: options.bugzilla = "https://bugzilla.redhat.com/xmlrpc.cgi" +# +# Connect to the Bugzilla and get all bugs reported by ABRT +# bz = RHBugzilla() bz.connect(options.bugzilla) bz.login(options.user, options.password) buginfos = bz.query({'status_whiteboard_type':'allwordssubstr','status_whiteboard':'abrt_hash'}) - print "{0} bugs found.".format(len(buginfos)) # -# Load cache from previous run. Speeds up the case Bugzilla closes connection. +# Load cache from previous run. It speeds up the case Bugzilla closes connection. # The cache should be manually removed after a day or so, because the data in it # are no longer valid. # @@ -58,21 +68,35 @@ def save_to_cache(): cPickle.dump(ids, f, 2) f.close() +# +# Go through all bugs, and get the rating for their backtraces. +# The result is stored into ids map. +# count = 0 for buginfo in buginfos: + # The progress indicator. count += 1 print "{0}/{1}".format(count, len(buginfos)) + + # Save to cache for the case the connection will be closed by the Bugzilla. + # This happens pretty often. if count % 100 == 0: save_to_cache() + # Skip the bugs already loaded from cache. if ids.has_key(buginfo.bug_id): continue + # We handle only unprocessed bugs. if not buginfo.bug_status in ["NEW", "ASSIGNED"]: continue # By default: rating 4, no comments. Do not touch strange bugs. - ids[buginfo.bug_id] = ( 4, 0 ) + ids[buginfo.bug_id] = { + 'rating': 4, + 'comment_count': 0, + 'component': buginfo.component + } # Skip bugs with already downloaded backtraces. filename = "{0}.bt".format(buginfo.bug_id) @@ -94,26 +118,32 @@ for buginfo in buginfos: if not downloaded: continue + # Rate the backtrace using external program. command = ["./abrt-rate-backtrace"] command.append(filename) - helper = subprocess.Popen(command, stdout=subprocess.PIPE) rating, err = helper.communicate() helper.wait() - if helper.returncode != 0: print "Problems with rating {0}".format(filename) continue - + + # Get the comment count. We do not want to close bugs which + # are in the middle of a discussion. bug = bz.getbug(buginfo.bug_id) - comments = 0 + comment_count = 0 for comment in bug.longdescs: # Do not count "rawhide" comments from Bug Zappers if comment["body"].find("against 'rawhide' during") > 0: continue - comments += 1 + comment_count += 1 - ids[buginfo.bug_id] = ( int(rating), comments ) + # Put the result to the database. + ids[buginfo.bug_id] = { + 'rating': int(rating), + 'comment_count': comment_count, + 'component': buginfo.component + } bz.logout() @@ -124,19 +154,31 @@ bugids = ids.keys() bugids.sort() if options.wiki: print "{|" - print " ! Bug !! Backtrace rating !! Comment count" + print " ! Bug !! Backtrace rating !! Comment count !! Component !! Owner" print " |-" for bugid in bugids: - rating = ids[bugid] - if rating[0] < 3: + bug = ids[bugid] + if bug['rating'] < 3: count += 1 - if rating[1] <= 2: + if bug['comment_count'] <= 2: closedcount += 1 + + # Get the component owner + owner = "Failed to get component owner" + try: + component_info = json.load(urllib.urlopen("https://admin.fedoraproject.org/pkgdb/packages/name/{0}?tg_format=json".format(bug['component']))) + component_packages = component_info['packageListings'] + component_f12 = filter(lambda x:x["collection"]["version"]=="12", component_packages) + if len(component_f12) == 1: + owner = component_f12[0]["owner"] + except KeyError: + pass + if options.wiki: - print " | #[https://bugzilla.redhat.com/show_bug.cgi?id={0} {0}] || {1}/4 || {2}".format(bugid, rating[0], rating[1]) + print " | #[https://bugzilla.redhat.com/show_bug.cgi?id={0} {0}] || {1}/4 || {2}".format(bugid, bug['rating'], bug['comment_count'], bug['component'], owner) print " |-" else: - print "#{0} has a backtrace with rating {1}/4 and {2} comments".format(bugid, rating[0], rating[1]) + print "#{0} has a backtrace with rating {1}/4 and {2} comments".format(bugid, bug['rating'], bug['comment_count'], bug['component'], owner) if options.wiki: print " |}" diff --git a/src/Backtrace/abrt-bz-dupchecker b/src/Backtrace/abrt-bz-dupchecker index cb11bf18..d7798acb 100755 --- a/src/Backtrace/abrt-bz-dupchecker +++ b/src/Backtrace/abrt-bz-dupchecker @@ -157,9 +157,6 @@ for buginfo in buginfos: bz.logout() -print "SUMMARY" -print "==========================================================================" - # The number of duplicates. dupcount = 0 # The number of duplicates that can be closed. @@ -172,36 +169,56 @@ for backtrace, components in database.items(): bugitems))), len(bugitems) - 1) -print "Total number of duplicate bugs detected: {0}".format(dupcount) -print "Number of duplicate bugs that will be closed : {0}".format(dupclosecount) -print "------------------------------" - -# Print the duplicates +# Sort the duplicates by the component owner, and +# filter out those which should not be printed. +dups = [] for backtrace, components in database.items(): for component, bugitems in components.items(): if len(bugitems) > 1: # Get the component owner - component_info = json.load(urllib.urlopen("https://admin.fedoraproject.org/pkgdb/packages/name/{0}?tg_format=json".format(buginfo.component))) - component_packages = component_info['packageListings'] - component_f12 = filter(lambda x:x["collection"]["version"]=="12", component_packages) owner = "Failed to get component owner" - if len(component_f12) == 1: - owner = component_f12["owner"] - - if options.wiki: - print "----" - print "* component: '''{0}''' ({1})".format(component, owner) - print "* duplicates: {0}".format( - reduce(lambda x,y: x+", "+y, - map(lambda x: "#[https://bugzilla.redhat.com/show_bug.cgi?id={0} {0}] ({1} comments)".format(x['id'],x['comments']), - bugitems))) - print "* backtrace:" - for line in backtrace.replace("Thread\n", "").splitlines(): - print "*# {0}".format(line) - else: - print "Component: {0} ({1})".format(component, owner) - print "Duplicates: {0}".format( - reduce(lambda x,y: x+", "+y, - map(lambda x: "{0} ({1})".format(x['id'],x['comments']), - bugitems))) - print "Backtrace: {0}".format(backtrace) + try: + component_info = json.load(urllib.urlopen("https://admin.fedoraproject.org/pkgdb/packages/name/{0}?tg_format=json".format(component))) + component_packages = component_info['packageListings'] + component_f12 = filter(lambda x:x["collection"]["version"]=="12", component_packages) + if len(component_f12) == 1: + owner = component_f12[0]["owner"] + except KeyError: + pass + + dups.append((component, owner, bugitems, backtrace)) + print ".", + +print +print "SUMMARY" +print "==========================================================================" +print "Total number of duplicate bugs detected: {0}".format(dupcount) +print "Number of duplicate bugs that will be closed : {0}".format(dupclosecount) +print "------------------------------" + +# Print the duplicates sorted by package owner. +def cmp(x, y): + if x[1] < y[1]: + return -1 + elif x[1] == y[1]: + return 0 + else: + return 1 +for (component, owner, bugitems, backtrace) in sorted(dups, cmp): + if options.wiki: + print "----" + print "* component: '''{0}''' ({1})".format(component, owner) + print "* duplicates: {0}".format( + reduce(lambda x,y: x+", "+y, + map(lambda x: "#[https://bugzilla.redhat.com/show_bug.cgi?id={0} {0}] ({1} comments)".format(x['id'],x['comments']), + bugitems))) + print "* backtrace:" + for line in backtrace.replace("Thread\n", "").splitlines(): + print "*# {0}".format(line) + else: + print "Component: {0} ({1})".format(component, owner) + print "Duplicates: {0}".format( + reduce(lambda x,y: x+", "+y, + map(lambda x: "{0} ({1})".format(x['id'],x['comments']), + bugitems))) + print "Backtrace: {0}".format(backtrace) |