#include <common/mi-lttng.h>
#include <common/time.h>
#include <common/tracker.h>
-#include <lttng/constant.h>
-#include <lttng/tracker.h>
+#include <lttng/lttng.h>
+#include <lttng/map/map.h>
#include "../command.h"
static int opt_log4j;
static int opt_python;
static char *opt_channel;
+static char *opt_map;
static int opt_domain;
static int opt_fields;
static int opt_syscall;
{"python", 'p', POPT_ARG_VAL, &opt_python, 1, 0, 0},
{"userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0},
{"channel", 'c', POPT_ARG_STRING, &opt_channel, 0, 0, 0},
+ {"map", 'm', POPT_ARG_STRING, &opt_map, 0, 0, 0},
{"domain", 'd', POPT_ARG_VAL, &opt_domain, 1, 0, 0},
{"fields", 'f', POPT_ARG_VAL, &opt_fields, 1, 0, 0},
{"syscall", 'S', POPT_ARG_VAL, &opt_syscall, 1, 0, 0},
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
{
const char *function_name;
- const char *binary_path;
+ char *binary_path;
MSG("%sType: Function", indent8);
function_name = lttng_userspace_probe_location_function_get_function_name(location);
MSG("%sLookup method: INVALID LOOKUP TYPE ENCOUNTERED", indent8);
break;
}
+
+ free(binary_path);
break;
}
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT:
{
const char *probe_name, *provider_name;
- const char *binary_path;
+ char *binary_path;
MSG("%sType: Tracepoint", indent8);
probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(location);
MSG("%sLookup method: INVALID LOOKUP TYPE ENCOUNTERED", indent8);
break;
}
+
+ free(binary_path);
break;
}
default:
return;
}
+static void print_map(const struct lttng_map *map)
+{
+ const char *map_name;
+ enum lttng_map_status map_status;
+ enum lttng_buffer_type buffer_type;
+ enum lttng_map_bitness bitness;
+ enum lttng_map_boundary_policy boundary_policy;
+ uint64_t bucket_count;
+ bool is_enabled;
+
+ bitness = lttng_map_get_bitness(map);
+ is_enabled = lttng_map_get_is_enabled(map);
+ buffer_type = lttng_map_get_buffer_type(map);
+
+ boundary_policy = lttng_map_get_boundary_policy(map);
+
+ map_status = lttng_map_get_name(map, &map_name);
+ if (map_status != LTTNG_MAP_STATUS_OK) {
+ ERR("Failed to get map name");
+ goto end;
+ }
+
+ map_status = lttng_map_get_dimension_length(map, 0, &bucket_count);
+ if (map_status != LTTNG_MAP_STATUS_OK) {
+ ERR("Failed to bucket count");
+ goto end;
+ }
+
+ MSG("- %s (%s)", map_name, is_enabled ? "enabled": "disabled");
+ MSG("%sAttributes:", indent4);
+ MSG("%sBitness: %s", indent6, bitness == LTTNG_MAP_BITNESS_32BITS ? "32" : "64");
+ _MSG("%sCounter type: ", indent6);
+ switch (buffer_type) {
+ case LTTNG_BUFFER_PER_PID:
+ MSG("per-pid");
+ break;
+ case LTTNG_BUFFER_PER_UID:
+ MSG("per-uid");
+ break;
+ case LTTNG_BUFFER_GLOBAL:
+ MSG("global");
+ break;
+ default:
+ abort();
+ }
+ MSG("%sBoundary policy: %s", indent6,
+ boundary_policy == LTTNG_MAP_BOUNDARY_POLICY_OVERFLOW ? "OVERFLOW" : "<unknown>");
+ MSG("%sBucket count: %"PRIu64, indent6, bucket_count);
+end:
+ return;
+}
+
/*
* Machine interface
* Print a list of channel
return ret;
}
+/*
+ * List map(s) of session and domain.
+ *
+ * If map_name is NULL, all maps are listed.
+ */
+static int list_maps(const char *desired_map_name)
+{
+ struct lttng_map_list *map_list = NULL;
+ enum lttng_map_status map_status;
+ enum lttng_error_code ret_code;
+ unsigned int i, map_count;
+ int ret = CMD_SUCCESS;
+
+ DBG("Listing map(s) (%s)", desired_map_name ? : "<all>");
+
+ ret_code = lttng_list_maps(handle, &map_list);
+ if (ret_code != LTTNG_OK) {
+ ERR("Error getting map list");
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ map_status = lttng_map_list_get_count(map_list, &map_count);
+ if (map_status != LTTNG_MAP_STATUS_OK) {
+ ERR("Error getting map list element count");
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ MSG("Maps:\n-------------");
+ for (i = 0; i < map_count; i++) {
+ const struct lttng_map *map = NULL;
+ const char *map_name = NULL;
+ map = lttng_map_list_get_at_index(map_list, i);
+ if (!map) {
+ ret = CMD_ERROR;
+ ERR("Error getting map from list: index = %u", i);
+ goto end;
+ }
+
+ map_status = lttng_map_get_name(map, &map_name);
+ if (map_status != LTTNG_MAP_STATUS_OK) {
+ ERR("Error getting map name");
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ if (desired_map_name != NULL) {
+ if (strncmp(map_name, desired_map_name, NAME_MAX) == 0) {
+ print_map(map);
+ break;
+ }
+ } else {
+ print_map(map);
+ }
+ }
+end:
+ // Should be in its own patch.
+ lttng_map_list_destroy(map_list);
+ return ret;
+}
+
static const char *get_capitalized_process_attr_str(enum lttng_process_attr process_attr)
{
switch (process_attr) {
goto end;
}
+ ret = list_maps(opt_map);
+ if (ret) {
+ goto end;
+ }
+
if (lttng_opt_mi) {
/* Close domain and domain element */
ret = mi_lttng_close_multi_element(writer, 2);
goto end;
}
+ ret = list_maps(opt_map);
+ if (ret) {
+ goto end;
+ }
+
next_domain:
if (lttng_opt_mi) {
/* Close domain element */