subsys/debug/gdb_server.c
/**
 * @brief parse given GDB command string
 *
 * Parse and execute the given GDB command string, and send acknowledgment if
 * acknowledgment is enabled.
 *
 * @return 0 on success, -1 if failed to send acknowledgment.
 */
@brief parse given GDB command string
Parse and execute the given GDB command string, and send acknowledgment if
acknowledgment is enabled.

@return 0 on success, -1 if failed to send acknowledgment.
@brief parse given GDB command string Parse and execute the given GDB command string and send acknowledgment if acknowledgment is enabled . @return 0 on success - 1 if failed to send acknowledgment .
static int protocol_parse(unsigned char *packet)
{
	unsigned char ch;
	int do_not_send_ack = 0;
	ch = *packet++;
	switch (ch) {
	case '?':
		handle_new_connection();
		break;
	case 'k':
		reboot();
		break;
	case 'D':
		detach();
		break;
	case 'T':
		packet = handle_thread_query(packet);
		break;
	case 'Q':
		if (strcmp((const char *)packet, "StartNoAckMode") == 0) {
			in_no_ack_mode = 1;
			fill_output_buffer(STUB_OK);
		} else {
			gdb_buffer[0] = '\0';
		}
		break;
	case 'q':
		packet = handle_general_query(packet);
		break;
	case 'g':
		handle_get_registers();
		break;
	case 'G':
		packet = handle_write_registers(packet);
		break;
#ifdef GDB_HAS_SINGLE_REG_ACCESS
	case 'P':
		packet = handle_write_single_register(packet);
		break;
	case 'p':
		packet = handle_read_single_register(packet);
		break;
#endif
	case 'm':
		packet = handle_read_memory(packet);
		break;
	case 'M':
		packet = handle_write_memory(packet, write_memory);
		break;
	case 'X':
		packet = handle_write_memory(packet,
					     write_memory_from_binary_format);
		break;
	case 'C':
		packet = handle_pass_signal_to_context(packet);
	case 'c':
		packet = handle_continue_execution(packet);
		do_not_send_ack = 1;
		break;
	case 'S':
		packet = handle_pass_signal_to_context(packet);
	case 's':
		packet = handle_step(packet);
		do_not_send_ack = 1;
		break;
	case 'v':
		if (strcmp((const char *)packet, "Cont?") == 0) {
			fill_output_buffer("vCont;c;s;C;S");
			break;
		} else if (strncmp((const char *)packet, "Cont;", 5) != 0) {
			gdb_buffer[0] = '\0';
			break;
		}
		packet = handle_vcont_action(packet, &do_not_send_ack);
		break;
#ifdef GDB_ARCH_HAS_RUNCONTROL
	case 'z':
		packet = handle_breakpoint_install(packet, delete_bp);
		break;
	case 'Z':
		packet = handle_breakpoint_install(packet, add_bp);
		break;
#endif
	default:
		gdb_buffer[0] = '\0';
		break;
	}
	if (!do_not_send_ack) {
		if (put_packet(gdb_buffer) < 0) {
			return -1;
		}
	}
	return 0;
}
static int protocol_parse ( unsigned char * packet ) { unsigned char ch ; int do_not_send_ack = 0 ; ch = * packet ++ ; switch ( ch ) { case ' ' : handle_new_connection ( ) ; break ; case ' ' : reboot ( ) ; break ; case ' ' : detach ( ) ; break ; case ' ' : packet = handle_thread_query ( packet ) ; break ; case ' ' : if ( strcmp ( ( const char * ) packet , " " ) == 0 ) { in_no_ack_mode = 1 ; fill_output_buffer ( STUB_OK ) ; } else { gdb_buffer [ 0 ] = ' \0 ' ; } break ; case ' ' : packet = handle_general_query ( packet ) ; break ; case ' ' : handle_get_registers ( ) ; break ; case ' ' : packet = handle_write_registers ( packet ) ; break ; #ifdef GDB_HAS_SINGLE_REG_ACCESS case ' ' : packet = handle_write_single_register ( packet ) ; break ; case ' ' : packet = handle_read_single_register ( packet ) ; break ; #endif case ' ' : packet = handle_read_memory ( packet ) ; break ; case ' ' : packet = handle_write_memory ( packet , write_memory ) ; break ; case ' ' : packet = handle_write_memory ( packet , write_memory_from_binary_format ) ; break ; case ' ' : packet = handle_pass_signal_to_context ( packet ) ; case ' ' : packet = handle_continue_execution ( packet ) ; do_not_send_ack = 1 ; break ; case ' ' : packet = handle_pass_signal_to_context ( packet ) ; case ' ' : packet = handle_step ( packet ) ; do_not_send_ack = 1 ; break ; case ' ' : if ( strcmp ( ( const char * ) packet , " " ) == 0 ) { fill_output_buffer ( " " ) ; break ; } else if ( strncmp ( ( const char * ) packet , " " , 5 ) != 0 ) { gdb_buffer [ 0 ] = ' \0 ' ; break ; } packet = handle_vcont_action ( packet , & do_not_send_ack ) ; break ; #ifdef GDB_ARCH_HAS_RUNCONTROL case ' ' : packet = handle_breakpoint_install ( packet , delete_bp ) ; break ; case ' ' : packet = handle_breakpoint_install ( packet , add_bp ) ; break ; #endif default : gdb_buffer [ 0 ] = ' \0 ' ; break ; } if ( ! do_not_send_ack ) { if ( put_packet ( gdb_buffer ) < 0 ) { return -1 ; } } return 0 ; }
@brief parse given GDB command string
 Parse and execute the given GDB command string, and send acknowledgment if
 acknowledgment is enabled.
@brief parse given GDB command string Parse and execute the given GDB command string and send acknowledgment if acknowledgment is enabled .
/* Kill request: we use it to reboot */ /* the only 'Q' command we support is "start no-ack mode" */ /* fall through */ /* fall through */ /* in case of an unsupported command, send empty response */ /* Send the acknowledgment command when necessary */