2013-08-10 03:44:55 +02:00
|
|
|
/*
|
|
|
|
* \brief TRACE session implementation
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2013-08-12
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2013-2017 Genode Labs GmbH
|
2013-08-10 03:44:55 +02:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 13:23:52 +01:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2013-08-10 03:44:55 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CORE__INCLUDE__TRACE__SESSION_COMPONENT_H_
|
|
|
|
#define _CORE__INCLUDE__TRACE__SESSION_COMPONENT_H_
|
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <base/allocator_guard.h>
|
|
|
|
#include <base/rpc_server.h>
|
|
|
|
#include <base/tslab.h>
|
2019-01-30 17:53:16 +01:00
|
|
|
#include <base/attached_ram_dataspace.h>
|
2013-08-10 03:44:55 +02:00
|
|
|
#include <trace_session/trace_session.h>
|
|
|
|
|
|
|
|
/* core-local includes */
|
|
|
|
#include <trace/subject_registry.h>
|
|
|
|
#include <trace/policy_registry.h>
|
|
|
|
|
|
|
|
namespace Genode { namespace Trace { class Session_component; } }
|
|
|
|
|
|
|
|
|
|
|
|
class Genode::Trace::Session_component
|
|
|
|
:
|
|
|
|
public Genode::Rpc_object<Genode::Trace::Session,
|
|
|
|
Genode::Trace::Session_component>,
|
|
|
|
public Genode::Trace::Policy_owner
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
2019-01-30 17:53:16 +01:00
|
|
|
Ram_allocator &_ram;
|
|
|
|
Region_map &_local_rm;
|
2017-01-30 11:07:58 +01:00
|
|
|
Allocator_guard _md_alloc;
|
|
|
|
Tslab<Trace::Subject, 4096> _subjects_slab;
|
|
|
|
Tslab<Trace::Policy, 4096> _policies_slab;
|
base/core: use references instead of pointers
This patch replaces the former prominent use of pointers by references
wherever feasible. This has the following benefits:
* The contract between caller and callee becomes more obvious. When
passing a reference, the contract says that the argument cannot be
a null pointer. The caller is responsible to ensure that. Therefore,
the use of reference eliminates the need to add defensive null-pointer
checks at the callee site, which sometimes merely exist to be on the
safe side. The bottom line is that the code becomes easier to follow.
* Reference members must be initialized via an object initializer,
which promotes a programming style that avoids intermediate object-
construction states. Within core, there are still a few pointers
as member variables left though. E.g., caused by the late association
of 'Platform_thread' objects with their 'Platform_pd' objects.
* If no pointers are present as member variables, we don't need to
manually provide declarations of a private copy constructor and
an assignment operator to avoid -Weffc++ errors "class ... has
pointer data members [-Werror=effc++]".
This patch also changes a few system bindings on NOVA and Fiasco.OC,
e.g., the return value of the global 'cap_map' accessor has become a
reference. Hence, the patch touches a few places outside of core.
Fixes #3135
2019-01-24 22:00:01 +01:00
|
|
|
unsigned const _parent_levels;
|
|
|
|
Session_label const _label;
|
2017-01-30 11:07:58 +01:00
|
|
|
Source_registry &_sources;
|
|
|
|
Policy_registry &_policies;
|
|
|
|
Subject_registry _subjects;
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 15:42:15 +01:00
|
|
|
unsigned _policy_cnt { 0 };
|
2019-01-30 17:53:16 +01:00
|
|
|
Attached_ram_dataspace _argument_buffer;
|
2013-08-10 03:44:55 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
2019-01-30 17:53:16 +01:00
|
|
|
Session_component(Ram_allocator &ram, Region_map &local_rm,
|
|
|
|
Allocator &md_alloc, size_t ram_quota,
|
|
|
|
size_t arg_buffer_size, unsigned parent_levels,
|
|
|
|
char const *label, Source_registry &sources,
|
|
|
|
Policy_registry &policies);
|
2013-08-10 03:44:55 +02:00
|
|
|
|
|
|
|
~Session_component();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register quota donation at allocator guard
|
|
|
|
*/
|
|
|
|
void upgrade_ram_quota(size_t ram_quota) { _md_alloc.upgrade(ram_quota); }
|
|
|
|
|
|
|
|
|
|
|
|
/***********************
|
|
|
|
** Session interface **
|
|
|
|
***********************/
|
|
|
|
|
|
|
|
Dataspace_capability dataspace();
|
|
|
|
size_t subjects();
|
|
|
|
|
|
|
|
Policy_id alloc_policy(size_t);
|
|
|
|
Dataspace_capability policy(Policy_id);
|
|
|
|
void unload_policy(Policy_id);
|
|
|
|
void trace(Subject_id, Policy_id, size_t);
|
|
|
|
void rule(Session_label const &, Thread_name const &, Policy_id, size_t);
|
|
|
|
void pause(Subject_id);
|
|
|
|
void resume(Subject_id);
|
|
|
|
Subject_info subject_info(Subject_id);
|
|
|
|
Dataspace_capability buffer(Subject_id);
|
|
|
|
void free(Subject_id);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _CORE__INCLUDE__TRACE__SESSION_COMPONENT_H_ */
|