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)
Check Out this Related Man Page
vprintf(3S)vprintf(3S)NAME
vprintf(), vfprintf(), vsprintf(), vsnprintf() - print formatted output of a varargs argument list
SYNOPSIS DESCRIPTION
and are the same as and respectively, except that instead of being called with a variable number of arguments, they are called with an
argument list as defined by
RETURN VALUE
Each function returns the number of bytes transmitted (excluding the null byte character in the case of or a negative value if an output
error was encountered.
By default, returns a negative value if maxsize is smaller than the number of characters formatted. In the UNIX 2003 standards environment
(see standards(5)) it returns the number of bytes that would have been written to buffer s, excluding the terminating null byte, if maxsize
had been sufficiently large.
EXAMPLES
The following demonstrates how could be used to write an error routine:
#include <stdarg.h>
#include <stdio.h>
.
.
.
/*
* error should be called using the form:
* error(function_name, format, arg1, arg2...);
*/
/*VARARGS0*/
void
error(va_alist)
va_dcl
{
va_list args;
char *fmt;
va_start(args);
/* print out name of function causing error */
(void)fprintf(stderr, "ERROR in %s: ", va_arg(args, char *));
fmt = va_arg(args, char *);
/* print out remainder of message */
(void)vfprintf(stderr, fmt, args);
va_end(args);
(void)abort( );
}
SEE ALSO setlocale(3C), printf(3S), standards(5), thread_safety(5), varargs(5), glossary(9).
STANDARDS CONFORMANCE vprintf(3S)
Because some program i have installed can not upload files bigger than some size as printing, the base got a packet bigger than 'max_allowed_packet' bytes what that i need to do as written in the documentation of the program increase the value of a fileld called LimitRequestBody told that is in... (3 Replies)
Because some program i have installed can not upload files bigger than some size as printing, the base got a packet bigger than 'max_allowed_packet' bytes what that i need to do as written in the documentation of the program increase the value of a fileld called LimitRequestBody told that is in... (5 Replies)
As you know we can output a string to the kernel /init/main.c
using printk.
I want to know if there are other function to make the appearance look better. is there any drawing function? color settings? if there is, i would thank if you name a few. (1 Reply)