Skip to content
Snippets Groups Projects
Commit f59a8a12 authored by Tomasz Grabiec's avatar Tomasz Grabiec Committed by Pekka Enberg
Browse files

trace: strip leading unimportant frames from backtrace


First couple of frames always come from trace logging functions. I
think we should not show them because they do not add any information.

There was already a list of function names which should be filtered
out. This is not appropriate in this case because tracing goes through
a function named 'log' which is a pretty generic name and could as
well be an application symbol, so we cannot just filter out all
functions named 'log. This patch adds support for knocking off a
leading sequence of frames form the backtrace which is more accurate
and seems good enough.

Reviewed-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: default avatarTomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent ada97980
No related branches found
No related tags found
No related merge requests found
...@@ -63,15 +63,17 @@ def format_time(time, format="%.2f %s"): ...@@ -63,15 +63,17 @@ def format_time(time, format="%.2f %s"):
return str(time) return str(time)
unimportant_functions = set([ unimportant_functions = set([
'trace_slow_path',
'operator()', 'operator()',
'std::function<void ()>::operator()() const', 'std::function<void ()>::operator()() const',
'tracepoint_base::do_log_backtrace',
'tracepoint_base::log_backtrace(trace_record*, unsigned char*&)',
'tracepoint_base::do_log_backtrace(trace_record*, unsigned char*&)',
'_M_invoke', '_M_invoke',
]) ])
unimportant_prefixes = [
('tracepoint_base::log_backtrace(trace_record*, unsigned char*&)',
'log',
'trace_slow_path'),
]
bottom_of_stack = set(['thread_main', 'thread_main_c']) bottom_of_stack = set(['thread_main', 'thread_main_c'])
def strip_garbage(backtrace): def strip_garbage(backtrace):
...@@ -80,6 +82,12 @@ def strip_garbage(backtrace): ...@@ -80,6 +82,12 @@ def strip_garbage(backtrace):
return True return True
return not src_addr.name in unimportant_functions return not src_addr.name in unimportant_functions
for chain in unimportant_prefixes:
if len(backtrace) >= len(chain) and \
tuple(map(attrgetter('name'), backtrace[:len(chain)])) == chain:
backtrace = backtrace[len(chain):]
break
backtrace = list(filter(is_good, backtrace)) backtrace = list(filter(is_good, backtrace))
for i, src_addr in enumerate(backtrace): for i, src_addr in enumerate(backtrace):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment