feat(esp_system): Add esp_backtrace_print_all_tasks()

This commit adds esp_backtrace_print_all_tasks() which prints the backtraces
of all tasks at runtime.

Closes https://github.com/espressif/esp-idf/issues/9708
CLoses https://github.com/espressif/esp-idf/pull/11575

[Omar Chebib: Prevent task switching while printing backtraces of tasks.]
[Omar Chebib: Ensure all task stacks are flushed from register to RAM.]
[Omar Chebib: Removed esp_task_snapshot_to_backtrace_frame() as task snapshot is private API.]
[Omar Chebib: Added test case for esp_backtrace_print_all_tasks().]

Signed-off-by: Omar Chebib <omar.chebib@espressif.com>
This commit is contained in:
Chip Weinberger
2023-06-01 17:57:08 -07:00
committed by Darian Leung
parent 558392b998
commit 3686689a2a
5 changed files with 213 additions and 14 deletions
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -13,8 +13,9 @@ extern "C" {
#ifndef __ASSEMBLER__
#include <stdbool.h>
#include "esp_err.h"
#include "sdkconfig.h"
#include "soc/soc.h" // [refactor-todo] IDF-2297
#include "esp_err.h"
#include "esp_cpu.h"
/*
@@ -114,6 +115,20 @@ esp_err_t esp_backtrace_print_from_frame(int depth, const esp_backtrace_frame_t*
*/
esp_err_t esp_backtrace_print(int depth);
/**
* @brief Print the backtrace of all tasks
*
* @param depth The maximum number of stack frames to print (must be > 0)
*
* @note Users must ensure that no tasks are created or deleted while this function is running.
* @note This function must be called from a task context.
*
* @return
* - ESP_OK All backtraces successfully printed to completion or to depth limit
* - ESP_FAIL One or more backtraces are corrupt
*/
esp_err_t esp_backtrace_print_all_tasks(int depth);
/**
* @brief Set a watchpoint to break/panic when a certain memory range is accessed.
* Superseded by esp_cpu_set_watchpoint in esp_cpu.h.