Re: [PATCH 4/5] libtraceevent, perf tools: Changes in tep_print_event_* APIs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 17 Sep 2019 22:03:38 -0400
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> From: Tzvetomir Stoyanov <tstoyanov@xxxxxxxxxx>
> 
> Libtraceevent APIs for printing various trace events information are
> complicated, there are complex extra parameters. To control the way
> event information is printed, the user should call a set of functions in
> a specific sequence.
> 
> These APIs are reimplemented to provide a more simple interface for
> printing event information.
> 
> Removed APIs:
> 
>  	tep_print_event_task()
> 	tep_print_event_time()
> 	tep_print_event_data()
> 	tep_event_info()
> 	tep_is_latency_format()
> 	tep_set_latency_format()
> 	tep_data_latency_format()
> 	tep_set_print_raw()
> 
> A new API for printing event information is introduced:
>    void tep_print_event(struct tep_handle *tep, struct trace_seq *s,
> 		        struct tep_record *record, const char *fmt, ...);
> where "fmt" is a printf-like format string, followed by the event
> fields to be printed. Supported fields:
>  TEP_PRINT_PID, "%d" - event PID
>  TEP_PRINT_CPU, "%d" - event CPU
>  TEP_PRINT_COMM, "%s" - event command string
>  TEP_PRINT_NAME, "%s" - event name
>  TEP_PRINT_LATENCY, "%s" - event latency
>  TEP_PRINT_TIME, %d - event time stamp. A divisor and precision
>    can be specified as part of this format string:
>    "%precision.divisord". Example:
>    "%3.1000d" - divide the time by 1000 and print the first 3 digits
>    before the dot. Thus, the time stamp "123456000" will be printed as
>    "123.456"
>  TEP_PRINT_INFO, "%s" - event information.
>  TEP_PRINT_INFO_RAW, "%s" - event information, in raw format.
> 
> Example:
>   tep_print_event(tep, s, record, "%16s-%-5d [%03d] %s %6.1000d %s %s",
> 		  TEP_PRINT_COMM, TEP_PRINT_PID, TEP_PRINT_CPU,
> 		  TEP_PRINT_LATENCY, TEP_PRINT_TIME, TEP_PRINT_NAME, TEP_PRINT_INFO);
> Output:
> 	ls-11314 [005] d.h. 185207.366383 function __wake_up
> 
> Signed-off-by: Tzvetomir Stoyanov <tstoyanov@xxxxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
> Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
> Cc: linux-trace-devel@xxxxxxxxxxxxxxx
> Cc: Patrick McLean <chutzpah@xxxxxxxxxx>
> Link: http://lore.kernel.org/linux-trace-devel/20190801074959.22023-2-tz.stoyanov@xxxxxxxxx
> Link: http://lore.kernel.org/lkml/20190805204355.041132030@xxxxxxxxxxx
> Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> [ Added support for trace-cmd trace-read.c ]
> Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>


I needed to modify this with the following changes:

diff --git a/kernel-shark/src/libkshark.c b/kernel-shark/src/libkshark.c
index 47ec9c21..4207ae6f 100644
--- a/kernel-shark/src/libkshark.c
+++ b/kernel-shark/src/libkshark.c
@@ -1103,7 +1103,7 @@ static const char *kshark_get_latency(struct tep_handle *pe,
 		return NULL;
 
 	trace_seq_reset(&seq);
-	tep_data_latency_format(pe, &seq, record);
+	tep_print_event(pe, &seq, record, "%s", TEP_PRINT_LATENCY);
 	return seq.buffer;
 }
 
@@ -1117,7 +1117,7 @@ static const char *kshark_get_info(struct tep_handle *pe,
 		return NULL;
 
 	trace_seq_reset(&seq);
-	tep_event_info(&seq, event, record);
+	tep_print_event(pe, &seq, record, "%s", TEP_PRINT_INFO);
 
 	/*
 	 * The event info string contains a trailing newline.


-- Steve



[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux