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

Go to the source code of this file.

Functions

static unsigned int get_len_or_sprintf (char *buf, unsigned int curr, const char *format,...)
 
static unsigned int print_number (char *buf, unsigned int offset, uint64_t value)
 
static unsigned int riscv_debug_reg_field_to_s (char *buf, unsigned int offset, struct riscv_debug_reg_field_info field, struct riscv_debug_reg_ctx context, uint64_t field_value)
 
static uint64_t riscv_debug_reg_field_value (struct riscv_debug_reg_field_info field, uint64_t value)
 
static unsigned int riscv_debug_reg_field_value_to_s (char *buf, unsigned int offset, const char *const *field_value_names, uint64_t field_value)
 
static unsigned int riscv_debug_reg_fields_to_s (char *buf, unsigned int offset, struct riscv_debug_reg_field_list(*get_next)(struct riscv_debug_reg_ctx contex), struct riscv_debug_reg_ctx context, uint64_t value, enum riscv_debug_reg_show show)
 
unsigned int riscv_debug_reg_to_s (char *buf, enum riscv_debug_reg_ordinal reg_ordinal, struct riscv_debug_reg_ctx context, uint64_t value, enum riscv_debug_reg_show show)
 This function is used to fill a buffer with a decoded string representation of register's value. More...
 

Function Documentation

◆ get_len_or_sprintf()

static unsigned int get_len_or_sprintf ( char *  buf,
unsigned int  curr,
const char *  format,
  ... 
)
static

◆ print_number()

static unsigned int print_number ( char *  buf,
unsigned int  offset,
uint64_t  value 
)
static

Definition at line 26 of file debug_reg_printer.c.

References get_len_or_sprintf(), and offset.

Referenced by riscv_debug_reg_field_value_to_s(), and riscv_debug_reg_to_s().

◆ riscv_debug_reg_field_to_s()

static unsigned int riscv_debug_reg_field_to_s ( char *  buf,
unsigned int  offset,
struct riscv_debug_reg_field_info  field,
struct riscv_debug_reg_ctx  context,
uint64_t  field_value 
)
static

◆ riscv_debug_reg_field_value()

static uint64_t riscv_debug_reg_field_value ( struct riscv_debug_reg_field_info  field,
uint64_t  value 
)
static

◆ riscv_debug_reg_field_value_to_s()

static unsigned int riscv_debug_reg_field_value_to_s ( char *  buf,
unsigned int  offset,
const char *const *  field_value_names,
uint64_t  field_value 
)
static

Definition at line 33 of file debug_reg_printer.c.

References field_value(), get_len_or_sprintf(), NULL, offset, and print_number().

Referenced by riscv_debug_reg_field_to_s().

◆ riscv_debug_reg_fields_to_s()

static unsigned int riscv_debug_reg_fields_to_s ( char *  buf,
unsigned int  offset,
struct riscv_debug_reg_field_list(*)(struct riscv_debug_reg_ctx contex)  get_next,
struct riscv_debug_reg_ctx  context,
uint64_t  value,
enum riscv_debug_reg_show  show 
)
static

◆ riscv_debug_reg_to_s()

unsigned int riscv_debug_reg_to_s ( char *  buf,
enum riscv_debug_reg_ordinal  reg_ordinal,
struct riscv_debug_reg_ctx  context,
uint64_t  value,
enum riscv_debug_reg_show  show 
)

This function is used to fill a buffer with a decoded string representation of register's value.

Parameters
bufIf non-NULL, the buffer to write the string into. Otherwise, the function does not perform any writes, it just calculates the number of characters used.
reg_ordinalThe ordinal of the register.
contextThe structure, containing the information about the target, necessary to decode the register.
valueThe value to be decoded.

Returns the number of characters used by the string representation (excluding '\0').

Example: const struct struct riscv_debug_reg_ctx context = { .abits = { .value = <abits value>, .is_set = true } }; char buf[riscv_debug_reg_to_s(NULL, DTM_DMI_ORDINAL, context, <dmi value>) + 1] riscv_debug_reg_to_s(buf, DTM_DMI_ORDINAL, context, <dmi value>);

Definition at line 91 of file debug_reg_printer.c.

References get_len_or_sprintf(), get_riscv_debug_reg_info(), length, reg::name, print_number(), and riscv_debug_reg_fields_to_s().

Referenced by decode_dmi(), and log_debug_reg().