diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2017-05-19 15:41:31 -0700 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2017-06-01 11:49:46 -0700 |
commit | 12303bd390b24b567505b3af5bd467a0636a2f2a (patch) | |
tree | 794bad54caea89aa1a5fb7f7d05615d2620e3c52 /src/intel | |
parent | 73c21e69d0c132a6d837b40b6a863bdd406085d4 (diff) |
genxml: Fix decoder to print the array element on field members.
Previously we'd print things like:
0xfffbb568: 0x00010000 : Dword 1
ReadLength: 0
ReadLength: 1
0xfffbb568: 0x00000001 : Dword 1
ReadLength: 1
ReadLength: 0
instead of the more obvious:
0xfffbb568: 0x00010000 : Dword 1
ReadLength[0]: 0
ReadLength[1]: 1
0xfffbb568: 0x00000001 : Dword 1
ReadLength[2]: 1
ReadLength[3]: 0
(Yes, the ralloc context here is bogus - the decoder leaks just about
everything. We need to use proper ralloc contexts someday...)
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Diffstat (limited to 'src/intel')
-rw-r--r-- | src/intel/common/gen_decoder.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/intel/common/gen_decoder.c b/src/intel/common/gen_decoder.c index f419b2118a..8d0bf3cee6 100644 --- a/src/intel/common/gen_decoder.c +++ b/src/intel/common/gen_decoder.c @@ -31,6 +31,7 @@ #include <zlib.h> #include <util/macros.h> +#include <util/ralloc.h> #include "gen_decoder.h" @@ -324,7 +325,7 @@ string_to_type(struct parser_context *ctx, const char *s) } static struct gen_field * -create_field(struct parser_context *ctx, const char **atts) +create_field(struct parser_context *ctx, const char **atts, int group_idx) { struct gen_field *field; char *p; @@ -334,7 +335,12 @@ create_field(struct parser_context *ctx, const char **atts) for (i = 0; atts[i]; i += 2) { if (strcmp(atts[i], "name") == 0) - field->name = xstrdup(atts[i + 1]); + if (ctx->group->elem_size == 0) { + field->name = xstrdup(atts[i + 1]); + } else { + field->name = + ralloc_asprintf(NULL, "%s[%d]", atts[i + 1], group_idx); + } else if (strcmp(atts[i], "start") == 0) field->start = ctx->group->group_offset+strtoul(atts[i + 1], &p, 0); else if (strcmp(atts[i], "end") == 0) { @@ -415,7 +421,7 @@ start_element(void *data, const char *element_name, const char **atts) &ctx->group->variable); } else if (strcmp(element_name, "field") == 0) { for (int g = 0; g < MAX2(ctx->group->group_count, 1); g++) { - ctx->fields[ctx->nfields++] = create_field(ctx, atts); + ctx->fields[ctx->nfields++] = create_field(ctx, atts, g); } } else if (strcmp(element_name, "enum") == 0) { ctx->enoom = create_enum(ctx, name, atts); |