genode/repos/os/src/app/trace_logger/policy.cc
Martin Stein ccc67d6f68 trace_logger: convenient tracing frontend
The 'trace_logger' component can be used to easily gather, process and export
different types of tracing data. Which subjects to select is configurable via
session label policies and thread names. Which data to collect from the
selected subjects can be configured for each subject individually, for groups
of subjects, or for all subjects. The gathered data can be exported as log
output.

This is an example configuration of the 'trace_logger' component which shows
the default value for each attribute except the policy.thread and
policy.label:

! <config verbose="no"
!         session_ram="10M"
!         session_arg_buffer="4K"
!         session_parent_levels="0"
!         period_sec="5"
!         activity="no"
!         affinity="no"
!         default_policy="null"
!         default_buffer="4K">
!
!    <policy label="init -> timer" />
!    <policy label_suffix=" -> ram_fs" />
!    <policy label_prefix="init -> encryption -> "
!            thread="worker"
!            buffer="4K"
!            policy="null" />
! </config>

For more details see os/src/app/trace_logger/README.

Fixes #2654
2018-02-09 13:34:20 +01:00

69 lines
1.4 KiB
C++

/*
* \brief Installs and maintains a tracing policy
* \author Martin Stein
* \date 2018-01-12
*/
/*
* Copyright (C) 2018 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/* local includes */
#include <policy.h>
using namespace Genode;
/***********************
** Policy_avl_member **
***********************/
Policy_avl_member::Policy_avl_member(Policy_name const &name,
::Policy &policy)
:
Avl_string_base(name.string()), _policy(policy)
{ }
/************
** Policy **
************/
Policy::Policy(Env &env, Trace::Connection &trace, Policy_name const &name)
:
Policy_base(name), _avl_member(_name, *this), _env(env), _trace(trace)
{
Dataspace_capability dst_ds = _trace.policy(_id);
void *dst = _env.rm().attach(dst_ds);
void *src = _env.rm().attach(_ds);
memcpy(dst, src, _size);
_env.rm().detach(dst);
_env.rm().detach(src);
}
/*****************
** Policy_tree **
*****************/
Policy &Policy_tree::policy(Avl_string_base const &node)
{
return static_cast<Policy_avl_member const *>(&node)->policy();
}
Policy &Policy_tree::find_by_name(Policy_name name)
{
if (name == Policy_name() || !first()) {
throw No_match(); }
Avl_string_base *node = first()->find_by_name(name.string());
if (!node) {
throw No_match(); }
return policy(*node);
}