OpenOCD
esp32_apptrace.c File Reference
Include dependency graph for esp32_apptrace.c:

Go to the source code of this file.

Data Structures

struct  esp32_apptrace_block
 
struct  esp32_apptrace_dest_file_data
 
struct  esp32_apptrace_dest_tcp_data
 
struct  esp32_apptrace_target_state
 
struct  esp_apptrace_target2host_hdr
 

Macros

#define APPTRACE_BLOCK_SIZE_OFFSET   0
 
#define APPTRACE_WR_SIZE_OFFSET   2
 
#define ESP32_APPTRACE_CMD_NUM_ARG_CHECK(_cmd_, _arg_, _start_, _end_)
 
#define ESP32_APPTRACE_TGT_STATE_TMO   5000
 
#define ESP32_APPTRACE_USER_BLOCK_CORE(_v_)   ((_v_) >> 15)
 
#define ESP32_APPTRACE_USER_BLOCK_HDR_SZ   4
 
#define ESP32_APPTRACE_USER_BLOCK_LEN(_v_)   ((_v_) & ~BIT(15))
 
#define ESP_APPTRACE_BLOCKS_POOL_SZ   10
 
#define ESP_APPTRACE_CMD_MODE_GEN   0
 
#define ESP_APPTRACE_CMD_MODE_SYNC   3
 
#define ESP_APPTRACE_CMD_MODE_SYSVIEW   1
 
#define ESP_APPTRACE_CMD_MODE_SYSVIEW_MCORE   2
 

Functions

 COMMAND_HANDLER (esp32_cmd_apptrace)
 
 COMMAND_HANDLER (esp32_cmd_sysview)
 
 COMMAND_HANDLER (esp32_cmd_sysview_mcore)
 
static int esp32_apptrace_block_free (struct esp32_apptrace_cmd_ctx *ctx, struct esp32_apptrace_block *block)
 
static void esp32_apptrace_blocks_pool_cleanup (struct esp32_apptrace_cmd_ctx *ctx)
 
static int esp32_apptrace_check_connection (struct esp32_apptrace_cmd_ctx *ctx)
 
void esp32_apptrace_cmd_args_parse (struct esp32_apptrace_cmd_ctx *cmd_ctx, struct esp32_apptrace_cmd_data *cmd_data, const char **argv, int argc)
 
static int esp32_apptrace_cmd_cleanup (struct esp32_apptrace_cmd_ctx *cmd_ctx)
 
int esp32_apptrace_cmd_ctx_cleanup (struct esp32_apptrace_cmd_ctx *cmd_ctx)
 
int esp32_apptrace_cmd_ctx_init (struct esp32_apptrace_cmd_ctx *cmd_ctx, struct command_invocation *cmd, int mode)
 
static int esp32_apptrace_cmd_init (struct esp32_apptrace_cmd_ctx *cmd_ctx, struct command_invocation *cmd, int mode, const char **argv, int argc)
 
static void esp32_apptrace_cmd_stop (struct esp32_apptrace_cmd_ctx *ctx)
 
static int esp32_apptrace_connect_targets (struct esp32_apptrace_cmd_ctx *ctx, bool conn, bool resume_target)
 
static int esp32_apptrace_console_dest_cleanup (void *priv)
 
static int esp32_apptrace_console_dest_init (struct esp32_apptrace_dest *dest, const char *dest_name)
 
static int esp32_apptrace_console_dest_write (void *priv, uint8_t *data, int size)
 
static int esp32_apptrace_core_id_get (struct target *target, uint8_t *hdr_buf)
 
static int esp32_apptrace_data_processor (void *priv)
 
int esp32_apptrace_dest_cleanup (struct esp32_apptrace_dest dest[], unsigned int max_dests)
 
int esp32_apptrace_dest_init (struct esp32_apptrace_dest dest[], const char *dest_paths[], unsigned int max_dests)
 
static int esp32_apptrace_file_dest_cleanup (void *priv)
 
static int esp32_apptrace_file_dest_init (struct esp32_apptrace_dest *dest, const char *dest_name)
 
static int esp32_apptrace_file_dest_write (void *priv, uint8_t *data, int size)
 
static struct esp32_apptrace_blockesp32_apptrace_free_block_get (struct esp32_apptrace_cmd_ctx *ctx)
 
static int esp32_apptrace_get_data_info (struct esp32_apptrace_cmd_ctx *ctx, struct esp32_apptrace_target_state *target_state, uint32_t *fired_target_num)
 
static int esp32_apptrace_handle_trace_block (struct esp32_apptrace_cmd_ctx *ctx, struct esp32_apptrace_block *block)
 
static int esp32_apptrace_poll (void *priv)
 
static void esp32_apptrace_print_stats (struct esp32_apptrace_cmd_ctx *ctx)
 
static int esp32_apptrace_process_data (struct esp32_apptrace_cmd_ctx *ctx, unsigned int core_id, uint8_t *data, uint32_t data_len)
 
static struct esp32_apptrace_blockesp32_apptrace_ready_block_get (struct esp32_apptrace_cmd_ctx *ctx)
 
static int esp32_apptrace_ready_block_put (struct esp32_apptrace_cmd_ctx *ctx, struct esp32_apptrace_block *block)
 
static int esp32_apptrace_safe_halt_targets (struct esp32_apptrace_cmd_ctx *ctx, struct esp32_apptrace_target_state *targets)
 
static int esp32_apptrace_tcp_dest_cleanup (void *priv)
 
static int esp32_apptrace_tcp_dest_init (struct esp32_apptrace_dest *dest, const char *dest_name)
 
static int esp32_apptrace_tcp_dest_write (void *priv, uint8_t *data, int size)
 
static uint32_t esp32_apptrace_usr_block_check (struct esp32_apptrace_cmd_ctx *ctx, uint8_t *hdr_buf)
 
static uint32_t esp32_apptrace_usr_block_len_get (struct target *target, uint8_t *hdr_buf, uint32_t *wr_len)
 
static int esp32_apptrace_wait4halt (struct esp32_apptrace_cmd_ctx *ctx, struct target *target)
 
static int esp32_apptrace_wait_tracing_finished (struct esp32_apptrace_cmd_ctx *ctx)
 
static int esp32_cmd_apptrace_generic (struct command_invocation *cmd, int mode, const char **argv, int argc)
 
static int esp32_sysview_start (struct esp32_apptrace_cmd_ctx *ctx)
 
static int esp32_sysview_stop (struct esp32_apptrace_cmd_ctx *ctx)
 
int esp_apptrace_usr_block_write (const struct esp32_apptrace_hw *hw, struct target *target, uint32_t block_id, const uint8_t *data, uint32_t size)
 
static bool is_sysview_mode (int mode)
 

Variables

const struct command_registration esp32_apptrace_command_handlers []
 
static const bool s_time_stats_enable = true
 

Macro Definition Documentation

◆ APPTRACE_BLOCK_SIZE_OFFSET

#define APPTRACE_BLOCK_SIZE_OFFSET   0

Definition at line 69 of file esp32_apptrace.c.

◆ APPTRACE_WR_SIZE_OFFSET

#define APPTRACE_WR_SIZE_OFFSET   2

Definition at line 70 of file esp32_apptrace.c.

◆ ESP32_APPTRACE_CMD_NUM_ARG_CHECK

#define ESP32_APPTRACE_CMD_NUM_ARG_CHECK (   _cmd_,
  _arg_,
  _start_,
  _end_ 
)
Value:
do { \
if ((_arg_) == 0 && (_start_) == (_end_)) { \
command_print(_cmd_, "Invalid '" # _arg_ "' arg!"); \
return; \
} \
} while (0)

Definition at line 506 of file esp32_apptrace.c.

◆ ESP32_APPTRACE_TGT_STATE_TMO

#define ESP32_APPTRACE_TGT_STATE_TMO   5000

Definition at line 48 of file esp32_apptrace.c.

◆ ESP32_APPTRACE_USER_BLOCK_CORE

#define ESP32_APPTRACE_USER_BLOCK_CORE (   _v_)    ((_v_) >> 15)

Definition at line 38 of file esp32_apptrace.c.

◆ ESP32_APPTRACE_USER_BLOCK_HDR_SZ

#define ESP32_APPTRACE_USER_BLOCK_HDR_SZ   4

Definition at line 41 of file esp32_apptrace.c.

◆ ESP32_APPTRACE_USER_BLOCK_LEN

#define ESP32_APPTRACE_USER_BLOCK_LEN (   _v_)    ((_v_) & ~BIT(15))

Definition at line 39 of file esp32_apptrace.c.

◆ ESP_APPTRACE_BLOCKS_POOL_SZ

#define ESP_APPTRACE_BLOCKS_POOL_SZ   10

Definition at line 49 of file esp32_apptrace.c.

◆ ESP_APPTRACE_CMD_MODE_GEN

#define ESP_APPTRACE_CMD_MODE_GEN   0

Definition at line 43 of file esp32_apptrace.c.

◆ ESP_APPTRACE_CMD_MODE_SYNC

#define ESP_APPTRACE_CMD_MODE_SYNC   3

Definition at line 46 of file esp32_apptrace.c.

◆ ESP_APPTRACE_CMD_MODE_SYSVIEW

#define ESP_APPTRACE_CMD_MODE_SYSVIEW   1

Definition at line 44 of file esp32_apptrace.c.

◆ ESP_APPTRACE_CMD_MODE_SYSVIEW_MCORE

#define ESP_APPTRACE_CMD_MODE_SYSVIEW_MCORE   2

Definition at line 45 of file esp32_apptrace.c.

Function Documentation

◆ COMMAND_HANDLER() [1/3]

COMMAND_HANDLER ( esp32_cmd_apptrace  )

◆ COMMAND_HANDLER() [2/3]

COMMAND_HANDLER ( esp32_cmd_sysview  )

◆ COMMAND_HANDLER() [3/3]

COMMAND_HANDLER ( esp32_cmd_sysview_mcore  )

◆ esp32_apptrace_block_free()

static int esp32_apptrace_block_free ( struct esp32_apptrace_cmd_ctx ctx,
struct esp32_apptrace_block block 
)
static

◆ esp32_apptrace_blocks_pool_cleanup()

◆ esp32_apptrace_check_connection()

◆ esp32_apptrace_cmd_args_parse()

◆ esp32_apptrace_cmd_cleanup()

◆ esp32_apptrace_cmd_ctx_cleanup()

◆ esp32_apptrace_cmd_ctx_init()

int esp32_apptrace_cmd_ctx_init ( struct esp32_apptrace_cmd_ctx cmd_ctx,
struct command_invocation cmd,
int  mode 
)

◆ esp32_apptrace_cmd_init()

◆ esp32_apptrace_cmd_stop()

◆ esp32_apptrace_connect_targets()

◆ esp32_apptrace_console_dest_cleanup()

static int esp32_apptrace_console_dest_cleanup ( void *  priv)
static

Definition at line 148 of file esp32_apptrace.c.

References ERROR_OK.

Referenced by esp32_apptrace_console_dest_init().

◆ esp32_apptrace_console_dest_init()

static int esp32_apptrace_console_dest_init ( struct esp32_apptrace_dest dest,
const char *  dest_name 
)
static

◆ esp32_apptrace_console_dest_write()

static int esp32_apptrace_console_dest_write ( void *  priv,
uint8_t *  data,
int  size 
)
static

Definition at line 142 of file esp32_apptrace.c.

References ERROR_OK, LOG_USER_N, and size.

Referenced by esp32_apptrace_console_dest_init().

◆ esp32_apptrace_core_id_get()

static int esp32_apptrace_core_id_get ( struct target target,
uint8_t *  hdr_buf 
)
static

◆ esp32_apptrace_data_processor()

◆ esp32_apptrace_dest_cleanup()

int esp32_apptrace_dest_cleanup ( struct esp32_apptrace_dest  dest[],
unsigned int  max_dests 
)

◆ esp32_apptrace_dest_init()

int esp32_apptrace_dest_init ( struct esp32_apptrace_dest  dest[],
const char *  dest_paths[],
unsigned int  max_dests 
)

◆ esp32_apptrace_file_dest_cleanup()

static int esp32_apptrace_file_dest_cleanup ( void *  priv)
static

Definition at line 108 of file esp32_apptrace.c.

References ERROR_OK, esp32_apptrace_dest_file_data::fout, and priv.

Referenced by esp32_apptrace_file_dest_init().

◆ esp32_apptrace_file_dest_init()

◆ esp32_apptrace_file_dest_write()

static int esp32_apptrace_file_dest_write ( void *  priv,
uint8_t *  data,
int  size 
)
static

◆ esp32_apptrace_free_block_get()

struct esp32_apptrace_block * esp32_apptrace_free_block_get ( struct esp32_apptrace_cmd_ctx ctx)
static

◆ esp32_apptrace_get_data_info()

int esp32_apptrace_get_data_info ( struct esp32_apptrace_cmd_ctx ctx,
struct esp32_apptrace_target_state target_state,
uint32_t *  fired_target_num 
)
static

◆ esp32_apptrace_handle_trace_block()

◆ esp32_apptrace_poll()

◆ esp32_apptrace_print_stats()

◆ esp32_apptrace_process_data()

◆ esp32_apptrace_ready_block_get()

static struct esp32_apptrace_block* esp32_apptrace_ready_block_get ( struct esp32_apptrace_cmd_ctx ctx)
static

◆ esp32_apptrace_ready_block_put()

static int esp32_apptrace_ready_block_put ( struct esp32_apptrace_cmd_ctx ctx,
struct esp32_apptrace_block block 
)
static

◆ esp32_apptrace_safe_halt_targets()

◆ esp32_apptrace_tcp_dest_cleanup()

static int esp32_apptrace_tcp_dest_cleanup ( void *  priv)
static

◆ esp32_apptrace_tcp_dest_init()

◆ esp32_apptrace_tcp_dest_write()

static int esp32_apptrace_tcp_dest_write ( void *  priv,
uint8_t *  data,
int  size 
)
static

◆ esp32_apptrace_usr_block_check()

◆ esp32_apptrace_usr_block_len_get()

static uint32_t esp32_apptrace_usr_block_len_get ( struct target target,
uint8_t *  hdr_buf,
uint32_t *  wr_len 
)
static

◆ esp32_apptrace_wait4halt()

static int esp32_apptrace_wait4halt ( struct esp32_apptrace_cmd_ctx ctx,
struct target target 
)
static

◆ esp32_apptrace_wait_tracing_finished()

◆ esp32_cmd_apptrace_generic()

◆ esp32_sysview_start()

◆ esp32_sysview_stop()

◆ esp_apptrace_usr_block_write()

int esp_apptrace_usr_block_write ( const struct esp32_apptrace_hw hw,
struct target target,
uint32_t  block_id,
const uint8_t *  data,
uint32_t  size 
)

◆ is_sysview_mode()

static bool is_sysview_mode ( int  mode)
inlinestatic

Variable Documentation

◆ esp32_apptrace_command_handlers

const struct command_registration esp32_apptrace_command_handlers[]
Initial value:
= {
{
.name = "apptrace",
.handler = esp32_cmd_apptrace,
.mode = COMMAND_EXEC,
.help =
"App Tracing: application level trace control. Starts, stops or queries tracing process status.",
.usage =
"(start <destination> [poll_period [trace_size [stop_tmo [wait4halt [skip_size]]]]) | (stop) | (status) | (dump <destination>)",
},
{
.name = "sysview",
.handler = esp32_cmd_sysview,
.mode = COMMAND_EXEC,
.help =
"App Tracing: SEGGER SystemView compatible trace control. Starts, stops or queries tracing process status.",
.usage =
"(start file://<outfile1> [file://<outfile2>] [poll_period [trace_size [stop_tmo [wait4halt [skip_size]]]]) | (stop) | (status)",
},
{
.name = "sysview_mcore",
.handler = esp32_cmd_sysview_mcore,
.mode = COMMAND_EXEC,
.help =
"App Tracing: Espressif multi-core SystemView trace control. Starts, stops or queries tracing process status.",
.usage =
"(start file://<outfile> [poll_period [trace_size [stop_tmo [wait4halt [skip_size]]]]) | (stop) | (status)",
},
}
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
@ COMMAND_EXEC
Definition: command.h:40

Definition at line 1601 of file esp32_apptrace.c.

◆ s_time_stats_enable

const bool s_time_stats_enable = true
static