Debian Codegraph @

src/libsysprof-capture/sysprof-capture-writer.h

raw
1 /* sysprof-capture-writer.h
2 *
3 * Copyright 2016-2019 Christian Hergert <[email protected]>
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * Subject to the terms and conditions of this license, each copyright holder
17 * and contributor hereby grants to those receiving rights under this license
18 * a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
19 * irrevocable (except for failure to satisfy the conditions of this license)
20 * patent license to make, have made, use, offer to sell, sell, import, and
21 * otherwise transfer this software, where such license applies only to those
22 * patent claims, already acquired or hereafter acquired, licensable by such
23 * copyright holder or contributor that are necessarily infringed by:
24 *
25 * (a) their Contribution(s) (the licensed copyrights of copyright holders
26 * and non-copyrightable additions of contributors, in source or binary
27 * form) alone; or
28 *
29 * (b) combination of their Contribution(s) with the work of authorship to
30 * which such Contribution(s) was added by such copyright holder or
31 * contributor, if, at the time the Contribution is added, such addition
32 * causes such combination to be necessarily infringed. The patent license
33 * shall not apply to any other combinations which include the
34 * Contribution.
35 *
36 * Except as expressly stated above, no rights or licenses from any copyright
37 * holder or contributor is granted under this license, whether expressly, by
38 * implication, estoppel or otherwise.
39 *
40 * DISCLAIMER
41 *
42 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
43 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
44 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
46 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
47 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
48 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
49 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
50 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
51 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
52 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53 *
54 * SPDX-License-Identifier: BSD-2-Clause-Patent
55 */
56
57 #pragma once
58
59 #include <stdbool.h>
60 #include <stdint.h>
61 #include <sys/types.h>
62
63 #include "sysprof-capture-types.h"
64 #include "sysprof-version-macros.h"
65
66 SYSPROF_BEGIN_DECLS
67
68 SYSPROF_AVAILABLE_IN_ALL
69 SysprofCaptureWriter *sysprof_capture_writer_new_from_env (size_t buffer_size);
70 SYSPROF_AVAILABLE_IN_ALL
71 SysprofCaptureWriter *sysprof_capture_writer_new (const char *filename,
72 size_t buffer_size);
73 SYSPROF_AVAILABLE_IN_ALL
74 SysprofCaptureWriter *sysprof_capture_writer_new_from_fd (int fd,
75 size_t buffer_size);
76 SYSPROF_AVAILABLE_IN_ALL
77 size_t sysprof_capture_writer_get_buffer_size (SysprofCaptureWriter *self);
78 SYSPROF_AVAILABLE_IN_ALL
79 SysprofCaptureWriter *sysprof_capture_writer_ref (SysprofCaptureWriter *self);
80 SYSPROF_AVAILABLE_IN_ALL
81 void sysprof_capture_writer_unref (SysprofCaptureWriter *self);
82 SYSPROF_AVAILABLE_IN_ALL
83 void sysprof_capture_writer_stat (SysprofCaptureWriter *self,
84 SysprofCaptureStat *stat);
85 SYSPROF_AVAILABLE_IN_ALL
86 bool sysprof_capture_writer_add_file (SysprofCaptureWriter *self,
87 int64_t time,
88 int cpu,
89 int32_t pid,
90 const char *path,
91 bool is_last,
92 const uint8_t *data,
93 size_t data_len);
94 SYSPROF_AVAILABLE_IN_ALL
95 bool sysprof_capture_writer_add_file_fd (SysprofCaptureWriter *self,
96 int64_t time,
97 int cpu,
98 int32_t pid,
99 const char *path,
100 int fd);
101 SYSPROF_AVAILABLE_IN_ALL
102 bool sysprof_capture_writer_add_map (SysprofCaptureWriter *self,
103 int64_t time,
104 int cpu,
105 int32_t pid,
106 uint64_t start,
107 uint64_t end,
108 uint64_t offset,
109 uint64_t inode,
110 const char *filename);
111 SYSPROF_AVAILABLE_IN_ALL
112 bool sysprof_capture_writer_add_map_with_build_id (SysprofCaptureWriter *self,
113 int64_t time,
114 int cpu,
115 int32_t pid,
116 uint64_t start,
117 uint64_t end,
118 uint64_t offset,
119 uint64_t inode,
120 const char *filename,
121 const char *build_id);
122 SYSPROF_AVAILABLE_IN_ALL
123 bool sysprof_capture_writer_add_mark (SysprofCaptureWriter *self,
124 int64_t time,
125 int cpu,
126 int32_t pid,
127 uint64_t duration,
128 const char *group,
129 const char *name,
130 const char *message);
131 SYSPROF_AVAILABLE_IN_ALL
132 bool sysprof_capture_writer_add_metadata (SysprofCaptureWriter *self,
133 int64_t time,
134 int cpu,
135 int32_t pid,
136 const char *id,
137 const char *metadata,
138 ssize_t metadata_len);
139 SYSPROF_AVAILABLE_IN_ALL
140 uint64_t sysprof_capture_writer_add_jitmap (SysprofCaptureWriter *self,
141 const char *name);
142 SYSPROF_AVAILABLE_IN_ALL
143 bool sysprof_capture_writer_add_process (SysprofCaptureWriter *self,
144 int64_t time,
145 int cpu,
146 int32_t pid,
147 const char *cmdline);
148 SYSPROF_AVAILABLE_IN_ALL
149 bool sysprof_capture_writer_add_sample (SysprofCaptureWriter *self,
150 int64_t time,
151 int cpu,
152 int32_t pid,
153 int32_t tid,
154 const SysprofCaptureAddress *addrs,
155 unsigned int n_addrs);
156 SYSPROF_AVAILABLE_IN_ALL
157 bool sysprof_capture_writer_add_trace (SysprofCaptureWriter *self,
158 int64_t time,
159 int cpu,
160 int32_t pid,
161 int32_t tid,
162 const SysprofCaptureAddress *addrs,
163 unsigned int n_addrs,
164 bool entering);
165 SYSPROF_AVAILABLE_IN_ALL
166 bool sysprof_capture_writer_add_fork (SysprofCaptureWriter *self,
167 int64_t time,
168 int cpu,
169 int32_t pid,
170 int32_t child_pid);
171 SYSPROF_AVAILABLE_IN_ALL
172 bool sysprof_capture_writer_add_exit (SysprofCaptureWriter *self,
173 int64_t time,
174 int cpu,
175 int32_t pid);
176 SYSPROF_AVAILABLE_IN_ALL
177 bool sysprof_capture_writer_add_timestamp (SysprofCaptureWriter *self,
178 int64_t time,
179 int cpu,
180 int32_t pid);
181 SYSPROF_AVAILABLE_IN_ALL
182 bool sysprof_capture_writer_define_counters (SysprofCaptureWriter *self,
183 int64_t time,
184 int cpu,
185 int32_t pid,
186 const SysprofCaptureCounter *counters,
187 unsigned int n_counters);
188 SYSPROF_AVAILABLE_IN_ALL
189 bool sysprof_capture_writer_set_counters (SysprofCaptureWriter *self,
190 int64_t time,
191 int cpu,
192 int32_t pid,
193 const unsigned int *counters_ids,
194 const SysprofCaptureCounterValue *values,
195 unsigned int n_counters);
196 SYSPROF_AVAILABLE_IN_ALL
197 bool sysprof_capture_writer_add_log (SysprofCaptureWriter *self,
198 int64_t time,
199 int cpu,
200 int32_t pid,
201 int severity,
202 const char *domain,
203 const char *message);
204 SYSPROF_AVAILABLE_IN_3_36
205 bool sysprof_capture_writer_add_allocation (SysprofCaptureWriter *self,
206 int64_t time,
207 int cpu,
208 int32_t pid,
209 int32_t tid,
210 SysprofCaptureAddress alloc_addr,
211 int64_t alloc_size,
212 SysprofBacktraceFunc backtrace_func,
213 void *backtrace_data);
214 SYSPROF_AVAILABLE_IN_3_36
215 bool sysprof_capture_writer_add_allocation_copy (SysprofCaptureWriter *self,
216 int64_t time,
217 int cpu,
218 int32_t pid,
219 int32_t tid,
220 SysprofCaptureAddress alloc_addr,
221 int64_t alloc_size,
222 const SysprofCaptureAddress *addrs,
223 unsigned int n_addrs);
224 SYSPROF_AVAILABLE_IN_3_40
225 bool sysprof_capture_writer_add_overlay (SysprofCaptureWriter *self,
226 int64_t time,
227 int cpu,
228 int32_t pid,
229 uint32_t layer,
230 const char *src,
231 const char *dst);
232 SYSPROF_AVAILABLE_IN_ALL
233 bool sysprof_capture_writer_add_dbus_message (SysprofCaptureWriter *self,
234 int64_t time,
235 int cpu,
236 int32_t pid,
237 uint16_t bus_type,
238 uint16_t flags,
239 const uint8_t *message_data,
240 size_t message_len);
241 SYSPROF_AVAILABLE_IN_ALL
242 bool sysprof_capture_writer_flush (SysprofCaptureWriter *self);
243 SYSPROF_AVAILABLE_IN_ALL
244 bool sysprof_capture_writer_save_as (SysprofCaptureWriter *self,
245 const char *filename);
246 SYSPROF_AVAILABLE_IN_ALL
247 unsigned int sysprof_capture_writer_request_counter (SysprofCaptureWriter *self,
248 unsigned int n_counters);
249 SYSPROF_AVAILABLE_IN_ALL
250 SysprofCaptureReader *sysprof_capture_writer_create_reader (SysprofCaptureWriter *self);
251 SYSPROF_AVAILABLE_IN_ALL
252 bool sysprof_capture_writer_splice (SysprofCaptureWriter *self,
253 SysprofCaptureWriter *dest);
254 SYSPROF_AVAILABLE_IN_ALL
255 bool sysprof_capture_writer_cat (SysprofCaptureWriter *self,
256 SysprofCaptureReader *reader);
257 SYSPROF_INTERNAL
258 bool _sysprof_capture_writer_add_raw (SysprofCaptureWriter *self,
259 const SysprofCaptureFrame *frame);
260 SYSPROF_INTERNAL
261 bool _sysprof_capture_writer_splice_from_fd (SysprofCaptureWriter *self,
262 int fd) SYSPROF_INTERNAL;
263 SYSPROF_INTERNAL
264 bool _sysprof_capture_writer_set_time_range (SysprofCaptureWriter *self,
265 int64_t start_time,
266 int64_t end_time) SYSPROF_INTERNAL;
267 SYSPROF_INTERNAL
268 int _sysprof_capture_writer_dup_fd (SysprofCaptureWriter *self);
269
270 SYSPROF_END_DECLS