[PATCH v2 2/2] trace-cmd: Add ftrace options for the fgraph retval feature

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

 



Add two internal options for fgraph: fgraph:retval-skip and
fgraph:retval-hex. By default, trace-cmd will print each function's
return value at the function_graph exit point, if the kernel supports
the fgraph-retval feature. If users want to skip the output of
functions' return values, then set fgraph:retval-skip. Alternatively,
users can set fgraph:retval-hex to force the return values to be
printed in hex format.

Here are example commands:
> trace-cmd report -O fgraph:retval-skip
> trace-cmd report -O fgraph:retval-hex

Signed-off-by: Jianfeng Wang <jianfeng.w.wang@xxxxxxxxxx>
---
 lib/trace-cmd/trace-ftrace.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/lib/trace-cmd/trace-ftrace.c b/lib/trace-cmd/trace-ftrace.c
index 2b4e49a5..d2378833 100644
--- a/lib/trace-cmd/trace-ftrace.c
+++ b/lib/trace-cmd/trace-ftrace.c
@@ -26,6 +26,18 @@ struct tep_plugin_option trace_ftrace_options[] = {
 		.description =
 		"Show the depth of each entry",
 	},
+	{
+		.name = "retval-skip",
+		.plugin_alias = "fgraph",
+		.description =
+		"Skip printing function retval in function graph",
+	},
+	{
+		.name = "retval-hex",
+		.plugin_alias = "fgraph",
+		.description =
+		"Print function retval in hex at function exit in function graph",
+	},
 	{
 		.name = NULL,
 	}
@@ -33,6 +45,8 @@ struct tep_plugin_option trace_ftrace_options[] = {
 
 static struct tep_plugin_option *fgraph_tail = &trace_ftrace_options[0];
 static struct tep_plugin_option *fgraph_depth = &trace_ftrace_options[1];
+static struct tep_plugin_option *fgraph_retval_skip = &trace_ftrace_options[2];
+static struct tep_plugin_option *fgraph_retval_hex = &trace_ftrace_options[3];
 
 static int find_ret_event(struct tracecmd_ftrace *finfo, struct tep_handle *pevent)
 {
@@ -235,8 +249,8 @@ print_graph_entry_leaf(struct trace_seq *s,
 		ret = trace_seq_printf(s, " (%lld)", depth);
 
 	/* Return Value */
-	if (ret && fgraph_retval_supported) {
-		if (!IS_LINUX_ERR_VALUE(retval))
+	if (ret && fgraph_retval_supported && !fgraph_retval_skip->set) {
+		if (fgraph_retval_hex->set || !IS_LINUX_ERR_VALUE(retval))
 			ret = trace_seq_printf(s, " (ret=0x%llx)", retval);
 		else
 			ret = trace_seq_printf(s, " (ret=%lld)", retval);
@@ -385,8 +399,8 @@ fgraph_ret_handler(struct trace_seq *s, struct tep_record *record,
 		trace_seq_printf(s, " (%lld)", depth);
 
 	/* Return Value */
-	if (fgraph_retval_supported) {
-		if (!IS_LINUX_ERR_VALUE(retval))
+	if (fgraph_retval_supported && !fgraph_retval_skip->set) {
+		if (fgraph_retval_hex->set || !IS_LINUX_ERR_VALUE(retval))
 			trace_seq_printf(s, " (ret=0x%llx)", retval);
 		else
 			trace_seq_printf(s, " (ret=%lld)", retval);
-- 
2.42.1





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

  Powered by Linux