Commit 6b0c7c28 authored by Donglin Peng's avatar Donglin Peng Committed by Steven Rostedt (Google)
Browse files

tracing: Pretty-print enum parameters in function arguments

Currently, print_function_args() prints enum parameter values
in decimal format, reducing trace log readability.

Use BTF information to resolve enum parameters and print their
symbolic names (where available). This improves readability by
showing meaningful identifiers instead of raw numbers.

Before:
  mod_memcg_lruvec_state(lruvec=0xffff..., idx=5, val=320)

After:
  mod_memcg_lruvec_state(lruvec=0xffff..., idx=5 [NR_SLAB_RECLAIMABLE_B], val=320)

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Link: https://patch.msgid.link/20260209071949.4040193-1-dolinux.peng@gmail.com


Signed-off-by: default avatarDonglin Peng <pengdonglin@xiaomi.com>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent f54f08b1
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -719,12 +719,13 @@ void print_function_args(struct trace_seq *s, unsigned long *args,
{
	const struct btf_param *param;
	const struct btf_type *t;
	const struct btf_enum *enums;
	const char *param_name;
	char name[KSYM_NAME_LEN];
	unsigned long arg;
	struct btf *btf;
	s32 tid, nr = 0;
	int a, p, x;
	int a, p, x, i;
	u16 encode;

	trace_seq_printf(s, "(");
@@ -778,6 +779,15 @@ void print_function_args(struct trace_seq *s, unsigned long *args,
			break;
		case BTF_KIND_ENUM:
			trace_seq_printf(s, "%ld", arg);
			enums = btf_enum(t);
			for (i = 0; i < btf_vlen(t); i++) {
				if (arg == enums[i].val) {
					trace_seq_printf(s, " [%s]",
							 btf_name_by_offset(btf,
							 enums[i].name_off));
					break;
				}
			}
			break;
		default:
			/* This does not handle complex arguments */