debug: fixed style and align code

Change-Id: I75875680feb7b814ed1fdafeb42de6f2d7049a90
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2016-12-17 13:31:24 -05:00 committed by Anas Nashif
commit e6b7ba40d1
2 changed files with 130 additions and 128 deletions

View file

@ -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>
@ -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];
@ -470,7 +472,7 @@ static void handle_system_stop(NANO_ISF *reg, int sig);
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;
@ -710,16 +712,16 @@ 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)
@ -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 {
@ -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)
{ {
@ -1371,6 +1373,7 @@ static ALWAYS_INLINE int is_valid_xml_query(unsigned char **packet,
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)
{ {
@ -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)
{ {
@ -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)
@ -1996,10 +1998,10 @@ 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)
@ -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)
{ {
@ -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)
{ {
@ -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)
{ {