debug: fixed style and align code
Change-Id: I75875680feb7b814ed1fdafeb42de6f2d7049a90 Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
569f0b4105
commit
e6b7ba40d1
2 changed files with 130 additions and 128 deletions
|
@ -322,7 +322,7 @@
|
||||||
*
|
*
|
||||||
* For example:
|
* For example:
|
||||||
* %CONFIG_GDB_REMOTE_SERIAL_EXT_NOTIF_PREFIX_STR:<notificationData>#<checksum>
|
* %CONFIG_GDB_REMOTE_SERIAL_EXT_NOTIF_PREFIX_STR:<notificationData>#<checksum>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <nanokernel.h>
|
#include <nanokernel.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -370,22 +370,22 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef GDB_ARCH_HAS_RUNCONTROL
|
#ifdef GDB_ARCH_HAS_RUNCONTROL
|
||||||
#define RESUME_SYSTEM() resume_system()
|
#define RESUME_SYSTEM() resume_system()
|
||||||
#define REMOVE_ALL_INSTALLED_BREAKPOINTS() \
|
#define REMOVE_ALL_INSTALLED_BREAKPOINTS() \
|
||||||
remove_all_installed_breakpoints()
|
remove_all_installed_breakpoints()
|
||||||
#define UNINSTALL_BREAKPOINTS() uninstall_breakpoints()
|
#define UNINSTALL_BREAKPOINTS() uninstall_breakpoints()
|
||||||
#else
|
#else
|
||||||
#define RESUME_SYSTEM()
|
#define RESUME_SYSTEM()
|
||||||
#define REMOVE_ALL_INSTALLED_BREAKPOINTS()
|
#define REMOVE_ALL_INSTALLED_BREAKPOINTS()
|
||||||
#define UNINSTALL_BREAKPOINTS()
|
#define UNINSTALL_BREAKPOINTS()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef GDB_ARCH_HAS_RUNCONTROL
|
#ifdef GDB_ARCH_HAS_RUNCONTROL
|
||||||
struct bp_array {
|
struct bp_array {
|
||||||
gdb_instr_t *addr; /* breakpoint address */
|
gdb_instr_t *addr; /* breakpoint address */
|
||||||
gdb_instr_t instr; /* saved instruction */
|
gdb_instr_t instr; /* saved instruction */
|
||||||
char valid; /* breakpoint is valid? */
|
char valid; /* breakpoint is valid? */
|
||||||
char enabled; /* breakpoint is enabled? */
|
char enabled; /* breakpoint is enabled? */
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -402,9 +402,11 @@ static volatile int cpu_stop_signal = GDB_SIG_NULL;
|
||||||
static volatile int cpu_pending_signal;
|
static volatile int cpu_pending_signal;
|
||||||
static struct gdb_reg_set gdb_regs;
|
static struct gdb_reg_set gdb_regs;
|
||||||
|
|
||||||
static const char *xml_target_header = "<?xml version=\"1.0\"?> "
|
static const char *xml_target_header =
|
||||||
|
"<?xml version=\"1.0\"?> "
|
||||||
"<!DOCTYPE target SYSTEM "
|
"<!DOCTYPE target SYSTEM "
|
||||||
"\"gdb-target.dtd\"> <target version=\"1.0\">\n";
|
"\"gdb-target.dtd\"> <target version=\"1.0\">\n";
|
||||||
|
|
||||||
static const char *xml_target_footer = "</target>";
|
static const char *xml_target_footer = "</target>";
|
||||||
static unsigned char gdb_buffer[GDB_BUF_SIZE];
|
static unsigned char gdb_buffer[GDB_BUF_SIZE];
|
||||||
|
|
||||||
|
@ -468,9 +470,9 @@ static void handle_system_stop(NANO_ISF *reg, int sig);
|
||||||
|
|
||||||
#define ADD_DEL_BP_SIG(x) \
|
#define ADD_DEL_BP_SIG(x) \
|
||||||
int(x)(enum gdb_bp_type type, long addr, int len, \
|
int(x)(enum gdb_bp_type type, long addr, int len, \
|
||||||
enum gdb_error_code *err)
|
enum gdb_error_code *err)
|
||||||
|
|
||||||
typedef ADD_DEL_BP_SIG(add_del_bp_t);
|
typedef ADD_DEL_BP_SIG (add_del_bp_t);
|
||||||
static ADD_DEL_BP_SIG(add_bp);
|
static ADD_DEL_BP_SIG(add_bp);
|
||||||
static ADD_DEL_BP_SIG(delete_bp);
|
static ADD_DEL_BP_SIG(delete_bp);
|
||||||
|
|
||||||
|
@ -573,7 +575,7 @@ static int hex_str_to_int(unsigned char **ptr, int *value)
|
||||||
/*
|
/*
|
||||||
* Consume two hex characters from a string and return the corresponding
|
* Consume two hex characters from a string and return the corresponding
|
||||||
* value.
|
* value.
|
||||||
*/
|
*/
|
||||||
static int hex_str_to_byte(unsigned char **str)
|
static int hex_str_to_byte(unsigned char **str)
|
||||||
{
|
{
|
||||||
unsigned char *ptr = *str;
|
unsigned char *ptr = *str;
|
||||||
|
@ -673,7 +675,7 @@ static unsigned char *compress(unsigned char *buf)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static unsigned char *mem2hex(unsigned char *mem, unsigned char *buf,
|
static unsigned char *mem2hex(unsigned char *mem, unsigned char *buf,
|
||||||
int count, int do_compress)
|
int count, int do_compress)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned char ch;
|
unsigned char ch;
|
||||||
|
@ -693,7 +695,7 @@ static unsigned char *mem2hex(unsigned char *mem, unsigned char *buf,
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int do_mem_probe(char *addr, int mode, int width,
|
static inline int do_mem_probe(char *addr, int mode, int width,
|
||||||
int preserve, long *dummy)
|
int preserve, long *dummy)
|
||||||
{
|
{
|
||||||
char *p = (char *)dummy;
|
char *p = (char *)dummy;
|
||||||
|
|
||||||
|
@ -710,19 +712,19 @@ static inline int do_mem_probe(char *addr, int mode, int width,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Probe if memory location is valid
|
* @brief Probe if memory location is valid
|
||||||
*
|
*
|
||||||
* @param addr Address to test
|
* @param addr Address to test
|
||||||
* @param mode Mode of access (SYS_MEM_SAFE_READ/WRITE)
|
* @param mode Mode of access (SYS_MEM_SAFE_READ/WRITE)
|
||||||
* @param size Number of bytes to test
|
* @param size Number of bytes to test
|
||||||
* @param width Width of memory access (1, 2, or 4)
|
* @param width Width of memory access (1, 2, or 4)
|
||||||
* @param preserve Preserve memory on write test ?
|
* @param preserve Preserve memory on write test ?
|
||||||
*
|
*
|
||||||
* @return 0 if memory is accessible, -1 otherwise.
|
* @return 0 if memory is accessible, -1 otherwise.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int mem_probe(char *addr, int mode, int size,
|
static int mem_probe(char *addr, int mode, int size,
|
||||||
int width, int preserve)
|
int width, int preserve)
|
||||||
{
|
{
|
||||||
long dummy;
|
long dummy;
|
||||||
|
|
||||||
|
@ -851,7 +853,7 @@ static void request_notification_packet_flush(void)
|
||||||
static inline int must_flush_notification_buffer(unsigned char ch)
|
static inline int must_flush_notification_buffer(unsigned char ch)
|
||||||
{
|
{
|
||||||
return (notif_data_idx == GDB_NOTIF_DATA_SIZE) ||
|
return (notif_data_idx == GDB_NOTIF_DATA_SIZE) ||
|
||||||
(ch == '\n') || (ch == '\r');
|
(ch == '\n') || (ch == '\r');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -947,7 +949,7 @@ again:
|
||||||
more_data = 0;
|
more_data = 0;
|
||||||
} else {
|
} else {
|
||||||
data_size = max_packet_size / 2;
|
data_size = max_packet_size / 2;
|
||||||
more_data = 1; /* Not enough room in notif packet */
|
more_data = 1; /* Not enough room in notif packet */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Encode data using hex values */
|
/* Encode data using hex values */
|
||||||
|
@ -981,8 +983,8 @@ static int has_hit_a_hw_bp(void)
|
||||||
{
|
{
|
||||||
/* instruction hw breakpoints are reported as sw breakpoints */
|
/* instruction hw breakpoints are reported as sw breakpoints */
|
||||||
return (cpu_stop_signal == GDB_SIG_TRAP) &&
|
return (cpu_stop_signal == GDB_SIG_TRAP) &&
|
||||||
(cpu_stop_bp_type != GDB_SOFT_BP) &&
|
(cpu_stop_bp_type != GDB_SOFT_BP) &&
|
||||||
(cpu_stop_bp_type != GDB_HW_INST_BP);
|
(cpu_stop_bp_type != GDB_HW_INST_BP);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1022,7 +1024,7 @@ static void do_post_event_hw_bp(unsigned char **buf, size_t *buf_size)
|
||||||
*buf += count;
|
*buf += count;
|
||||||
*buf_size -= count;
|
*buf_size -= count;
|
||||||
count = snprintf((char *)*buf, *buf_size, ":%lx",
|
count = snprintf((char *)*buf, *buf_size, ":%lx",
|
||||||
cpu_stop_hw_bp_addr);
|
cpu_stop_hw_bp_addr);
|
||||||
*buf += count;
|
*buf += count;
|
||||||
*buf_size -= count;
|
*buf_size -= count;
|
||||||
}
|
}
|
||||||
|
@ -1069,7 +1071,7 @@ static void do_post_event(void)
|
||||||
buf_size--;
|
buf_size--;
|
||||||
}
|
}
|
||||||
count = snprintf((char *)buf, buf_size, "T%02xthread:%02x",
|
count = snprintf((char *)buf, buf_size, "T%02xthread:%02x",
|
||||||
cpu_stop_signal, 1);
|
cpu_stop_signal, 1);
|
||||||
buf += count;
|
buf += count;
|
||||||
buf_size -= count;
|
buf_size -= count;
|
||||||
|
|
||||||
|
@ -1204,7 +1206,7 @@ static unsigned char *get_packet(unsigned char *buffer, size_t size)
|
||||||
cs[0] = get_hex_char_value(get_debug_char()) << 4;
|
cs[0] = get_hex_char_value(get_debug_char()) << 4;
|
||||||
cs[1] = get_hex_char_value(get_debug_char());
|
cs[1] = get_hex_char_value(get_debug_char());
|
||||||
|
|
||||||
if (checksum != (cs[0]|cs[1])) {
|
if (checksum != (cs[0] | cs[1])) {
|
||||||
/* checksum failed */
|
/* checksum failed */
|
||||||
put_debug_char('-');
|
put_debug_char('-');
|
||||||
} else {
|
} else {
|
||||||
|
@ -1244,7 +1246,7 @@ static void write_xml_string(char *buf, const char *xml_str, int off, int len)
|
||||||
/* we can read the full data */
|
/* we can read the full data */
|
||||||
buf[0] = 'l';
|
buf[0] = 'l';
|
||||||
int size_to_copy = len <= (GDB_BUF_SIZE - 2) ? len :
|
int size_to_copy = len <= (GDB_BUF_SIZE - 2) ? len :
|
||||||
GDB_BUF_SIZE - 2;
|
GDB_BUF_SIZE - 2;
|
||||||
strncpy(&buf[1], xml_str + off, size_to_copy);
|
strncpy(&buf[1], xml_str + off, size_to_copy);
|
||||||
} else {
|
} else {
|
||||||
buf[0] = 'm';
|
buf[0] = 'm';
|
||||||
|
@ -1255,15 +1257,15 @@ static void write_xml_string(char *buf, const char *xml_str, int off, int len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get XML target description
|
* @brief get XML target description
|
||||||
*
|
*
|
||||||
* This routine is used to build the string that will hold the XML target
|
* This routine is used to build the string that will hold the XML target
|
||||||
* description provided to the GDB client.
|
* description provided to the GDB client.
|
||||||
*
|
*
|
||||||
* NOTE: Non-re-entrant, since it uses a static buffer.
|
* NOTE: Non-re-entrant, since it uses a static buffer.
|
||||||
*
|
*
|
||||||
* @return a pointer on XML target description
|
* @return a pointer on XML target description
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static char *get_xml_target_description(void)
|
static char *get_xml_target_description(void)
|
||||||
{
|
{
|
||||||
|
@ -1366,11 +1368,12 @@ static size_t concat_reboot_feature_if_supported(size_t size)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static ALWAYS_INLINE int is_valid_xml_query(unsigned char **packet,
|
static ALWAYS_INLINE int is_valid_xml_query(unsigned char **packet,
|
||||||
int *off, int *len)
|
int *off, int *len)
|
||||||
{
|
{
|
||||||
unsigned char *p = *packet;
|
unsigned char *p = *packet;
|
||||||
int is_valid = hex_str_to_int(&p, off) && *p++ == ','
|
int is_valid = hex_str_to_int(&p, off) && *p++ == ','
|
||||||
&& hex_str_to_int(&p, len) && *p == '\0';
|
&& hex_str_to_int(&p, len) && *p == '\0';
|
||||||
|
|
||||||
*packet = p;
|
*packet = p;
|
||||||
return is_valid;
|
return is_valid;
|
||||||
}
|
}
|
||||||
|
@ -1396,7 +1399,7 @@ static const char *supported_features_cmd =
|
||||||
#ifdef GDB_ARCH_HAS_REMOTE_SERIAL_EXT_USING_NOTIF_PACKETS
|
#ifdef GDB_ARCH_HAS_REMOTE_SERIAL_EXT_USING_NOTIF_PACKETS
|
||||||
";" CONFIG_GDB_REMOTE_SERIAL_EXT_NOTIF_PREFIX_STR "+"
|
";" CONFIG_GDB_REMOTE_SERIAL_EXT_NOTIF_PREFIX_STR "+"
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
static unsigned char *handle_general_query(unsigned char *packet)
|
static unsigned char *handle_general_query(unsigned char *packet)
|
||||||
{
|
{
|
||||||
|
@ -1409,7 +1412,7 @@ static unsigned char *handle_general_query(unsigned char *packet)
|
||||||
size_t size = GDB_BUF_SIZE;
|
size_t size = GDB_BUF_SIZE;
|
||||||
|
|
||||||
snprintf((char *)gdb_buffer, size, supported_features_cmd,
|
snprintf((char *)gdb_buffer, size, supported_features_cmd,
|
||||||
GDB_BUF_SIZE);
|
GDB_BUF_SIZE);
|
||||||
size -= (strlen((char *)gdb_buffer) + 1);
|
size -= (strlen((char *)gdb_buffer) + 1);
|
||||||
|
|
||||||
size -= concat_reboot_feature_if_supported(size);
|
size -= concat_reboot_feature_if_supported(size);
|
||||||
|
@ -1560,7 +1563,7 @@ unsigned char *handle_read_memory(unsigned char *packet)
|
||||||
|
|
||||||
#define WRITE_MEM_SIG(x) \
|
#define WRITE_MEM_SIG(x) \
|
||||||
unsigned char *(x)(unsigned char *packet, unsigned char *dest, int len)
|
unsigned char *(x)(unsigned char *packet, unsigned char *dest, int len)
|
||||||
typedef WRITE_MEM_SIG(write_mem_t);
|
typedef WRITE_MEM_SIG (write_mem_t);
|
||||||
|
|
||||||
static ALWAYS_INLINE unsigned char *handle_write_memory(unsigned char *packet,
|
static ALWAYS_INLINE unsigned char *handle_write_memory(unsigned char *packet,
|
||||||
write_mem_t *write_mem)
|
write_mem_t *write_mem)
|
||||||
|
@ -1596,7 +1599,6 @@ static ALWAYS_INLINE unsigned char *handle_write_memory(unsigned char *packet,
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static WRITE_MEM_SIG(write_memory)
|
static WRITE_MEM_SIG(write_memory)
|
||||||
{
|
{
|
||||||
unsigned char value;
|
unsigned char value;
|
||||||
|
@ -1751,13 +1753,13 @@ unsigned char *handle_breakpoint_install(unsigned char *packet,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief parse given GDB command string
|
* @brief parse given GDB command string
|
||||||
*
|
*
|
||||||
* Parse and execute the given GDB command string, and send acknowledgment if
|
* Parse and execute the given GDB command string, and send acknowledgment if
|
||||||
* acknowledgment is enabled.
|
* acknowledgment is enabled.
|
||||||
*
|
*
|
||||||
* @return 0 on success, -1 if failed to send acknowledgment.
|
* @return 0 on success, -1 if failed to send acknowledgment.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int protocol_parse(unsigned char *packet)
|
static int protocol_parse(unsigned char *packet)
|
||||||
{
|
{
|
||||||
|
@ -1816,12 +1818,12 @@ static int protocol_parse(unsigned char *packet)
|
||||||
break;
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
packet = handle_write_memory(packet,
|
packet = handle_write_memory(packet,
|
||||||
write_memory_from_binary_format);
|
write_memory_from_binary_format);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'C':
|
case 'C':
|
||||||
packet = handle_pass_signal_to_context(packet);
|
packet = handle_pass_signal_to_context(packet);
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case 'c':
|
case 'c':
|
||||||
packet = handle_continue_execution(packet);
|
packet = handle_continue_execution(packet);
|
||||||
do_not_send_ack = 1;
|
do_not_send_ack = 1;
|
||||||
|
@ -1829,7 +1831,7 @@ static int protocol_parse(unsigned char *packet)
|
||||||
|
|
||||||
case 'S':
|
case 'S':
|
||||||
packet = handle_pass_signal_to_context(packet);
|
packet = handle_pass_signal_to_context(packet);
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case 's':
|
case 's':
|
||||||
packet = handle_step(packet);
|
packet = handle_step(packet);
|
||||||
do_not_send_ack = 1;
|
do_not_send_ack = 1;
|
||||||
|
@ -1899,7 +1901,7 @@ static void put_debug_char(unsigned char ch)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int add_hw_bp(long addr, enum gdb_bp_type type, int len,
|
static int add_hw_bp(long addr, enum gdb_bp_type type, int len,
|
||||||
enum gdb_error_code *err)
|
enum gdb_error_code *err)
|
||||||
{
|
{
|
||||||
#ifdef GDB_ARCH_HAS_HW_BP
|
#ifdef GDB_ARCH_HAS_HW_BP
|
||||||
if (gdb_hw_bp_set(&dbg_regs, addr, type, len, err) == -1) {
|
if (gdb_hw_bp_set(&dbg_regs, addr, type, len, err) == -1) {
|
||||||
|
@ -1926,7 +1928,7 @@ static int add_hw_bp(long addr, enum gdb_bp_type type, int len,
|
||||||
* @param err Container for returning error code
|
* @param err Container for returning error code
|
||||||
*
|
*
|
||||||
* @return 0 on success, -1 if failed (Error code returned via @a err).
|
* @return 0 on success, -1 if failed (Error code returned via @a err).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int remove_hw_bp(long addr, enum gdb_bp_type type, int len,
|
static int remove_hw_bp(long addr, enum gdb_bp_type type, int len,
|
||||||
enum gdb_error_code *err)
|
enum gdb_error_code *err)
|
||||||
|
@ -1969,7 +1971,7 @@ static int remove_hw_bp(long addr, enum gdb_bp_type type, int len,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int add_bp(enum gdb_bp_type type, long addr, int len,
|
static int add_bp(enum gdb_bp_type type, long addr, int len,
|
||||||
enum gdb_error_code *err)
|
enum gdb_error_code *err)
|
||||||
{
|
{
|
||||||
if (type != GDB_SOFT_BP) {
|
if (type != GDB_SOFT_BP) {
|
||||||
return add_hw_bp(addr, type, len, err);
|
return add_hw_bp(addr, type, len, err);
|
||||||
|
@ -1996,13 +1998,13 @@ static int add_bp(enum gdb_bp_type type, long addr, int len,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief delete a breakpoint or watchpoint from breakpoint list
|
* @brief delete a breakpoint or watchpoint from breakpoint list
|
||||||
*
|
*
|
||||||
* @return 0 on success, -1 if failed to remove breakpoint.
|
* @return 0 on success, -1 if failed to remove breakpoint.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int delete_bp(enum gdb_bp_type type, long addr, int len,
|
static int delete_bp(enum gdb_bp_type type, long addr, int len,
|
||||||
enum gdb_error_code *err)
|
enum gdb_error_code *err)
|
||||||
{
|
{
|
||||||
gdb_instr_t *bp_addr = (gdb_instr_t *)addr;
|
gdb_instr_t *bp_addr = (gdb_instr_t *)addr;
|
||||||
|
|
||||||
|
@ -2102,11 +2104,11 @@ static inline void clear_debug_regs_for_hw_breakpoints(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Physically uninstall breakpoints, and make sure that modified memory is
|
* Physically uninstall breakpoints, and make sure that modified memory is
|
||||||
* flushed on all CPUs.
|
* flushed on all CPUs.
|
||||||
*
|
*
|
||||||
* Must only be called in the CPU control loop.
|
* Must only be called in the CPU control loop.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void uninstall_breakpoints(void)
|
static void uninstall_breakpoints(void)
|
||||||
{
|
{
|
||||||
|
@ -2160,8 +2162,8 @@ static inline void disable_trace_mode(void)
|
||||||
#ifdef GDB_ARCH_NO_SINGLE_STEP
|
#ifdef GDB_ARCH_NO_SINGLE_STEP
|
||||||
/* remove temporary breakpoint */
|
/* remove temporary breakpoint */
|
||||||
(void)set_instruction(gdb_step_emu_next_pc,
|
(void)set_instruction(gdb_step_emu_next_pc,
|
||||||
&gdb_step_emu_instr,
|
&gdb_step_emu_instr,
|
||||||
sizeof(gdb_instr_t));
|
sizeof(gdb_instr_t));
|
||||||
/* Disable trace mode */
|
/* Disable trace mode */
|
||||||
gdb_int_regs_unlock(&gdb_regs, trace_lock_key);
|
gdb_int_regs_unlock(&gdb_regs, trace_lock_key);
|
||||||
#else
|
#else
|
||||||
|
@ -2171,13 +2173,13 @@ static inline void disable_trace_mode(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief stop mode agent BP/trace handler
|
* @brief stop mode agent BP/trace handler
|
||||||
*
|
*
|
||||||
* Common handler of breakpoint and trace mode exceptions.
|
* Common handler of breakpoint and trace mode exceptions.
|
||||||
* It is invoked with interrupts locked.
|
* It is invoked with interrupts locked.
|
||||||
*
|
*
|
||||||
* @return n/a
|
* @return n/a
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void gdb_handler(enum gdb_exc_mode mode, void *esf, int signal)
|
void gdb_handler(enum gdb_exc_mode mode, void *esf, int signal)
|
||||||
{
|
{
|
||||||
|
@ -2249,24 +2251,24 @@ static inline int handle_single_stepping(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief GDB control loop
|
* @brief GDB control loop
|
||||||
*
|
*
|
||||||
* The CPU control loop is an active wait loop used to stop CPU activity.
|
* The CPU control loop is an active wait loop used to stop CPU activity.
|
||||||
*
|
*
|
||||||
* It must be called with interrupts locked.
|
* It must be called with interrupts locked.
|
||||||
*
|
*
|
||||||
* It loops while waiting for debug events which can be:
|
* It loops while waiting for debug events which can be:
|
||||||
*
|
*
|
||||||
* - System resumed: gdb_debug_status != NOT_DEBUGGING
|
* - System resumed: gdb_debug_status != NOT_DEBUGGING
|
||||||
* The control loop must be exited.
|
* The control loop must be exited.
|
||||||
*
|
*
|
||||||
* - Single step request: gdb_debug_status == SINGLE_STEP
|
* - Single step request: gdb_debug_status == SINGLE_STEP
|
||||||
* Notify client that CPU is already stopped.
|
* Notify client that CPU is already stopped.
|
||||||
* This is done by setting event_is_pending = 1.
|
* This is done by setting event_is_pending = 1.
|
||||||
* event_is_pending will be handled by next get_packet().
|
* event_is_pending will be handled by next get_packet().
|
||||||
*
|
*
|
||||||
* @return n/a
|
* @return n/a
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void control_loop(void)
|
static void control_loop(void)
|
||||||
{
|
{
|
||||||
|
@ -2312,17 +2314,17 @@ static void control_loop(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief handle a system stop request
|
* @brief handle a system stop request
|
||||||
*
|
*
|
||||||
* The purpose of this routine is to handle a stop request issued by remote
|
* The purpose of this routine is to handle a stop request issued by remote
|
||||||
* debug client. It is called when receiving a break char.
|
* debug client. It is called when receiving a break char.
|
||||||
*
|
*
|
||||||
* It indicates that a GDB event is pending (the answer to stop request) and
|
* It indicates that a GDB event is pending (the answer to stop request) and
|
||||||
* transfer control from the runtime system to the stop mode agent. The event
|
* transfer control from the runtime system to the stop mode agent. The event
|
||||||
* will be posted by this control loop.
|
* will be posted by this control loop.
|
||||||
*
|
*
|
||||||
* @return n/a
|
* @return n/a
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void handle_system_stop(NANO_ISF *regs, int signal)
|
static void handle_system_stop(NANO_ISF *regs, int signal)
|
||||||
{
|
{
|
||||||
|
@ -2332,7 +2334,7 @@ static void handle_system_stop(NANO_ISF *regs, int signal)
|
||||||
if (signal != 0) {
|
if (signal != 0) {
|
||||||
cpu_stop_signal = signal;
|
cpu_stop_signal = signal;
|
||||||
} else {
|
} else {
|
||||||
cpu_stop_signal = GDB_SIG_INT; /* Stopped by a command */
|
cpu_stop_signal = GDB_SIG_INT; /* Stopped by a command */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save registers */
|
/* Save registers */
|
||||||
|
@ -2364,14 +2366,14 @@ static void handle_system_stop(NANO_ISF *regs, int signal)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief wrapper to send a character to console
|
* @brief wrapper to send a character to console
|
||||||
*
|
*
|
||||||
* This routine is a specific wrapper to send a character to console.
|
* This routine is a specific wrapper to send a character to console.
|
||||||
* If the GDB Server is started, this routine intercepts the data and transfer
|
* If the GDB Server is started, this routine intercepts the data and transfer
|
||||||
* it to the connected debug clients using a GDB notification packet.
|
* it to the connected debug clients using a GDB notification packet.
|
||||||
*
|
*
|
||||||
* @return n/a
|
* @return n/a
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static UART_CONSOLE_OUT_DEBUG_HOOK_SIG(gdb_console_out)
|
static UART_CONSOLE_OUT_DEBUG_HOOK_SIG(gdb_console_out)
|
||||||
{
|
{
|
||||||
|
|
|
@ -112,7 +112,7 @@ static inline int is_in_a_rw_region(vaddr_t addr, vaddr_t end_addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int mem_probe_no_check(void *p, int perm, size_t num_bytes,
|
static inline int mem_probe_no_check(void *p, int perm, size_t num_bytes,
|
||||||
void *buf)
|
void *buf)
|
||||||
{
|
{
|
||||||
vaddr_t addr = (vaddr_t)p;
|
vaddr_t addr = (vaddr_t)p;
|
||||||
vaddr_t end_addr = addr + num_bytes - 1;
|
vaddr_t end_addr = addr + num_bytes - 1;
|
||||||
|
@ -162,7 +162,7 @@ int _mem_probe(void *p, int perm, size_t num_bytes, void *buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int mem_access(void *p, void *buf, size_t num_bytes,
|
static inline int mem_access(void *p, void *buf, size_t num_bytes,
|
||||||
int len, int perm)
|
int len, int perm)
|
||||||
{
|
{
|
||||||
char *p_char = p, *buf_char = buf, *p_end = ((char *)p + len);
|
char *p_char = p, *buf_char = buf, *p_end = ((char *)p + len);
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ static inline int get_align(const uint32_t value)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_width(const void *p1, const void *p2,
|
static inline int get_width(const void *p1, const void *p2,
|
||||||
size_t num_bytes, int width)
|
size_t num_bytes, int width)
|
||||||
{
|
{
|
||||||
vaddr_t p1_addr = (vaddr_t)p1, p2_addr = (vaddr_t)p2;
|
vaddr_t p1_addr = (vaddr_t)p1, p2_addr = (vaddr_t)p2;
|
||||||
|
|
||||||
|
@ -205,15 +205,15 @@ static inline int get_width(const void *p1, const void *p2,
|
||||||
int _mem_safe_read(void *src, char *buf, size_t num_bytes, int width)
|
int _mem_safe_read(void *src, char *buf, size_t num_bytes, int width)
|
||||||
{
|
{
|
||||||
width = get_width(src, buf, num_bytes, width);
|
width = get_width(src, buf, num_bytes, width);
|
||||||
return unlikely(width < 0) ? -EINVAL :
|
return unlikely(width < 0) ? -EINVAL :
|
||||||
mem_access(src, buf, width, num_bytes, SYS_MEM_SAFE_READ);
|
mem_access(src, buf, width, num_bytes, SYS_MEM_SAFE_READ);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _mem_safe_write(void *dest, char *buf, size_t num_bytes, int width)
|
int _mem_safe_write(void *dest, char *buf, size_t num_bytes, int width)
|
||||||
{
|
{
|
||||||
width = get_width(dest, buf, num_bytes, width);
|
width = get_width(dest, buf, num_bytes, width);
|
||||||
return unlikely(width < 0) ? -EINVAL :
|
return unlikely(width < 0) ? -EINVAL :
|
||||||
mem_access(dest, buf, width, num_bytes, SYS_MEM_SAFE_WRITE);
|
mem_access(dest, buf, width, num_bytes, SYS_MEM_SAFE_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_XIP)
|
#if defined(CONFIG_XIP)
|
||||||
|
@ -231,7 +231,7 @@ int _mem_safe_write_to_text_section(void *dest, char *buf, size_t num_bytes)
|
||||||
{
|
{
|
||||||
vaddr_t v = (vaddr_t)dest;
|
vaddr_t v = (vaddr_t)dest;
|
||||||
int is_in_text = ((v >= IMAGE_TEXT_START) &&
|
int is_in_text = ((v >= IMAGE_TEXT_START) &&
|
||||||
((v + num_bytes) <= IMAGE_TEXT_END));
|
((v + num_bytes) <= IMAGE_TEXT_END));
|
||||||
|
|
||||||
if (unlikely(!is_in_text)) {
|
if (unlikely(!is_in_text)) {
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue