Convert LTTngTop to C++ and state system
[lttngtop.git] / src / common.h
CommitLineData
1fc22eb4 1/*
aa15ac1c 2 * Copyright (C) 2011-2012 Julien Desfossez
1fc22eb4
JD
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
71bd7ce1
AM
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1fc22eb4
JD
16 */
17
18#ifndef _COMMON_H
19#define _COMMON_H
20
21#include <semaphore.h>
715cf83c 22extern "C" {
1fc22eb4 23#include <babeltrace/ctf/events.h>
715cf83c
PBT
24}
25#include <state/IntervalHistoryProvider.hpp>
26#include <state/StateSystem.hpp>
27#include <state/statevalue/StateValue.hpp>
28#include <state/statevalue/IntegerStateValue.hpp>
29#include <state/statevalue/StringStateValue.hpp>
30#include <state/statevalue/NullStateValue.hpp>
31#include <state/statevalue/QuarkStateValue.hpp>
32#include <sstream>
33#include <map>
34#include <vector>
35#include <set>
36
1fc22eb4
JD
37#include "lttngtoptypes.h"
38#include "cputop.h"
39
715cf83c
PBT
40using namespace State;
41
1fc22eb4
JD
42#define NSEC_PER_USEC 1000
43#define NSEC_PER_SEC 1000000000L
44
715cf83c
PBT
45extern StateSystem *state_system;
46extern std::set<Quark> modified_quarks;
47const unsigned long refresh_display = 1 * NSEC_PER_SEC;
48extern unsigned long last_display_update;
49extern unsigned long first_display_update;
1fc22eb4 50
715cf83c 51extern sem_t goodtodisplay, goodtoupdate, timer, pause_sem, end_trace_sem, bootstrap;
59288610 52
715cf83c
PBT
53bool find_process_tid(int tid, Quark &ret_proc_quark);
54Quark add_proc(int tid, std::string comm, unsigned long timestamp);
55void update_proc(unsigned long timestamp, Quark proc, int pid, int tid,
56 int ppid, char *comm);
57void add_thread(unsigned long timestamp, Quark parent, Quark thread);
58Quark get_proc(int tid, char *comm, unsigned long timestamp);
59Quark get_proc_pid(int pid, int tid, unsigned long timestamp);
60void death_proc(int tid, char *comm, unsigned long timestamp);
59288610 61
715cf83c
PBT
62Quark add_cpu(int cpu, unsigned long timestamp);
63Quark get_cpu(int cpu, unsigned long timestamp);
64void update_state_on_refresh(unsigned long start, unsigned long end);
65Quark get_perf_counter(unsigned long timestamp, Quark root, std::string name);
1fc22eb4 66
d67167cd 67/* common field access functions */
715cf83c
PBT
68int get_cpu_id(const struct bt_ctf_event *event);
69int get_context_tid(const struct bt_ctf_event *event);
70int get_context_pid(const struct bt_ctf_event *event);
71int get_context_ppid(const struct bt_ctf_event *event);
4adc8274 72char *get_context_comm(const struct bt_ctf_event *event);
d67167cd 73
715cf83c
PBT
74enum bt_cb_ret handle_statedump_process_state(
75 struct bt_ctf_event *call_data, void *private_data);
76
77std::string path_name_from_cpuid(int cpuid);
78std::string thread_path_name_from_tid(int tid);
79std::string path_name_from_tid(int tid);
80std::string path_name_from_fd(int fd);
81
82void update_file_on_refresh(Quark proc, Quark file, unsigned long end);
83void update_proc_on_refresh(Quark proc, unsigned long start, unsigned long end);
84
85void modify_attribute(unsigned long timestamp, const Quark *starting_node,
86 std::string attribute, int value);
87void modify_attribute(unsigned long timestamp, const Quark *starting_node,
88 std::string attribute, Quark value);
89void modify_attribute(unsigned long timestamp, const Quark *starting_node,
90 std::string attribute, char *value);
91void modify_attribute(unsigned long timestamp, const Quark *starting_node,
92 std::string attribute, unsigned long value);
93void modify_attribute(unsigned long timestamp, const Quark *starting_node,
94 std::string attribute, std::string value);
95void nullify_attribute(unsigned long timestamp, const Quark *starting_node,
96 std::string attribute);
97void increment_attribute(unsigned long timestamp, const Quark *starting_node,
98 std::string attribute);
99void increase_attribute(unsigned long timestamp, const Quark *starting_node,
100 std::string attribute, int amount);
101void increase_attribute(unsigned long timestamp, const Quark *starting_node,
102 std::string attribute, unsigned long amount);
103void decrement_attribute(unsigned long timestamp, const Quark *starting_node,
104 std::string attribute);
105void decrease_attribute(unsigned long timestamp, const Quark *starting_node,
106 std::string attribute, int amount);
107void decrease_attribute(unsigned long timestamp, const Quark *starting_node,
108 std::string attribute, unsigned long amount);
109bool get_current_attribute_value_int(const Quark *starting_node,
110 std::string attribute, int &value);
111bool get_current_attribute_value_ulong(const Quark *starting_node,
112 std::string attribute, unsigned long &value);
113bool get_current_attribute_value_quark(const Quark *starting_node,
114 std::string attribute, Quark &value);
115bool get_current_attribute_value_string(const Quark *starting_node,
116 std::string attribute, std::string &value);
117bool get_attribute_value_at_int(unsigned long timestamp,
118 const Quark *starting_node,
119 std::string attribute,
120 int &value);
121bool get_attribute_value_at_ulong(unsigned long timestamp,
122 const Quark *starting_node,
123 std::string attribute,
124 unsigned long &value);
125bool get_attribute_value_at_quark(unsigned long timestamp,
126 const Quark *starting_node,
127 std::string attribute,
128 Quark &value);
129bool get_attribute_value_at_string(unsigned long timestamp,
130 const Quark *starting_node,
131 std::string attribute,
132 std::string &value);
133bool get_interval_value_int(unsigned long start,
134 unsigned long end,
135 const Quark *starting_node,
136 std::string attribute,
137 int &value);
138bool get_interval_value_ulong(unsigned long start,
139 unsigned long end,
140 const Quark *starting_node,
141 std::string attribute,
142 unsigned long &value);
143void add_in_sequence(unsigned long timestamp, Quark item, Quark beg);
144void remove_from_sequence(unsigned long timestamp, Quark item, Quark beg);
145int get_sequence_length(unsigned long timestamp, Quark beg);
146int sequence_to_array(unsigned long timestamp, Quark beg, Quark *arr,
147 int len);
148int get_global_perf_list(unsigned long timestamp, Quark *arr, int len);
149int get_global_perf_list_size(unsigned long timestamp);
150int get_number_of_opened_files(unsigned long timestamp, Quark proc);
151int get_opened_files(unsigned long timestamp, Quark proc, Quark *arr, int len);
928f18a6 152
1fc22eb4 153#endif /* _COMMON_H */
This page took 0.029289 seconds and 4 git commands to generate.