diff options
author | Brendan Jackman <brendan.jackman@arm.com> | 2017-05-03 12:45:43 +0100 |
---|---|---|
committer | Javi Merino <merino.jav@gmail.com> | 2017-05-13 14:44:27 +0100 |
commit | b1b1c9ec6deb6cb879c683f7ddaebb98d2f016ac (patch) | |
tree | c493910dd12e97c6a3b23913ab12950e302226d3 /trappy | |
parent | 3e3ba734d077b116ecf912a51d3428ca6e8ae329 (diff) | |
download | trappy-b1b1c9ec6deb6cb879c683f7ddaebb98d2f016ac.tar.gz |
ftrace: Improve error messages when failing to parse trace
Diffstat (limited to 'trappy')
-rw-r--r-- | trappy/ftrace.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/trappy/ftrace.py b/trappy/ftrace.py index 6a5fce0..dd0a2fc 100644 --- a/trappy/ftrace.py +++ b/trappy/ftrace.py @@ -25,6 +25,9 @@ import pandas as pd from trappy.bare_trace import BareTrace from trappy.utils import listify +class FTraceParseError(Exception): + pass + def _plot_freq_hists(allfreqs, what, axis, title): """Helper function for plot_freq_hists @@ -181,11 +184,13 @@ subclassed by FTrace (for parsing FTrace coming from trace-cmd) and SysTrace.""" trace_class = cls break else: - raise ValueError("No unique in {}".format(line)) + raise FTraceParseError("No unique word in '{}'".format(line)) line = line[:-1] special_fields_match = special_fields_regexp.match(line) + if not special_fields_match: + raise FTraceParseError("Couldn't match special fields in '{}'".format(line)) comm = special_fields_match.group('comm') pid = int(special_fields_match.group('pid')) cpu = int(special_fields_match.group('cpu')) @@ -262,8 +267,13 @@ is part of the trace. if len(cls_for_unique_word) == 0: return - with open(trace_file) as fin: - self.__populate_data(fin, cls_for_unique_word, window, abs_window) + try: + with open(trace_file) as fin: + self.__populate_data( + fin, cls_for_unique_word, window, abs_window) + except FTraceParseError as e: + raise ValueError('Failed to parse ftrace file {}:\n{}'.format( + trace_file, str(e))) # TODO: Move thermal specific functionality |