Skip to content

Commit e69d5df

Browse files
ahunter6acmel
authored andcommitted
perf scripts python: exported-sql-viewer.py: Add ability for Call tree to open at a specified task and time
Add ability for Call tree to open at a specified task and time. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lore.kernel.org/lkml/20190821083216.1340-6-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent da4264f commit e69d5df

1 file changed

Lines changed: 43 additions & 1 deletion

File tree

‎tools/perf/scripts/python/exported-sql-viewer.py‎

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ def __init__(self, glb, parent=None):
10941094

10951095
class CallTreeWindow(TreeWindowBase):
10961096

1097-
def __init__(self, glb, parent=None):
1097+
def __init__(self, glb, parent=None, thread_at_time=None):
10981098
super(CallTreeWindow, self).__init__(parent)
10991099

11001100
self.model = LookupCreateModel("Call Tree", lambda x=glb: CallTreeModel(x))
@@ -1112,6 +1112,48 @@ def __init__(self, glb, parent=None):
11121112

11131113
AddSubWindow(glb.mainwindow.mdi_area, self, "Call Tree")
11141114

1115+
if thread_at_time:
1116+
self.DisplayThreadAtTime(*thread_at_time)
1117+
1118+
def DisplayThreadAtTime(self, comm_id, thread_id, time):
1119+
parent = QModelIndex()
1120+
for dbid in (comm_id, thread_id):
1121+
found = False
1122+
n = self.model.rowCount(parent)
1123+
for row in xrange(n):
1124+
child = self.model.index(row, 0, parent)
1125+
if child.internalPointer().dbid == dbid:
1126+
found = True
1127+
self.view.setCurrentIndex(child)
1128+
parent = child
1129+
break
1130+
if not found:
1131+
return
1132+
found = False
1133+
while True:
1134+
n = self.model.rowCount(parent)
1135+
if not n:
1136+
return
1137+
last_child = None
1138+
for row in xrange(n):
1139+
child = self.model.index(row, 0, parent)
1140+
child_call_time = child.internalPointer().call_time
1141+
if child_call_time < time:
1142+
last_child = child
1143+
elif child_call_time == time:
1144+
self.view.setCurrentIndex(child)
1145+
return
1146+
elif child_call_time > time:
1147+
break
1148+
if not last_child:
1149+
if not found:
1150+
child = self.model.index(0, 0, parent)
1151+
self.view.setCurrentIndex(child)
1152+
return
1153+
found = True
1154+
self.view.setCurrentIndex(last_child)
1155+
parent = last_child
1156+
11151157
# Child data item finder
11161158

11171159
class ChildDataItemFinder():

0 commit comments

Comments
 (0)