diff options
author | Jiri Olsa <Jiri Olsa jolsa@redhat.com> | 2011-06-10 13:44:25 +0200 |
---|---|---|
committer | Jiri Olsa <Jiri Olsa jolsa@redhat.com> | 2011-06-17 13:00:06 +0200 |
commit | d07b36b6bb898666c313b6d3708aee82d5b80550 (patch) | |
tree | 9269600e3acb59f712daa2530b10c1cb7617e24a /src | |
parent | 73ae529a915c6445d5cf0a43f8cba140d7d79e83 (diff) | |
download | latrace-d07b36b6bb898666c313b6d3708aee82d5b80550.tar.gz latrace-d07b36b6bb898666c313b6d3708aee82d5b80550.tar.xz latrace-d07b36b6bb898666c313b6d3708aee82d5b80550.zip |
args: Aadd support to display string pointer and length
Add ARGS_STRING_POINTER_LENGTH option. It allows to display
pointer value and string length for "char *" arguments.
Diffstat (limited to 'src')
-rw-r--r-- | src/args.c | 10 | ||||
-rw-r--r-- | src/config-bison.y | 8 | ||||
-rw-r--r-- | src/config-flex.l | 1 | ||||
-rw-r--r-- | src/config.c | 13 | ||||
-rw-r--r-- | src/config.h | 5 |
5 files changed, 32 insertions, 5 deletions
@@ -838,12 +838,18 @@ do { \ char *s = val; int slen = strlen(s); int left = alen; + int info_len = 0; + + if (lt_sh(cfg, args_string_pointer_length)) { + info_len = snprintf(argbuf, left, "(%p, %lu) ", s, strlen(s)); + left -= info_len; + } if ((slen + 2) > left) { - snprintf(argbuf, left, "\"%s", s); + snprintf(argbuf + info_len, left, "\"%s", s); strncpy(argbuf + left - sizeof("...\"") + 1, "...\"", sizeof("...\"")); } else { - strcpy(argbuf, "\""); + strcpy(argbuf + info_len, "\""); strcat(argbuf, s); strcat(argbuf, "\""); } diff --git a/src/config-bison.y b/src/config-bison.y index cc7d88b..944f59b 100644 --- a/src/config-bison.y +++ b/src/config-bison.y @@ -46,7 +46,7 @@ static LT_LIST_HEAD(opt_list); #define OPTION_ADD(idx, sval, nval) \ do { \ struct lt_config_opt *opt; \ - opt = lt_config_opt_new(idx, sval, nval); \ + opt = lt_config_opt_new(scfg, idx, sval, nval); \ if (!opt) \ ERROR("failed to process option\n"); \ lt_list_add_tail(&opt->list, &opt_list); \ @@ -65,6 +65,7 @@ static struct lt_list_head ln_names; %token OPT_DETAIL_ARGS OPT_OUTPUT_TTY %token OPT_LIBS OPT_LIBS_TO OPT_LIBS_FROM %token OPT_SYM OPT_SYM_OMIT OPT_SYM_BELOW OPT_SYM_NOEXIT +%token OPT_ARGS_STRING_POINTER_LENGTH %union { @@ -250,6 +251,11 @@ OPTIONS_DEF OPT_SYM_NOEXIT '=' list_names_comma OPTION_ADD(LT_OPT_SYM_NOEXIT, sym_noexit, -1); } | +OPTIONS_DEF OPT_ARGS_STRING_POINTER_LENGTH '=' BOOL +{ + OPTION_ADD(LT_OPT_ARGS_STRING_POINTER_LENGTH, $4, -1); +} +| /* left blank intentionally */ list_names_comma: diff --git a/src/config-flex.l b/src/config-flex.l index 89de981..433992f 100644 --- a/src/config-flex.l +++ b/src/config-flex.l @@ -91,6 +91,7 @@ OPTIONS { BEGIN(options); return OPTIONS; } <options>SYM_OMIT { return OPT_SYM_OMIT; } <options>SYM_BELOW { return OPT_SYM_BELOW; } <options>SYM_NOEXIT { return OPT_SYM_NOEXIT; } +<options>ARGS_STRING_POINTER_LENGTH { return OPT_ARGS_STRING_POINTER_LENGTH; } <options>{bool} { RETURN_STR(BOOL); } <options>{value} { RETURN_LONG(VALUE); } diff --git a/src/config.c b/src/config.c index 20eaa45..bd60c53 100644 --- a/src/config.c +++ b/src/config.c @@ -325,6 +325,14 @@ static int process_option_val(struct lt_config_app *cfg, int idx, lt_sh(cfg, symbols_noexit)); break; + case LT_OPT_ARGS_STRING_POINTER_LENGTH: + CHECK_BOOL(val, sval, ival); + lt_sh(cfg, args_string_pointer_length) = val; + + PRINT_VERBOSE(cfg, 1, "ARGS_STRING_POINTER_LENGTH %d\n", + lt_sh(cfg, args_detailed)); + break; + default: return -1; } @@ -351,7 +359,8 @@ int lt_config_opt_process(struct lt_config_app *cfg, struct lt_list_head *list) return 0; } -struct lt_config_opt *lt_config_opt_new(int idx, char *sval, long nval) +struct lt_config_opt *lt_config_opt_new(struct lt_config_app *cfg, + int idx, char *sval, long nval) { struct lt_config_opt *opt; @@ -364,6 +373,8 @@ struct lt_config_opt *lt_config_opt_new(int idx, char *sval, long nval) opt->sval = sval ? strdup(sval) : NULL; opt->nval = nval; + PRINT_VERBOSE(cfg, 1, "idx %d = %s, %d\n", + opt->idx, opt->sval , opt->nval); return opt; } diff --git a/src/config.h b/src/config.h index 9f0b5d7..278771a 100644 --- a/src/config.h +++ b/src/config.h @@ -91,6 +91,7 @@ enum { LT_OPT_SYM_OMIT, LT_OPT_SYM_BELOW, LT_OPT_SYM_NOEXIT, + LT_OPT_ARGS_STRING_POINTER_LENGTH, }; struct lt_config_opt { @@ -126,6 +127,7 @@ struct lt_config_shared { char args_def[LT_MAXFILE]; char args_enabled; char args_detailed; + char args_string_pointer_length; #define LR_ARGS_MAXLEN 1000 int args_maxlen; #define LR_ARGS_DETAIL_MAXLEN 1000 @@ -369,7 +371,8 @@ struct lt_symbol* lt_symbol_get(struct lt_config_shared *cfg, void *ptr, const char *name); /* config options */ -struct lt_config_opt *lt_config_opt_new(int idx, char *sval, long nval); +struct lt_config_opt *lt_config_opt_new(struct lt_config_app *cfg, + int idx, char *sval, long nval); int lt_config_opt_process(struct lt_config_app *cfg, struct lt_list_head *list); int lt_config_ln_add(struct lt_list_head *head, char *name); int lt_config_ln_fill(struct lt_list_head *head, char *buf, int size); |