esp_sysview_trace.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Copyright 2018 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef ESP_SYSVIEW_TRACE_H_
  14. #define ESP_SYSVIEW_TRACE_H_
  15. #include <stdarg.h>
  16. #include "esp_err.h"
  17. #include "SEGGER_RTT.h" // SEGGER_RTT_ESP32_Flush
  18. #include "esp_app_trace_util.h" // ESP_APPTRACE_TMO_INFINITE
  19. /**
  20. * @brief Flushes remaining data in SystemView trace buffer to host.
  21. *
  22. * @param tmo Timeout for operation (in us). Use ESP_APPTRACE_TMO_INFINITE to wait indefinetly.
  23. *
  24. * @return ESP_OK.
  25. */
  26. static inline esp_err_t esp_sysview_flush(uint32_t tmo)
  27. {
  28. SEGGER_RTT_ESP32_Flush(0, tmo);
  29. return ESP_OK;
  30. }
  31. /**
  32. * @brief vprintf-like function to sent log messages to the host.
  33. *
  34. * @param format Address of format string.
  35. * @param args List of arguments.
  36. *
  37. * @return Number of bytes written.
  38. */
  39. int esp_sysview_vprintf(const char * format, va_list args);
  40. /**
  41. * @brief Starts SystemView heap tracing.
  42. *
  43. * @param tmo Timeout (in us) to wait for the host to be connected. Use -1 to wait forever.
  44. *
  45. * @return ESP_OK on success, ESP_ERR_TIMEOUT if operation has been timed out.
  46. */
  47. esp_err_t esp_sysview_heap_trace_start(uint32_t tmo);
  48. /**
  49. * @brief Stops SystemView heap tracing.
  50. *
  51. * @return ESP_OK.
  52. */
  53. esp_err_t esp_sysview_heap_trace_stop(void);
  54. /**
  55. * @brief Sends heap allocation event to the host.
  56. *
  57. * @param addr Address of allocated block.
  58. * @param size Size of allocated block.
  59. * @param callers Pointer to array with callstack addresses.
  60. * Array size must be CONFIG_HEAP_TRACING_STACK_DEPTH.
  61. */
  62. void esp_sysview_heap_trace_alloc(void *addr, uint32_t size, const void *callers);
  63. /**
  64. * @brief Sends heap de-allocation event to the host.
  65. *
  66. * @param addr Address of de-allocated block.
  67. * @param callers Pointer to array with callstack addresses.
  68. * Array size must be CONFIG_HEAP_TRACING_STACK_DEPTH.
  69. */
  70. void esp_sysview_heap_trace_free(void *addr, const void *callers);
  71. #endif //ESP_SYSVIEW_TRACE_H_