esp_sysview_trace.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef ESP_SYSVIEW_TRACE_H_
  7. #define ESP_SYSVIEW_TRACE_H_
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. #include <stdarg.h>
  12. #include "esp_err.h"
  13. #include "SEGGER_RTT.h" // SEGGER_RTT_ESP_Flush
  14. #include "esp_app_trace_util.h" // ESP_APPTRACE_TMO_INFINITE
  15. /**
  16. * @brief Flushes remaining data in SystemView trace buffer to host.
  17. *
  18. * @param tmo Timeout for operation (in us). Use ESP_APPTRACE_TMO_INFINITE to wait indefinetly.
  19. *
  20. * @return ESP_OK.
  21. */
  22. static inline esp_err_t esp_sysview_flush(uint32_t tmo)
  23. {
  24. SEGGER_RTT_ESP_Flush(0, tmo);
  25. return ESP_OK;
  26. }
  27. /**
  28. * @brief vprintf-like function to sent log messages to the host.
  29. *
  30. * @param format Address of format string.
  31. * @param args List of arguments.
  32. *
  33. * @return Number of bytes written.
  34. */
  35. int esp_sysview_vprintf(const char * format, va_list args);
  36. /**
  37. * @brief Starts SystemView heap tracing.
  38. *
  39. * @param tmo Timeout (in us) to wait for the host to be connected. Use -1 to wait forever.
  40. *
  41. * @return ESP_OK on success, ESP_ERR_TIMEOUT if operation has been timed out.
  42. */
  43. esp_err_t esp_sysview_heap_trace_start(uint32_t tmo);
  44. /**
  45. * @brief Stops SystemView heap tracing.
  46. *
  47. * @return ESP_OK.
  48. */
  49. esp_err_t esp_sysview_heap_trace_stop(void);
  50. /**
  51. * @brief Sends heap allocation event to the host.
  52. *
  53. * @param addr Address of allocated block.
  54. * @param size Size of allocated block.
  55. * @param callers Pointer to array with callstack addresses.
  56. * Array size must be CONFIG_HEAP_TRACING_STACK_DEPTH.
  57. */
  58. void esp_sysview_heap_trace_alloc(void *addr, uint32_t size, const void *callers);
  59. /**
  60. * @brief Sends heap de-allocation event to the host.
  61. *
  62. * @param addr Address of de-allocated block.
  63. * @param callers Pointer to array with callstack addresses.
  64. * Array size must be CONFIG_HEAP_TRACING_STACK_DEPTH.
  65. */
  66. void esp_sysview_heap_trace_free(void *addr, const void *callers);
  67. #ifdef __cplusplus
  68. }
  69. #endif
  70. #endif //ESP_SYSVIEW_TRACE_H_