Skip to contentSkip to conversation

perf: add support for logging debug messages to file

PATCH In review Changbin Du 2 participants 5 messages Nov 26, 2019 – Nov 28, 2019 perf events

lore
Share & tools
lore
#0 lore raw

v7 cover perf: add support for logging debug messages to file

When in TUI mode, it is impossible to show all the debug messages to console. This make it hard to debug perf issues using debug messages. This patch adds support for logging debug messages to file to resolve this problem.

v7:
o fix a mistake.
v6:
o rebase to perf/core.
v5:
o doc default log path.
v4:
o fix another segfault.
v3:
o fix a segfault issue.
v2:
o specific all debug options one time.

Changbin Du (2):
perf: support multiple debug options separated by ','
perf: add support for logging debug messages to file

 tools/perf/Documentation/perf.txt |  24 +++---
 tools/perf/util/debug.c           | 127 ++++++++++++++++++++----------
 2 files changed, 98 insertions(+), 53 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH v7 1/2 perf: support multiple debug options separated by ','

This patch adds support for multiple debug options separated by ',' and non-int values.
--debug verbose=2,stderr

---
 tools/perf/Documentation/perf.txt | 18 +++----
 tools/perf/util/debug.c           | 89 ++++++++++++++++---------------
 2 files changed, 56 insertions(+), 51 deletions(-)
tools/perf/Documentation/perf.txt +9 -9
index 3f37ded13f8c..dcf9d98065f2 100644
@@ -13,19 +13,19 @@ SYNOPSIS
 OPTIONS
 -------
 --debug::
-	Setup debug variable (see list below) in value
-	range (0, 10). Use like:
+	Setup debug variable (see list below). The range of 'level' value
+	is (0, 10). Use like:
 	  --debug verbose   # sets verbose = 1
 	  --debug verbose=2 # sets verbose = 2
 
 	List of debug variables allowed to set:
-	  verbose          - general debug messages
-	  ordered-events   - ordered events object debug messages
-	  data-convert     - data convert command debug messages
-	  stderr           - write debug output (option -v) to stderr
-	                     in browser mode
-	  perf-event-open  - Print perf_event_open() arguments and
-			     return value
+	  verbose[=level]	- general debug messages
+	  ordered-events[=level]- ordered events object debug messages
+	  data-convert[=level]	- data convert command debug messages
+	  stderr		- write debug output (option -v) to stderr
+	                          in browser mode
+	  perf-event-open	- Print perf_event_open() arguments and
+	                          return value
 
 --buildid-dir::
 	Setup buildid cache directory. It has higher priority than
tools/perf/util/debug.c +47 -42

116 lines not on this page · raw message

Signature · 1 line
2.20.1
#2 lore raw

PATCH v7 2/2 perf: add support for logging debug messages to file

In reply to Changbin Du

When in TUI mode, it is impossible to show all the debug messages to console. This make it hard to debug perf issues using debug messages. This patch adds support for logging debug messages to file to resolve this problem.

The usage is:
perf -debug verbose=2,file=~/perf.log COMMAND

---
v5: doc default log path.
v4: fix another segfault.
v3: fix a segfault issue.

---
 tools/perf/Documentation/perf.txt |  6 ++++-
 tools/perf/util/debug.c           | 44 ++++++++++++++++++++++++++++---
 2 files changed, 45 insertions(+), 5 deletions(-)
tools/perf/Documentation/perf.txt +5 -1
index dcf9d98065f2..52c6ba825552 100644
@@ -16,7 +16,8 @@ OPTIONS
 	Setup debug variable (see list below). The range of 'level' value
 	is (0, 10). Use like:
 	  --debug verbose   # sets verbose = 1
-	  --debug verbose=2 # sets verbose = 2
+	  --debug verbose=2,file=~/perf.log
+	                    # sets verbose = 2 and save log to file
 
 	List of debug variables allowed to set:
 	  verbose[=level]	- general debug messages
@@ -26,6 +27,9 @@ OPTIONS
 	                          in browser mode
 	  perf-event-open	- Print perf_event_open() arguments and
 	                          return value
+	  file[=path]           - write debug output to log file, default
+	                          'perf.log' (stderr and file options are
+	                          exclusive)
 
 --buildid-dir::
 	Setup buildid cache directory. It has higher priority than
tools/perf/util/debug.c +40 -4

77 lines not on this page · raw message

Signature · 1 line
2.20.1
#3 lore raw
In reply to Changbin Du
Quoted 4 lines · Changbin Du

When in TUI mode, it is impossible to show all the debug messages to console. This make it hard to debug perf issues using debug messages. This patch adds support for logging debug messages to file to resolve this problem.

This was already solved in

commit f78eaef0e0493f6068777a246b9c4d9d5cf2b7aa

Author: Andi Kleen <[email protected]>
Date:   Fri Nov 21 13:38:00 2014 -0800

perf tools: Allow to force redirect pr_debug to stderr.

When debugging the tui browser I find it useful to redirect the debug
log into a file. Currently it's always forced to the message
line.

Add an option to force it to stderr. Then it can be easily redirected.

You can do

perf report --debug stderr 2> file ...

-Andi

#4 lore raw
Quoted 20 lines · Andi Kleen
Quoted 4 lines · Changbin Du

When in TUI mode, it is impossible to show all the debug messages to console. This make it hard to debug perf issues using debug messages. This patch adds support for logging debug messages to file to resolve this problem.

This was already solved in

commit f78eaef0e0493f6068777a246b9c4d9d5cf2b7aa

Author: Andi Kleen <[email protected]>
Date:   Fri Nov 21 13:38:00 2014 -0800

perf tools: Allow to force redirect pr_debug to stderr.

When debugging the tui browser I find it useful to redirect the debug
log into a file. Currently it's always forced to the message
line.

Quoted 7 lines

Add an option to force it to stderr. Then it can be easily redirected.

You can do

perf report --debug stderr 2> file ...

Yes, this is a good alternate approach with existing code. I still think a new option 'file' is not bad. And later maybe we can ouput debug messages to file only while errors ouput to both.

Quoted 1 line

-Andi

Signature · 2 lines
Cheers,
Changbin Du