OpenOCD
log.h File Reference
Include dependency graph for log.h:

Go to the source code of this file.

Data Structures

struct  log_callback
 

Macros

#define ERROR_BUF_TOO_SMALL   (-3)
 
#define ERROR_FAIL   (-4)
 
#define ERROR_NO_CONFIG_FILE   (-2)
 
#define ERROR_NOT_IMPLEMENTED   (-7)
 
#define ERROR_OK   (0)
 
#define ERROR_TIMEOUT_REACHED   (-6)
 
#define ERROR_WAIT   (-5)
 
#define LOG_DEBUG(expr ...)
 
#define LOG_DEBUG_IO(expr ...)
 
#define LOG_ERROR(expr ...)    log_printf_lf(LOG_LVL_ERROR, __FILE__, __LINE__, __func__, expr)
 
#define LOG_INFO(expr ...)    log_printf_lf(LOG_LVL_INFO, __FILE__, __LINE__, __func__, expr)
 
#define LOG_LEVEL_IS(FOO)   ((debug_level) >= (FOO))
 
#define LOG_OUTPUT(expr ...)    log_printf(LOG_LVL_OUTPUT, __FILE__, __LINE__, __func__, expr)
 
#define LOG_TARGET_DEBUG(target, fmt_str, ...)    LOG_DEBUG("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)
 
#define LOG_TARGET_DEBUG_IO(target, fmt_str, ...)    LOG_DEBUG_IO("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)
 
#define LOG_TARGET_ERROR(target, fmt_str, ...)    LOG_ERROR("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)
 
#define LOG_TARGET_INFO(target, fmt_str, ...)    LOG_INFO("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)
 
#define LOG_TARGET_WARNING(target, fmt_str, ...)    LOG_WARNING("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)
 
#define LOG_USER(expr ...)    log_printf_lf(LOG_LVL_USER, __FILE__, __LINE__, __func__, expr)
 
#define LOG_USER_N(expr ...)    log_printf(LOG_LVL_USER, __FILE__, __LINE__, __func__, expr)
 
#define LOG_WARNING(expr ...)    log_printf_lf(LOG_LVL_WARNING, __FILE__, __LINE__, __func__, expr)
 
#define PRINTF_ATTRIBUTE_FORMAT   printf
 

Typedefs

typedef void(* log_callback_fn) (void *priv, const char *file, unsigned line, const char *function, const char *string)
 

Enumerations

enum  log_levels {
  LOG_LVL_SILENT = -3 , LOG_LVL_OUTPUT = -2 , LOG_LVL_USER = -1 , LOG_LVL_ERROR = 0 ,
  LOG_LVL_WARNING = 1 , LOG_LVL_INFO = 2 , LOG_LVL_DEBUG = 3 , LOG_LVL_DEBUG_IO = 4
}
 

Functions

void alive_sleep (uint64_t ms)
 
char * alloc_printf (const char *fmt,...) __attribute__((format(PRINTF_ATTRIBUTE_FORMAT
 
char * alloc_vprintf (const char *fmt, va_list ap)
 
void busy_sleep (uint64_t ms)
 
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. More...
 
void keep_alive (void)
 
void kept_alive (void)
 
int log_add_callback (log_callback_fn fn, void *priv)
 
void log_exit (void)
 
void 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,...) __attribute__((format(PRINTF_ATTRIBUTE_FORMAT
 
void log_printf_lf (enum log_levels level, const char *file, unsigned line, const char *function, const char *format,...) __attribute__((format(PRINTF_ATTRIBUTE_FORMAT
 
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 void log_vprintf_lf (enum log_levels level, const char *file, unsigned line, const char *function, const char *format, va_list args)
 

Variables

int debug_level
 

Macro Definition Documentation

◆ ERROR_BUF_TOO_SMALL

#define ERROR_BUF_TOO_SMALL   (-3)

Definition at line 157 of file log.h.

◆ ERROR_FAIL

#define ERROR_FAIL   (-4)

Definition at line 161 of file log.h.

◆ ERROR_NO_CONFIG_FILE

#define ERROR_NO_CONFIG_FILE   (-2)

Definition at line 156 of file log.h.

◆ ERROR_NOT_IMPLEMENTED

#define ERROR_NOT_IMPLEMENTED   (-7)

Definition at line 165 of file log.h.

◆ ERROR_OK

#define ERROR_OK   (0)

Definition at line 155 of file log.h.

◆ ERROR_TIMEOUT_REACHED

#define ERROR_TIMEOUT_REACHED   (-6)

Definition at line 164 of file log.h.

◆ ERROR_WAIT

#define ERROR_WAIT   (-5)

Definition at line 162 of file log.h.

◆ LOG_DEBUG

#define LOG_DEBUG (   expr ...)
Value:
do { \
log_printf_lf(LOG_LVL_DEBUG, \
__FILE__, __LINE__, __func__, \
expr); \
} while (0)
int debug_level
Definition: log.c:34
@ LOG_LVL_DEBUG
Definition: log.h:47

Definition at line 109 of file log.h.

◆ LOG_DEBUG_IO

#define LOG_DEBUG_IO (   expr ...)
Value:
do { \
log_printf_lf(LOG_LVL_DEBUG, \
__FILE__, __LINE__, __func__, \
expr); \
} while (0)
@ LOG_LVL_DEBUG_IO
Definition: log.h:48

Definition at line 101 of file log.h.

◆ LOG_ERROR

#define LOG_ERROR (   expr ...)     log_printf_lf(LOG_LVL_ERROR, __FILE__, __LINE__, __func__, expr)

Definition at line 123 of file log.h.

◆ LOG_INFO

#define LOG_INFO (   expr ...)     log_printf_lf(LOG_LVL_INFO, __FILE__, __LINE__, __func__, expr)

Definition at line 117 of file log.h.

◆ LOG_LEVEL_IS

#define LOG_LEVEL_IS (   FOO)    ((debug_level) >= (FOO))

Definition at line 99 of file log.h.

◆ LOG_OUTPUT

#define LOG_OUTPUT (   expr ...)     log_printf(LOG_LVL_OUTPUT, __FILE__, __LINE__, __func__, expr)

Definition at line 132 of file log.h.

◆ LOG_TARGET_DEBUG

#define LOG_TARGET_DEBUG (   target,
  fmt_str,
  ... 
)     LOG_DEBUG("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)

Definition at line 140 of file log.h.

◆ LOG_TARGET_DEBUG_IO

#define LOG_TARGET_DEBUG_IO (   target,
  fmt_str,
  ... 
)     LOG_DEBUG_IO("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)

Definition at line 137 of file log.h.

◆ LOG_TARGET_ERROR

#define LOG_TARGET_ERROR (   target,
  fmt_str,
  ... 
)     LOG_ERROR("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)

Definition at line 149 of file log.h.

◆ LOG_TARGET_INFO

#define LOG_TARGET_INFO (   target,
  fmt_str,
  ... 
)     LOG_INFO("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)

Definition at line 143 of file log.h.

◆ LOG_TARGET_WARNING

#define LOG_TARGET_WARNING (   target,
  fmt_str,
  ... 
)     LOG_WARNING("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)

Definition at line 146 of file log.h.

◆ LOG_USER

#define LOG_USER (   expr ...)     log_printf_lf(LOG_LVL_USER, __FILE__, __LINE__, __func__, expr)

Definition at line 126 of file log.h.

◆ LOG_USER_N

#define LOG_USER_N (   expr ...)     log_printf(LOG_LVL_USER, __FILE__, __LINE__, __func__, expr)

Definition at line 129 of file log.h.

◆ LOG_WARNING

#define LOG_WARNING (   expr ...)     log_printf_lf(LOG_LVL_WARNING, __FILE__, __LINE__, __func__, expr)

Definition at line 120 of file log.h.

◆ PRINTF_ATTRIBUTE_FORMAT

#define PRINTF_ATTRIBUTE_FORMAT   printf

Definition at line 25 of file log.h.

Typedef Documentation

◆ log_callback_fn

typedef void(* log_callback_fn) (void *priv, const char *file, unsigned line, const char *function, const char *string)

Definition at line 76 of file log.h.

Enumeration Type Documentation

◆ log_levels

enum log_levels
Enumerator
LOG_LVL_SILENT 
LOG_LVL_OUTPUT 
LOG_LVL_USER 
LOG_LVL_ERROR 
LOG_LVL_WARNING 
LOG_LVL_INFO 
LOG_LVL_DEBUG 
LOG_LVL_DEBUG_IO 

Definition at line 40 of file log.h.

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()

char* alloc_printf ( const char *  fmt,
  ... 
)

◆ alloc_vprintf()

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

◆ busy_sleep()

void busy_sleep ( uint64_t  ms)

◆ find_nonprint_char()

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().

◆ 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_init()

void 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,
  ... 
)

◆ log_printf_lf()

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

◆ 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 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

◆ debug_level