tracing_format_async.c 1.5 KB

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