* 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.
This commit is contained in:
parent
5a1f5858d4
commit
a06660f799
6 changed files with 115 additions and 27 deletions
|
@ -1,3 +1,17 @@
|
||||||
|
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>
|
2005-07-13 Daniel Jacobowitz <dan@codesourcery.com>
|
||||||
|
|
||||||
* linux-low.c (fetch_register, usr_store_inferior_registers): Handle
|
* linux-low.c (fetch_register, usr_store_inferior_registers): Handle
|
||||||
|
|
|
@ -30,6 +30,7 @@ struct thread_info
|
||||||
struct inferior_list_entry entry;
|
struct inferior_list_entry entry;
|
||||||
void *target_data;
|
void *target_data;
|
||||||
void *regcache_data;
|
void *regcache_data;
|
||||||
|
unsigned int gdb_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct inferior_list all_threads;
|
struct inferior_list all_threads;
|
||||||
|
@ -102,7 +103,7 @@ remove_inferior (struct inferior_list *list,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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 *new_thread
|
||||||
= (struct thread_info *) malloc (sizeof (*new_thread));
|
= (struct thread_info *) malloc (sizeof (*new_thread));
|
||||||
|
@ -118,6 +119,45 @@ add_thread (unsigned long thread_id, void *target_data)
|
||||||
|
|
||||||
new_thread->target_data = target_data;
|
new_thread->target_data = target_data;
|
||||||
set_inferior_regcache_data (new_thread, new_register_cache ());
|
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
|
static void
|
||||||
|
|
|
@ -160,7 +160,7 @@ linux_create_inferior (char *program, char **allargs)
|
||||||
}
|
}
|
||||||
|
|
||||||
new_process = add_process (pid);
|
new_process = add_process (pid);
|
||||||
add_thread (pid, new_process);
|
add_thread (pid, new_process, pid);
|
||||||
|
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ linux_attach_lwp (unsigned long pid, unsigned long tid)
|
||||||
}
|
}
|
||||||
|
|
||||||
new_process = (struct process_info *) add_process (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
|
/* 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
|
brings it to a halt. We should ignore that SIGSTOP and resume the process
|
||||||
|
|
|
@ -683,6 +683,8 @@ prepare_resume_reply (char *buf, char status, unsigned char signo)
|
||||||
{
|
{
|
||||||
/* FIXME right place to set this? */
|
/* FIXME right place to set this? */
|
||||||
thread_from_wait = ((struct inferior_list_entry *)current_inferior)->id;
|
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)
|
if (debug_threads)
|
||||||
fprintf (stderr, "Writing resume reply for %ld\n\n", thread_from_wait);
|
fprintf (stderr, "Writing resume reply for %ld\n\n", thread_from_wait);
|
||||||
/* This if (1) ought to be unnecessary. But remote_wait in GDB
|
/* This if (1) ought to be unnecessary. But remote_wait in GDB
|
||||||
|
@ -692,7 +694,7 @@ prepare_resume_reply (char *buf, char status, unsigned char signo)
|
||||||
if (1 || old_thread_from_wait != thread_from_wait)
|
if (1 || old_thread_from_wait != thread_from_wait)
|
||||||
{
|
{
|
||||||
general_thread = 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);
|
buf += strlen (buf);
|
||||||
old_thread_from_wait = thread_from_wait;
|
old_thread_from_wait = thread_from_wait;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ handle_query (char *own_buf)
|
||||||
if (strcmp ("qfThreadInfo", own_buf) == 0)
|
if (strcmp ("qfThreadInfo", own_buf) == 0)
|
||||||
{
|
{
|
||||||
thread_ptr = all_threads.head;
|
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;
|
thread_ptr = thread_ptr->next;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ handle_query (char *own_buf)
|
||||||
{
|
{
|
||||||
if (thread_ptr != NULL)
|
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;
|
thread_ptr = thread_ptr->next;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -218,13 +218,21 @@ handle_v_cont (char *own_buf, char *status, int *signal)
|
||||||
}
|
}
|
||||||
else if (p[0] == ':')
|
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)
|
if (p == q)
|
||||||
goto err;
|
goto err;
|
||||||
p = q;
|
p = q;
|
||||||
if (p[0] != ';' && p[0] != 0)
|
if (p[0] != ';' && p[0] != 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
thread_id = gdb_id_to_thread_id (gdb_id);
|
||||||
|
if (thread_id)
|
||||||
|
resume_info[i].thread = thread_id;
|
||||||
|
else
|
||||||
|
goto err;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -431,26 +439,35 @@ main (int argc, char *argv[])
|
||||||
prepare_resume_reply (own_buf, status, signal);
|
prepare_resume_reply (own_buf, status, signal);
|
||||||
break;
|
break;
|
||||||
case 'H':
|
case 'H':
|
||||||
switch (own_buf[1])
|
if (own_buf[1] == 'c' || own_buf[1] == 'g' || own_buf[1] == 's')
|
||||||
{
|
{
|
||||||
case 'g':
|
unsigned long gdb_id, thread_id;
|
||||||
general_thread = strtoul (&own_buf[2], NULL, 16);
|
|
||||||
|
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);
|
write_ok (own_buf);
|
||||||
set_desired_inferior (1);
|
}
|
||||||
break;
|
else
|
||||||
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);
|
|
||||||
write_ok (own_buf);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* Silently ignore it so that gdb can extend the protocol
|
/* Silently ignore it so that gdb can extend the protocol
|
||||||
without compatibility headaches. */
|
without compatibility headaches. */
|
||||||
own_buf[0] = '\0';
|
own_buf[0] = '\0';
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
|
@ -592,10 +609,22 @@ main (int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'T':
|
case 'T':
|
||||||
if (mythread_alive (strtoul (&own_buf[1], NULL, 16)))
|
{
|
||||||
write_ok (own_buf);
|
unsigned long gdb_id, thread_id;
|
||||||
else
|
|
||||||
write_enn (own_buf);
|
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;
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
/* Restarting the inferior is only supported in the
|
/* Restarting the inferior is only supported in the
|
||||||
|
|
|
@ -97,7 +97,10 @@ extern struct thread_info *current_inferior;
|
||||||
void remove_inferior (struct inferior_list *list,
|
void remove_inferior (struct inferior_list *list,
|
||||||
struct inferior_list_entry *entry);
|
struct inferior_list_entry *entry);
|
||||||
void remove_thread (struct thread_info *thread);
|
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);
|
void clear_inferiors (void);
|
||||||
struct inferior_list_entry *find_inferior
|
struct inferior_list_entry *find_inferior
|
||||||
(struct inferior_list *,
|
(struct inferior_list *,
|
||||||
|
|
Loading…
Add table
Reference in a new issue