[Mesa-dev] [PATCH 6/7] intel/tools: Support json format in decoder

Jordan Justen jordan.l.justen at intel.com
Tue Jan 10 01:22:17 UTC 2017


Notably, json doesn't allow hexidecimal numbers. :\

Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 src/intel/tools/aubinator.c | 4 ++--
 src/intel/tools/decoder.c   | 7 +++++--
 src/intel/tools/decoder.h   | 4 +++-
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c
index 901d427657b..efd7c0496e3 100644
--- a/src/intel/tools/aubinator.c
+++ b/src/intel/tools/aubinator.c
@@ -148,7 +148,7 @@ decode_structure(struct gen_spec *spec, struct gen_group *strct,
       offset = 0;
 
    gen_field_iterator_init(&iter, strct, p,
-                           option_color == COLOR_ALWAYS);
+                           option_color == COLOR_ALWAYS, false);
    while (gen_field_iterator_next(&iter)) {
       idx = 0;
       print_dword_val(&iter, offset, &dword_num);
@@ -804,7 +804,7 @@ parse_commands(struct gen_spec *spec, uint32_t *cmds, int size, int engine)
          char *token = NULL;
          int idx = 0, dword_num = 0;
          gen_field_iterator_init(&iter, inst, p,
-                                 option_color == COLOR_ALWAYS);
+                                 option_color == COLOR_ALWAYS, false);
          while (gen_field_iterator_next(&iter)) {
             idx = 0;
             print_dword_val(&iter, offset, &dword_num);
diff --git a/src/intel/tools/decoder.c b/src/intel/tools/decoder.c
index 0e6a139ddaa..fd3b8783309 100644
--- a/src/intel/tools/decoder.c
+++ b/src/intel/tools/decoder.c
@@ -664,12 +664,14 @@ void
 gen_field_iterator_init(struct gen_field_iterator *iter,
                         struct gen_group *group,
                         const uint32_t *p,
-                        bool print_colors)
+                        bool print_colors,
+                        bool json_mode)
 {
    iter->group = group;
    iter->p = p;
    iter->i = 0;
    iter->print_colors = print_colors;
+   iter->json_mode = json_mode;
 }
 
 static void
@@ -738,7 +740,8 @@ gen_field_iterator_next(struct gen_field_iterator *iter)
    case GEN_TYPE_ADDRESS:
    case GEN_TYPE_OFFSET:
       snprintf(iter->value, sizeof(iter->value),
-               "0x%08"PRIx64, field_address(v.qw, f->start, f->end));
+               iter->json_mode ? "%"PRId64 : "0x%08"PRIx64,
+               field_address(v.qw, f->start, f->end));
       break;
    case GEN_TYPE_STRUCT:
       snprintf(iter->value, sizeof(iter->value),
diff --git a/src/intel/tools/decoder.h b/src/intel/tools/decoder.h
index 9f0aa4f35f1..1b23f175ff1 100644
--- a/src/intel/tools/decoder.h
+++ b/src/intel/tools/decoder.h
@@ -58,6 +58,7 @@ struct gen_field_iterator {
    const uint32_t *p;
    int i;
    bool print_colors;
+   bool json_mode;
 };
 
 struct gen_group {
@@ -124,7 +125,8 @@ struct gen_field {
 void gen_field_iterator_init(struct gen_field_iterator *iter,
                              struct gen_group *group,
                              const uint32_t *p,
-                             bool print_colors);
+                             bool print_colors,
+                             bool json_mode);
 
 bool gen_field_iterator_next(struct gen_field_iterator *iter);
 
-- 
2.11.0



More information about the mesa-dev mailing list