trace: initialize trace control in Thread::start

Previously, the trace control of a thread was initialized in its
constructor (which is generic for all components). This has the
disadvantage that the CPU-session-pointer member of the thread might not
be valid at this point. And it cannot be replaced by using the
"deprecated_env" CPU session neither as constructing the deprecated
environment in causes troubles in Core. But as the trace control
shouldn't be needed in Core anyway, the initialization can be moved to
the Thread::start implementation of non-core components. This code
already takes care of the CPU session pointer.

Fixes #2901
This commit is contained in:
Martin Stein 2018-07-02 14:55:01 +02:00 committed by Christian Helmuth
parent 09bf68e8ad
commit fbe9d26c47
6 changed files with 20 additions and 15 deletions

View File

@ -48,9 +48,7 @@ void Thread::_deinit_platform_thread()
void Thread::_init_platform_thread(size_t weight, Type type)
{
/* if no cpu session is given, use it from the environment */
if (!_cpu_session)
_cpu_session = env_deprecated()->cpu_session();
_init_cpu_session_and_trace_control();
if (type == NORMAL)
{

View File

@ -37,7 +37,8 @@ namespace Hw {
void Thread::_init_platform_thread(size_t weight, Type type)
{
if (!_cpu_session) { _cpu_session = env_deprecated()->cpu_session(); }
_init_cpu_session_and_trace_control();
if (type == NORMAL) {
/* create server object */

View File

@ -107,9 +107,8 @@ void Thread::_init_platform_thread(size_t weight, Type type)
if (native_thread().exc_pt_sel == Native_thread::INVALID_INDEX)
throw Cpu_session::Thread_creation_failed();
/* if no cpu session is given, use it from the environment */
if (!_cpu_session)
_cpu_session = env_deprecated()->cpu_session();
_init_cpu_session_and_trace_control();
/* create thread at core */
_thread_cap = _cpu_session->create_thread(env_deprecated()->pd_session_cap(), name(),

View File

@ -172,6 +172,8 @@ class Genode::Thread
*/
void _init_platform_thread(size_t weight, Type type);
void _init_cpu_session_and_trace_control();
public:
/**

View File

@ -207,12 +207,19 @@ Thread::Thread(size_t weight, const char *name, size_t stack_size,
_join_lock(Lock::LOCKED)
{
_init_platform_thread(weight, type);
}
if (_cpu_session) {
Dataspace_capability ds = _cpu_session->trace_control();
if (ds.valid())
_trace_control = env_deprecated()->rm_session()->attach(ds);
}
void Thread::_init_cpu_session_and_trace_control()
{
/* if no CPU session is given, use it from the environment */
if (!_cpu_session) {
_cpu_session = env_deprecated()->cpu_session(); }
/* initialize trace control now that the CPU session must be valid */
Dataspace_capability ds = _cpu_session->trace_control();
if (ds.valid()) {
_trace_control = env_deprecated()->rm_session()->attach(ds); }
}

View File

@ -67,9 +67,7 @@ void Thread::_deinit_platform_thread()
void Thread::start()
{
/* if no CPU session is given, use it from the environment */
if (!_cpu_session)
_cpu_session = env_deprecated()->cpu_session();
_init_cpu_session_and_trace_control();
/* create thread at core */
addr_t const utcb = (addr_t)&_stack->utcb();