4 * Copyright (C) 2021 Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 * SPDX-License-Identifier: GPL-2.1-only
10 #ifndef LTTNG_ERROR_QUERY_H
11 #define LTTNG_ERROR_QUERY_H
13 #include <lttng/lttng.h>
14 #include <lttng/trigger/trigger.h>
22 struct lttng_error_query
;
25 * A collection of "lttng_error_query_result" returned after executing an error
26 * query against an endpoint.
28 struct lttng_error_query_results
;
30 /* A 'result' is an opaque error type. */
31 struct lttng_error_query_result
;
33 enum lttng_error_query_status
{
34 LTTNG_ERROR_QUERY_STATUS_OK
= 0,
35 /* An error occurred while querying for errors. */
36 LTTNG_ERROR_QUERY_STATUS_ERROR
= -1,
37 /* The target of the query does not make sense for this endpoint. */
38 LTTNG_ERROR_QUERY_STATUS_INVALID_QUERY_TARGET
= -2,
39 LTTNG_ERROR_QUERY_STATUS_INVALID_PARAMETER
= -3,
42 enum lttng_error_query_result_type
{
43 /* A count of errors provided as an unsigned integral value. */
44 LTTNG_ERROR_QUERY_RESULT_TYPE_COUNTER
= 0,
45 LTTNG_ERROR_QUERY_RESULT_TYPE_UNKNOWN
= -1,
48 enum lttng_error_query_result_status
{
49 LTTNG_ERROR_QUERY_RESULT_STATUS_OK
= 0,
50 LTTNG_ERROR_QUERY_RESULT_STATUS_ERROR
= -1,
51 LTTNG_ERROR_QUERY_RESULT_STATUS_INVALID_PARAMETER
= -2,
54 enum lttng_error_query_results_status
{
55 LTTNG_ERROR_QUERY_RESULTS_STATUS_OK
= 0,
56 LTTNG_ERROR_QUERY_RESULTS_STATUS_ERROR
= -1,
57 LTTNG_ERROR_QUERY_RESULTS_STATUS_INVALID_PARAMETER
= -2,
60 /* Create an error query targetting a trigger object. */
61 extern struct lttng_error_query
*lttng_error_query_trigger_create(
62 const struct lttng_trigger
*trigger
);
64 /* Create an error query targetting a trigger's condition object. */
65 extern struct lttng_error_query
*lttng_error_query_condition_create(
66 const struct lttng_trigger
*trigger
);
69 * Create an error query targetting an action object.
71 * `action_path` is copied internally. The root of the `action_path` is the
72 * action of `trigger`.
74 extern struct lttng_error_query
*lttng_error_query_action_create(
75 const struct lttng_trigger
*trigger
,
76 const struct lttng_action_path
*action_path
);
78 /* Destroy an error query. */
79 extern void lttng_error_query_destroy(struct lttng_error_query
*query
);
82 * Run an error query against an endpoint.
84 * Currently, only the `lttng_session_daemon_command_endpoint` is supported,
85 * see `lttng/endpoint.h`.
87 extern enum lttng_error_code
lttng_error_query_execute(
88 const struct lttng_error_query
*query
,
89 const struct lttng_endpoint
*endpoint
,
90 struct lttng_error_query_results
**results
);
92 /* Get the number of results in a result set. */
93 extern enum lttng_error_query_results_status
94 lttng_error_query_results_get_count(
95 const struct lttng_error_query_results
*results
,
98 /* Get a result from a result set by index. */
99 extern enum lttng_error_query_results_status
100 lttng_error_query_results_get_result(
101 const struct lttng_error_query_results
*results
,
102 const struct lttng_error_query_result
**result
,
105 /* Destroy an error query result set. */
106 extern void lttng_error_query_results_destroy(
107 struct lttng_error_query_results
*results
);
109 /* Get the type of an error query result. */
110 extern enum lttng_error_query_result_type
lttng_error_query_result_get_type(
111 const struct lttng_error_query_result
*result
);
113 /* Get the name of result. */
114 extern enum lttng_error_query_result_status
lttng_error_query_result_get_name(
115 const struct lttng_error_query_result
*result
,
118 /* Get the description of a result. */
119 extern enum lttng_error_query_result_status
120 lttng_error_query_result_get_description(
121 const struct lttng_error_query_result
*result
,
122 const char **description
);
124 /* Get the value of an error counter. */
125 extern enum lttng_error_query_result_status
126 lttng_error_query_result_counter_get_value(
127 const struct lttng_error_query_result
*result
, uint64_t *value
);
133 #endif /* LTTNG_ERROR_QUERY_H */