gdbserver crash running gdb.threads/non-ldr-exc-1.exp
This fixes a gdbserver crash when running gdb.threads/non-ldr-exc-1.exp with "maint set target-non-stop on". The problem is that qSymbol is called when gdbserver has current_thread == NULL. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdbthread.h (find_any_thread_of_pid): Declare. * inferiors.c (thread_of_pid, find_any_thread_of_pid): New functions. * server.c (handle_query): If current_thread is NULL, look for another thread of the selected process.
This commit is contained in:
parent
066f6b6edc
commit
34c6591498
4 changed files with 59 additions and 0 deletions
|
@ -1975,6 +1975,28 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
|
|||
|
||||
if (strcmp ("qSymbol::", own_buf) == 0)
|
||||
{
|
||||
struct thread_info *save_thread = current_thread;
|
||||
|
||||
/* For qSymbol, GDB only changes the current thread if the
|
||||
previous current thread was of a different process. So if
|
||||
the previous thread is gone, we need to pick another one of
|
||||
the same process. This can happen e.g., if we followed an
|
||||
exec in a non-leader thread. */
|
||||
if (current_thread == NULL)
|
||||
{
|
||||
current_thread
|
||||
= find_any_thread_of_pid (ptid_get_pid (general_thread));
|
||||
|
||||
/* Just in case, if we didn't find a thread, then bail out
|
||||
instead of crashing. */
|
||||
if (current_thread == NULL)
|
||||
{
|
||||
write_enn (own_buf);
|
||||
current_thread = save_thread;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* GDB is suggesting new symbols have been loaded. This may
|
||||
mean a new shared library has been detected as loaded, so
|
||||
take the opportunity to check if breakpoints we think are
|
||||
|
@ -1993,6 +2015,8 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
|
|||
if (current_thread != NULL && the_target->look_up_symbols != NULL)
|
||||
(*the_target->look_up_symbols) ();
|
||||
|
||||
current_thread = save_thread;
|
||||
|
||||
strcpy (own_buf, "OK");
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue