summaryrefslogtreecommitdiff
path: root/utilities/ovs-parse-backtrace.in
diff options
context:
space:
mode:
authorEthan Jackson <ethan@nicira.com>2012-10-22 15:42:31 -0700
committerEthan Jackson <ethan@nicira.com>2012-10-25 11:14:07 -0700
commit7d1563e9612e2f99df5da488981b5bc05fb88180 (patch)
tree38d993f1db628ce05db1ef99595589d5cb06612d /utilities/ovs-parse-backtrace.in
parentfdce775cc57314913b663c3efbdce25cdf61591e (diff)
downloadopenvswitch-7d1563e9612e2f99df5da488981b5bc05fb88180.tar.gz
timeval: Coalesce backtraces with counts.
With this patch, `ovs-appctl backtrace` will return a unique list of backtraces and a count of how many times it has been recorded. This work had previously been done by ovs-parse-backtrace. However, in future patches poll-loop will begin logging backtraces as a matter of course. At this point, coalescing the backtraces will help keep these log messages brief. Signed-off-by: Ethan Jackson <ethan@nicira.com>
Diffstat (limited to 'utilities/ovs-parse-backtrace.in')
-rwxr-xr-xutilities/ovs-parse-backtrace.in26
1 files changed, 11 insertions, 15 deletions
diff --git a/utilities/ovs-parse-backtrace.in b/utilities/ovs-parse-backtrace.in
index 4f793beeb..350cbd9f8 100755
--- a/utilities/ovs-parse-backtrace.in
+++ b/utilities/ovs-parse-backtrace.in
@@ -73,23 +73,19 @@ result. Expected usage is for ovs-appctl backtrace to be piped in.""")
print "Binary: %s\n" % binary
stdin = sys.stdin.read()
- trace_list = stdin.strip().split("\n\n")
- try:
- #Remove the first line from each trace.
- trace_list = [trace[(trace.index("\n") + 1):] for trace in trace_list]
- except ValueError:
- sys.stdout.write(stdin)
- sys.exit(1)
-
- trace_map = {}
- for trace in trace_list:
- trace_map[trace] = trace_map.get(trace, 0) + 1
-
- sorted_traces = sorted(trace_map.items(), key=(lambda x: x[1]),
- reverse=True)
- for trace, count in sorted_traces:
+ traces = []
+ for trace in stdin.strip().split("\n\n"):
lines = trace.splitlines()
+ match = re.search(r'Count (\d+)', lines[0])
+ if match:
+ count = int(match.group(1))
+ else:
+ count = 0
+ traces.append((lines[1:], count))
+ traces = sorted(traces, key=(lambda x: x[1]), reverse=True)
+
+ for lines, count in traces:
longest = max(len(l) for l in lines)
print "Backtrace Count: %d" % count