L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
debug.h
1/*
2 * (c) 2013-2014 Alexander Warg <warg@os.inf.tu-dresden.de>
3 * economic rights: Technische Universität Dresden (Germany)
4 *
5 * License: see LICENSE.spdx (in this directory or the directories above)
6 */
7#pragma once
8
9#include <l4/re/util/debug>
10
11struct Err : L4Re::Util::Err
12{
13 Err(Level l = Fatal) : L4Re::Util::Err(l, "VSwitch") {}
14};
15
16class Dbg : public L4Re::Util::Dbg
17{
18 enum
19 {
20 Verbosity_shift = 4,
21 Verbosity_mask = (1UL << Verbosity_shift) - 1
22 };
23
24public:
26 enum Verbosity : unsigned long
27 {
28 Quiet = 0,
29 Warn = 1,
30 Info = 2,
31 Debug = 4,
32 Trace = 8,
33 Max_verbosity = 8
34 };
35
39 enum Component
40 {
41 Core = 0,
42 Virtio,
43 Port,
44 Request,
45 Queue,
46 Packet,
47 Max_component
48 };
49
50#ifndef NDEBUG
51
52 static_assert(Max_component * Verbosity_shift <= sizeof(level) * 8,
53 "Too many components for level mask");
54 static_assert((Max_verbosity & Verbosity_mask) == Max_verbosity,
55 "Verbosity_shift to small for verbosity levels");
56
62 static void set_verbosity(unsigned mask)
63 {
64 for (unsigned i = 0; i < Max_component; ++i)
65 set_verbosity(i, mask);
66 }
67
74 static void set_verbosity(unsigned c, unsigned mask)
75 {
76 level &= ~(Verbosity_mask << (Verbosity_shift * c));
77 level |= (mask & Verbosity_mask) << (Verbosity_shift * c);
78 }
79
89 static bool is_active(unsigned c, unsigned mask)
90 { return level & (mask & Verbosity_mask) << (Verbosity_shift * c); }
91
98 using L4Re::Util::Dbg::is_active;
99
100 Dbg(Component c = Core, Verbosity v = Warn, char const *subsys = "")
101 : L4Re::Util::Dbg(v << (Verbosity_shift * c), "SWI", subsys)
102 {}
103
104#else
105
106 static void set_verbosity(unsigned) {}
107 static void set_verbosity(unsigned, unsigned) {}
108
109 static bool is_active(unsigned, unsigned) { return false; }
110 using L4Re::Util::Dbg::is_active;
111
112 Dbg(Component c = Core, Verbosity v = Warn, char const *subsys = "")
113 : L4Re::Util::Dbg(v << (Verbosity_shift * c), "", subsys)
114 {}
115
116#endif
117};
L4Re C++ Interfaces.
Definition cmd_control:14