[PATCH] libtracefs: Have tracefs_sql() cast handle stacktrace

Steven Rostedt <[email protected]> Thu, 10 Apr 2025 21:21:12 -0400
Newsgroups org.kernel.vger.linux-trace-devel
Message-ID <[email protected]>
From: "Steven Rostedt (Google)" <[email protected]>

A histogram can have a "stacktrace" type. Allow casts to make that:

  # sqlhist select cast '('start.stack as stacktrace')' from sleep_lat as start
  echo 'hist:keys=stack.stacktrace' > /sys/kernel/tracing/events/synthetic/sleep_lat/trigger

Signed-off-by: Steven Rostedt (Google) <[email protected]>
---
 src/tracefs-sqlhist.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/tracefs-sqlhist.c b/src/tracefs-sqlhist.c
index 67be678..30c8ccc 100644
--- a/src/tracefs-sqlhist.c
+++ b/src/tracefs-sqlhist.c
@@ -1450,6 +1450,10 @@ static int verify_field_type(struct tep_handle *tep,
 		if (tfield->flags & (TEP_FIELD_IS_STRING | TEP_FIELD_IS_ARRAY))
 			goto fail_type;
 		ret = TRACEFS_HIST_KEY_BUCKETS;
+	} else if (!strcmp(type, "stacktrace")) {
+		if (!(tfield->flags & (TEP_FIELD_IS_ARRAY)))
+			goto fail_type;
+		ret = TRACEFS_HIST_KEY_STACKTRACE;
 	} else {
 		parse_error(sb, field->raw,
 			    "Cast of '%s' to unknown type '%s'\n",
-- 
2.47.2