+2015-08-21 Pedro Alves <palves@redhat.com>
+
+ * linux-low.c (wait_for_sigstop): Always switch to no thread
+ selected if the previously current thread dies.
+ * lynx-low.c (lynx_request_interrupt): Use the first thread's
+ process instead of the current thread's.
+ * remote-utils.c (input_interrupt): Don't check if there's no
+ current thread.
+ * server.c (gdb_read_memory, gdb_write_memory): If setting the
+ current thread to the general thread fails, error out.
+ (handle_qxfer_auxv, handle_qxfer_libraries)
+ (handle_qxfer_libraries_svr4, handle_qxfer_siginfo)
+ (handle_qxfer_spu, handle_qxfer_statictrace, handle_qxfer_fdpic)
+ (handle_query): Check if there's a thread selected instead of
+ checking whether there's any thread in the thread list.
+ (handle_qxfer_threads, handle_qxfer_btrace)
+ (handle_qxfer_btrace_conf): Don't error out early if there's no
+ thread in the thread list.
+ (handle_v_cont, myresume): Don't set the current thread to the
+ continue thread.
+ (process_serial_event) <Hg handling>: Also set thread_id if the
+ previous general thread is still alive.
+ (process_serial_event) <g/G handling>: If setting the current
+ thread to the general thread fails, error out.
+ * spu-low.c (spu_resume, spu_request_interrupt): Use the first
+ thread's lwp instead of the current thread's.
+ * target.c (set_desired_thread): If the desired thread was not
+ found, leave the current thread pointing to NULL. Return an int
+ (boolean) indicating success.
+ * target.h (set_desired_thread): Change return type to int.
+
2015-08-20 Max Filippov <jcmvbkbc@gmail.com>
* configure.srv (xtensa*-*-linux*): Add srv_linux_thread_db=yes.
res = prepare_to_access_memory ();
if (res == 0)
{
- res = read_inferior_memory (memaddr, myaddr, len);
+ if (set_desired_thread (1))
+ res = read_inferior_memory (memaddr, myaddr, len);
+ else
+ res = 1;
done_accessing_memory ();
return res == 0 ? len : -1;
ret = prepare_to_access_memory ();
if (ret == 0)
{
- ret = write_inferior_memory (memaddr, myaddr, len);
+ if (set_desired_thread (1))
+ ret = write_inferior_memory (memaddr, myaddr, len);
+ else
+ ret = EIO;
done_accessing_memory ();
}
return ret;
if (the_target->read_auxv == NULL || writebuf != NULL)
return -2;
- if (annex[0] != '\0' || !target_running ())
+ if (annex[0] != '\0' || current_thread == NULL)
return -1;
return (*the_target->read_auxv) (offset, readbuf, len);
if (writebuf != NULL)
return -2;
- if (annex[0] != '\0' || !target_running ())
+ if (annex[0] != '\0' || current_thread == NULL)
return -1;
total_len = 64;
if (writebuf != NULL)
return -2;
- if (!target_running () || the_target->qxfer_libraries_svr4 == NULL)
+ if (current_thread == NULL || the_target->qxfer_libraries_svr4 == NULL)
return -1;
return the_target->qxfer_libraries_svr4 (annex, readbuf, writebuf, offset, len);
if (the_target->qxfer_siginfo == NULL)
return -2;
- if (annex[0] != '\0' || !target_running ())
+ if (annex[0] != '\0' || current_thread == NULL)
return -1;
return (*the_target->qxfer_siginfo) (annex, readbuf, writebuf, offset, len);
if (the_target->qxfer_spu == NULL)
return -2;
- if (!target_running ())
+ if (current_thread == NULL)
return -1;
return (*the_target->qxfer_spu) (annex, readbuf, writebuf, offset, len);
if (writebuf != NULL)
return -2;
- if (annex[0] != '\0' || !target_running () || current_traceframe == -1)
+ if (annex[0] != '\0' || current_thread == NULL || current_traceframe == -1)
return -1;
if (traceframe_read_sdata (current_traceframe, offset,
if (writebuf != NULL)
return -2;
- if (!target_running () || annex[0] != '\0')
+ if (annex[0] != '\0')
return -1;
if (offset == 0)
if (the_target->read_loadmap == NULL)
return -2;
- if (!target_running ())
+ if (current_thread == NULL)
return -1;
return (*the_target->read_loadmap) (annex, offset, readbuf, len);
if (the_target->read_btrace == NULL || writebuf != NULL)
return -2;
- if (!target_running ())
- return -1;
-
if (ptid_equal (general_thread, null_ptid)
|| ptid_equal (general_thread, minus_one_ptid))
{
if (the_target->read_btrace_conf == NULL || writebuf != NULL)
return -2;
- if (annex[0] != '\0' || !target_running ())
+ if (annex[0] != '\0')
return -1;
if (ptid_equal (general_thread, null_ptid)
if (target_supports_tracepoints ())
tracepoint_look_up_symbols ();
- if (target_running () && the_target->look_up_symbols != NULL)
+ if (current_thread != NULL && the_target->look_up_symbols != NULL)
(*the_target->look_up_symbols) ();
strcpy (own_buf, "OK");
if (i < n)
resume_info[i] = default_action;
- set_desired_thread (0);
-
resume (resume_info, n);
free (resume_info);
return;
int n = 0;
int valid_cont_thread;
- set_desired_thread (0);
-
valid_cont_thread = (!ptid_equal (cont_thread, null_ptid)
&& !ptid_equal (cont_thread, minus_one_ptid));
(struct thread_info *) find_inferior_id (&all_threads,
general_thread);
if (thread == NULL)
- {
- thread = get_first_thread ();
- thread_id = thread->entry.id;
- }
+ thread = get_first_thread ();
+ thread_id = thread->entry.id;
}
general_thread = thread_id;
set_desired_thread (1);
+ gdb_assert (current_thread != NULL);
}
else if (own_buf[1] == 'c')
cont_thread = thread_id;
{
struct regcache *regcache;
- set_desired_thread (1);
- regcache = get_thread_regcache (current_thread, 1);
- registers_to_string (regcache, own_buf);
+ if (!set_desired_thread (1))
+ write_enn (own_buf);
+ else
+ {
+ regcache = get_thread_regcache (current_thread, 1);
+ registers_to_string (regcache, own_buf);
+ }
}
break;
case 'G':
{
struct regcache *regcache;
- set_desired_thread (1);
- regcache = get_thread_regcache (current_thread, 1);
- registers_from_string (regcache, &own_buf[1]);
- write_ok (own_buf);
+ if (!set_desired_thread (1))
+ write_enn (own_buf);
+ else
+ {
+ regcache = get_thread_regcache (current_thread, 1);
+ registers_from_string (regcache, &own_buf[1]);
+ write_ok (own_buf);
+ }
}
break;
case 'm':
static void
spu_resume (struct thread_resume *resume_info, size_t n)
{
+ struct thread_info *thr = get_first_thread ();
size_t i;
for (i = 0; i < n; i++)
if (ptid_equal (resume_info[i].thread, minus_one_ptid)
- || ptid_equal (resume_info[i].thread, current_ptid))
+ || ptid_equal (resume_info[i].thread, ptid_of (thr)))
break;
if (i == n)
regcache_invalidate ();
errno = 0;
- ptrace (PTRACE_CONT, ptid_get_lwp (current_ptid), 0, resume_info[i].sig);
+ ptrace (PTRACE_CONT, ptid_get_lwp (ptid_of (thr)), 0, resume_info[i].sig);
if (errno)
perror_with_name ("ptrace");
}
static void
spu_request_interrupt (void)
{
- syscall (SYS_tkill, ptid_get_lwp (current_ptid), SIGINT);
+ struct thread_info *thr = get_first_thread ();
+
+ syscall (SYS_tkill, ptid_get_lwp (thr), SIGINT);
}
static struct target_ops spu_target_ops = {