- if (strstr(packet, "qP"))
- {
- #define TAG_THREADID 1 /* Echo the thread identifier */
- #define TAG_EXISTS 2 /* Is this process defined enough to
- fetch registers and its stack */
- #define TAG_DISPLAY 4 /* A short thing maybe to put on a window */
- #define TAG_THREADNAME 8 /* string, maps 1-to-1 with a thread is */
- #define TAG_MOREDISPLAY 16 /* Whatever the kernel wants to say about */
-
- // TODO: need to scanf the mode variable (or it with the tags), and the threadid
-
- unsigned long mode;
- threadid_t threadid = 0;
- struct thread_detail* detail;
- sscanf(packet, "qP%8lx%16" SCNx64, &mode, &threadid);
-
-
- int found = -1;
-
- if ((target->rtos != NULL) && (target->rtos->thread_details
- != NULL)) {
- int thread_num;
- for (thread_num = 0; thread_num
- < target->rtos->thread_count; thread_num++) {
- if (target->rtos->thread_details[thread_num].threadid
- == threadid) {
- if (target->rtos->thread_details[thread_num].exists) {
- found = thread_num;
- }
- }
- }
- }
- if (found == -1) {
- gdb_put_packet(connection, "E01", 3); // thread not found
- return ERROR_OK;
- }
-
- detail = &target->rtos->thread_details[found];
-
- if ( detail->display_str != NULL )
- {
- mode &= TAG_DISPLAY;
- }
- if ( detail->thread_name_str != NULL )
- {
- mode &= TAG_THREADNAME;
- }
- if ( detail->extra_info_str != NULL )
- {
- mode &= TAG_MOREDISPLAY;
- }
-
-
- mode &= TAG_THREADID | TAG_EXISTS;
-
- char thread_str[1000];
+ struct target *target = get_target_from_connection(connection);
+ if (target->rtos == NULL)
+ return rtos_thread_packet(connection, packet, packet_size); /* thread not found*/
+ return target->rtos->gdb_thread_packet(connection, packet, packet_size);
+}