Commit d777f8de authored by Steven Rostedt (VMware)'s avatar Steven Rostedt (VMware) Committed by Arnaldo Carvalho de Melo

tools lib traceevent: Fix get_field_str() for dynamic strings

If a field is a dynamic string, get_field_str() returned just the
offset/size value and not the string. Have it parse the offset/size
correctly to return the actual string. Otherwise filtering fails when
trying to filter fields that are dynamic strings.
Reported-by: default avatarGopanapalli Pradeep <prap_hai@yahoo.com>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/20180112004823.146333275@goodmis.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 806efaed
...@@ -1877,17 +1877,25 @@ static const char *get_field_str(struct filter_arg *arg, struct pevent_record *r ...@@ -1877,17 +1877,25 @@ static const char *get_field_str(struct filter_arg *arg, struct pevent_record *r
struct pevent *pevent; struct pevent *pevent;
unsigned long long addr; unsigned long long addr;
const char *val = NULL; const char *val = NULL;
unsigned int size;
char hex[64]; char hex[64];
/* If the field is not a string convert it */ /* If the field is not a string convert it */
if (arg->str.field->flags & FIELD_IS_STRING) { if (arg->str.field->flags & FIELD_IS_STRING) {
val = record->data + arg->str.field->offset; val = record->data + arg->str.field->offset;
size = arg->str.field->size;
if (arg->str.field->flags & FIELD_IS_DYNAMIC) {
addr = *(unsigned int *)val;
val = record->data + (addr & 0xffff);
size = addr >> 16;
}
/* /*
* We need to copy the data since we can't be sure the field * We need to copy the data since we can't be sure the field
* is null terminated. * is null terminated.
*/ */
if (*(val + arg->str.field->size - 1)) { if (*(val + size - 1)) {
/* copy it */ /* copy it */
memcpy(arg->str.buffer, val, arg->str.field->size); memcpy(arg->str.buffer, val, arg->str.field->size);
/* the buffer is already NULL terminated */ /* the buffer is already NULL terminated */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment