From 0e6280ae3156e8a2b5e56e7c2d4288a79cde1687 Mon Sep 17 00:00:00 2001 From: Douglas RAILLARD Date: Mon, 4 Nov 2019 17:47:06 +0000 Subject: [PATCH] ftrace: Ensure /proc/kallsyms contains symbol addresses The content of /proc/kallsyms depends on the value of /proc/sys/kernel/kptr_restrict: * If 0, restriction is lifted and kallsyms contains real addresses * If 1, kallsyms will contain null pointers Since trace-cmd records the content of kallsyms into the trace.dat and uses that to pretty-print function names (function tracer/grapher), ensure that its content is available. Signed-off-by: Douglas RAILLARD --- devlib/trace/ftrace.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/devlib/trace/ftrace.py b/devlib/trace/ftrace.py index 980d491..5568243 100644 --- a/devlib/trace/ftrace.py +++ b/devlib/trace/ftrace.py @@ -20,6 +20,7 @@ import time import re import subprocess import sys +import contextlib from pipes import quote from devlib.trace import TraceCollector @@ -226,6 +227,11 @@ class FtraceCollector(TraceCollector): tracer_string = '-p {}'.format(self.tracer) if self.tracer else '' + # Ensure kallsyms contains addresses if possible, so that function the + # collected trace contains enough data for pretty printing + with contextlib.suppress(TargetStableError): + self.target.write_value('/proc/sys/kernel/kptr_restrict', 0) + self.target.write_value(self.trace_clock_file, self.trace_clock, verify=False) try: self.target.write_value(self.save_cmdlines_size_file, self.saved_cmdlines_nr)