^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: LGPL-2.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2009 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include "trace-seq.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <stdio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <stdlib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <stdarg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <asm/bug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "event-parse.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "event-utils.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * The TRACE_SEQ_POISON is to catch the use of using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * a trace_seq structure after it was destroyed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define TRACE_SEQ_POISON ((void *)0xdeadbeef)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define TRACE_SEQ_CHECK(s) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) if (WARN_ONCE((s)->buffer == TRACE_SEQ_POISON, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) "Usage of trace_seq after it was destroyed")) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) (s)->state = TRACE_SEQ__BUFFER_POISONED; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define TRACE_SEQ_CHECK_RET_N(s, n) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) TRACE_SEQ_CHECK(s); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) if ((s)->state != TRACE_SEQ__GOOD) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) return n; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define TRACE_SEQ_CHECK_RET(s) TRACE_SEQ_CHECK_RET_N(s, )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define TRACE_SEQ_CHECK_RET0(s) TRACE_SEQ_CHECK_RET_N(s, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * trace_seq_init - initialize the trace_seq structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * @s: a pointer to the trace_seq structure to initialize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) void trace_seq_init(struct trace_seq *s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) s->len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) s->readpos = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) s->buffer_size = TRACE_SEQ_BUF_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) s->buffer = malloc(s->buffer_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) if (s->buffer != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) s->state = TRACE_SEQ__GOOD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) s->state = TRACE_SEQ__MEM_ALLOC_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * trace_seq_reset - re-initialize the trace_seq structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * @s: a pointer to the trace_seq structure to reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) void trace_seq_reset(struct trace_seq *s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) if (!s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) TRACE_SEQ_CHECK(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) s->len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) s->readpos = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * trace_seq_destroy - free up memory of a trace_seq
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * @s: a pointer to the trace_seq to free the buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * Only frees the buffer, not the trace_seq struct itself.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) void trace_seq_destroy(struct trace_seq *s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) if (!s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) TRACE_SEQ_CHECK_RET(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) free(s->buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) s->buffer = TRACE_SEQ_POISON;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) static void expand_buffer(struct trace_seq *s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) char *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) buf = realloc(s->buffer, s->buffer_size + TRACE_SEQ_BUF_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) if (WARN_ONCE(!buf, "Can't allocate trace_seq buffer memory")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) s->state = TRACE_SEQ__MEM_ALLOC_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) s->buffer = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) s->buffer_size += TRACE_SEQ_BUF_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * trace_seq_printf - sequence printing of trace information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * @s: trace sequence descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * @fmt: printf format string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * It returns 0 if the trace oversizes the buffer's free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * space, the number of characters printed, or a negative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * value in case of an error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * The tracer may use either sequence operations or its own
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * copy to user routines. To simplify formating of a trace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * trace_seq_printf is used to store strings into a special
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * buffer (@s). Then the output may be either used by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * the sequencer or pulled into another buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) va_list ap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) try_again:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) TRACE_SEQ_CHECK_RET0(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) len = (s->buffer_size - 1) - s->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) va_start(ap, fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) ret = vsnprintf(s->buffer + s->len, len, fmt, ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) va_end(ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) if (ret >= len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) expand_buffer(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) goto try_again;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) if (ret > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) s->len += ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * trace_seq_vprintf - sequence printing of trace information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * @s: trace sequence descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * @fmt: printf format string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) * It returns 0 if the trace oversizes the buffer's free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) * space, the number of characters printed, or a negative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) * value in case of an error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) * *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) * The tracer may use either sequence operations or its own
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * copy to user routines. To simplify formating of a trace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) * trace_seq_printf is used to store strings into a special
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * buffer (@s). Then the output may be either used by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) * the sequencer or pulled into another buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) try_again:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) TRACE_SEQ_CHECK_RET0(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) len = (s->buffer_size - 1) - s->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) ret = vsnprintf(s->buffer + s->len, len, fmt, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if (ret >= len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) expand_buffer(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) goto try_again;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) if (ret > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) s->len += ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * trace_seq_puts - trace sequence printing of simple string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * @s: trace sequence descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * @str: simple string to record
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) * The tracer may use either the sequence operations or its own
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) * copy to user routines. This function records a simple string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) * into a special buffer (@s) for later retrieval by a sequencer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) * or other mechanism.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) int trace_seq_puts(struct trace_seq *s, const char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) TRACE_SEQ_CHECK_RET0(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) len = strlen(str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) while (len > ((s->buffer_size - 1) - s->len))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) expand_buffer(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) TRACE_SEQ_CHECK_RET0(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) memcpy(s->buffer + s->len, str, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) s->len += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) int trace_seq_putc(struct trace_seq *s, unsigned char c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) TRACE_SEQ_CHECK_RET0(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) while (s->len >= (s->buffer_size - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) expand_buffer(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) TRACE_SEQ_CHECK_RET0(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) s->buffer[s->len++] = c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) void trace_seq_terminate(struct trace_seq *s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) TRACE_SEQ_CHECK_RET(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) /* There's always one character left on the buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) s->buffer[s->len] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) int trace_seq_do_fprintf(struct trace_seq *s, FILE *fp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) TRACE_SEQ_CHECK(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) switch (s->state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) case TRACE_SEQ__GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) return fprintf(fp, "%.*s", s->len, s->buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) case TRACE_SEQ__BUFFER_POISONED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) fprintf(fp, "%s\n", "Usage of trace_seq after it was destroyed");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) case TRACE_SEQ__MEM_ALLOC_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) fprintf(fp, "%s\n", "Can't allocate trace_seq buffer memory");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) int trace_seq_do_printf(struct trace_seq *s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) return trace_seq_do_fprintf(s, stdout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }