Skip to contentSkip to conversation

perf: Move debug initialization earlier

PATCH In review Ian Rogers 2 participants 3 messages May 19, 2021 – May 27, 2021 perf events

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH 1/1 perf: Move debug initialization earlier

This avoids segfaults during option handlers that use pr_err. For example, "perf --debug nopager list" segfaults before this change.

Fixes 8abceacff87d (perf debug: Add debug_set_file function)
---
 tools/perf/perf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/perf.c +2 -2
index 20cb91ef06ff..2f6b67189b42 100644
@@ -443,6 +443,8 @@ int main(int argc, const char **argv)
 	const char *cmd;
 	char sbuf[STRERR_BUFSIZE];
 
+	perf_debug_setup();
+
 	/* libsubcmd init */
 	exec_cmd_init("perf", PREFIX, PERF_EXEC_PATH, EXEC_PATH_ENVIRONMENT);
 	pager_init(PERF_PAGER_ENVIRONMENT);
@@ -531,8 +533,6 @@ int main(int argc, const char **argv)
 	 */
 	pthread__block_sigwinch();
 
-	perf_debug_setup();
-
 	while (1) {
 		static int done_help;
 
Signature · 1 line
2.31.1.751.gd2f1c929bd-goog
author reviewer
#1 lore raw
Quoted 6 lines · Ian Rogers

This avoids segfaults during option handlers that use pr_err. For example, "perf --debug nopager list" segfaults before this change.

Fixes 8abceacff87d (perf debug: Add debug_set_file function)

Ping.

Thanks!
Ian

Quoted 29 lines
---
 tools/perf/perf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/perf.c +2 -3
index 20cb91ef06ff..2f6b67189b42 100644
@@ -443,6 +443,8 @@ int main(int argc, const char **argv)
        const char *cmd;
        char sbuf[STRERR_BUFSIZE];
 
+       perf_debug_setup();
+
        /* libsubcmd init */
        exec_cmd_init("perf", PREFIX, PERF_EXEC_PATH, EXEC_PATH_ENVIRONMENT);
        pager_init(PERF_PAGER_ENVIRONMENT);
@@ -531,8 +533,6 @@ int main(int argc, const char **argv)
         */
        pthread__block_sigwinch();
 
-       perf_debug_setup();
-
        while (1) {
                static int done_help;
 
--

2.31.1.751.gd2f1c929bd-goog

#2 lore raw

Em Thu, May 27, 2021 at 08:51:41AM -0700, Ian Rogers escreveu:

Quoted 9 lines · Ian Rogers
Quoted 6 lines

This avoids segfaults during option handlers that use pr_err. For example, "perf --debug nopager list" segfaults before this change.

Fixes 8abceacff87d (perf debug: Add debug_set_file function)

Ping.

I thought I had this one in, its now, will go to Linus probably tomorrow,

- Arnaldo

Quoted 32 lines

Thanks!
Ian

Quoted 29 lines
---
 tools/perf/perf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/perf.c +2 -3
index 20cb91ef06ff..2f6b67189b42 100644
@@ -443,6 +443,8 @@ int main(int argc, const char **argv)
        const char *cmd;
        char sbuf[STRERR_BUFSIZE];
 
+       perf_debug_setup();
+
        /* libsubcmd init */
        exec_cmd_init("perf", PREFIX, PERF_EXEC_PATH, EXEC_PATH_ENVIRONMENT);
        pager_init(PERF_PAGER_ENVIRONMENT);
@@ -531,8 +533,6 @@ int main(int argc, const char **argv)
         */
        pthread__block_sigwinch();
 
-       perf_debug_setup();
-
        while (1) {
                static int done_help;
 
--

2.31.1.751.gd2f1c929bd-goog

Signature · 1 line
- Arnaldo