Commit 9489b66e authored by Ell's avatar Ell
Browse files

tools: a few improvements in performance-log-viewer.py

In sample-search predicates, remove the "exclusive" parameter of
the "function()" function, and replace it with optional "id" and
"state" parameters, which limit the match to the call-stacks of
matching threads, as per the "thread()" function.

Sort the backtrace thread-list by thread ID.

(cherry picked from commit 0b2d4163)
parent 3fdb5b32
...@@ -726,23 +726,22 @@ class FindSamplesPopover (Gtk.Popover): ...@@ -726,23 +726,22 @@ class FindSamplesPopover (Gtk.Popover):
for i in range (len (samples)): for i in range (len (samples)):
try: try:
def thread (id, state = None): def match_thread (thread, id, state = None):
for thread in samples[i].backtrace or []: return (type (id) == int and \
if (type (id) == int and id == thread.id) or \ id == thread.id) or \
(type (id) == str and thread.name and \ (type (id) == str and \
re.fullmatch (id, thread.name)): thread.name and \
if state is None or \ re.fullmatch (id, thread.name)) and \
re.fullmatch (state, str (thread.state)): (state is None or \
return True re.fullmatch (state, str (thread.state)))
return False def thread (id, state = None):
return any (match_thread (thread, id, state)
for thread in samples[i].backtrace or [])
def function (name, exclusive = False): def function (name, id = None, state = None):
for thread in samples[i].backtrace or []: for thread in samples[i].backtrace or []:
if exclusive: if match_thread (thread, id, state):
if re.fullmatch (name, thread.frames[0].info.name):
return True
else:
for frame in thread.frames: for frame in thread.frames:
if re.fullmatch (name, frame.info.name): if re.fullmatch (name, frame.info.name):
return True return True
...@@ -1887,6 +1886,7 @@ class BacktraceViewer (Gtk.Box): ...@@ -1887,6 +1886,7 @@ class BacktraceViewer (Gtk.Box):
store = self.ThreadStore () store = self.ThreadStore ()
self.thread_store = store self.thread_store = store
store.set_sort_column_id (store.ID, Gtk.SortType.ASCENDING)
tree = Gtk.TreeView (model = store) tree = Gtk.TreeView (model = store)
self.thread_tree = tree self.thread_tree = tree
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment