OpenOCD
log.c File Reference
Include dependency graph for 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)
 
char * find_nonprint_char (char *buf, unsigned buf_len)
 Find the first non-printable character in the char buffer, return a pointer to it. More...
 
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)
 
void log_exit (void)
 
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)
 

Variables

static int count
 
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 397 of file log.c.

◆ KEEP_ALIVE_TIMEOUT_MS

#define KEEP_ALIVE_TIMEOUT_MS   1000

Definition at line 398 of file log.c.

◆ MAX_SOCKET_ERR_MSG_LENGTH

#define MAX_SOCKET_ERR_MSG_LENGTH   256

Definition at line 484 of file log.c.

Function Documentation

◆ alive_sleep()

void alive_sleep ( uint64_t  ms)

Definition at line 460 of file log.c.

References keep_alive().

Referenced by aduc702x_check_flash_completion(), aducm360_check_flash_completion(), aice_usb_packet_flush(), 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(), esp32_soc_reset(), esp32s2_soc_reset(), esp32s3_soc_reset(), 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(), 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(), 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_multidrop(), swd_connect_single(), swm050_erase(), swm050_mass_erase(), target_profiling_default(), target_run_flash_async_algorithm(), target_run_read_async_algorithm(), 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  )

◆ find_nonprint_char()

char* find_nonprint_char ( char *  buf,
unsigned  buf_len 
)

Find the first non-printable character in the char buffer, return a pointer to it.

If no such character exists, return NULL.

Definition at line 512 of file log.c.

References NULL.

Referenced by gdb_log_incoming_packet(), and gdb_log_outgoing_packet().

◆ gdb_timeout_warning()

static void gdb_timeout_warning ( int64_t  delta_time)
static

Definition at line 400 of file 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 419 of file log.c.

References gdb_timeout_warning(), KEEP_ALIVE_KICK_TIME_MS, KEEP_ALIVE_TIMEOUT_MS, last_time, server_keep_clients_alive(), and timeval_ms().

Referenced by aice_check_dbger(), aice_issue_srst(), aice_pipe_read(), aice_usb_packet_flush(), 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(), 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(), cortex_m_load_core_reg_u32(), cortex_m_store_core_reg_u32(), dmi_op_timeout(), 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(), npcx_get_flash_id(), nrf5_wait_for_nvmc(), qspi_verify(), read_memory_bus_v1(), riscv_batch_run(), riscv_get_register(), riscv_program_exec(), riscv_set_register(), samd_check_error(), same5_wait_and_check_error(), sh_qspi_erase(), slow_fespi_write_buffer(), stlink_tcp_send_cmd(), 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(), xmc4xxx_wait_status_busy(), xscale_read_tx(), and xscale_write_rx().

◆ kept_alive()

void kept_alive ( void  )

Definition at line 447 of file log.c.

References gdb_timeout_warning(), KEEP_ALIVE_TIMEOUT_MS, last_time, and timeval_ms().

Referenced by gdb_put_packet().

◆ log_add_callback()

◆ log_exit()

void log_exit ( void  )

Definition at line 289 of file log.c.

References log_output, and NULL.

Referenced by openocd_main().

◆ log_forward()

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

Definition at line 55 of file 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 269 of file log.c.

References debug_level, ERROR_OK, last_time, LOG_LVL_DEBUG_IO, LOG_LVL_SILENT, log_output, 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 133 of file log.c.

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

◆ log_printf_lf()

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

Definition at line 182 of file log.c.

References log_vprintf_lf().

Referenced by dump_field(), gdb_new_connection(), jtag_examine_chain_display(), and svf_hexbuf_print().

◆ 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 264 of file log.c.

References log_command_handlers, NULL, and register_commands().

Referenced by setup_command_handler().

◆ log_remove_callback()

◆ log_socket_error()

◆ 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 158 of file log.c.

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

Referenced by jaylink_log_handler(), and log_printf_lf().

Variable Documentation

◆ count

int count
static

Definition at line 52 of file log.c.

Referenced by log_printf(), log_puts(), and log_vprintf_lf().

◆ debug_level

◆ last_time

int64_t last_time
static

Definition at line 39 of file log.c.

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

◆ log_callbacks

struct log_callback* log_callbacks
static

Definition at line 37 of file log.c.

Referenced by log_add_callback(), log_forward(), and log_remove_callback().

◆ 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:247
@ COMMAND_ANY
Definition: command.h:42

Definition at line 214 of file log.c.

Referenced by log_register_commands().

◆ log_output

FILE* log_output
static

Definition at line 36 of file log.c.

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

◆ log_strings

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

Definition at line 43 of file log.c.

Referenced by log_puts().

◆ start