diag-trace 5.0.0
µOS++ Tracing Infrastructure
Loading...
Searching...
No Matches

Primary C functions for outputting trace messages. More...

Functions

int micro_os_plus_trace_printf (const char *format,...)
 Write a formatted string to the trace output channel.
int micro_os_plus_trace_putchar (int c)
 Write the single character to the trace output channel.
int micro_os_plus_trace_puts (const char *s)
 Write the string and a line terminator to the trace output channel.
int micro_os_plus_trace_vprintf (const char *format, va_list arguments)
 Write a formatted variable arguments list to the trace output channel.

Detailed Description

These functions constitute the primary methods for outputting trace messages in C projects.

Function Documentation

◆ micro_os_plus_trace_printf()

int micro_os_plus_trace_printf ( const char * format,
... )
Parameters
formatA null terminated string with the format.
...Additional arguments matching the format specifiers.
Returns
The number of bytes written, or -1 if an error occurred.

Formatting is performed into a fixed-size stack buffer of MICRO_OS_PLUS_DIAG_TRACE_PRINTF_BUFFER_ARRAY_SIZE_INTEGER bytes (default: 200). If the formatted output exceeds this limit, it is silently truncated before being passed to micro_os_plus_trace_write. The return value reflects the number of bytes actually written, not the number that the format string would have produced.

Definition at line 66 of file trace-c-api.cpp.

67{
68 std::va_list arguments;
69 va_start (arguments, format);
70
71#pragma GCC diagnostic push
72#if defined(__clang__)
73#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
74#endif
75 int ret = tracer<implementation>::vprintf (format, arguments);
76#pragma GCC diagnostic pop
77
78 va_end (arguments);
79 return ret;
80}
static int vprintf(const char *format, std::va_list arguments) noexcept
Write a formatted variable arguments list to the trace output channel.

References micro_os_plus::trace::detail::tracer< T >::vprintf().

◆ micro_os_plus_trace_putchar()

int micro_os_plus_trace_putchar ( int c)
Parameters
cA single byte character, passed as an int.
Returns
The written character as an int, or EOF (-1) if an error occurred.

Converts c to char and passes it as a one-byte buffer to micro_os_plus_trace_write. On success, returns the original value of c; on failure, returns EOF.

Definition at line 105 of file trace-c-api.cpp.

106{
108}
static int putchar(int c) noexcept
Write the single character to the trace output channel.

References micro_os_plus::trace::detail::tracer< T >::putchar().

◆ micro_os_plus_trace_puts()

int micro_os_plus_trace_puts ( const char * s)
Parameters
sA null terminated string.
Returns
The total number of bytes written (string + newline), or EOF (-1) if an error occurred.

Writes the characters of s followed by a single newline character ('\n'). Unlike the standard C puts(), this function returns the total byte count written, not merely a non-negative indicator. If writing the newline fails after the string has been written successfully, EOF is returned.

Definition at line 94 of file trace-c-api.cpp.

95{
96#pragma GCC diagnostic push
97#if defined(__clang__)
98#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
99#endif
101#pragma GCC diagnostic pop
102}
static int puts(const char *s="") noexcept
Write the string and a line terminator to the trace output channel.

References micro_os_plus::trace::detail::tracer< T >::puts().

◆ micro_os_plus_trace_vprintf()

int micro_os_plus_trace_vprintf ( const char * format,
va_list arguments )
Parameters
formatA null terminated string with the format.
argumentsA variable arguments list.
Returns
The number of bytes written, or -1 if an error occurred.

Equivalent to micro_os_plus_trace_printf, but accepts a va_list instead of a variadic argument list. Subject to the same fixed-size stack buffer constraint and truncation behaviour. Typically called by micro_os_plus_trace_printf.

Definition at line 83 of file trace-c-api.cpp.

84{
85#pragma GCC diagnostic push
86#if defined(__clang__)
87#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
88#endif
89 return tracer<implementation>::vprintf (format, arguments);
90#pragma GCC diagnostic pop
91}

References micro_os_plus::trace::detail::tracer< T >::vprintf().