#include <errno.h>
#include <stdlib.h>
#include <string.h>
-#include <assert.h>
+#include <babeltrace/assert-internal.h>
#include <stdio.h>
#include <stdbool.h>
#include <inttypes.h>
#include "babeltrace-cfg.h"
#include "babeltrace-cfg-cli-args.h"
#include "babeltrace-cfg-cli-args-connect.h"
+#include "version.h"
/*
* Error printf() macro which prepends "Error: " the first time it's
GString *gs_comp_cls = NULL;
size_t end_pos;
- assert(arg);
- assert(plugin);
- assert(comp_cls);
- assert(comp_cls_type);
+ BT_ASSERT(arg);
+ BT_ASSERT(plugin);
+ BT_ASSERT(comp_cls);
+ BT_ASSERT(comp_cls_type);
if (!bt_common_string_is_printable(arg)) {
printf_err("Argument contains a non-printable character\n");
static
void print_version(void)
{
- puts("Babeltrace " VERSION);
+ if (GIT_VERSION[0] == '\0') {
+ puts("Babeltrace " VERSION);
+ } else {
+ puts("Babeltrace " VERSION " - " GIT_VERSION);
+ }
}
/*
goto error;
}
- bt_object_init(cfg_component, bt_config_component_destroy);
+ bt_object_init_shared(&cfg_component->base,
+ bt_config_component_destroy);
cfg_component->type = type;
cfg_component->plugin_name = g_string_new(plugin_name);
if (!cfg_component->plugin_name) {
static
void append_param_arg(GString *params_arg, const char *key, const char *value)
{
- assert(params_arg);
- assert(key);
- assert(value);
+ BT_ASSERT(params_arg);
+ BT_ASSERT(key);
+ BT_ASSERT(value);
if (params_arg->len != 0) {
g_string_append_c(params_arg, ',');
goto error;
}
- bt_object_init(cfg, bt_config_destroy);
+ bt_object_init_shared(&cfg->base, bt_config_destroy);
cfg->command = command;
cfg->command_needs_plugins = needs_plugins;
goto error;
}
- assert(params);
+ BT_ASSERT(params);
BT_MOVE(cfg->cmd_data.query.cfg_component->params, params);
} else {
print_query_usage(stdout);
abort();
}
- assert(cur_base_params);
+ BT_ASSERT(cur_base_params);
bt_put(cur_cfg_comp->params);
cur_cfg_comp->params = bt_value_copy(cur_base_params);
if (!cur_cfg_comp->params) {
break;
case OPT_RETRY_DURATION:
if (retry_duration < 0) {
- printf_err("--retry-duration option's argument must be positive or 0: %lld\n",
+ printf_err("--retry-duration option's argument must be positive or 0: %ld\n",
retry_duration);
goto error;
}
struct bt_value *arg_value = bt_value_array_get(run_args, i);
const char *arg;
- assert(arg_value);
+ BT_ASSERT(arg_value);
ret = bt_value_string_get(arg_value, &arg);
- assert(ret == 0);
- assert(arg);
+ BT_ASSERT(ret == 0);
+ BT_ASSERT(arg);
argv[i + 1] = arg;
bt_put(arg_value);
}
goto error;
}
- assert(bt_value_is_string(elem));
+ BT_ASSERT(bt_value_is_string(elem));
if (bt_value_string_get(elem, &arg)) {
goto error;
}
static
void finalize_implicit_component_args(struct implicit_component_args *args)
{
- assert(args);
+ BT_ASSERT(args);
if (args->comp_arg) {
g_string_free(args->comp_arg, TRUE);
void append_implicit_component_param(struct implicit_component_args *args,
const char *key, const char *value)
{
- assert(args);
- assert(key);
- assert(value);
+ BT_ASSERT(args);
+ BT_ASSERT(key);
+ BT_ASSERT(value);
append_param_arg(args->params_arg, key, value);
}
{
int ret = 0;
- assert(args);
- assert(key);
- assert(value);
+ BT_ASSERT(args);
+ BT_ASSERT(key);
+ BT_ASSERT(value);
if (bt_value_array_append_string(args->extra_params, "--key")) {
print_err_oom();
GList *filter_prev;
GList *sink_at = sink_names;
- assert(source_names);
- assert(filter_names);
- assert(sink_names);
+ BT_ASSERT(source_names);
+ BT_ASSERT(filter_names);
+ BT_ASSERT(sink_names);
/* Connect all sources to the first filter */
for (source_at = source_names; source_at != NULL; source_at = g_list_next(source_at)) {
GString *g_begin = NULL;
GString *g_end = NULL;
- assert(arg);
+ BT_ASSERT(arg);
if (*ch == '[') {
ch++;
goto error;
}
- assert(begin);
- assert(end);
+ BT_ASSERT(begin);
+ BT_ASSERT(end);
*begin = g_begin->str;
*end = g_end->str;
g_string_free(g_begin, FALSE);
int ret = 0;
GString *gs = g_string_new(string);
- assert(list);
+ BT_ASSERT(list);
if (!gs) {
print_err_oom();
GString *quoted = NULL;
const char *arg_to_print;
- assert(arg_value);
+ BT_ASSERT(arg_value);
ret = bt_value_string_get(arg_value, &arg);
- assert(ret == 0);
+ BT_ASSERT(ret == 0);
BT_PUT(arg_value);
if (print_run_args) {
fprintf(fp, "\n");
fprintf(fp, " -d, --debug Enable debug mode (same as --log-level=V)\n");
fprintf(fp, " -h, --help Show this help and quit\n");
- fprintf(fp, " --log-level=LVL Set all log levels to LVL (`N`, `V`, `D`,\n");
+ fprintf(fp, " -l, --log-level=LVL Set all log levels to LVL (`N`, `V`, `D`,\n");
fprintf(fp, " `I`, `W` (default), `E`, or `F`)\n");
fprintf(fp, " -v, --verbose Enable verbose mode (same as --log-level=I)\n");
fprintf(fp, " -V, --version Show version and quit\n");
*/
log_level = 'I';
}
- } else if (strcmp(cur_arg, "--log-level") == 0) {
+ } else if (strcmp(cur_arg, "--log-level") == 0 ||
+ strcmp(cur_arg, "-l") == 0) {
if (!next_arg) {
printf_err("Missing log level value for --log-level option\n");
*retcode = 1;
} else if (strncmp(cur_arg, "--log-level=", 12) == 0) {
const char *arg = &cur_arg[12];
+ log_level = log_level_from_arg(arg);
+ if (log_level == 'U') {
+ printf_err("Invalid argument for --log-level option:\n %s\n",
+ arg);
+ *retcode = 1;
+ goto end;
+ }
+ } else if (strncmp(cur_arg, "-l", 2) == 0) {
+ const char *arg = &cur_arg[2];
+
log_level = log_level_from_arg(arg);
if (log_level == 'U') {
printf_err("Invalid argument for --log-level option:\n %s\n",
goto end;
}
- assert(command_argv);
- assert(command_argc >= 0);
+ BT_ASSERT(command_argv);
+ BT_ASSERT(command_argc >= 0);
switch (command_type) {
case COMMAND_TYPE_RUN: