X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Flist.c;h=77a49e17208fe077a752df4a2037ad3f405ede3b;hp=4540177941faf9e30f610caf448ff6728c486a45;hb=refs%2Fheads%2Fsow-2020-0002-rev2;hpb=11f6ce94d8fb73f017888681aaba5d7df55fc735 diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index 454017794..77a49e172 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "../command.h" @@ -28,6 +29,7 @@ static int opt_jul; 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; @@ -63,6 +65,7 @@ static struct poptOption long_options[] = { {"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}, @@ -1367,6 +1370,58 @@ skip_stats_printing: 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" : ""); + MSG("%sBucket count: %"PRIu64, indent6, bucket_count); +end: + return; +} + /* * Machine interface * Print a list of channel @@ -1508,6 +1563,68 @@ error_channels: 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 ? : ""); + + 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) { @@ -2460,6 +2577,11 @@ int cmd_list(int argc, const char **argv) 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); @@ -2560,6 +2682,11 @@ int cmd_list(int argc, const char **argv) goto end; } + ret = list_maps(opt_map); + if (ret) { + goto end; + } + next_domain: if (lttng_opt_mi) { /* Close domain element */