freertos_debug.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include "sdkconfig.h"
  8. #include "freertos/FreeRTOS.h"
  9. #include "freertos/task.h"
  10. /*
  11. * This header contains private API used by various ESP-IDF debugging features (e.g., esp_gdbstub).
  12. */
  13. /* *INDENT-OFF* */
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /* *INDENT-ON* */
  18. /* -------------------------------------------------- Task Snapshot ------------------------------------------------- */
  19. /**
  20. * @brief Task Snapshot structure
  21. *
  22. * - Used with the uxTaskGetSnapshotAll() function to save memory snapshot of each task in the system.
  23. * - We need this structure because TCB_t is defined (hidden) in tasks.c.
  24. */
  25. typedef struct xTASK_SNAPSHOT
  26. {
  27. void * pxTCB; /*!< Address of the task control block. */
  28. StackType_t * pxTopOfStack; /*!< Points to the location of the last item placed on the tasks stack. */
  29. StackType_t * pxEndOfStack; /*!< Points to the end of the stack. pxTopOfStack < pxEndOfStack, stack grows hi2lo
  30. * pxTopOfStack > pxEndOfStack, stack grows lo2hi*/
  31. } TaskSnapshot_t;
  32. /**
  33. * @brief Iterate over all tasks in the system
  34. *
  35. * - This function can be used to iterate over every task in the system
  36. * - The first call to this function must set pxTask to NULL
  37. * - When all functions have been iterated, this function will return NULL.
  38. *
  39. * @note This function should only be called when FreeRTOS is no longer running (e.g., during a panic) as this function
  40. * does not acquire any locks.
  41. * @param pxTask Handle of the previous task (or NULL on the first call of this function)
  42. * @return TaskHandle_t Handle of the next task (or NULL when all tasks have been iterated over)
  43. */
  44. TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask );
  45. /**
  46. * @brief Fill a TaskSnapshot_t structure for specified task.
  47. *
  48. * - This function is used by the panic handler to get the snapshot of a particular task.
  49. *
  50. * @note This function should only be called when FreeRTOS is no longer running (e.g., during a panic) as this function
  51. * does not acquire any locks.
  52. * @param[in] pxTask Task's handle
  53. * @param[out] pxTaskSnapshot Snapshot of the task
  54. * @return pdTRUE if operation was successful else pdFALSE
  55. */
  56. BaseType_t vTaskGetSnapshot( TaskHandle_t pxTask,
  57. TaskSnapshot_t * pxTaskSnapshot );
  58. /**
  59. * @brief Fill an array of TaskSnapshot_t structures for every task in the system
  60. *
  61. * - This function is used by the panic handler to get a snapshot of all tasks in the system
  62. *
  63. * @note This function should only be called when FreeRTOS is no longer running (e.g., during a panic) as this function
  64. * does not acquire any locks.
  65. * @param[out] pxTaskSnapshotArray Array of TaskSnapshot_t structures filled by this function
  66. * @param[in] uxArrayLength Length of the provided array
  67. * @param[out] pxTCBSize Size of the a task's TCB structure
  68. * @return UBaseType_t
  69. */
  70. UBaseType_t uxTaskGetSnapshotAll( TaskSnapshot_t * const pxTaskSnapshotArray,
  71. const UBaseType_t uxArrayLength,
  72. UBaseType_t * const pxTCBSize );
  73. /* ----------------------------------------------------- Misc ----------------------------------------------------- */
  74. /**
  75. * @brief Get a void pointer to the current TCB of a particular core
  76. *
  77. * @note This function provides no guarantee that the return TCB will still be the current task (or that the task still
  78. * exists) when it returns. It is the caller's responsibility to ensure that the task does not get scheduled or deleted.
  79. * @param xCoreID The core to query
  80. * @return Void pointer to current TCB
  81. */
  82. void * pvTaskGetCurrentTCBForCore( BaseType_t xCoreID );
  83. /* *INDENT-OFF* */
  84. #ifdef __cplusplus
  85. }
  86. #endif
  87. /* *INDENT-ON* */