Commit | Line | Data |
---|---|---|
91d76f53 DG |
1 | /* |
2 | * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca> | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU General Public License | |
82a3637f DG |
6 | * as published by the Free Software Foundation; only version 2 |
7 | * of the License. | |
91d76f53 DG |
8 | * |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program; if not, write to the Free Software | |
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 | */ | |
18 | ||
f6a9efaa DG |
19 | #ifndef _LTT_UST_APP_H |
20 | #define _LTT_UST_APP_H | |
91d76f53 | 21 | |
099e26bd | 22 | #include <stdint.h> |
1e307fab DG |
23 | #include <urcu/list.h> |
24 | ||
44d3bd01 DG |
25 | #include "trace-ust.h" |
26 | ||
099e26bd DG |
27 | /* |
28 | * Application registration data structure. | |
29 | */ | |
30 | struct ust_register_msg { | |
31 | uint32_t major; | |
32 | uint32_t minor; | |
33 | pid_t pid; | |
34 | pid_t ppid; | |
35 | uid_t uid; | |
36 | gid_t gid; | |
37 | char name[16]; | |
38 | }; | |
39 | ||
48842b30 DG |
40 | /* |
41 | * Global applications HT used by the session daemon. | |
42 | */ | |
f6a9efaa DG |
43 | struct cds_lfht *ust_app_ht; |
44 | ||
45 | struct cds_lfht *ust_app_sock_key_map; | |
46 | ||
47 | struct ust_app_key { | |
48 | pid_t pid; | |
49 | int sock; | |
50 | struct cds_lfht_node node; | |
91d76f53 DG |
51 | }; |
52 | ||
48842b30 DG |
53 | struct ust_app_event { |
54 | int enabled; | |
55 | int handle; | |
13161846 | 56 | struct lttng_ust_object_data *obj; |
48842b30 DG |
57 | char name[LTTNG_UST_SYM_NAME_LEN]; |
58 | struct cds_lfht *ctx; | |
59 | struct cds_lfht_node node; | |
60 | }; | |
61 | ||
62 | struct ust_app_channel { | |
63 | int enabled; | |
64 | int handle; | |
65 | char name[LTTNG_UST_SYM_NAME_LEN]; | |
66 | struct lttng_ust_channel attr; | |
13161846 | 67 | struct lttng_ust_object_data *obj; |
5af2f756 | 68 | struct ltt_ust_stream_list streams; |
48842b30 DG |
69 | struct cds_lfht *ctx; |
70 | struct cds_lfht *events; | |
71 | struct cds_lfht_node node; | |
72 | }; | |
73 | ||
74 | struct ust_app_session { | |
75 | int enabled; | |
76 | int handle; /* Used has unique identifier */ | |
77 | unsigned int uid; | |
78 | struct ltt_ust_metadata *metadata; | |
13161846 | 79 | struct lttng_ust_object_data *obj; |
48842b30 DG |
80 | struct cds_lfht *channels; /* Registered channels */ |
81 | struct cds_lfht_node node; | |
82 | }; | |
83 | ||
f6a9efaa DG |
84 | /* |
85 | * Registered traceable applications. Libust registers to the session daemon | |
050349bb | 86 | * and a linked list is kept of all running traceable app. |
91d76f53 | 87 | */ |
56fff090 | 88 | struct ust_app { |
099e26bd DG |
89 | pid_t ppid; |
90 | uid_t uid; /* User ID that owns the apps */ | |
91 | gid_t gid; /* Group ID that owns the apps */ | |
92 | uint32_t v_major; /* Verion major number */ | |
93 | uint32_t v_minor; /* Verion minor number */ | |
94 | char name[17]; /* Process name (short) */ | |
48842b30 | 95 | struct cds_lfht *sessions; |
f6a9efaa DG |
96 | struct cds_lfht_node node; |
97 | struct ust_app_key key; | |
91d76f53 DG |
98 | }; |
99 | ||
74d0b642 | 100 | #ifdef HAVE_LIBLTTNG_UST_CTL |
3bd1e081 | 101 | |
56fff090 DG |
102 | int ust_app_register(struct ust_register_msg *msg, int sock); |
103 | void ust_app_unregister(int sock); | |
48842b30 DG |
104 | int ust_app_add_channel(struct ltt_ust_session *usess, |
105 | struct ltt_ust_channel *uchan); | |
106 | int ust_app_add_event(struct ltt_ust_session *usess, | |
107 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent); | |
f6a9efaa | 108 | unsigned long ust_app_list_count(void); |
48842b30 | 109 | int ust_app_start_trace(struct ltt_ust_session *usess); |
91d76f53 | 110 | |
56fff090 | 111 | void ust_app_clean_list(void); |
f6a9efaa DG |
112 | void ust_app_ht_alloc(void); |
113 | struct cds_lfht *ust_app_get_ht(void); | |
114 | struct ust_app *ust_app_find_by_pid(pid_t pid); | |
44d3bd01 | 115 | |
74d0b642 | 116 | #else /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 | 117 | |
d974f197 DG |
118 | static inline |
119 | int ust_app_start_trace(struct ltt_ust_session *usess) | |
120 | { | |
121 | return -ENOSYS; | |
122 | } | |
3bd1e081 MD |
123 | static inline |
124 | int ust_app_register(struct ust_register_msg *msg, int sock) | |
125 | { | |
126 | return -ENOSYS; | |
127 | } | |
128 | static inline | |
129 | void ust_app_unregister(int sock) | |
130 | { | |
131 | } | |
132 | static inline | |
133 | unsigned int ust_app_list_count(void) | |
134 | { | |
135 | return 0; | |
136 | } | |
3bd1e081 MD |
137 | static inline |
138 | void ust_app_lock_list(void) | |
139 | { | |
140 | } | |
141 | static inline | |
142 | void ust_app_unlock_list(void) | |
143 | { | |
144 | } | |
145 | static inline | |
146 | void ust_app_clean_list(void) | |
147 | { | |
148 | } | |
149 | static inline | |
150 | struct ust_app_list *ust_app_get_list(void) | |
151 | { | |
152 | return NULL; | |
153 | } | |
154 | static inline | |
155 | struct ust_app *ust_app_get_by_pid(pid_t pid) | |
156 | { | |
157 | return NULL; | |
158 | } | |
48842b30 DG |
159 | static inline |
160 | int ust_app_add_channel(struct ltt_ust_session *usess, | |
161 | struct ltt_ust_channel *uchan) | |
162 | { | |
163 | return 0; | |
164 | } | |
d974f197 DG |
165 | static inline |
166 | int ust_app_add_event(struct ltt_ust_session *usess, | |
167 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent) | |
168 | { | |
169 | return -ENOSYS; | |
170 | } | |
171 | static inline | |
172 | struct cds_lfht *ust_app_get_ht(void) | |
173 | { | |
174 | return NULL; | |
175 | } | |
176 | static inline | |
177 | void ust_app_ht_alloc(void) | |
178 | { | |
179 | } | |
48842b30 | 180 | |
74d0b642 | 181 | #endif /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 | 182 | |
f6a9efaa | 183 | #endif /* _LTT_UST_APP_H */ |