subsys/debug/gdb_server.c
/*
 * Handle pending notification packets for the CPU. It is invoked while
 * running in GDB CPU control loop (When system is stopped).
 */
Handle pending notification packets for the CPU. It is invoked while
running in GDB CPU control loop (When system is stopped).
Handle pending notification packets for the CPU . It is invoked while running in GDB CPU control loop ( When system is stopped ) .
static void handle_notification(void)
{
	const char *name = CONFIG_GDB_REMOTE_SERIAL_EXT_NOTIF_PREFIX_STR;
	unsigned char checksum = 0;
	int ix = 0;
	unsigned char ch;
	int more_data = 0;
	u32_t max_packet_size;
	u32_t data_size;
	unsigned char *ptr = notif_data;
	if (notif_data[0] == '\0') {
		return;
	}
again:
	put_debug_char('%');
	checksum = 0;
	ix = 0;
	while ((ch = name[ix++])) {
		put_debug_char(ch);
		checksum += ch;
	}
	put_debug_char(':');
	checksum += ':';
	max_packet_size =
		GDB_BUF_SIZE - (strlen(name) + NOTIF_PACKET_OVERHEAD);
	data_size = strlen((char *)ptr);
	if (data_size <= (max_packet_size / 2)) {
		more_data = 0;
	} else {
		data_size = max_packet_size / 2;
		more_data = 1;  
	}
	for (ix = 0; ix < data_size; ix++) {
		ch = hex_chars[(*ptr >> 4)];
		put_debug_char(ch);
		checksum += ch;
		ch = hex_chars[(*ptr & 0xf)];
		put_debug_char(ch);
		checksum += ch;
		ptr++;
	}
	put_debug_char('#');
	put_debug_char(hex_chars[(checksum >> 4)]);
	put_debug_char(hex_chars[(checksum & 0xf)]);
	if (more_data) {
		goto again;
	}
	notif_data[0] = '\0';
	notif_data_idx = 0;
}
static void handle_notification ( void ) { const char * name = CONFIG_GDB_REMOTE_SERIAL_EXT_NOTIF_PREFIX_STR ; unsigned char checksum = 0 ; int ix = 0 ; unsigned char ch ; int more_data = 0 ; u32_t max_packet_size ; u32_t data_size ; unsigned char * ptr = notif_data ; if ( notif_data [ 0 ] == ' \0 ' ) { return ; } again : put_debug_char ( ' ' ) ; checksum = 0 ; ix = 0 ; while ( ( ch = name [ ix ++ ] ) ) { put_debug_char ( ch ) ; checksum += ch ; } put_debug_char ( ' ' ) ; checksum += ' ' ; max_packet_size = GDB_BUF_SIZE - ( strlen ( name ) + NOTIF_PACKET_OVERHEAD ) ; data_size = strlen ( ( char * ) ptr ) ; if ( data_size <= ( max_packet_size / 2 ) ) { more_data = 0 ; } else { data_size = max_packet_size / 2 ; more_data = 1 ; } for ( ix = 0 ; ix < data_size ; ix ++ ) { ch = hex_chars [ ( * ptr >> 4 ) ] ; put_debug_char ( ch ) ; checksum += ch ; ch = hex_chars [ ( * ptr & 0xf ) ] ; put_debug_char ( ch ) ; checksum += ch ; ptr ++ ; } put_debug_char ( ' ' ) ; put_debug_char ( hex_chars [ ( checksum >> 4 ) ] ) ; put_debug_char ( hex_chars [ ( checksum & 0xf ) ] ) ; if ( more_data ) { goto again ; } notif_data [ 0 ] = ' \0 ' ; notif_data_idx = 0 ; }
Handle pending notification packets for the CPU.
Handle pending notification packets for the CPU .
/* First, check if there is pending data */ /*
	 * Build notification packet.
	 *
	 * A notification packet has the form `%<data>#<checksum>', where data
	 * is the content of the notification, and checksum is a checksum of
	 * data, computed and formatted as for ordinary gdb packets. A
	 * notification's data never contains `$', `%' or `#' characters. Upon
	 * receiving a notification, the recipient sends no `+' or `-' to
	 * acknowledge the notification's receipt or to report its corruption.
	 *
	 * Every notification's data begins with a name, which contains no
	 * colon characters, followed by a colon character.
	 */ /* Add name to notification packet */ /* Name must be followed by a colon character. */ /*
	 * Add data to notification packet.
	 * Warning: The value to hex encoding double the size of the data,
	 * so we must not encode more than the remaining GDB buffer size
	 * divided by 2.
	 */ /* Not enough room in notif packet */ /* Encode data using hex values */ /* Terminate packet with #<checksum> */ /* Clear buffer & index */