heap trace standalone: Fix initialization of the unused linked list, update tests

- Call TAILQ_INSERT_TAIL in linked_list_setup to add unused records from the tail of the list
- Fix test "heap trace leak check" to expect that after a free, the record is zeroed instead of checking that
  the whole list of records is moved by one index in the array.
- Use esp_rom_printf() under lock instead of printf() since it does not rely on interrupts.
This commit is contained in:
Guillaume Souchere
2023-02-14 09:48:14 +01:00
parent a555563558
commit 2cf9236f6c
5 changed files with 96 additions and 73 deletions

View File

@@ -30,16 +30,16 @@ typedef enum {
/**
* @brief Trace record data type. Stores information about an allocated region of memory.
*/
struct heap_trace_record_struct_t {
typedef struct heap_trace_record_t {
uint32_t ccount; ///< CCOUNT of the CPU when the allocation was made. LSB (bit value 1) is the CPU number (0 or 1).
void *address; ///< Address which was allocated. If NULL, then this record is empty.
size_t size; ///< Size of the allocation
void *alloced_by[CONFIG_HEAP_TRACING_STACK_DEPTH]; ///< Call stack of the caller which allocated the memory.
void *freed_by[CONFIG_HEAP_TRACING_STACK_DEPTH]; ///< Call stack of the caller which freed the memory (all zero if not freed.)
TAILQ_ENTRY(heap_trace_record_struct_t) tailq; ///< Linked list: prev & next records
};
typedef struct heap_trace_record_struct_t heap_trace_record_t;
#ifdef CONFIG_HEAP_TRACING_STANDALONE
TAILQ_ENTRY(heap_trace_record_t) tailq; ///< Linked list: prev & next records
#endif // CONFIG_HEAP_TRACING_STANDALONE
} heap_trace_record_t;
/**
* @brief Stores information about the result of a heap trace.