esp_sysview_trace.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include <stdarg.h>
  19. #include "esp_err.h"
  20. #include "SEGGER_RTT.h" // SEGGER_RTT_ESP32_Flush
  21. #include "esp_app_trace_util.h" // ESP_APPTRACE_TMO_INFINITE
  22. /**
  23. * @brief Flushes remaining data in SystemView trace buffer to host.
  24. *
  25. * @param tmo Timeout for operation (in us). Use ESP_APPTRACE_TMO_INFINITE to wait indefinetly.
  26. *
  27. * @return ESP_OK.
  28. */
  29. static inline esp_err_t esp_sysview_flush(uint32_t tmo)
  30. {
  31. SEGGER_RTT_ESP32_Flush(0, tmo);
  32. return ESP_OK;
  33. }
  34. /**
  35. * @brief vprintf-like function to sent log messages to the host.
  36. *
  37. * @param format Address of format string.
  38. * @param args List of arguments.
  39. *
  40. * @return Number of bytes written.
  41. */
  42. int esp_sysview_vprintf(const char * format, va_list args);
  43. /**
  44. * @brief Starts SystemView heap tracing.
  45. *
  46. * @param tmo Timeout (in us) to wait for the host to be connected. Use -1 to wait forever.
  47. *
  48. * @return ESP_OK on success, ESP_ERR_TIMEOUT if operation has been timed out.
  49. */
  50. esp_err_t esp_sysview_heap_trace_start(uint32_t tmo);
  51. /**
  52. * @brief Stops SystemView heap tracing.
  53. *
  54. * @return ESP_OK.
  55. */
  56. esp_err_t esp_sysview_heap_trace_stop(void);
  57. /**
  58. * @brief Sends heap allocation event to the host.
  59. *
  60. * @param addr Address of allocated block.
  61. * @param size Size of allocated block.
  62. * @param callers Pointer to array with callstack addresses.
  63. * Array size must be CONFIG_HEAP_TRACING_STACK_DEPTH.
  64. */
  65. void esp_sysview_heap_trace_alloc(void *addr, uint32_t size, const void *callers);
  66. /**
  67. * @brief Sends heap de-allocation event to the host.
  68. *
  69. * @param addr Address of de-allocated block.
  70. * @param callers Pointer to array with callstack addresses.
  71. * Array size must be CONFIG_HEAP_TRACING_STACK_DEPTH.
  72. */
  73. void esp_sysview_heap_trace_free(void *addr, const void *callers);
  74. #ifdef __cplusplus
  75. }
  76. #endif
  77. #endif //ESP_SYSVIEW_TRACE_H_