perf tools: A couple of TUI improvements
Namhyung Kim
maintainercover perf tools: A couple of TUI improvements
Hello,
I was playing with TUI code and added two new windows. One for showing log messages and another for showing header information. (Maybe they can be implemented on the GTK code too someday.)
Please try to use it! :)
I put the patches on 'perf/tui-v1' branch in my tree:
git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
Any feedbacks are more than welcome, thanks
Namhyung
Namhyung Kim (6):
perf report: Use pr_*() functions if possible
perf tools: Introduce struct perf_log
perf tools: Get rid of a duplicate va_end()
perf tools: Save message when pr_*() was called
perf ui/tui: Implement log window
perf ui/tui: Implement header window
tools/perf/Makefile.perf | 3 ++ tools/perf/builtin-report.c | 24 +++++---- tools/perf/perf.c | 3 ++ tools/perf/ui/browser.h | 3 ++ tools/perf/ui/browsers/header.c | 116 ++++++++++++++++++++++++++++++++++++++++ tools/perf/ui/browsers/hists.c | 8 +++ tools/perf/ui/browsers/log.c | 92 +++++++++++++++++++++++++++++++ tools/perf/util/debug.c | 7 ++- tools/perf/util/debug.h | 15 ++++++ tools/perf/util/log.c | 105 ++++++++++++++++++++++++++++++++++++ 10 files changed, 364 insertions(+), 12 deletions(-) create mode 100644 tools/perf/ui/browsers/header.c create mode 100644 tools/perf/ui/browsers/log.c create mode 100644 tools/perf/util/log.c
Signature · 1 line
1.7.11.7
Namhyung Kim
maintainerPATCH 1/6 perf report: Use pr_*() functions if possible
From: Namhyung Kim <[email protected]>
There're some places printing a message to stdout/err directly. It should be converted to use proper error printing functions instead.
If it's not possible, just do it when --stdio was enabled only.
--- tools/perf/builtin-report.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
tools/perf/builtin-report.c +13 -11
@@ -321,8 +321,8 @@ static int process_sample_event(struct perf_tool *tool,int ret;if (perf_event__preprocess_sample (event, machine, &al, sample) <0 ) { -fprintf (stderr,"problem processing %d event, skipping it.\n" , - event->header.type); +pr_debug ("problem processing %d event, skipping it.\n" , + event->header.type);return -1 ; }
@@ -552,15 +552,17 @@ static int __cmd_report(struct perf_report *rep) desc); } -if (verbose >3 ) -perf_session__fprintf (session, stdout); +if (use_browser ==0 ) { +if (verbose >3 ) +perf_session__fprintf (session, stdout); -if (verbose >2 ) -perf_session__fprintf_dsos (session, stdout); +if (verbose >2 ) +perf_session__fprintf_dsos (session, stdout); -if (dump_trace) { -perf_session__fprintf_nr_events (session, stdout); -return 0 ; +if (dump_trace) { +perf_session__fprintf_nr_events (session, stdout); +return 0 ; + } } nr_samples =0 ;
@@ -720,7 +722,7 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset)return -1 ; setup:if (callchain_register_param (&callchain_param) <0 ) { -fprintf (stderr,"Can't register callchain params\n" ); +pr_err ("Can't register callchain params\n" );return -1 ; }return 0 ;
@@ -942,7 +944,7 @@ repeat: }if (report.mem_mode) {if (sort__mode ==SORT_MODE__BRANCH ) { -fprintf (stderr,"branch and mem mode incompatible\n" ); +pr_err ("branch and mem mode incompatible\n" ); goto error; } sort__mode =SORT_MODE__MEMORY ;
Signature · 1 line
1.7.11.7
Re: [PATCH 1/6] perf report: Use pr_*() functions if possible
Em Thu, Dec 19, 2013 at 04:00:06PM +0900, Namhyung Kim escreveu:
Quoted 40 lines
From: Namhyung Kim <[email protected]>
There're some places printing a message to stdout/err directly. It should be converted to use proper error printing functions instead.
If it's not possible, just do it when --stdio was enabled only.
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/builtin-report.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)tools/perf/builtin-report.c +6
-6@@ -321,8 +321,8 @@ static int process_sample_event(struct perf_tool *tool,int ret;if (perf_event__preprocess_sample (event, machine, &al, sample) <0 ) { -fprintf (stderr,"problem processing %d event, skipping it.\n" , - event->header.type); +pr_debug ("problem processing %d event, skipping it.\n" , + event->header.type);return -1 ; }@@ -552,15 +552,17 @@ static int __cmd_report(struct perf_report *rep) desc); } -if (verbose >3 ) -perf_session__fprintf (session, stdout); +if (use_browser ==0 ) { +if (verbose >3 ) +perf_session__fprintf (session, stdout); -if (verbose >2 ) -perf_session__fprintf_dsos (session, stdout); +if (verbose >2 )
tools/perf/builtin-report.c static int __cmd_report(struct perf_report *rep) · line 566
Quoted 10 lines
tools/perf/builtin-report.c +5
-3+perf_session__fprintf_dsos (session, stdout); -if (dump_trace) { -perf_session__fprintf_nr_events (session, stdout); -return 0 ; +if (dump_trace) { +perf_session__fprintf_nr_events (session, stdout); +return 0 ; + } }
This should be in a different patch, one that is related just to dump_trace, i.e. if -D, aka dump_trace (right?) is enabled, then probably we won't be initializing the TUI/GUI, no?
So having a patch that deals just with conversions of fprintf -> pr_{err,etc} and another that deals with dump_trace related seems to be the best course of action.
- Arnaldo
Quoted 21 lines
tools/perf/builtin-report.c +2
-2nr_samples =0 ;@@ -720,7 +722,7 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset)return -1 ; setup:if (callchain_register_param (&callchain_param) <0 ) { -fprintf (stderr,"Can't register callchain params\n" ); +pr_err ("Can't register callchain params\n" );return -1 ; }return 0 ;@@ -942,7 +944,7 @@ repeat: }if (report.mem_mode) {if (sort__mode ==SORT_MODE__BRANCH ) { -fprintf (stderr,"branch and mem mode incompatible\n" ); +pr_err ("branch and mem mode incompatible\n" ); goto error; } sort__mode =SORT_MODE__MEMORY ;Signature · 1 line
1.7.11.7
Namhyung Kim
maintainerRe: [PATCH 1/6] perf report: Use pr_*() functions if possible
Quoted 12 lines · Arnaldo Carvalho de Melo
Em Thu, Dec 19, 2013 at 04:00:06PM +0900, Namhyung Kim escreveu:
Quoted 11 lines
tools/perf/builtin-report.c +5
-4-if (verbose >3 ) -perf_session__fprintf (session, stdout); +if (use_browser ==0 ) { +if (verbose >3 ) +perf_session__fprintf (session, stdout); -if (verbose >2 ) -perf_session__fprintf_dsos (session, stdout); +if (verbose >2 ) +perf_session__fprintf_dsos (session, stdout);
Quoted 12 lines
tools/perf/builtin-report.c static int __cmd_report(struct perf_report *rep) · line 566
Quoted 8 lines
tools/perf/builtin-report.c +4
-3-if (dump_trace) { -perf_session__fprintf_nr_events (session, stdout); -return 0 ; +if (dump_trace) { +perf_session__fprintf_nr_events (session, stdout); +return 0 ; + } }This should be in a different patch, one that is related just to
dump_trace, i.e. if -D, akadump_trace(right?) is enabled, then probably we won't be initializing the TUI/GUI, no?
Yes, the dump_trace will make use_browser = 0. So I just moved it under the if (use_browser == 0).
Quoted 4 lines
So having a patch that deals just with conversions of fprintf -> pr_{err,etc} and another that deals with
dump_tracerelated seems to be the best course of action.
Okay, I'll split this into two.
Thanks,
Namhyung
Re: [PATCH 1/6] perf report: Use pr_*() functions if possible
In reply to Namhyung KimQuoted 8 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
There're some places printing a message to stdout/err directly. It should be converted to use proper error printing functions instead.
If it's not possible, just do it when --stdio was enabled only.
Signed-off-by Namhyung Kim <[email protected]>
Maybe it'd be worthwhile to factor perf_session__fprintf* functions so the info could end up in the log window.
jirka
Namhyung Kim
maintainerRe: [PATCH 1/6] perf report: Use pr_*() functions if possible
Hi Jiri,
Quoted 6 lines · Jiri Olsa
Quoted 5 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
There're some places printing a message to stdout/err directly. It should be converted to use proper error printing functions instead.
Quoted 6 lines
Quoted 3 lines
If it's not possible, just do it when --stdio was enabled only.
Signed-off-by Namhyung Kim <[email protected]>Maybe it'd be worthwhile to factor perf_session__fprintf* functions so the info could end up in the log window.
I thought about it too. And then considered something like below:
FILE *sfp = open_memstream(&ptr, &size); perf_session__fprintf*(session, sfp, ...); fclose(sfp); perf_log_add(ptr); fprintf(orig_fp, "%s", ptr); free(ptr);
What do you think?
Quoted 2 lines
Acked-by Jiri Olsa <[email protected]>
Thanks!
Namhyung
Namhyung Kim
maintainerPATCH 2/6 perf tools: Introduce struct perf_log
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
Add new functions to save error messages in a temp file. It'll be used by some UI front-ends to see the messages.
--- tools/perf/Makefile.perf | 1 + tools/perf/perf.c | 3 ++ tools/perf/util/debug.h | 15 +++++++ tools/perf/util/log.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 tools/perf/util/log.c
tools/perf/Makefile.perf +1 -0
@@ -372,6 +372,7 @@ LIB_OBJS += $(OUTPUT)util/stat.o LIB_OBJS += $(OUTPUT)util/record.o LIB_OBJS += $(OUTPUT)util/srcline.o LIB_OBJS += $(OUTPUT)util/data.o +LIB_OBJS += $(OUTPUT)util/log.o LIB_OBJS += $(OUTPUT)ui/setup.o LIB_OBJS += $(OUTPUT)ui/helpline.o
tools/perf/perf.c +3 -0
@@ -10,6 +10,7 @@#include "util/exec_cmd.h" #include "util/cache.h" +#include "util/debug.h" #include "util/quote.h" #include "util/run-command.h" #include "util/parse-events.h"
@@ -524,6 +525,7 @@ int main(int argc, const char **argv)*/ pthread__block_sigwinch (); +perf_log_init ();while (1 ) {static int done_help;int was_alias =run_argv (&argc, &argv);
@@ -543,6 +545,7 @@ int main(int argc, const char **argv) }else break ; } +perf_log_exit ();fprintf (stderr,"Failed to run command '%s': %s\n" , cmd,strerror (errno));
tools/perf/util/debug.h +15 -0
@@ -19,4 +19,19 @@ int ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2)));void pr_stat (const char *fmt, ...); +struct perf_log { +FILE *fp; +off_t *linemap; +u32 lines; +u32 nr_alloc; +bool seen_newline; +}; + +extern struct perf_log perf_log; + +int perf_log_init (void ); +int perf_log_exit (void ); +void perf_log_add (const char *msg); +void perf_log_addv (const char *fmt,va_list ap); +#endif /* __PERF_DEBUG_H */
tools/perf/util/log.c new file +105 -0
105 lines not on this page · raw message
Signature · 1 line
1.7.11.7
Re: [PATCH 2/6] perf tools: Introduce struct perf_log
Em Thu, Dec 19, 2013 at 04:00:07PM +0900, Namhyung Kim escreveu:
Quoted 4 lines
From: Namhyung Kim <[email protected]>
Add new functions to save error messages in a temp file. It'll be used by some UI front-ends to see the messages.
Do we really have to grow a logging facility like this? Can't we somehow openlog/syslog/closelog? Just a first gut reaction, continuing to read the series...
- Arnaldo
Quoted 186 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/Makefile.perf | 1 + tools/perf/perf.c | 3 ++ tools/perf/util/debug.h | 15 +++++++ tools/perf/util/log.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 tools/perf/util/log.ctools/perf/Makefile.perf +1
-0@@ -372,6 +372,7 @@ LIB_OBJS += $(OUTPUT)util/stat.o LIB_OBJS += $(OUTPUT)util/record.o LIB_OBJS += $(OUTPUT)util/srcline.o LIB_OBJS += $(OUTPUT)util/data.o +LIB_OBJS += $(OUTPUT)util/log.o LIB_OBJS += $(OUTPUT)ui/setup.o LIB_OBJS += $(OUTPUT)ui/helpline.otools/perf/perf.c +3
-0@@ -10,6 +10,7 @@#include "util/exec_cmd.h" #include "util/cache.h" +#include "util/debug.h" #include "util/quote.h" #include "util/run-command.h" #include "util/parse-events.h" @@ -524,6 +525,7 @@ int main(int argc, const char **argv)*/ pthread__block_sigwinch (); +perf_log_init ();while (1 ) {static int done_help;int was_alias =run_argv (&argc, &argv);@@ -543,6 +545,7 @@ int main(int argc, const char **argv) }else break ; } +perf_log_exit ();fprintf (stderr,"Failed to run command '%s': %s\n" , cmd,strerror (errno));tools/perf/util/debug.h +15
-0@@ -19,4 +19,19 @@ int ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2)));void pr_stat (const char *fmt, ...); +struct perf_log { +FILE *fp; +off_t *linemap; +u32 lines; +u32 nr_alloc; +bool seen_newline; +}; + +extern struct perf_log perf_log; + +int perf_log_init (void ); +int perf_log_exit (void ); +void perf_log_add (const char *msg); +void perf_log_addv (const char *fmt,va_list ap); +#endif /* __PERF_DEBUG_H */ tools/perf/util/log.c new file +105
-0@@ -0,0 +1,105 @@ +#include <stdio.h> +#include <stdlib.h> +#include "util/debug.h" + +#define LINEMAP_GROW 128 + +struct perf_log perf_log = { + .seen_newline = true, +}; + +int perf_log_init (void ) +{ +FILE *fp; +char name[] ="/tmp/perf-tui-log-XXXXXX" ; +int fd =mkstemp (name); + +if (fd <0 ) +return -1 ; + + fp =fdopen (fd,"r+" ); +if (fp ==NULL ) { +close (fd); +return -1 ; + } + + perf_log.fp = fp; + +return 0 ; +} + +int perf_log_exit (void ) +{ +FILE *fp = perf_log.fp; +if (fp) +fclose (fp); + +free (perf_log.linemap); + + perf_log.fp =NULL ; + perf_log.linemap =NULL ; +return 0 ; +} + +static int grow_linemap (struct perf_log *log) +{ +off_t *newmap; +int newsize = log->nr_alloc +LINEMAP_GROW ; + + newmap =realloc (log->linemap, newsize *sizeof (*log->linemap)); +if (newmap ==NULL ) +return -1 ; + + log->nr_alloc = newsize; + log->linemap = newmap; +return 0 ; +} + +static int __add_to_linemap (struct perf_log *log,off_t index) +{ +if (log->lines == log->nr_alloc) +if (grow_linemap (log) <0 ) +return -1 ; + + log->linemap[log->lines++] = index; +return 0 ; +} + +static void add_to_linemap (struct perf_log *log,const char *msg,off_t base) +{ +const char *pos; + +if (strlen (msg) ==0 ) +return ; + +if (log->seen_newline) { +if (__add_to_linemap (log, base) <0 ) +return ; + } + +if ((pos =strchr (msg,'\n' )) !=NULL ) { + log->seen_newline = true; + pos++; +add_to_linemap (log, pos, base + (pos - msg)); + }else { + log->seen_newline = false; + } +} + +void perf_log_add (const char *msg) +{ +FILE *fp = perf_log.fp; +off_t offset =ftello (fp); + +add_to_linemap (&perf_log, msg, offset); + +fwrite (msg,1 ,strlen (msg), fp); +} + +void perf_log_addv (const char *fmt,va_list ap) +{ +char buf[4096 ]; + +vsnprintf (buf,sizeof (buf), fmt, ap); +perf_log_add (buf); +}Signature · 1 line
1.7.11.7
Namhyung Kim
maintainerRe: [PATCH 2/6] perf tools: Introduce struct perf_log
Hi Arnaldo,
Quoted 9 lines · Arnaldo Carvalho de Melo
Em Thu, Dec 19, 2013 at 04:00:07PM +0900, Namhyung Kim escreveu:
Quoted 4 lines
From: Namhyung Kim <[email protected]>
Add new functions to save error messages in a temp file. It'll be used by some UI front-ends to see the messages.
Do we really have to grow a logging facility like this? Can't we somehow openlog/syslog/closelog? Just a first gut reaction, continuing to read the series...
I'm not sure. It's not really a logging facility - I just wanted a way to save log messages somewhere in order to show them in a TUI window. My feeling is that it doesn't need to grow since perf is not a service or so..
Thanks,
Namhyung
Namhyung Kim
maintainerPATCH 3/6 perf tools: Get rid of a duplicate va_end()
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
The va_end() in _eprintf() should be removed since the caller also invokes va_end().
--- tools/perf/util/debug.c | 1 - 1 file changed, 1 deletion(-)
tools/perf/util/debug.c +0 -1
@@ -25,7 +25,6 @@ static int _eprintf(int level, const char *fmt, va_list args)ui_helpline__vshow (fmt, args); else ret =vfprintf (stderr, fmt, args); -va_end (args); }return ret;
Signature · 1 line
1.7.11.7
Arnaldo Carvalho de Melo
AppliedRe: [PATCH 3/6] perf tools: Get rid of a duplicate va_end()
Em Thu, Dec 19, 2013 at 04:00:08PM +0900, Namhyung Kim escreveu:
Quoted 4 lines
From: Namhyung Kim <[email protected]>
The
va_end()in_eprintf()should be removed since the caller also invokesva_end().
Thanks, applied.
Quoted 19 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/util/debug.c | 1 - 1 file changed, 1 deletion(-)tools/perf/util/debug.c +0
-1@@ -25,7 +25,6 @@ static int _eprintf(int level, const char *fmt, va_list args)ui_helpline__vshow (fmt, args); else ret =vfprintf (stderr, fmt, args); -va_end (args); }return ret;Signature · 1 line
1.7.11.7
Re: [PATCH 3/6] perf tools: Get rid of a duplicate va_end()
In reply to Namhyung KimQuoted 6 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
The
va_end()in_eprintf()should be removed since the caller also invokesva_end().Signed-off-by Namhyung Kim <[email protected]>
jirka
Quoted 19 lines
--- tools/perf/util/debug.c | 1 - 1 file changed, 1 deletion(-)tools/perf/util/debug.c +0
-1@@ -25,7 +25,6 @@ static int _eprintf(int level, const char *fmt, va_list args)ui_helpline__vshow (fmt, args); else ret =vfprintf (stderr, fmt, args); -va_end (args); }return ret;Signature · 1 line
1.7.11.7
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf tools: Get rid of a duplicate va_end() in error reporting routine
In reply to Namhyung Kimperf tools: Get rid of a duplicate va_end() in error reporting routine
Commit-ID: 73db8f82619b7538d9b4badfe13f3ab2fef7d9b3 Gitweb: http://git.kernel.org/tip/73db8f82619b7538d9b4badfe13f3ab2fef7d9b3 Author: Namhyung Kim <[email protected]> AuthorDate: Thu, 19 Dec 2013 16:00:08 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 19 Dec 2013 11:38:42 -0300
perf tools: Get rid of a duplicate va_end() in error reporting routine
The va_end() in _eprintf() should be removed since the caller also invokes va_end().
--- tools/perf/util/debug.c | 1 - 1 file changed, 1 deletion(-)
tools/perf/util/debug.c +0 -1
@@ -25,7 +25,6 @@ static int _eprintf(int level, const char *fmt, va_list args)ui_helpline__vshow (fmt, args); else ret =vfprintf (stderr, fmt, args); -va_end (args); }return ret;
Namhyung Kim
maintainerPATCH 4/6 perf tools: Save message when pr_*() was called
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
The message will be saved in a temp file so that it can be shown at a UI dialog at any time.
--- tools/perf/util/debug.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/perf/util/debug.c +6 -0
@@ -19,12 +19,18 @@ bool dump_trace = false, quiet = false;static int _eprintf (int level,const char *fmt,va_list args) {int ret =0 ; +va_list ap;if (verbose >= level) { +va_copy (ap, args); +if (use_browser >=1 )ui_helpline__vshow (fmt, args);else ret =vfprintf (stderr, fmt, args); + +perf_log_addv (fmt, ap); +va_end (ap); }return ret;
Signature · 1 line
1.7.11.7
Namhyung Kim
maintainerPATCH 5/6 perf ui/tui: Implement log window
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
Implement a simple, full-screen log window which shows error messages saved so far. Press 'l' (lower-case 'L') key to display the log window. It'll be used usually with -v option.
--- tools/perf/Makefile.perf | 1 + tools/perf/ui/browser.h | 1 + tools/perf/ui/browsers/hists.c | 4 ++ tools/perf/ui/browsers/log.c | 92 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 tools/perf/ui/browsers/log.c
tools/perf/Makefile.perf +1 -0
@@ -490,6 +490,7 @@ ifndef NO_SLANG LIB_OBJS += $(OUTPUT)ui/browsers/hists.o LIB_OBJS += $(OUTPUT)ui/browsers/map.o LIB_OBJS += $(OUTPUT)ui/browsers/scripts.o + LIB_OBJS += $(OUTPUT)ui/browsers/log.o LIB_OBJS += $(OUTPUT)ui/tui/setup.o LIB_OBJS += $(OUTPUT)ui/tui/util.o LIB_OBJS += $(OUTPUT)ui/tui/helpline.o
tools/perf/ui/browser.h +1 -0
@@ -59,6 +59,7 @@ int ui_browser__help_window(struct ui_browser *browser, const char *text);bool ui_browser__dialog_yesno (struct ui_browser *browser,const char *text);int ui_browser__input_window (const char *title,const char *text,char *input,const char *exit_msg,int delay_sec); +int tui__log_window (void );void ui_browser__argv_seek (struct ui_browser *browser,off_t offset,int whence);unsigned int ui_browser__argv_refresh (struct ui_browser *browser);
tools/perf/ui/browsers/hists.c +4 -0
@@ -1484,6 +1484,9 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,if (is_report_browser (hbt)) goto do_data_switch;continue ; +case 'l' : +tui__log_window (); +continue ;case K_F1 :case 'h' :case '?' :
@@ -1506,6 +1509,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,"s Switch to another data file in PWD ('perf report' only)\n" "P Print histograms to perf.hist.N\n" "V Verbose (DSO names in callchains, etc)\n" +"l Show log messages\n" "/ Filter symbol by name");continue ;case K_ENTER :
tools/perf/ui/browsers/log.c new file +92 -0
92 lines not on this page · raw message
Signature · 1 line
1.7.11.7
Namhyung Kim
maintainerPATCH 6/6 perf ui/tui: Implement header window
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
Implement a simple, full-screen header window which shows session header (metadata) information. Press 'i' key to display the header window.
--- tools/perf/Makefile.perf | 1 + tools/perf/ui/browser.h | 2 + tools/perf/ui/browsers/header.c | 116 ++++++++++++++++++++++++++++++++++++++++ tools/perf/ui/browsers/hists.c | 4 ++ 4 files changed, 123 insertions(+) create mode 100644 tools/perf/ui/browsers/header.c
tools/perf/Makefile.perf +1 -0
@@ -491,6 +491,7 @@ ifndef NO_SLANG LIB_OBJS += $(OUTPUT)ui/browsers/map.o LIB_OBJS += $(OUTPUT)ui/browsers/scripts.o LIB_OBJS += $(OUTPUT)ui/browsers/log.o + LIB_OBJS += $(OUTPUT)ui/browsers/header.o LIB_OBJS += $(OUTPUT)ui/tui/setup.o LIB_OBJS += $(OUTPUT)ui/tui/util.o LIB_OBJS += $(OUTPUT)ui/tui/helpline.o
tools/perf/ui/browser.h +2 -0
@@ -60,6 +60,8 @@ bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text);int ui_browser__input_window (const char *title,const char *text,char *input,const char *exit_msg,int delay_sec);int tui__log_window (void ); +struct perf_session_env ; +int tui__header_window (struct perf_session_env *env);void ui_browser__argv_seek (struct ui_browser *browser,off_t offset,int whence);unsigned int ui_browser__argv_refresh (struct ui_browser *browser);
tools/perf/ui/browsers/header.c new file +116 -0
116 lines not on this page · raw message
tools/perf/ui/browsers/hists.c +4 -0
@@ -1487,6 +1487,9 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,case 'l' :tui__log_window ();continue ; +case 'i' : +tui__header_window (env); +continue ;case K_F1 :case 'h' :case '?' :
@@ -1510,6 +1513,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,"P Print histograms to perf.hist.N\n" "V Verbose (DSO names in callchains, etc)\n" "l Show log messages\n" +"i Show header information\n" "/ Filter symbol by name");continue ;case K_ENTER :
Signature · 1 line
1.7.11.7
Quoted 6 lines · Namhyung Kim
Hello,
I was playing with TUI code and added two new windows. One for showing log messages and another for showing header information. (Maybe they can be implemented on the GTK code too someday.)
Quoted 8 lines
Please try to use it! :)
I put the patches on 'perf/tui-v1' branch in my tree:
git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.gitAny feedbacks are more than welcome, thanks
Namhyung
In the morning haze it took me some time to figure out that typing 'l' gives leads to the log window, 'i' to the header information.
'l' seems to work (no log messages though :-), but in perf-top 'i' segfaulted:
comet:~/tip/tools/perf> perf top
perf: Segmentation fault
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff0d39700 (LWP 14785)]perf_header__fprintf_info (session=session@entry=0x957bf0, fp=fp@entry=0x7fffec000a30, full=full@entry=true) at util/header.c:2195
2195 int fd = perf_data_file__fd(session->file);
Missing separate debuginfos, use: debuginfo-install audit-libs-2.3.2-1.fc19.x86_64 bzip2-libs-1.0.6-8.fc19.x86_64 elfutils-libelf-0.156-5.fc19.x86_64 elfutils-libs-0.156-5.fc19.x86_64 glibc-2.17-19.fc19.x86_64 libgcc-4.8.2-1.fc19.x86_64 libunwind-1.1-2.fc19.x86_64 nss-softokn-freebl-3.15.2-2.fc19.x86_64 numactl-libs-2.0.8-4.fc19.x86_64 perl-libs-5.16.3-266.fc19.x86_64 python-libs-2.7.5-9.fc19.x86_64 slang-2.2.4-8.fc19.x86_64 xz-libs-5.1.2-4alpha.fc19.x86_64 zlib-1.2.7-10.fc19.x86_64 (gdb) bt
#0 perf_header__fprintf_info (session=session@entry=0x957bf0, fp=fp@entry=0x7fffec000a30, full=full@entry=true) at util/header.c:2195
#1 0x00000000004ce3fe in tui__header_window (env=env@entry=0x957c30) at ui/browsers/header.c:92
#2 0x00000000004cbdfd in perf_evsel__hists_browse (evsel=evsel@entry=0x957560, nr_events=nr_events@entry=1,
helpline=helpline@entry=0x57db88 "For a higher level overview, try: perf top --sort comm,dso", ev_name=0x957870 "cycles", left_exits=left_exits@entry=false,
hbt=hbt@entry=0x7ffff0d38ea0, min_pcnt=min_pcnt@entry=0, env=env@entry=0x957c30) at ui/browsers/hists.c:1491
#3 0x00000000004cd5a5 in perf_evlist__tui_browse_hists (evlist=0x8e5930, help=help@entry=0x57db88 "For a higher level overview, try: perf top --sort comm,dso",
hbt=hbt@entry=0x7ffff0d38ea0, min_pcnt=0, env=0x957c30) at ui/browsers/hists.c:1957
#4 0x0000000000433b48 in display_thread_tui (arg=0x7fffffffb150) at builtin-top.c:584
#5 0x0000003e59407c53 in start_thread () from /lib64/libpthread.so.0
#6 0x0000003e590f5dbd in clone () from /lib64/libc.so.6(gdb)
I suspect it got surprised by perf top not having a header per se? Still it might make sense to also robustify perf_header__fprintf_info() against segfaulting and such.
But it's a nice feature nevertheless!
Btw., it would be nice if 'P' worked on these screens, so any interesting data can be extracted! Cut & paste is usually a PITA due to the graphical TUI characters.
Btw., in case you are taking TUI usability bugreports, here's a few I noticed while playing with your changes:
1)
In histogram view it would be nice if 'P' gave some status bar indication that it just wrote to perf.hist.0 or so - otherwise the user is kept in the dark.
2)
Likewise, in a TUI every keypress must produce some tangible feedback to the user. Try hitting 'o' for example - it should probably output into the status bar that 'o' is not a bound keypress or so.
3)
Same goes for page up / page down in histogram view if we are at the end of the list: some low-key, single-character feedback should be given that the keypress was seen but we are at the end of the list. For exampe the scrollbar 'diamond' character could briefly inverse-flash or so.
Thanks,
Ingo
Namhyung Kim
maintainerHi Ingo,
Quoted 17 lines · Ingo Molnar
Quoted 6 lines · Namhyung Kim
Hello,
I was playing with TUI code and added two new windows. One for showing log messages and another for showing header information. (Maybe they can be implemented on the GTK code too someday.)
Quoted 8 lines
Please try to use it! :)
I put the patches on 'perf/tui-v1' branch in my tree:
git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.gitAny feedbacks are more than welcome, thanks
Namhyung
Quoted 8 lines
In the morning haze it took me some time to figure out that typing 'l' gives leads to the log window, 'i' to the header information.
'l' seems to work (no log messages though :-), but in perf-top 'i' segfaulted:
comet:~/tip/tools/perf> perf top
perf: Segmentation fault
Ah, forgot to test perf top - I just played with perf report at this time. :-/
Quoted 17 lines
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread0x7ffff0d39700(LWP 14785)]perf_header__fprintf_info(session=session@entry=0x957bf0, fp=fp@entry=0x7fffec000a30, full=full@entry=true) atutil/header.c:2195
2195 int fd =perf_data_file__fd(session->file);
Missing separate debuginfos, use: debuginfo-install audit-libs-2.3.2-1.fc19.x86_64 bzip2-libs-1.0.6-8.fc19.x86_64 elfutils-libelf-0.156-5.fc19.x86_64 elfutils-libs-0.156-5.fc19.x86_64 glibc-2.17-19.fc19.x86_64 libgcc-4.8.2-1.fc19.x86_64 libunwind-1.1-2.fc19.x86_64 nss-softokn-freebl-3.15.2-2.fc19.x86_64 numactl-libs-2.0.8-4.fc19.x86_64 perl-libs-5.16.3-266.fc19.x86_64 python-libs-2.7.5-9.fc19.x86_64 slang-2.2.4-8.fc19.x86_64 xz-libs-5.1.2-4alpha.fc19.x86_64 zlib-1.2.7-10.fc19.x86_64 (gdb) bt#0 perf_header__fprintf_info (session=session@entry=0x957bf0, fp=fp@entry=0x7fffec000a30, full=full@entry=true) at util/header.c:2195 #1 0x00000000004ce3fe in tui__header_window (env=env@entry=0x957c30) at ui/browsers/header.c:92 #2 0x00000000004cbdfd in perf_evsel__hists_browse (evsel=evsel@entry=0x957560, nr_events=nr_events@entry=1, helpline=helpline@entry=0x57db88 "For a higher level overview, try: perf top --sort comm,dso", ev_name=0x957870 "cycles", left_exits=left_exits@entry=false, hbt=hbt@entry=0x7ffff0d38ea0, min_pcnt=min_pcnt@entry=0, env=env@entry=0x957c30) at ui/browsers/hists.c:1491 #3 0x00000000004cd5a5 in perf_evlist__tui_browse_hists (evlist=0x8e5930, help=help@entry=0x57db88 "For a higher level overview, try: perf top --sort comm,dso", hbt=hbt@entry=0x7ffff0d38ea0, min_pcnt=0, env=0x957c30) at ui/browsers/hists.c:1957 #4 0x0000000000433b48 in display_thread_tui (arg=0x7fffffffb150) at builtin-top.c:584 #5 0x0000003e59407c53 in start_thread () from /lib64/libpthread.so.0 #6 0x0000003e590f5dbd in clone () from /lib64/libc.so.6
Quoted 5 lines
(gdb)
I suspect it got surprised by perf top not having a header per se? Still it might make sense to also robustify
perf_header__fprintf_info()against segfaulting and such.
Right. To be precise, perf top do have header.env but not set the actual info in it. I had to check it, sorry. The patch below will fix the problem.
Quoted 1 line
From
451a267fb2243860f62390151cc156a9eab7d317Mon Sep 17 00:00:00 2001
From: Namhyung Kim <[email protected]>
Date: Fri, 20 Dec 2013 09:14:23 +0900
Subject: [PATCH 1/3] perf ui/tui: fixup for header window on perf-top
It should check whether header.env is valid.
--- tools/perf/ui/browsers/hists.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/ui/browsers/hists.c +3 -1
@@ -1488,7 +1488,9 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,tui__log_window ();continue ;case 'i' : -tui__header_window (env); +/* env->arch is NULL for live-mode (i.e. perf top) */ +if (env->arch) +tui__header_window (env);continue ;case K_F1 :case 'h' :
Signature · 4 lines
1.7.11.7 I'll fold it to the original patch.
Quoted 2 lines
But it's a nice feature nevertheless!
Thanks! :)
Quoted 4 lines
Btw., it would be nice if 'P' worked on these screens, so any interesting data can be extracted! Cut & paste is usually a PITA due to the graphical TUI characters.
Ah, okay. I think it should be easy, will cook a patch.
Quoted 3 lines
Btw., in case you are taking TUI usability bugreports, here's a few I noticed while playing with your changes:
Hmm.. I'll take a look at them next week too. :)
Quoted 24 lines
1)
In histogram view it would be nice if 'P' gave some status bar indication that it just wrote to perf.hist.0 or so - otherwise the user is kept in the dark.
2)
Likewise, in a TUI every keypress must produce some tangible feedback to the user. Try hitting 'o' for example - it should probably output into the status bar that 'o' is not a bound keypress or so.
3)
Same goes for page up / page down in histogram view if we are at the end of the list: some low-key, single-character feedback should be given that the keypress was seen but we are at the end of the list. For exampe the scrollbar 'diamond' character could briefly inverse-flash or so.
Thanks,
Ingo
Quoted 7 lines · Namhyung Kim
Hello,
I was playing with TUI code and added two new windows. One for showing log messages and another for showing header information. (Maybe they can be implemented on the GTK code too someday.)
Please try to use it! :)
hi,
I'm sure the 'i' header display will be appreciated!
Any chance of searching capability in the 'l' log window? mutt-like limit('l') command would be great ;-)
thanks,
jirka
Quoted 7 lines · Jiri Olsa
Quoted 6 lines · Namhyung Kim
Hello,
I was playing with TUI code and added two new windows. One for showing log messages and another for showing header information. (Maybe they can be implemented on the GTK code too someday.)
Quoted 7 lines
Quoted 1 line
Please try to use it! :)
hi,
I'm sure the 'i' header display will be appreciated!Any chance of searching capability in the 'l' log window? mutt-like limit('l') command would be great ;-)
A bit like how '/' works in histogram view, it will filter on partial matches as well, making it really easy to filter down to larger classes of functions (in projects that have good function name namespaces).
Thanks,
Ingo
Namhyung Kim
maintainerQuoted 14 lines · Ingo Molnar
Quoted 12 lines · Jiri Olsa
Quoted 7 lines · Namhyung Kim
Hello,
I was playing with TUI code and added two new windows. One for showing log messages and another for showing header information. (Maybe they can be implemented on the GTK code too someday.)
Please try to use it! :)
hi,
I'm sure the 'i' header display will be appreciated!
Quoted 7 lines
Quoted 2 lines
Any chance of searching capability in the 'l' log window? mutt-like limit('l') command would be great ;-)
A bit like how '/' works in histogram view, it will filter on partial matches as well, making it really easy to filter down to larger classes of functions (in projects that have good function name namespaces).
Yes, I was thinking about that too. Will send a patch soon.
Thanks,
Namhyung
Quoted 7 lines · Jiri Olsa
Quoted 6 lines · Namhyung Kim
Hello,
I was playing with TUI code and added two new windows. One for showing log messages and another for showing header information. (Maybe they can be implemented on the GTK code too someday.)
Quoted 7 lines
Quoted 1 line
Please try to use it! :)
hi,
I'm sure the 'i' header display will be appreciated!Any chance of searching capability in the 'l' log window? mutt-like limit('l') command would be great ;-)
+1 :-)
Ingo