4 #include <lttng/lttng.h>
5 #include <lttng/handle.h>
7 #include <lttng/map-query.h>
11 enum lttng_map_query_status query_status
;
12 enum lttng_error_code ret_code
;
13 unsigned int map_count
, list_count
;
14 enum lttng_map_status map_status
;
15 struct lttng_map_content
*map_content
= NULL
;
16 struct lttng_map_list
*map_list
= NULL
;
17 const struct lttng_map
*map
= NULL
;
18 struct lttng_domain
*domains
= NULL
;
19 const struct lttng_map_key_value_pair_list
*kv_list
;
20 const struct lttng_map_key_value_pair
*kv_pair
;
26 nb_domains
= lttng_list_domains("mysession", &domains
);
28 struct lttng_handle
*handle
= lttng_create_handle("mysession", &domains
[0]);
30 struct lttng_map_query
*map_query
= lttng_map_query_create(
31 LTTNG_MAP_QUERY_CONFIG_CPU_SUBSET
,
32 LTTNG_MAP_QUERY_CONFIG_BUFFER_UST_UID_ALL
,
33 LTTNG_MAP_QUERY_CONFIG_APP_BITNESS_ALL
);
36 printf("Error creating the map query\n");
41 query_status
= lttng_map_query_add_cpu(map_query
, 0);
42 if (query_status
!= LTTNG_MAP_QUERY_STATUS_OK
) {
43 printf("Error setting the targeted cpu\n");
48 query_status
= lttng_map_query_add_key_filter(map_query
,
49 "total number of hits");
50 if (query_status
!= LTTNG_MAP_QUERY_STATUS_OK
) {
51 printf("Error setting the targeted key\n");
56 ret_code
= lttng_list_maps(handle
, &map_list
);
57 if (ret_code
!= LTTNG_OK
) {
58 printf("Error getting list of all maps\n");
63 map_status
= lttng_map_list_get_count(map_list
, &map_count
);
64 if (map_status
!= LTTNG_MAP_STATUS_OK
) {
65 printf("Error getting the number of maps\n");
71 printf("Error: expecting at least 1 map.\n");
76 map
= lttng_map_list_get_at_index(map_list
, 0);
78 printf("Error getting map at index 0\n");
83 ret_code
= lttng_list_map_content(handle
, map
, map_query
, &map_content
);
84 if (ret_code
!= LTTNG_OK
) {
85 printf("Error executing the query on map\n");
90 map_status
= lttng_map_content_get_count(map_content
, &list_count
);
91 if (map_status
!= LTTNG_MAP_STATUS_OK
) {
92 printf("Error getting the number of key value pair list\n");
98 printf("Error: expecting at least 1 list.\n");
103 kv_list
= lttng_map_content_get_at_index(map_content
, 0);
105 printf("Error getting key value pair list at index 0\n");
110 kv_pair
= lttng_map_key_value_pair_list_get_at_index(kv_list
, 0);
112 printf("Error getting key value pair at index 0\n");
117 lttng_map_key_value_pair_get_key(kv_pair
, &key
);
118 lttng_map_key_value_pair_get_value(kv_pair
, &value
);
120 printf("Key: \"%s\", value: %"PRId64
"\n", key
, value
);