genode/repos/os/src/app/trace_logger/monitor.h
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

104 lines
2.3 KiB
C++

/*
* \brief Monitoring of a trace subject
* \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.
*/
#ifndef _MONITOR_H_
#define _MONITOR_H_
/* local includes */
#include <avl_tree.h>
#include <trace_buffer.h>
/* Genode includes */
#include <base/trace/types.h>
namespace Genode { namespace Trace { class Connection; } }
/**
* To attach and detach trace-buffer dataspace in the right moments
*/
class Monitor_base
{
protected:
Genode::Trace::Connection &_trace;
Genode::Region_map &_rm;
Genode::Trace::Buffer &_buffer_raw;
Monitor_base(Genode::Trace::Connection &trace,
Genode::Region_map &rm,
Genode::Trace::Subject_id subject_id);
~Monitor_base();
};
/**
* Monitors tracing information of one tracing subject
*/
class Monitor : public Monitor_base,
public Local::Avl_node<Monitor>
{
private:
enum { MAX_ENTRY_LENGTH = 256 };
Genode::Trace::Subject_id const _subject_id;
Trace_buffer _buffer;
unsigned long _report_id { 0 };
Genode::Trace::Subject_info _info { };
unsigned long long _recent_exec_time { 0 };
char _curr_entry_data[MAX_ENTRY_LENGTH];
void _update_info();
public:
Monitor(Genode::Trace::Connection &trace,
Genode::Region_map &rm,
Genode::Trace::Subject_id subject_id);
void print(bool activity, bool affinity);
/**************
** Avl_node **
**************/
Monitor &find_by_subject_id(Genode::Trace::Subject_id const subject_id);
bool higher(Monitor *monitor) { return monitor->_subject_id.id > _subject_id.id; }
/***************
** Accessors **
***************/
Genode::Trace::Subject_id subject_id() const { return _subject_id; }
Genode::Trace::Subject_info const &info() const { return _info; }
};
/**
* AVL tree of monitors with their subject ID as index
*/
struct Monitor_tree : Local::Avl_tree<Monitor>
{
struct No_match : Genode::Exception { };
Monitor &find_by_subject_id(Genode::Trace::Subject_id const subject_id);
};
#endif /* _MONITOR_H_ */