21
21
// /
22
22
// / The high-level usage pattern for these APIs look like the following:
23
23
// /
24
- // / // Before we try initializing the log implementation, we must set it as
25
- // / // the log implementation. We provide the function pointers that define
26
- // / // the various initialization, finalization, and other pluggable hooks
27
- // / // that we need .
28
- // / __xray_set_log_impl({...} );
29
- // /
30
- // / // Once that's done , we can now initialize the implementation. Each
31
- // / // implementation has a chance to let users customize the implementation
32
- // / // with a struct that their implementation supports. Roughly this might
33
- // / // look like:
34
- // / MyImplementationOptions opts;
35
- // / opts.enable_feature = true;
36
- // / .. .
37
- // / auto init_status = __xray_log_init (
38
- // / BufferSize, MaxBuffers, &opts, sizeof opts );
39
- // / if (init_status != XRayLogInitStatus::XRAY_LOG_INITIALIZED) {
24
+ // / // We choose the mode which we'd like to install, and check whether this
25
+ // / // has succeeded. Each mode will have their own set of flags they will
26
+ // / // support, outside of the global XRay configuration options that are
27
+ // / // defined in the XRAY_OPTIONS environment variable .
28
+ // / auto select_status = __xray_log_select_mode("xray-fdr" );
29
+ // / if (select_status != XRayLogRegisterStatus::XRAY_REGISTRATION_OK) {
30
+ // / // This failed , we should not proceed with attempting to initialise
31
+ // / // the currently selected mode.
32
+ // / return;
33
+ // / }
34
+ // /
35
+ // / // Once that's done, we can now attempt to configure the implementation.
36
+ // / // To do this, we provide the string flags configuration for the mode .
37
+ // / auto config_status = __xray_log_init_mode (
38
+ // / "xray-fdr", "verbosity=1 some_flag=1 another_flag=2" );
39
+ // / if (config_status != XRayLogInitStatus::XRAY_LOG_INITIALIZED) {
40
40
// / // deal with the error here, if there is one.
41
41
// / }
42
42
// /
43
43
// / // When the log implementation has had the chance to initialize, we can
44
- // / // now patch the sleds.
44
+ // / // now patch the instrumentation points. Note that we could have patched
45
+ // / // the instrumentation points first, but there's no strict ordering to
46
+ // / // these operations.
45
47
// / auto patch_status = __xray_patch();
46
48
// / if (patch_status != XRayPatchingStatus::SUCCESS) {
47
49
// / // deal with the error here, if it is an error.
56
58
// /
57
59
// / // We can optionally wait before flushing the log to give other threads a
58
60
// / // chance to see that the implementation is already finalized. Also, at
59
- // / // this point we can optionally unpatch the sleds to reduce overheads at
60
- // / // runtime.
61
+ // / // this point we can optionally unpatch the instrumentation points to
62
+ // / // reduce overheads at runtime.
61
63
// / auto unpatch_status = __xray_unpatch();
62
64
// / if (unpatch_status != XRayPatchingStatus::SUCCESS) {
63
- // // deal with the error here, if it is an error.
64
- // }
65
+ // / // deal with the error here, if it is an error.
66
+ // / }
65
67
// /
66
68
// / // If there are logs or data to be flushed somewhere, we can do so only
67
69
// / // after we've finalized the log. Some implementations may not actually
@@ -193,9 +195,13 @@ struct XRayLogImpl {
193
195
XRayLogFlushStatus (*flush_log)();
194
196
};
195
197
198
+ // / DEPRECATED: Use the mode registration workflow instead with
199
+ // / __xray_log_register_mode(...) and __xray_log_select_mode(...). See the
200
+ // / documentation for those function.
201
+ // /
196
202
// / This function installs a new logging implementation that XRay will use. In
197
203
// / case there are any nullptr members in Impl, XRay will *uninstall any
198
- // / existing implementations*. It does NOT patch the instrumentation sleds .
204
+ // / existing implementations*. It does NOT patch the instrumentation points .
199
205
// /
200
206
// / NOTE: This function does NOT attempt to finalize the currently installed
201
207
// / implementation. Use with caution.
@@ -245,7 +251,7 @@ const char *__xray_log_get_current_mode();
245
251
246
252
// / This function removes the currently installed implementation. It will also
247
253
// / uninstall any handlers that have been previously installed. It does NOT
248
- // / unpatch the instrumentation sleds .
254
+ // / unpatch the instrumentation points .
249
255
// /
250
256
// / NOTE: This function does NOT attempt to finalize the currently installed
251
257
// / implementation. Use with caution.
@@ -260,11 +266,37 @@ const char *__xray_log_get_current_mode();
260
266
// / called while in any other states.
261
267
void __xray_remove_log_impl ();
262
268
269
+ // / DEPRECATED: Use __xray_log_init_mode() instead, and provide all the options
270
+ // / in string form.
263
271
// / Invokes the installed implementation initialization routine. See
264
272
// / XRayLogInitStatus for what the return values mean.
265
273
XRayLogInitStatus __xray_log_init (size_t BufferSize, size_t MaxBuffers,
266
274
void *Args, size_t ArgsSize);
267
275
276
+ // / Invokes the installed initialization routine, which *must* support the
277
+ // / string based form.
278
+ // /
279
+ // / NOTE: When this API is used, we still invoke the installed initialization
280
+ // / routine, but we will call it with the following convention to signal that we
281
+ // / are using the string form:
282
+ // /
283
+ // / - BufferSize = 0
284
+ // / - MaxBuffers = 0
285
+ // / - ArgsSize = 0
286
+ // / - Args will be the pointer to the character buffer representing the
287
+ // / configuration.
288
+ // /
289
+ // / FIXME: Updating the XRayLogImpl struct is an ABI breaking change. When we
290
+ // / are ready to make a breaking change, we should clean this up appropriately.
291
+ XRayLogInitStatus __xray_log_init_mode (const char *Mode, const char *Config);
292
+
293
+ // / Like __xray_log_init_mode(...) this version allows for providing
294
+ // / configurations that might have non-null-terminated strings. This will
295
+ // / operate similarly to __xray_log_init_mode, with the exception that
296
+ // / |ArgsSize| will be what |ConfigSize| is.
297
+ XRayLogInitStatus __xray_log_init_mode_bin (const char *Mode, const char *Config,
298
+ size_t ConfigSize);
299
+
268
300
// / Invokes the installed implementation finalization routine. See
269
301
// / XRayLogInitStatus for what the return values mean.
270
302
XRayLogInitStatus __xray_log_finalize ();
@@ -325,12 +357,16 @@ XRayLogFlushStatus __xray_log_process_buffers(void (*Processor)(const char *,
325
357
326
358
namespace __xray {
327
359
360
+ // / DEPRECATED: Use __xray_log_init_mode(...) instead, and provide flag
361
+ // / configuration strings to set the options instead.
328
362
// / Options used by the LLVM XRay FDR logging implementation.
329
363
struct FDRLoggingOptions {
330
364
bool ReportErrors = false ;
331
365
int Fd = -1 ;
332
366
};
333
367
368
+ // / DEPRECATED: Use __xray_log_init_mode(...) instead, and provide flag
369
+ // / configuration strings to set the options instead.
334
370
// / Options used by the LLVM XRay Basic (Naive) logging implementation.
335
371
struct BasicLoggingOptions {
336
372
int DurationFilterMicros = 0 ;
0 commit comments