/* Ada Ravenscar thread support.
- Copyright (C) 2004-2017 Free Software Foundation, Inc.
+ Copyright (C) 2004-2018 Free Software Foundation, Inc.
This file is part of GDB.
#include "inferior.h"
#include "command.h"
#include "ravenscar-thread.h"
-#include "observer.h"
+#include "observable.h"
#include "gdbcmd.h"
#include "top.h"
#include "regcache.h"
static int
is_ravenscar_task (ptid_t ptid)
{
- /* By construction, ravenscar tasks have their LWP set to zero. */
- return ptid_get_lwp (ptid) == 0;
+ /* By construction, ravenscar tasks have their LWP set to zero.
+ Also make sure that the TID is nonzero, as some remotes, when
+ asked for the list of threads, will return the first thread
+ as having its TID set to zero. For instance, TSIM version
+ 2.0.48 for LEON3 sends 'm0' as a reply to the 'qfThreadInfo'
+ query, which the remote protocol layer then treats as a thread
+ whose TID is 0. This is obviously not a ravenscar task. */
+ return ptid_get_lwp (ptid) == 0 && ptid_get_tid (ptid) != 0;
}
/* Given PTID, which can be either a ravenscar task or a CPU thread,
int options)
{
struct target_ops *beneath = find_target_beneath (ops);
+ ptid_t event_ptid;
inferior_ptid = base_ptid;
- beneath->to_wait (beneath, base_ptid, status, 0);
+ event_ptid = beneath->to_wait (beneath, base_ptid, status, 0);
/* Find any new threads that might have been created, and update
inferior_ptid to the active thread.
if (status->kind != TARGET_WAITKIND_EXITED
&& status->kind != TARGET_WAITKIND_SIGNALLED)
{
+ inferior_ptid = event_ptid;
ravenscar_update_thread_list (ops);
ravenscar_update_inferior_ptid ();
}
static void
ravenscar_inferior_created (struct target_ops *target, int from_tty)
{
+ const char *err_msg;
if (!ravenscar_task_support
|| gdbarch_ravenscar_ops (target_gdbarch ()) == NULL
|| !has_ravenscar_runtime ())
return;
+ err_msg = ada_get_tcb_types_info ();
+ if (err_msg != NULL)
+ {
+ warning (_("%s. Task/thread support disabled."), err_msg);
+ return;
+ }
+
ravenscar_update_inferior_ptid ();
push_target (&ravenscar_ops);
}
/* Notice when the inferior is created in order to push the
ravenscar ops if needed. */
- observer_attach_inferior_created (ravenscar_inferior_created);
+ gdb::observers::inferior_created.attach (ravenscar_inferior_created);
complete_target_initialization (&ravenscar_ops);