1 /*
2 * Copyright (c) 2019 Intel corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #define DISABLE_SYSCALL_TRACING
8
9 #include <tracing_core.h>
10 #include <tracing_buffer.h>
11 #include <tracing_format_common.h>
12
tracing_format_string(const char * str,...)13 void tracing_format_string(const char *str, ...)
14 {
15 va_list args;
16 bool put_success, before_put_is_empty;
17
18 if (!is_tracing_enabled() || is_tracing_thread()) {
19 return;
20 }
21
22 va_start(args, str);
23
24 TRACING_LOCK();
25 before_put_is_empty = tracing_buffer_is_empty();
26 put_success = tracing_format_string_put(str, args);
27 TRACING_UNLOCK();
28
29 va_end(args);
30
31 if (put_success) {
32 tracing_trigger_output(before_put_is_empty);
33 } else {
34 tracing_packet_drop_handle();
35 }
36 }
37
tracing_format_raw_data(uint8_t * data,uint32_t length)38 void tracing_format_raw_data(uint8_t *data, uint32_t length)
39 {
40 bool put_success, before_put_is_empty;
41
42 if (!is_tracing_enabled() || is_tracing_thread()) {
43 return;
44 }
45
46 TRACING_LOCK();
47 before_put_is_empty = tracing_buffer_is_empty();
48 put_success = tracing_format_raw_data_put(data, length);
49 TRACING_UNLOCK();
50
51 if (put_success) {
52 tracing_trigger_output(before_put_is_empty);
53 } else {
54 tracing_packet_drop_handle();
55 }
56 }
57
tracing_format_data(tracing_data_t * tracing_data_array,uint32_t count)58 void tracing_format_data(tracing_data_t *tracing_data_array, uint32_t count)
59 {
60 bool put_success, before_put_is_empty;
61
62 if (!is_tracing_enabled() || is_tracing_thread()) {
63 return;
64 }
65
66 TRACING_LOCK();
67 before_put_is_empty = tracing_buffer_is_empty();
68 put_success = tracing_format_data_put(tracing_data_array, count);
69 TRACING_UNLOCK();
70
71 if (put_success) {
72 tracing_trigger_output(before_put_is_empty);
73 } else {
74 tracing_packet_drop_handle();
75 }
76 }
77