OpenOCD
helper/log.c File Reference
Include dependency graph for helper/log.c:

Go to the source code of this file.

Macros

#define KEEP_ALIVE_KICK_TIME_MS   500
 
#define KEEP_ALIVE_TIMEOUT_MS   1000
 
#define MAX_SOCKET_ERR_MSG_LENGTH   256
 

Functions

void alive_sleep (uint64_t ms)
 
char * alloc_printf (const char *format,...)
 
char * alloc_vprintf (const char *fmt, va_list ap)
 
void busy_sleep (uint64_t ms)
 
 COMMAND_HANDLER (handle_debug_level_command)
 
 COMMAND_HANDLER (handle_log_output_command)
 
static void gdb_timeout_warning (int64_t delta_time)
 
void keep_alive (void)
 
void kept_alive (void)
 
int log_add_callback (log_callback_fn fn, void *priv)
 
static void log_forward (const char *file, unsigned line, const char *function, const char *string)
 
void log_init (void)
 Initialize logging module. More...
 
void log_printf (enum log_levels level, const char *file, unsigned line, const char *function, const char *format,...)
 
void log_printf_lf (enum log_levels level, const char *file, unsigned line, const char *function, const char *format,...)
 
static void log_puts (enum log_levels level, const char *file, int line, const char *function, const char *string)
 
int log_register_commands (struct command_context *cmd_ctx)
 
int log_remove_callback (log_callback_fn fn, void *priv)
 
void log_socket_error (const char *socket_desc)
 
void log_vprintf_lf (enum log_levels level, const char *file, unsigned line, const char *function, const char *format, va_list args)
 
int set_log_output (struct command_context *cmd_ctx, FILE *output)
 

Variables

static int count
 
static int64_t current_time
 
int debug_level = LOG_LVL_INFO
 
static int64_t last_time
 
static struct log_callbacklog_callbacks
 
static const struct command_registration log_command_handlers []
 
static FILE * log_output
 
static const char *const log_strings [6]
 
static int64_t start
 

Macro Definition Documentation

◆ KEEP_ALIVE_KICK_TIME_MS

#define KEEP_ALIVE_KICK_TIME_MS   500

Definition at line 409 of file helper/log.c.

Referenced by keep_alive().

◆ KEEP_ALIVE_TIMEOUT_MS

#define KEEP_ALIVE_TIMEOUT_MS   1000

Definition at line 410 of file helper/log.c.

Referenced by gdb_timeout_warning(), keep_alive(), and kept_alive().

◆ MAX_SOCKET_ERR_MSG_LENGTH

#define MAX_SOCKET_ERR_MSG_LENGTH   256

Definition at line 497 of file helper/log.c.

Referenced by log_socket_error().

Function Documentation

◆ alive_sleep()

void alive_sleep ( uint64_t  ms)

Definition at line 473 of file helper/log.c.

References keep_alive().

Referenced by aduc702x_check_flash_completion(), aducm360_check_flash_completion(), aice_usb_packet_flush(), aice_usb_profiling(), ambiqmicro_exec_command(), ap_poll_register(), arc_halt(), arc_step(), arm720t_soft_reset_halt(), arm7_9_execute_sys_speed(), arm7_9_soft_reset_halt(), arm920t_soft_reset_halt(), arm926ejs_soft_reset_halt(), at91sam7_wait_status_busy(), at91sam9_nand_ready(), cfi_intel_wait_status_busy(), cfi_spansion_wait_status_busy(), COMMAND_HANDLER(), cortex_m_soft_reset_halt(), dap_dp_poll_register(), davinci_nand_ready(), efm32x_wait_status(), em357_wait_status_busy(), esirisc_wait_debug_active(), fespi_wip(), imx31_nand_ready(), isc_leave(), jtag_sleep(), jtagspi_wait(), kinetis_ke_ftmrx_command(), kinetis_ke_mdm_poll_register(), kinetis_ke_prepare_flash(), kinetis_mdm_poll_register(), lpc288x_wait_status_busy(), lpc2900_wait_status(), lpc3180_controller_ready(), lpc3180_nand_ready(), lpc3180_tc_ready(), lpc32xx_controller_ready(), lpc32xx_dma_ready(), lpc32xx_nand_ready(), lpc32xx_tc_ready(), mrvlqspi_fifo_flush(), mrvlqspi_flash_busy_status(), mrvlqspi_set_ss_state(), mrvlqspi_stop_transfer(), mxc_nand_ready(), nand_page_command(), nand_poll_ready(), nand_read_status(), nds32_assert_reset(), nuc910_nand_ready(), or1k_is_cpu_running(), pic32mx_wait_status_busy(), poll_busy(), poll_ssp_busy(), poll_tff(), psoc5lp_spc_busy_wait_data(), psoc5lp_spc_busy_wait_idle(), rpc_hf_wait_tend(), s3c2410_nand_ready(), s3c2440_nand_ready(), sh_qspi_wait_for_bit(), sim3x_erase_page(), sim3x_flash_erase(), stm32l4_wait_status_busy(), stm32lx_wait_until_bsy_clear_timeout(), stm32x_wait_flash_op_queue(), stm32x_wait_status_busy(), stm32x_write_option(), stmqspi_erase(), str7x_waitbusy(), str9x_erase(), str9x_write(), str9xpec_erase_area(), swd_connect(), swm050_erase(), swm050_mass_erase(), target_profiling_default(), target_run_flash_async_algorithm(), target_run_read_async_algorithm(), tms470_erase_sector(), tms470_try_flash_keys(), tms470_write(), w600_start_do(), wait_till_ready(), xcf_erase_check(), xds110_init(), xmc4xxx_wait_status_busy(), xscale_read_tx(), and xscale_write_rx().

◆ alloc_printf()

◆ alloc_vprintf()

char* alloc_vprintf ( const char *  fmt,
va_list  ap 
)

◆ busy_sleep()

void busy_sleep ( uint64_t  ms)

◆ COMMAND_HANDLER() [1/2]

COMMAND_HANDLER ( handle_debug_level_command  )

◆ COMMAND_HANDLER() [2/2]

COMMAND_HANDLER ( handle_log_output_command  )

◆ gdb_timeout_warning()

static void gdb_timeout_warning ( int64_t  delta_time)
static

Definition at line 412 of file helper/log.c.

References gdb_actual_connections, KEEP_ALIVE_TIMEOUT_MS, LOG_DEBUG, and LOG_WARNING.

Referenced by keep_alive(), and kept_alive().

◆ keep_alive()

void keep_alive ( void  )

Definition at line 431 of file helper/log.c.

References current_time, gdb_timeout_warning(), KEEP_ALIVE_KICK_TIME_MS, KEEP_ALIVE_TIMEOUT_MS, last_time, LOG_USER_N, and timeval_ms().

Referenced by aice_check_dbger(), aice_issue_srst(), aice_pipe_read(), aice_usb_packet_flush(), aice_usb_profiling(), alive_sleep(), arm720t_soft_reset_halt(), arm7_9_execute_sys_speed(), arm7_9_read_memory(), arm7_9_soft_reset_halt(), arm7_9_write_memory(), arm920t_soft_reset_halt(), arm926ejs_soft_reset_halt(), armjtagew_usb_read(), armv7a_l1_d_cache_clean_virt(), armv7a_l1_d_cache_flush_level(), armv7a_l1_d_cache_flush_virt(), armv7a_l1_d_cache_inval_virt(), armv7a_l1_i_cache_inval_virt(), ath79_erase(), avrf_write(), cc26xx_wait_algo_done(), cc26xx_write(), cc3220sf_erase(), cc3220sf_mass_erase(), cc3220sf_write(), cfi_intel_write_block(), COMMAND_HANDLER(), COMMAND_HELPER(), efm32x_write_word(), esirisc_flash_wait(), fespi_erase(), image_calculate_checksum(), ipc_acquire(), ipc_poll_lock_stat(), jtag_add_sleep(), kinetis_write_inner(), kinetis_write_sections(), mips64_ejtag_fastdata_scan(), mips_ejtag_add_scan_96(), mips_ejtag_drscan_32_queued(), mips_ejtag_drscan_64(), mips_ejtag_fastdata_scan(), mpsse_flush(), msp432_wait_inactive(), msp432_wait_return_code(), msp432_write(), nrf5_wait_for_nvmc(), qspi_verify(), read_memory_progbuf(), riscv_batch_run(), riscv_program_exec(), same5_wait_and_check_error(), sh_qspi_erase(), slow_fespi_write_buffer(), steps_execute(), stmqspi_blank_check(), stmqspi_erase(), stmsmi_erase(), stmsmi_write(), target_call_timer_callbacks_check_time(), target_fill_mem(), target_run_flash_async_algorithm(), target_run_read_async_algorithm(), target_wait_state(), waitSRST(), xmc4xxx_wait_status_busy(), xscale_read_tx(), and xscale_write_rx().

◆ kept_alive()

void kept_alive ( void  )

◆ log_add_callback()

◆ log_forward()

static void log_forward ( const char *  file,
unsigned  line,
const char *  function,
const char *  string 
)
static

Definition at line 65 of file helper/log.c.

References log_callback::fn, log_callbacks, log_callback::next, and log_callback::priv.

Referenced by log_puts().

◆ log_init()

void log_init ( void  )

Initialize logging module.

Call during program startup.

Definition at line 284 of file helper/log.c.

References debug_level, ERROR_OK, last_time, LOG_LVL_DEBUG_IO, LOG_LVL_SILENT, log_output, NULL, start, and timeval_ms().

Referenced by setup_command_handler().

◆ log_printf()

void log_printf ( enum log_levels  level,
const char *  file,
unsigned  line,
const char *  function,
const char *  format,
  ... 
)

Definition at line 148 of file helper/log.c.

References alloc_vprintf(), count, debug_level, log_puts(), and NULL.

◆ log_printf_lf()

void log_printf_lf ( enum log_levels  level,
const char *  file,
unsigned  line,
const char *  function,
const char *  format,
  ... 
)

◆ log_puts()

static void log_puts ( enum log_levels  level,
const char *  file,
int  line,
const char *  function,
const char *  string 
)
static

◆ log_register_commands()

int log_register_commands ( struct command_context cmd_ctx)

Definition at line 279 of file helper/log.c.

References NULL, and register_commands().

Referenced by setup_command_handler().

◆ log_remove_callback()

◆ log_socket_error()

void log_socket_error ( const char *  socket_desc)

Definition at line 501 of file helper/log.c.

References DWORD, LOG_ERROR, MAX_SOCKET_ERR_MSG_LENGTH, and NULL.

Referenced by jtag_vpi_quit(), jtag_vpi_receive_cmd(), and jtag_vpi_send_cmd().

◆ log_vprintf_lf()

void log_vprintf_lf ( enum log_levels  level,
const char *  file,
unsigned  line,
const char *  function,
const char *  format,
va_list  args 
)

Definition at line 173 of file helper/log.c.

References alloc_vprintf(), count, debug_level, and log_puts().

Referenced by jaylink_log_handler(), and log_printf_lf().

◆ set_log_output()

int set_log_output ( struct command_context cmd_ctx,
FILE *  output 
)

Definition at line 304 of file helper/log.c.

References ERROR_OK, log_output, and output.

Variable Documentation

◆ count

int count
static

Definition at line 62 of file helper/log.c.

Referenced by aarch64_read_cpu_memory_slow(), aarch64_write_cpu_memory_slow(), aduc702x_erase(), aduc702x_write_single(), aducm360_erase(), aducm360_write_modified(), aice_pipe_write(), aice_usb_read_memory_unit(), aice_usb_write_memory_unit(), ambiqmicro_write_block(), arc_jtag_enque_register_rw(), arc_jtag_read_memory(), arc_jtag_read_registers(), arc_jtag_write_memory(), arc_mem_is_slow_memory(), arc_mem_write_block16(), arc_mem_write_block8(), arm11_read_memory_inner(), arm11_run_instr_data_to_core_noack_inner_default(), arm11_write_memory_inner(), arm7_9_bulk_write_memory(), arm7_9_dcc_completion(), arm_access_size(), at91sam7_write(), avr32_jtag_read_memory32(), avr32_jtag_read_memory8(), avr32_jtag_write_memory32(), avr32_jtag_write_memory8(), avrf_write(), cc26xx_write(), cc3220sf_write(), COMMAND_HANDLER(), command_unknown(), cortex_a_read_cpu_memory_slow(), cortex_a_write_cpu_memory_slow(), dap_dp_poll_register(), dsp563xx_read_memory(), dsp563xx_read_memory_core(), dsp563xx_write_memory(), dsp563xx_write_memory_core(), dsp5680xx_read(), dsp5680xx_write(), dsp5680xx_write_16(), dsp5680xx_write_32(), dsp5680xx_write_8(), efm32x_write(), embeddedice_write_dcc(), embeddedice_write_reg_inner(), ep1_generic_commandl(), ep1_memory_write(), esirisc_read_memory(), esirisc_trace_analyze_full(), esirisc_trace_buf_get_u32(), esirisc_write_memory(), execute_command(), feroceon_bulk_write_memory(), fespi_write(), fetch_packet(), find_sfdp_dummy(), find_status_bit(), handle_iod_output(), hexify(), icdi_usb_read_mem(), icdi_usb_write_mem(), image_ihex_buffer_complete_inner(), image_mot_buffer_complete_inner(), is_arm7_9(), isc_data_read_out(), jim_nds32_bulk_read(), jim_nds32_bulk_write(), jlink_quit(), jlink_register(), jtag_clock_tck(), jtag_clock_tms(), jtag_slow_clock_tck(), jtag_slow_clock_tms(), jtagspi_write(), kinetis_ke_ftmrx_command(), kinetis_ke_write(), kinetis_write_inner(), kinetis_write_sections(), log_printf(), log_puts(), log_vprintf_lf(), lpc2000_write(), lpc288x_write(), lpc2900_write(), max32xxx_write(), mdr_read(), mdr_write(), mem_ap_read(), mem_ap_write(), mips32_dmaacc_read_mem16(), mips32_dmaacc_read_mem32(), mips32_dmaacc_read_mem8(), mips32_dmaacc_write_mem16(), mips32_dmaacc_write_mem32(), mips32_dmaacc_write_mem8(), mips32_pracc_fastdata_xfer(), mips32_pracc_synchronize_cache(), mips64_pracc_fastdata_xfer(), mips64_pracc_read_mem16(), mips64_pracc_read_mem32(), mips64_pracc_read_mem64(), mips64_pracc_read_mem8(), mips64_pracc_write_mem16(), mips64_pracc_write_mem32(), mips64_pracc_write_mem64(), mips64_pracc_write_mem8(), mrvlqspi_flash_read(), msp432_write(), next_hex_encoded_field(), niietcm4_write(), nulink_usb_read_mem(), nulink_usb_read_mem32(), nulink_usb_read_mem8(), nulink_usb_write_mem(), nulink_usb_write_mem32(), nulink_usb_write_mem8(), numicro_write(), ocl_write(), openjtag_add_scan(), openjtag_execute_tap_queue(), or1k_adv_jtag_read_memory(), or1k_adv_jtag_write_memory(), osbdm_send_and_recv(), pracc_swap16_array(), psoc4_write(), read_flash_id(), read_memory_abstract(), read_memory_bus_v0(), read_memory_progbuf(), read_memory_progbuf_inner(), read_phys_mem(), read_sfdp_block(), read_status_reg(), read_write_data(), remote_bitbang_fill_buf(), remote_bitbang_rread(), rpchf_target_read_memory(), rtos_put_gdb_reg_list(), sam3_write(), sam4_write(), sam4l_write(), samd_write(), same5_modify_user_row_masked(), same5_write(), semihosting_common(), sim3x_flash_write(), stlink_usb_read_mem(), stlink_usb_write_mem(), stmqspi_blank_check(), stmsmi_write(), str7x_write(), str9x_write(), str9xpec_write(), target_array2mem(), target_buffer_get_u16_array(), target_buffer_get_u32_array(), target_buffer_get_u64_array(), target_buffer_set_u16_array(), target_buffer_set_u32_array(), target_buffer_set_u64_array(), target_handle_md_output(), target_mem2array(), target_set_examined(), target_to_arm926(), target_to_dsp5680xx(), tms470_write(), ulink_append_clock_tms_cmd(), unhexify(), usb_bulk_with_retries(), usb_connect(), usb_get_response(), write_memory_abstract(), write_memory_bus_v0(), write_memory_bus_v1(), write_memory_progbuf(), write_phys_mem(), xscale_analyze_trace(), xscale_read_memory(), and xscale_write_memory().

◆ current_time

int64_t current_time
static

Definition at line 49 of file helper/log.c.

Referenced by keep_alive(), and kept_alive().

◆ debug_level

◆ last_time

int64_t last_time
static

Definition at line 48 of file helper/log.c.

Referenced by keep_alive(), kept_alive(), and log_init().

◆ log_callbacks

struct log_callback* log_callbacks
static

Definition at line 46 of file helper/log.c.

Referenced by log_add_callback(), and log_forward().

◆ log_command_handlers

const struct command_registration log_command_handlers[]
static
Initial value:
= {
{
.name = "log_output",
.handler = handle_log_output_command,
.mode = COMMAND_ANY,
.help = "redirect logging to a file (default: stderr)",
.usage = "[file_name | \"default\"]",
},
{
.name = "debug_level",
.handler = handle_debug_level_command,
.mode = COMMAND_ANY,
.help = "Sets the verbosity level of debugging output. "
"0 shows errors only; 1 adds warnings; "
"2 (default) adds other info; 3 adds debugging; "
"4 adds extra verbose debugging.",
.usage = "number",
},
}
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:234

Definition at line 258 of file helper/log.c.

◆ log_output

FILE* log_output
static

Definition at line 45 of file helper/log.c.

Referenced by COMMAND_HANDLER(), log_init(), log_puts(), and set_log_output().

◆ log_strings

const char* const log_strings[6]
static
Initial value:
= {
"User : ",
"Error: ",
"Warn : ",
"Info : ",
"Debug: ",
"Debug: "
}

Definition at line 53 of file helper/log.c.

Referenced by log_puts().

◆ start