heap_trace_standalone.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include <string.h>
  7. #include <sdkconfig.h>
  8. #include <inttypes.h>
  9. #include "esp_log.h"
  10. #define HEAP_TRACE_SRCFILE /* don't warn on inclusion here */
  11. #include "esp_heap_trace.h"
  12. #undef HEAP_TRACE_SRCFILE
  13. #include "esp_heap_caps.h"
  14. #include "esp_attr.h"
  15. #include "freertos/FreeRTOS.h"
  16. #include "freertos/task.h"
  17. #include "esp_memory_utils.h"
  18. #include "sys/queue.h"
  19. static __attribute__((unused)) const char* TAG = "heaptrace";
  20. #define STACK_DEPTH CONFIG_HEAP_TRACING_STACK_DEPTH
  21. #if CONFIG_HEAP_TRACING_STANDALONE
  22. static portMUX_TYPE trace_mux = portMUX_INITIALIZER_UNLOCKED;
  23. static bool tracing;
  24. static heap_trace_mode_t mode;
  25. /* Define struct: linked list of records */
  26. TAILQ_HEAD(heap_trace_record_list_struct_t, heap_trace_record_t);
  27. typedef struct heap_trace_record_list_struct_t heap_trace_record_list_t;
  28. /* Linked List of Records */
  29. typedef struct {
  30. /* Buffer used for records. */
  31. heap_trace_record_t *buffer;
  32. /* Linked list of recorded allocations */
  33. heap_trace_record_list_t list;
  34. /* Linked list of available record objects */
  35. heap_trace_record_list_t unused;
  36. /* capacity of 'buffer' */
  37. size_t capacity;
  38. /* Count of entries in 'list' */
  39. size_t count;
  40. /* During execution, we remember the maximum
  41. value of 'count'. This can help you
  42. choose the right size for your buffer capacity.*/
  43. size_t high_water_mark;
  44. /* Has the buffer overflowed and lost trace entries? */
  45. bool has_overflowed;
  46. } records_t;
  47. // Forward Defines
  48. static void heap_trace_dump_base(bool internal_ram, bool psram);
  49. static void record_deep_copy(heap_trace_record_t *r_dest, const heap_trace_record_t *r_src);
  50. static void list_setup(void);
  51. static void list_remove(heap_trace_record_t *r_remove);
  52. static heap_trace_record_t* list_add(const heap_trace_record_t *r_append);
  53. static heap_trace_record_t* list_pop_unused(void);
  54. static heap_trace_record_t* list_find(void *p);
  55. static void list_find_and_remove(void* p);
  56. /* The actual records. */
  57. static records_t records;
  58. /* Actual number of allocations logged */
  59. static size_t total_allocations;
  60. /* Actual number of frees logged */
  61. static size_t total_frees;
  62. /* Used to speed up heap_trace_get */
  63. static heap_trace_record_t* r_get;
  64. static size_t r_get_idx;
  65. #if CONFIG_HEAP_TRACE_HASH_MAP
  66. // We use a hash_map to make locating a record by memory address very fast.
  67. // Key: addr // the memory address returned by malloc, calloc, realloc
  68. // Value: hash_map[hash(key)] // a list of records ptrs, which contains the relevant record.
  69. SLIST_HEAD(heap_trace_hash_list_struct_t, heap_trace_record_t);
  70. typedef struct heap_trace_hash_list_struct_t heap_trace_hash_list_t;
  71. static heap_trace_hash_list_t* hash_map; // array of lists
  72. static size_t total_hashmap_hits;
  73. static size_t total_hashmap_miss;
  74. static HEAP_IRAM_ATTR size_t hash_idx(void* p)
  75. {
  76. static const uint32_t fnv_prime = 16777619UL; // expression 2^24 + 2^8 + 0x93 (32 bits size)
  77. // since all the addresses are 4 bytes aligned, computing address * fnv_prime always gives
  78. // a modulo 4 number. The bit shift goal is to distribute more evenly the hashes in the
  79. // given range [0 , CONFIG_HEAP_TRACE_HASH_MAP_SIZE - 1].
  80. return ((((uint32_t)p >> 3) +
  81. ((uint32_t)p >> 5) +
  82. ((uint32_t)p >> 7)) * fnv_prime) % (uint32_t)CONFIG_HEAP_TRACE_HASH_MAP_SIZE;
  83. }
  84. static HEAP_IRAM_ATTR void map_add(heap_trace_record_t *r_add)
  85. {
  86. size_t idx = hash_idx(r_add->address);
  87. SLIST_INSERT_HEAD(&hash_map[idx], r_add, slist_hashmap);
  88. }
  89. static HEAP_IRAM_ATTR void map_remove(heap_trace_record_t *r_remove)
  90. {
  91. size_t idx = hash_idx(r_remove->address);
  92. SLIST_REMOVE(&hash_map[idx], r_remove, heap_trace_record_t, slist_hashmap);
  93. }
  94. static HEAP_IRAM_ATTR heap_trace_record_t* map_find(void *p)
  95. {
  96. size_t idx = hash_idx(p);
  97. heap_trace_record_t *r_cur = NULL;
  98. SLIST_FOREACH(r_cur, &hash_map[idx], slist_hashmap) {
  99. if (r_cur->address == p) {
  100. total_hashmap_hits++;
  101. return r_cur;
  102. }
  103. }
  104. total_hashmap_miss++;
  105. return NULL;
  106. }
  107. static HEAP_IRAM_ATTR heap_trace_record_t* map_find_and_remove(void *p)
  108. {
  109. size_t idx = hash_idx(p);
  110. heap_trace_record_t *r_cur = NULL;
  111. SLIST_FOREACH(r_cur, &hash_map[idx], slist_hashmap) {
  112. if (r_cur->address == p) {
  113. total_hashmap_hits++;
  114. SLIST_REMOVE(&hash_map[idx], r_cur, heap_trace_record_t, slist_hashmap);
  115. return r_cur;
  116. }
  117. }
  118. total_hashmap_miss++;
  119. return NULL;
  120. }
  121. #endif // CONFIG_HEAP_TRACE_HASH_MAP
  122. esp_err_t heap_trace_init_standalone(heap_trace_record_t *record_buffer, size_t num_records)
  123. {
  124. if (tracing) {
  125. return ESP_ERR_INVALID_STATE;
  126. }
  127. if (record_buffer == NULL || num_records == 0) {
  128. return ESP_ERR_INVALID_ARG;
  129. }
  130. #if CONFIG_HEAP_TRACE_HASH_MAP
  131. if (hash_map == NULL) {
  132. uint32_t map_size = sizeof(heap_trace_record_list_t) * CONFIG_HEAP_TRACE_HASH_MAP_SIZE;
  133. #if CONFIG_HEAP_TRACE_HASH_MAP_IN_EXT_RAM
  134. ESP_LOGI(TAG, "hashmap: allocating %" PRIu32 " bytes (PSRAM)\n", map_size);
  135. hash_map = heap_caps_calloc(1, map_size, MALLOC_CAP_SPIRAM);
  136. #else
  137. ESP_LOGI(TAG, "hashmap: allocating %" PRIu32 " bytes (Internal RAM)\n", map_size);
  138. hash_map = heap_caps_calloc(1, map_size, MALLOC_CAP_INTERNAL);
  139. #endif // CONFIG_HEAP_TRACE_HASH_MAP_IN_EXT_RAM
  140. }
  141. #endif // CONFIG_HEAP_TRACE_HASH_MAP
  142. records.buffer = record_buffer;
  143. records.capacity = num_records;
  144. return ESP_OK;
  145. }
  146. static esp_err_t set_tracing(bool enable)
  147. {
  148. if (tracing == enable) {
  149. return ESP_ERR_INVALID_STATE;
  150. }
  151. tracing = enable;
  152. return ESP_OK;
  153. }
  154. esp_err_t heap_trace_start(heap_trace_mode_t mode_param)
  155. {
  156. if (records.buffer == NULL || records.capacity == 0) {
  157. return ESP_ERR_INVALID_STATE;
  158. }
  159. portENTER_CRITICAL(&trace_mux);
  160. set_tracing(false);
  161. mode = mode_param;
  162. // clear buffers
  163. memset(records.buffer, 0, sizeof(heap_trace_record_t) * records.capacity);
  164. #if CONFIG_HEAP_TRACE_HASH_MAP
  165. for (size_t i = 0; i < (size_t)CONFIG_HEAP_TRACE_HASH_MAP_SIZE; i++) {
  166. SLIST_INIT(&hash_map[i]);
  167. }
  168. total_hashmap_hits = 0;
  169. total_hashmap_miss = 0;
  170. #endif // CONFIG_HEAP_TRACE_HASH_MAP
  171. records.count = 0;
  172. records.has_overflowed = false;
  173. list_setup();
  174. total_allocations = 0;
  175. total_frees = 0;
  176. const esp_err_t ret_val = set_tracing(true);
  177. portEXIT_CRITICAL(&trace_mux);
  178. return ret_val;
  179. }
  180. esp_err_t heap_trace_stop(void)
  181. {
  182. portENTER_CRITICAL(&trace_mux);
  183. const esp_err_t ret_val = set_tracing(false);
  184. portEXIT_CRITICAL(&trace_mux);
  185. return ret_val;
  186. }
  187. esp_err_t heap_trace_resume(void)
  188. {
  189. portENTER_CRITICAL(&trace_mux);
  190. const esp_err_t ret_val = set_tracing(true);
  191. portEXIT_CRITICAL(&trace_mux);
  192. return ret_val;
  193. }
  194. size_t heap_trace_get_count(void)
  195. {
  196. return records.count;
  197. }
  198. esp_err_t heap_trace_get(size_t index, heap_trace_record_t *r_out)
  199. {
  200. if (r_out == NULL) {
  201. return ESP_ERR_INVALID_STATE;
  202. }
  203. esp_err_t result = ESP_OK;
  204. portENTER_CRITICAL(&trace_mux);
  205. if (index >= records.count) {
  206. result = ESP_ERR_INVALID_ARG; /* out of range for 'count' */
  207. } else {
  208. // Perf: speed up sequential access
  209. if (r_get && r_get_idx == index - 1) {
  210. r_get = TAILQ_NEXT(r_get, tailq_list);
  211. r_get_idx = index;
  212. } else {
  213. // Iterate through through the linked list
  214. r_get = TAILQ_FIRST(&records.list);
  215. for (int i = 0; i < index; i++) {
  216. if (r_get == NULL) {
  217. break;
  218. }
  219. r_get = TAILQ_NEXT(r_get, tailq_list);
  220. r_get_idx = i + 1;
  221. }
  222. }
  223. // We already checked that index < records.count,
  224. // This could be indicative of memory corruption.
  225. assert(r_get != NULL);
  226. memcpy(r_out, r_get, sizeof(heap_trace_record_t));
  227. }
  228. portEXIT_CRITICAL(&trace_mux);
  229. return result;
  230. }
  231. esp_err_t heap_trace_summary(heap_trace_summary_t *summary)
  232. {
  233. if (summary == NULL) {
  234. return ESP_ERR_INVALID_ARG;
  235. }
  236. portENTER_CRITICAL(&trace_mux);
  237. summary->mode = mode;
  238. summary->total_allocations = total_allocations;
  239. summary->total_frees = total_frees;
  240. summary->count = records.count;
  241. summary->capacity = records.capacity;
  242. summary->high_water_mark = records.high_water_mark;
  243. summary->has_overflowed = records.has_overflowed;
  244. #if CONFIG_HEAP_TRACE_HASH_MAP
  245. summary->total_hashmap_hits = total_hashmap_hits;
  246. summary->total_hashmap_miss = total_hashmap_miss;
  247. #endif // CONFIG_HEAP_TRACE_HASH_MAP
  248. portEXIT_CRITICAL(&trace_mux);
  249. return ESP_OK;
  250. }
  251. void heap_trace_dump(void) {
  252. heap_trace_dump_caps(MALLOC_CAP_INTERNAL | MALLOC_CAP_SPIRAM);
  253. }
  254. void heap_trace_dump_caps(const uint32_t caps) {
  255. heap_trace_dump_base(caps & MALLOC_CAP_INTERNAL, caps & MALLOC_CAP_SPIRAM);
  256. }
  257. static void heap_trace_dump_base(bool internal_ram, bool psram)
  258. {
  259. portENTER_CRITICAL(&trace_mux);
  260. size_t delta_size = 0;
  261. size_t delta_allocs = 0;
  262. size_t start_count = records.count;
  263. esp_rom_printf("====== Heap Trace: %"PRIu32" records (%"PRIu32" capacity) ======\n",
  264. records.count, records.capacity);
  265. // Iterate through through the linked list
  266. heap_trace_record_t *r_cur = TAILQ_FIRST(&records.list);
  267. for (int i = 0; i < records.count; i++) {
  268. // check corruption
  269. if (r_cur == NULL) {
  270. esp_rom_printf("\nError: heap trace linked list is corrupt. expected more records.\n");
  271. break;
  272. }
  273. bool should_print = r_cur->address != NULL &&
  274. ((psram && internal_ram) ||
  275. (internal_ram && esp_ptr_internal(r_cur->address)) ||
  276. (psram && esp_ptr_external_ram(r_cur->address)));
  277. if (should_print) {
  278. const char* label = "";
  279. if (esp_ptr_internal(r_cur->address)) {
  280. label = ", Internal";
  281. }
  282. if (esp_ptr_external_ram(r_cur->address)) {
  283. label = ", PSRAM";
  284. }
  285. esp_rom_printf("%6d bytes (@ %p%s) allocated CPU %d ccount 0x%08x caller ",
  286. r_cur->size, r_cur->address, label, r_cur->ccount & 1, r_cur->ccount & ~3);
  287. for (int j = 0; j < STACK_DEPTH && r_cur->alloced_by[j] != 0; j++) {
  288. esp_rom_printf("%p%s", r_cur->alloced_by[j],
  289. (j < STACK_DEPTH - 1) ? ":" : "");
  290. }
  291. if (mode != HEAP_TRACE_ALL || STACK_DEPTH == 0 || r_cur->freed_by[0] == NULL) {
  292. delta_size += r_cur->size;
  293. delta_allocs++;
  294. esp_rom_printf("\n");
  295. } else {
  296. esp_rom_printf("\nfreed by ");
  297. for (int j = 0; j < STACK_DEPTH; j++) {
  298. esp_rom_printf("%p%s", r_cur->freed_by[j],
  299. (j < STACK_DEPTH - 1) ? ":" : "\n");
  300. }
  301. }
  302. }
  303. r_cur = TAILQ_NEXT(r_cur, tailq_list);
  304. }
  305. esp_rom_printf("====== Heap Trace Summary ======\n");
  306. if (mode == HEAP_TRACE_ALL) {
  307. esp_rom_printf("Mode: Heap Trace All\n");
  308. esp_rom_printf("%"PRIu32" bytes alive in trace (%"PRIu32"/%"PRIu32" allocations)\n",
  309. delta_size, delta_allocs, heap_trace_get_count());
  310. } else {
  311. esp_rom_printf("Mode: Heap Trace Leaks\n");
  312. esp_rom_printf("%"PRIu32" bytes 'leaked' in trace (%"PRIu32" allocations)\n", delta_size, delta_allocs);
  313. }
  314. esp_rom_printf("records: %"PRIu32" (%"PRIu32" capacity, %"PRIu32" high water mark)\n",
  315. records.count, records.capacity, records.high_water_mark);
  316. #if CONFIG_HEAP_TRACE_HASH_MAP
  317. esp_rom_printf("hashmap: %"PRIu32" capacity (%"PRIu32" hits, %"PRIu32" misses)\n",
  318. (size_t)CONFIG_HEAP_TRACE_HASH_MAP_SIZE, total_hashmap_hits, total_hashmap_miss);
  319. #endif // CONFIG_HEAP_TRACE_HASH_MAP
  320. esp_rom_printf("total allocations: %"PRIu32"\n", total_allocations);
  321. esp_rom_printf("total frees: %"PRIu32"\n", total_frees);
  322. if (start_count != records.count) { // only a problem if trace isn't stopped before dumping
  323. esp_rom_printf("(NB: New entries were traced while dumping, so trace dump may have duplicate entries.)\n");
  324. }
  325. if (records.has_overflowed) {
  326. esp_rom_printf("(NB: Internal Buffer has overflowed, so trace data is incomplete.)\n");
  327. }
  328. esp_rom_printf("================================\n");
  329. portEXIT_CRITICAL(&trace_mux);
  330. }
  331. /* Add a new allocation to the heap trace records */
  332. static HEAP_IRAM_ATTR void record_allocation(const heap_trace_record_t *r_allocation)
  333. {
  334. if (!tracing || r_allocation->address == NULL) {
  335. return;
  336. }
  337. portENTER_CRITICAL(&trace_mux);
  338. if (tracing) {
  339. // If buffer is full, pop off the oldest
  340. // record to make more space
  341. if (records.count == records.capacity) {
  342. records.has_overflowed = true;
  343. heap_trace_record_t *r_first = TAILQ_FIRST(&records.list);
  344. // always remove from hashmap first since list_remove is setting address field
  345. // of the record to 0x00
  346. #if CONFIG_HEAP_TRACE_HASH_MAP
  347. map_remove(r_first);
  348. #endif
  349. list_remove(r_first);
  350. }
  351. // push onto end of list
  352. list_add(r_allocation);
  353. total_allocations++;
  354. }
  355. portEXIT_CRITICAL(&trace_mux);
  356. }
  357. /* record a free event in the heap trace log
  358. For HEAP_TRACE_ALL, this means filling in the freed_by pointer.
  359. For HEAP_TRACE_LEAKS, this means removing the record from the log.
  360. callers is an array of STACK_DEPTH function pointer from the call stack
  361. leading to the call of record_free.
  362. */
  363. static HEAP_IRAM_ATTR void record_free(void *p, void **callers)
  364. {
  365. if (!tracing || p == NULL) {
  366. return;
  367. }
  368. portENTER_CRITICAL(&trace_mux);
  369. // return directly if records.count == 0. In case of hashmap being used
  370. // this prevents the hashmap to return an item that is no longer in the
  371. // records list.
  372. if (records.count == 0) {
  373. portEXIT_CRITICAL(&trace_mux);
  374. return;
  375. }
  376. if (tracing) {
  377. total_frees++;
  378. if (mode == HEAP_TRACE_ALL) {
  379. heap_trace_record_t *r_found = list_find(p);
  380. if (r_found != NULL) {
  381. // add 'freed_by' info to the record
  382. memcpy(r_found->freed_by, callers, sizeof(void *) * STACK_DEPTH);
  383. }
  384. } else { // HEAP_TRACE_LEAKS
  385. // Leak trace mode, once an allocation is freed
  386. // we remove it from the list & hashmap
  387. list_find_and_remove(p);
  388. }
  389. }
  390. portEXIT_CRITICAL(&trace_mux);
  391. }
  392. // connect all records into a linked list of 'unused' records
  393. static void list_setup(void)
  394. {
  395. TAILQ_INIT(&records.list);
  396. TAILQ_INIT(&records.unused);
  397. for (int i = 0; i < records.capacity; i++) {
  398. heap_trace_record_t *r_cur = &records.buffer[i];
  399. TAILQ_INSERT_TAIL(&records.unused, r_cur, tailq_list);
  400. }
  401. }
  402. /* 1. removes record r_remove from records.list,
  403. 2. places it into records.unused */
  404. static HEAP_IRAM_ATTR void list_remove(heap_trace_record_t* r_remove)
  405. {
  406. assert(records.count > 0);
  407. // remove from records.list
  408. TAILQ_REMOVE(&records.list, r_remove, tailq_list);
  409. // set as unused
  410. r_remove->address = 0;
  411. r_remove->size = 0;
  412. // add to records.unused
  413. TAILQ_INSERT_HEAD(&records.unused, r_remove, tailq_list);
  414. // decrement
  415. records.count--;
  416. }
  417. // pop record from unused list
  418. static HEAP_IRAM_ATTR heap_trace_record_t* list_pop_unused(void)
  419. {
  420. // no records left?
  421. if (records.count >= records.capacity) {
  422. return NULL;
  423. }
  424. // get from records.unused
  425. heap_trace_record_t *r_unused = TAILQ_FIRST(&records.unused);
  426. assert(r_unused->address == NULL);
  427. assert(r_unused->size == 0);
  428. // remove from records.unused
  429. TAILQ_REMOVE(&records.unused, r_unused, tailq_list);
  430. return r_unused;
  431. }
  432. // deep copy a record.
  433. // Note: only copies the *allocation data*, not the next & prev ptrs
  434. static HEAP_IRAM_ATTR void record_deep_copy(heap_trace_record_t *r_dest, const heap_trace_record_t *r_src)
  435. {
  436. r_dest->ccount = r_src->ccount;
  437. r_dest->address = r_src->address;
  438. r_dest->size = r_src->size;
  439. memcpy(r_dest->freed_by, r_src->freed_by, sizeof(void *) * STACK_DEPTH);
  440. memcpy(r_dest->alloced_by, r_src->alloced_by, sizeof(void *) * STACK_DEPTH);
  441. }
  442. // Append a record to records.list
  443. // Note: This deep copies r_append
  444. static HEAP_IRAM_ATTR heap_trace_record_t* list_add(const heap_trace_record_t *r_append)
  445. {
  446. if (records.count < records.capacity) {
  447. // get unused record
  448. heap_trace_record_t *r_dest = list_pop_unused();
  449. // we checked that there is capacity, so this
  450. // should never be null.
  451. assert(r_dest != NULL);
  452. // copy allocation data
  453. record_deep_copy(r_dest, r_append);
  454. // append to records.list
  455. TAILQ_INSERT_TAIL(&records.list, r_dest, tailq_list);
  456. // increment
  457. records.count++;
  458. // high water mark
  459. if (records.count > records.high_water_mark) {
  460. records.high_water_mark = records.count;
  461. }
  462. #if CONFIG_HEAP_TRACE_HASH_MAP
  463. map_add(r_dest);
  464. #endif
  465. return r_dest;
  466. } else {
  467. records.has_overflowed = true;
  468. return NULL;
  469. }
  470. }
  471. // search records.list for the allocation record matching this address
  472. static HEAP_IRAM_ATTR heap_trace_record_t* list_find(void* p)
  473. {
  474. heap_trace_record_t *r_found = NULL;
  475. #if CONFIG_HEAP_TRACE_HASH_MAP
  476. // check the hashmap
  477. r_found = map_find(p);
  478. if (r_found != NULL) {
  479. return r_found;
  480. }
  481. #endif
  482. // to the end of the list and most allocations are short lived.
  483. heap_trace_record_t *r_cur = NULL;
  484. TAILQ_FOREACH(r_cur, &records.list, tailq_list) {
  485. if (r_cur->address == p) {
  486. r_found = r_cur;
  487. break;
  488. }
  489. }
  490. return r_found;
  491. }
  492. static HEAP_IRAM_ATTR void list_find_and_remove(void* p)
  493. {
  494. #if CONFIG_HEAP_TRACE_HASH_MAP
  495. heap_trace_record_t *r_found = map_find_and_remove(p);
  496. if (r_found != NULL) {
  497. list_remove(r_found);
  498. return;
  499. }
  500. #endif
  501. heap_trace_record_t *r_cur = NULL;
  502. TAILQ_FOREACH(r_cur, &records.list, tailq_list) {
  503. if (r_cur->address == p) {
  504. list_remove(r_cur);
  505. break;
  506. }
  507. }
  508. }
  509. #include "heap_trace.inc"
  510. #endif // CONFIG_HEAP_TRACING_STANDALONE