+ /* Next RTOS selected - invalidate current symbol */
+ cur_sym[0] = '\x00';
+ }
+ }
+ }
+
+ LOG_DEBUG("RTOS: Address of symbol '%s%s' is 0x%" PRIx64, cur_sym, cur_suffix, addr);
+
+ if (!next_sym) {
+ next_sym = next_symbol(os, cur_sym, addr);
+ next_suffix = no_suffix;
+ }
+
+ /* Should never happen unless the debugger misbehaves */
+ if (!next_sym) {
+ LOG_WARNING("RTOS: Debugger sent us qSymbol with '%s%s' that we did not ask for", cur_sym, cur_suffix);
+ 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;
+ }
+ }
+
+ assert(next_suffix);
+
+ reply_len = 8; /* snprintf(..., "qSymbol:") */
+ reply_len += 2 * strlen(next_sym->symbol_name); /* hexify(..., next_sym->symbol_name, ...) */
+ reply_len += 2 * strlen(next_suffix); /* hexify(..., next_suffix, ...) */
+ reply_len += 1; /* Terminating NUL */
+ if (reply_len > sizeof(reply)) {
+ LOG_ERROR("ERROR: RTOS symbol '%s%s' name is too long for GDB!", next_sym->symbol_name, next_suffix);
+ goto done;
+ }
+
+ LOG_DEBUG("RTOS: Requesting symbol lookup of '%s%s' from the debugger", next_sym->symbol_name, next_suffix);
+
+ 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);
+ reply_len += hexify(reply + reply_len,
+ (const uint8_t *)next_suffix, strlen(next_suffix),
+ 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)) {