Bug 217339 - trace-cmd report does not handle "+" flag in trace_printk specifier
Summary: trace-cmd report does not handle "+" flag in trace_printk specifier
Status: RESOLVED CODE_FIX
Alias: None
Product: Tools
Classification: Unclassified
Component: Trace-cmd/Kernelshark (show other bugs)
Hardware: All Linux
: P3 normal
Assignee: Default virtual assignee for Trace-cmd and kernelshark
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-14 18:21 UTC by Douglas RAILLARD
Modified: 2023-06-07 19:34 UTC (History)
1 user (show)

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Douglas RAILLARD 2023-04-14 18:21:49 UTC
The "+" printf flag format is not handled by trace-cmd report. "%+d" should result in printing "+N" with N a positive signed integer. Instead, it prints ">+<d"

Tested on trace-cmd v3.1.5
Comment 1 Steven Rostedt 2023-06-01 12:41:24 UTC
The printf formats are handled by libtraceevent, so this is actually a libtraceevent bug and not a trace-cmd one.

I'm curious, how did you find this? I don't see an event in the kernel that uses '%+d'. I was able to trigger it by adding a trace_printk("%+d", val).
Comment 2 Steven Rostedt 2023-06-01 12:47:10 UTC
Silly me didn't read the subject of this bugzilla where you specifically specify that it's a problem with 'trace_printk()' ;-)
Comment 3 Douglas RAILLARD 2023-06-01 14:05:50 UTC
I just found it when implementing support for implementing trace_printk() (or more: the vbin_printf() things) in the Rust parser, so I essentially used a combo of what is defined here:
https://docs.kernel.org/core-api/printk-formats.html
and what the ISO C printf handles.

Right now I'm implementing the last "custom functions" like __print_array() & co, after which I should have an equivalent of trace-cmd report. The only thing I left out for now are %pI and __get_sockaddr() because I'd like to share a PoC, and the code is not super clean or commented but I'm almost there :)
Comment 4 Steven Rostedt 2023-06-07 19:34:18 UTC
Fixed by https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/commit/?id=0b9a34e45975edecfb8569849bfd9f5b3039f19f

("libtraceevent: Handle printf '%+d" case")

Note You need to log in before you can comment on or make changes to this bug.