+ if (!os)
+ goto done;
+
+ /* Decode any symbol name in the packet*/
+ size_t len = unhexify((uint8_t *)cur_sym, strchr(packet + 8, ':') + 1, strlen(strchr(packet + 8, ':') + 1));
+ cur_sym[len] = 0;
+
+ if ((strcmp(packet, "qSymbol::") != 0) && /* GDB is not offering symbol lookup for the first time */
+ (!sscanf(packet, "qSymbol:%" SCNx64 ":", &addr)) && /* GDB did not find an address for a symbol */
+ is_symbol_mandatory(os, cur_sym)) { /* the symbol is mandatory for this RTOS */
+
+ /* GDB could not find an address for the previous symbol */
+ if (!target->rtos_auto_detect) {
+ LOG_WARNING("RTOS %s not detected. (GDB could not find symbol \'%s\')", os->type->name, cur_sym);
+ goto done;
+ } else {
+ /* Autodetecting RTOS - try next RTOS */
+ if (!rtos_try_next(target)) {
+ LOG_WARNING("No RTOS could be auto-detected!");
+ goto done;
+ }
+
+ /* Next RTOS selected - invalidate current symbol */
+ cur_sym[0] = '\x00';
+ }
+ }
+
+ LOG_DEBUG("RTOS: Address of symbol '%s' is 0x%" PRIx64, cur_sym, addr);
+
+ next_sym = next_symbol(os, cur_sym, addr);
+
+ /* Should never happen unless the debugger misbehaves */
+ if (!next_sym) {
+ LOG_WARNING("RTOS: Debugger sent us qSymbol with '%s' that we did not ask for", cur_sym);
+ goto done;
+ }
+
+ if (!next_sym->symbol_name) {
+ /* No more symbols need looking up */
+
+ if (!target->rtos_auto_detect) {
+ rtos_detected = 1;
+ goto done;
+ }
+
+ if (os->type->detect_rtos(target)) {
+ LOG_INFO("Auto-detected RTOS: %s", os->type->name);
+ rtos_detected = 1;
+ goto done;
+ } else {
+ LOG_WARNING("No RTOS could be auto-detected!");
+ goto done;
+ }
+ }
+
+ if (8 + (strlen(next_sym->symbol_name) * 2) + 1 > sizeof(reply)) {
+ LOG_ERROR("ERROR: RTOS symbol '%s' name is too long for GDB!", next_sym->symbol_name);
+ goto done;
+ }
+
+ LOG_DEBUG("RTOS: Requesting symbol lookup of '%s' from the debugger", next_sym->symbol_name);
+
+ reply_len = snprintf(reply, sizeof(reply), "qSymbol:");
+ reply_len += hexify(reply + reply_len,
+ (const uint8_t *)next_sym->symbol_name, strlen(next_sym->symbol_name),
+ sizeof(reply) - reply_len);
+
+done:
+ gdb_put_packet(connection, reply, reply_len);
+ return rtos_detected;
+}
+
+int rtos_thread_packet(struct connection *connection, char const *packet, int packet_size)
+{
+ struct target *target = get_target_from_connection(connection);
+
+ if (strncmp(packet, "qThreadExtraInfo,", 17) == 0) {
+ if ((target->rtos) && (target->rtos->thread_details) &&
+ (target->rtos->thread_count != 0)) {