Unix and Linux Discussions Tagged with developer |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
107 |
48,458 |
What is on Your Mind? |
|
|
|
0 |
1,852 |
MySQL DevZone RSS |
|
|
|
0 |
1,022 |
UNIX and Linux RSS News |
|
|
|
0 |
1,441 |
UNIX and Linux RSS News |
|
|
|
0 |
1,678 |
MySQL DevZone RSS |
|
|
|
0 |
1,895 |
Red Hat |
|
|
|
0 |
802 |
Software Releases - RSS News |
|
|
|
0 |
934 |
Software Releases - RSS News |
|
|
|
0 |
959 |
UNIX and Linux RSS News |
|
|
|
0 |
1,018 |
UNIX and Linux RSS News |
|
|
|
0 |
2,848 |
Oracle Updates (RSS) |
|
|
|
0 |
814 |
Software Releases - RSS News |
|
|
|
0 |
1,130 |
UNIX and Linux RSS News |
|
|
|
0 |
1,072 |
Software Releases - RSS News |
|
|
|
0 |
1,028 |
UNIX and Linux RSS News |
|
|
|
0 |
1,539 |
UNIX and Linux RSS News |
|
|
|
1 |
2,777 |
UNIX for Advanced & Expert Users |
|
|
|
1 |
2,493 |
UNIX for Dummies Questions & Answers |
|
|
|
5 |
9,767 |
Programming |
TRACE_PRINTK(9) Driver Basics TRACE_PRINTK(9)
NAME
trace_printk - printf formatting in the ftrace buffer
SYNOPSIS
trace_printk(fmt, ...);
ARGUMENTS
fmt
the printf format for printing
...
variable arguments
NOTE
__trace_printk is an internal function for trace_printk and the ip is passed in via the trace_printk macro.
This function allows a kernel developer to debug fast path sections that printk is not appropriate for. By scattering in various printk
like tracing in the code, a developer can quickly see where problems are occurring.
This is intended as a debugging tool for the developer only. Please refrain from leaving trace_printks scattered around in your code.
(Extra memory is used for special buffers that are allocated when trace_printk is used)
A little optization trick is done here. If there's only one argument, there's no need to scan the string for printf formats. The trace_puts
will suffice. But how can we take advantage of using trace_puts when trace_printk has only one argument? By stringifying the args and
checking the size we can tell whether or not there are args. __stringify((__VA_ARGS__)) will turn into "() " with a size of 3 when there
are no args, anything else will be bigger. All we need to do is define a string to this, and then take its size and compare to 3. If it's
bigger, use do_trace_printk otherwise, optimize it to trace_puts. Then just let gcc optimize the rest.
COPYRIGHT
Kernel Hackers Manual 3.10 June 2014 TRACE_PRINTK(9)