Add ability for Call tree to open at a specified task and time.
Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all
Unified · Split
| @@ -1094,7 +1094,7 @@ class CallGraphWindow(TreeWindowBase): · 1093 unmodified lines | ||
| 1094 | 1094 | |
| 1095 | 1095 | class CallTreeWindow(TreeWindowBase): |
| 1096 | 1096 | |
| 1097 | − def __init__(self, glb, parent=None): | |
| 1097 | + def __init__(self, glb, parent=None, thread_at_time=None): | |
| 1098 | 1098 | super(CallTreeWindow, self).__init__(parent) |
| 1099 | 1099 | |
| 1100 | 1100 | self.model = LookupCreateModel("Call Tree", lambda x=glb: CallTreeModel(x)) |
| @@ -1112,6 +1112,48 @@ class CallTreeWindow(TreeWindowBase): · 11 unmodified lines | ||
| 1112 | 1112 | |
| 1113 | 1113 | AddSubWindow(glb.mainwindow.mdi_area, self, "Call Tree") |
| 1114 | 1114 | |
| 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 | + | |
| 1115 | 1157 | # Child data item finder |
| 1116 | 1158 | |
| 1117 | 1159 | class ChildDataItemFinder(): |