(add_thread): Add gdb_id argument.
(thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): New.
* linux-low.c (linux_create_inferior, linux_attach_lwp): Update
calls to add_thread.
* remote-utils.c (prepare_resume_reply: Use thread_to_gdb_id.
* server.c (handle_query): Use thread_to_gdb_id.
(handle_v_cont, main): Use gdb_id_to_thread_id.
* server.h (add_thread): Update prototype.
(thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): New
prototypes.
+2005-07-13 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * inferiors.c (struct thread_info): Add gdb_id.
+ (add_thread): Add gdb_id argument.
+ (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): New.
+ * linux-low.c (linux_create_inferior, linux_attach_lwp): Update
+ calls to add_thread.
+ * remote-utils.c (prepare_resume_reply: Use thread_to_gdb_id.
+ * server.c (handle_query): Use thread_to_gdb_id.
+ (handle_v_cont, main): Use gdb_id_to_thread_id.
+ * server.h (add_thread): Update prototype.
+ (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): New
+ prototypes.
+
2005-07-13 Daniel Jacobowitz <dan@codesourcery.com>
* linux-low.c (fetch_register, usr_store_inferior_registers): Handle
struct inferior_list_entry entry;
void *target_data;
void *regcache_data;
+ unsigned int gdb_id;
};
struct inferior_list all_threads;
}
void
-add_thread (unsigned long thread_id, void *target_data)
+add_thread (unsigned long thread_id, void *target_data, unsigned int gdb_id)
{
struct thread_info *new_thread
= (struct thread_info *) malloc (sizeof (*new_thread));
new_thread->target_data = target_data;
set_inferior_regcache_data (new_thread, new_register_cache ());
+ new_thread->gdb_id = gdb_id;
+}
+
+unsigned int
+thread_id_to_gdb_id (unsigned long thread_id)
+{
+ struct inferior_list_entry *inf = all_threads.head;
+
+ while (inf != NULL)
+ {
+ struct thread_info *thread = get_thread (inf);
+ if (inf->id == thread_id)
+ return thread->gdb_id;
+ inf = inf->next;
+ }
+
+ return 0;
+}
+
+unsigned int
+thread_to_gdb_id (struct thread_info *thread)
+{
+ return thread->gdb_id;
+}
+
+unsigned long
+gdb_id_to_thread_id (unsigned int gdb_id)
+{
+ struct inferior_list_entry *inf = all_threads.head;
+
+ while (inf != NULL)
+ {
+ struct thread_info *thread = get_thread (inf);
+ if (thread->gdb_id == gdb_id)
+ return inf->id;
+ inf = inf->next;
+ }
+
+ return 0;
}
static void
}
new_process = add_process (pid);
- add_thread (pid, new_process);
+ add_thread (pid, new_process, pid);
return pid;
}
}
new_process = (struct process_info *) add_process (pid);
- add_thread (tid, new_process);
+ add_thread (tid, new_process, pid);
/* The next time we wait for this LWP we'll see a SIGSTOP as PTRACE_ATTACH
brings it to a halt. We should ignore that SIGSTOP and resume the process
{
/* FIXME right place to set this? */
thread_from_wait = ((struct inferior_list_entry *)current_inferior)->id;
+ unsigned int gdb_id_from_wait = thread_to_gdb_id (current_inferior);
+
if (debug_threads)
fprintf (stderr, "Writing resume reply for %ld\n\n", thread_from_wait);
/* This if (1) ought to be unnecessary. But remote_wait in GDB
if (1 || old_thread_from_wait != thread_from_wait)
{
general_thread = thread_from_wait;
- sprintf (buf, "thread:%lx;", thread_from_wait);
+ sprintf (buf, "thread:%x;", gdb_id_from_wait);
buf += strlen (buf);
old_thread_from_wait = thread_from_wait;
}
if (strcmp ("qfThreadInfo", own_buf) == 0)
{
thread_ptr = all_threads.head;
- sprintf (own_buf, "m%lx", thread_ptr->id);
+ sprintf (own_buf, "m%x", thread_to_gdb_id ((struct thread_info *)thread_ptr));
thread_ptr = thread_ptr->next;
return;
}
{
if (thread_ptr != NULL)
{
- sprintf (own_buf, "m%lx", thread_ptr->id);
+ sprintf (own_buf, "m%x", thread_to_gdb_id ((struct thread_info *)thread_ptr));
thread_ptr = thread_ptr->next;
return;
}
}
else if (p[0] == ':')
{
- resume_info[i].thread = strtoul (p + 1, &q, 16);
+ unsigned int gdb_id = strtoul (p + 1, &q, 16);
+ unsigned long thread_id;
+
if (p == q)
goto err;
p = q;
if (p[0] != ';' && p[0] != 0)
goto err;
+ thread_id = gdb_id_to_thread_id (gdb_id);
+ if (thread_id)
+ resume_info[i].thread = thread_id;
+ else
+ goto err;
+
i++;
}
}
prepare_resume_reply (own_buf, status, signal);
break;
case 'H':
- switch (own_buf[1])
+ if (own_buf[1] == 'c' || own_buf[1] == 'g' || own_buf[1] == 's')
{
- case 'g':
- general_thread = strtoul (&own_buf[2], NULL, 16);
- write_ok (own_buf);
- set_desired_inferior (1);
- break;
- case 'c':
- cont_thread = strtoul (&own_buf[2], NULL, 16);
- write_ok (own_buf);
- break;
- case 's':
- step_thread = strtoul (&own_buf[2], NULL, 16);
+ unsigned long gdb_id, thread_id;
+
+ gdb_id = strtoul (&own_buf[2], NULL, 16);
+ thread_id = gdb_id_to_thread_id (gdb_id);
+ if (thread_id == 0)
+ {
+ write_enn (own_buf);
+ break;
+ }
+
+ if (own_buf[1] == 'g')
+ {
+ general_thread = thread_id;
+ set_desired_inferior (1);
+ }
+ else if (own_buf[1] == 'c')
+ cont_thread = thread_id;
+ else if (own_buf[1] == 's')
+ step_thread = thread_id;
+
write_ok (own_buf);
- break;
- default:
+ }
+ else
+ {
/* Silently ignore it so that gdb can extend the protocol
without compatibility headaches. */
own_buf[0] = '\0';
- break;
}
break;
case 'g':
break;
}
case 'T':
- if (mythread_alive (strtoul (&own_buf[1], NULL, 16)))
- write_ok (own_buf);
- else
- write_enn (own_buf);
+ {
+ unsigned long gdb_id, thread_id;
+
+ gdb_id = strtoul (&own_buf[1], NULL, 16);
+ thread_id = gdb_id_to_thread_id (gdb_id);
+ if (thread_id == 0)
+ {
+ write_enn (own_buf);
+ break;
+ }
+
+ if (mythread_alive (thread_id))
+ write_ok (own_buf);
+ else
+ write_enn (own_buf);
+ }
break;
case 'R':
/* Restarting the inferior is only supported in the
void remove_inferior (struct inferior_list *list,
struct inferior_list_entry *entry);
void remove_thread (struct thread_info *thread);
-void add_thread (unsigned long thread_id, void *target_data);
+void add_thread (unsigned long thread_id, void *target_data, unsigned int);
+unsigned int thread_id_to_gdb_id (unsigned long);
+unsigned int thread_to_gdb_id (struct thread_info *);
+unsigned long gdb_id_to_thread_id (unsigned int);
void clear_inferiors (void);
struct inferior_list_entry *find_inferior
(struct inferior_list *,