Re: [PATCH v2 2/2] tracing: Use seq_buf_hex_dump() to dump buffers

From: Steven Rostedt
Date: Tue Nov 26 2019 - 14:51:06 EST


On Tue, 26 Nov 2019 15:53:26 +0100
Piotr Maziarz <piotrx.maziarz@xxxxxxxxxxxxxxx> wrote:
> Hello Steven,
>
> I'm writing handle in event-parse and I came across some technical
> problems. I have an event which print function looks like that:
> TP_printk("%s",
> __print_hex_dump("", DUMP_PREFIX_OFFSET, 16, 4,
> __get_dynamic_array(buf),
> __get_dynamic_array_len(buf), false))
> It works properly when printing events to debugfs.
> I'm testing my implementation with trace-cmd and it has problem with
> parsing DUMP_PREFIX_OFFSET and false (I'm using
> alloc_and_process_delim()). Instead of having numerical values
> tep_print_args are of type TEP_PRINT_ATOM and have char array
> "DUMP_PREFIX_OFFSET" or "true".
> Am I doing something incorrect? Parsing it this way is problematic
> because instead of false someone may use 0 or logic expression. And
> writing it to support all possible scenarios may be tedious and prone to
> errors.

You can force the enum to be a number by including the following in the
trace event header:

TRACE_DEFINE_ENUM(DUMP_PREFIX_OFFSET);
TRACE_DEFINE_ENUM(DUMP_PREFIX_ADDRESS);
TRACE_DEFINE_ENUM(DUMP_PREFIX_NONE);

and the format files will convert these to their actual numbers when
displaying it to user space.

-- Steve