diff --git a/lisa/analysis/tasks.py b/lisa/analysis/tasks.py index 5033aa24c00d4c72b07609ba427d96b014ec4e8d..7ce3aeed1aadecd2fb97506f4ef06405cee5fcaa 100644 --- a/lisa/analysis/tasks.py +++ b/lisa/analysis/tasks.py @@ -1144,30 +1144,34 @@ class TasksAnalysis(TraceAnalysisBase): df['active'] *= df['duty_cycle'] data = make_rect_df(df[df['active'] != 0]) - name_df = self.trace.df_event('sched_switch') - name_df = name_df[name_df['next_pid'] == task.pid] - names = name_df['next_comm'].reindex(data.index, method='ffill') - - # If there was no sched_switch with next_pid matching task.pid, we - # simply take the last known name of the task, which could - # originate from another field or another event. - # - # Note: This prevents an value, which makes bokeh choke. - last_comm = self.trace.get_task_pid_names(task.pid)[-1] - if last_comm not in names.cat.categories: - names = names.cat.add_categories([last_comm]) - names = names.fillna(last_comm) - - # Use a string for PID so that holoviews interprets it as - # categorical variable, rather than continuous. This is important - # for correct color mapping - data['pid'] = str(task.pid) - data['comm'] = names - data['start'] = data.index - data['cpu'] = df['cpu'] - data['duration'] = df['duration'] - data['duty_cycle'] = df['duty_cycle'] - return data + if data.empty: + return data + else: + name_df = self.trace.df_event('sched_switch') + name_df = name_df[name_df['next_pid'] == task.pid] + names = name_df['next_comm'].reindex(data.index, method='ffill') + + # If there was no sched_switch with next_pid matching task.pid, we + # simply take the last known name of the task, which could + # originate from another field or another event. + # + # Note: This prevent an value, which makes bokeh choke. + last_comm = self.trace.get_task_pid_names(task.pid)[-1] + + if last_comm not in names.cat.categories: + names = names.cat.add_categories([last_comm]) + names = names.fillna(last_comm) + + # Use a string for PID so that holoviews interprets it as + # categorical variable, rather than continuous. This is important + # for correct color mapping + data['pid'] = str(task.pid) + data['comm'] = names + data['start'] = data.index + data['cpu'] = df['cpu'] + data['duration'] = df['duration'] + data['duty_cycle'] = df['duty_cycle'] + return data def plot_rect(data): if show_legend: