- Fixes '<<' whitespace
[fw/openocd] / src / server / gdb_server.c
index 8f02435043a7165c783fa19dc644ec4b2f25d168..ed0a6a4979913c56b9614730a00ff3c24a9b80e4 100644 (file)
@@ -133,7 +133,7 @@ int check_pending(connection_t *connection, int timeout_s, int *got_data)
                        return ERROR_OK;
                }
        }
-       *got_data=FD_ISSET(connection->fd, &read_fds)!=0;
+       *got_data=FD_ISSET(connection->fd, &read_fds) != 0;
        return ERROR_OK;
 }
 
@@ -188,7 +188,7 @@ int gdb_get_char(connection_t *connection, int* next_char)
 #ifdef _WIN32
                errno = WSAGetLastError();
 
-               switch(errno)
+               switch (errno)
                {
                        case WSAEWOULDBLOCK:
                                usleep(1000);
@@ -204,7 +204,7 @@ int gdb_get_char(connection_t *connection, int* next_char)
                                exit(-1);
                }
 #else
-               switch(errno)
+               switch (errno)
                {
                        case EAGAIN:
                                usleep(1000);
@@ -313,13 +313,13 @@ int gdb_put_packet_inner(connection_t *connection, char *buffer, int len)
        int gotdata;
        for (;;)
        {
-               if ((retval=check_pending(connection, 0, &gotdata))!=ERROR_OK)
+               if ((retval=check_pending(connection, 0, &gotdata)) != ERROR_OK)
                        return retval;
                if (!gotdata)
                        break;
                if ((retval = gdb_get_char(connection, &reply)) != ERROR_OK)
                        return retval;
-               if( reply == '$' ){
+               if ( reply == '$' ){
                        /* fix a problem with some IAR tools */
                        gdb_putback_char( connection, reply );
                        LOG_DEBUG("Unexpected start of new packet");
@@ -349,7 +349,7 @@ int gdb_put_packet_inner(connection_t *connection, char *buffer, int len)
                        local_buffer[len++] = '#';
                        local_buffer[len++] = DIGITS[(my_checksum >> 4) & 0xf];
                        local_buffer[len++] = DIGITS[my_checksum & 0xf];
-                       if((retval = gdb_write(connection, local_buffer, len)) != ERROR_OK)
+                       if ((retval = gdb_write(connection, local_buffer, len)) != ERROR_OK)
                        {
                                return retval;
                        }
@@ -361,15 +361,15 @@ int gdb_put_packet_inner(connection_t *connection, char *buffer, int len)
                        local_buffer[1] = '#';
                        local_buffer[2] = DIGITS[(my_checksum >> 4) & 0xf];
                        local_buffer[3] = DIGITS[my_checksum & 0xf];
-                       if((retval = gdb_write(connection, local_buffer, 1)) != ERROR_OK)
+                       if ((retval = gdb_write(connection, local_buffer, 1)) != ERROR_OK)
                        {
                                return retval;
                        }
-                       if((retval = gdb_write(connection, buffer, len)) != ERROR_OK)
+                       if ((retval = gdb_write(connection, buffer, len)) != ERROR_OK)
                        {
                                return retval;
                        }
-                       if((retval = gdb_write(connection, local_buffer+1, 3)) != ERROR_OK)
+                       if ((retval = gdb_write(connection, local_buffer+1, 3)) != ERROR_OK)
                        {
                                return retval;
                        }
@@ -402,7 +402,7 @@ int gdb_put_packet_inner(connection_t *connection, char *buffer, int len)
                                log_remove_callback(gdb_log_callback, connection);
                                LOG_WARNING("negative reply, retrying");
                        }
-                       else if( reply == '$' ){
+                       else if ( reply == '$' ){
                                LOG_ERROR("GDB missing ack(1) - assumed good");
                                gdb_putback_char( connection, reply );
                                return ERROR_OK;
@@ -413,7 +413,7 @@ int gdb_put_packet_inner(connection_t *connection, char *buffer, int len)
                                return ERROR_SERVER_REMOTE_CLOSED;
                        }
                }
-               else if( reply == '$' ){
+               else if ( reply == '$' ){
                        LOG_ERROR("GDB missing ack(2) - assumed good");
                        gdb_putback_char( connection, reply );
                        return ERROR_OK;
@@ -600,11 +600,11 @@ int gdb_get_packet_inner(connection_t *connection, char *buffer, int *len)
                 */
                if (gdb_con->noack_mode)
                {
-                       if ((retval=fetch_packet(connection, &checksum_ok, 1, len, buffer))!=ERROR_OK)
+                       if ((retval=fetch_packet(connection, &checksum_ok, 1, len, buffer)) != ERROR_OK)
                                return retval;
                } else
                {
-                       if ((retval=fetch_packet(connection, &checksum_ok, 0, len, buffer))!=ERROR_OK)
+                       if ((retval=fetch_packet(connection, &checksum_ok, 0, len, buffer)) != ERROR_OK)
                                return retval;
                }
 
@@ -720,7 +720,7 @@ int gdb_target_callback_event_handler(struct target_s *target, enum target_event
                        break;
                case TARGET_EVENT_GDB_FLASH_ERASE_START:
                        target_handle_event( target, TARGET_EVENT_OLD_gdb_program_config );
-                       if((retval = jtag_execute_queue()) != ERROR_OK)
+                       if ((retval = jtag_execute_queue()) != ERROR_OK)
                        {
                                return retval;
                        }
@@ -923,9 +923,9 @@ void gdb_target_to_reg(target_t *target, char *tstr, int str_len, uint8_t *bin)
        }
 
        int i;
-       for (i = 0; i < str_len; i+=2)
+       for (i = 0; i < str_len; i += 2)
        {
-               uint8_t t = hextoint(tstr[i])<<4;
+               uint8_t t = hextoint(tstr[i]) << 4;
                t |= hextoint(tstr[i+1]);
 
                int j = gdb_reg_pos(target, i/2, str_len/2);
@@ -1190,7 +1190,7 @@ int gdb_read_memory_packet(connection_t *connection, target_t *target, char *pac
 
        retval = target_read_buffer(target, addr, len, buffer);
 
-       if ((retval!=ERROR_OK)&&!gdb_report_data_abort)
+       if ((retval != ERROR_OK)&&!gdb_report_data_abort)
        {
                /* TODO : Here we have to lie and send back all zero's lest stack traces won't work.
                 * At some point this might be fixed in GDB, in which case this code can be removed.
@@ -1397,7 +1397,7 @@ int gdb_breakpoint_watchpoint_packet(connection_t *connection, target_t *target,
        else if (type == 4) /* access watchpoint */
                wp_type = WPT_ACCESS;
 
-       if (gdb_breakpoint_override&&((bp_type==BKPT_SOFT)||(bp_type==BKPT_HARD)))
+       if (gdb_breakpoint_override && ((bp_type==BKPT_SOFT)||(bp_type==BKPT_HARD)))
        {
                bp_type=gdb_breakpoint_override_type;
        }
@@ -1654,7 +1654,7 @@ int gdb_query_packet(connection_t *connection, target_t *target, char *packet, i
 
                xml_printf(&retval, &buffer, &pos, &size,
                                "PacketSize=%x;qXfer:memory-map:read%c;qXfer:features:read-;QStartNoAckMode+",
-                               (GDB_BUFFER_SIZE - 1), ((gdb_use_memory_map == 1)&&(flash_get_bank_count()>0)) ? '+' : '-');
+                               (GDB_BUFFER_SIZE - 1), ((gdb_use_memory_map == 1) && (flash_get_bank_count()>0)) ? '+' : '-');
 
                if (retval != ERROR_OK)
                {
@@ -1667,7 +1667,7 @@ int gdb_query_packet(connection_t *connection, target_t *target, char *packet, i
 
                return ERROR_OK;
        }
-       else if (strstr(packet, "qXfer:memory-map:read::")&&(flash_get_bank_count()>0))
+       else if (strstr(packet, "qXfer:memory-map:read::") && (flash_get_bank_count()>0))
        {
                /* We get away with only specifying flash here. Regions that are not
                 * specified are treated as if we provided no memory map(if not we
@@ -1738,7 +1738,7 @@ int gdb_query_packet(connection_t *connection, target_t *target, char *packet, i
                                p->base, p->size, blocksize);
                        ram_start=p->base+p->size;
                }
-               if (ram_start!=0)
+               if (ram_start != 0)
                {
                        xml_printf(&retval, &xml, &pos, &size, "<memory type=\"ram\" start=\"0x%x\" length=\"0x%x\"/>\n",
                                ram_start, 0-ram_start);
@@ -1918,7 +1918,7 @@ int gdb_v_packet(connection_t *connection, target_t *target, char *packet, int p
                }
 
                /* create new section with content from packet buffer */
-               if((retval = image_add_section(gdb_connection->vflash_image, addr, length, 0x0, (uint8_t*)parse)) != ERROR_OK)
+               if ((retval = image_add_section(gdb_connection->vflash_image, addr, length, 0x0, (uint8_t*)parse)) != ERROR_OK)
                {
                        return retval;
                }
@@ -1964,7 +1964,7 @@ int gdb_v_packet(connection_t *connection, target_t *target, char *packet, int p
 int gdb_detach(connection_t *connection, target_t *target)
 {
 
-       switch( detach_mode )
+       switch ( detach_mode )
        {
                case GDB_DETACH_RESUME:
                        target_handle_event( target, TARGET_EVENT_OLD_pre_resume );
@@ -2036,12 +2036,12 @@ int gdb_input_inner(connection_t *connection)
                /* terminate with zero */
                packet[packet_size] = 0;
 
-               if( LOG_LEVEL_IS( LOG_LVL_DEBUG ) ){
-                       if( packet[0] == 'X' ){
+               if ( LOG_LEVEL_IS( LOG_LVL_DEBUG ) ){
+                       if ( packet[0] == 'X' ){
                                // binary packets spew junk into the debug log stream
                                char buf[ 50 ];
                                int x;
-                               for( x = 0 ; (x < 49) && (packet[x] != ':') ; x++ ){
+                               for ( x = 0 ; (x < 49) && (packet[x] != ':') ; x++ ){
                                        buf[x] = packet[x];
                                }
                                buf[x] = 0;
@@ -2109,7 +2109,7 @@ int gdb_input_inner(connection_t *connection)
                                                        log_add_callback(gdb_log_callback, connection);
                                                        target_call_event_callbacks(target, TARGET_EVENT_GDB_START);
                                                        int retval=gdb_step_continue_packet(connection, target, packet, packet_size);
-                                                       if (retval!=ERROR_OK)
+                                                       if (retval != ERROR_OK)
                                                        {
                                                                /* we'll never receive a halted condition... issue a false one.. */
                                                                gdb_frontend_halted(target, connection);