[Mesa-dev] [PATCH 4/7] intel/aubinator: Print disassembly by generating a string

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


Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 src/intel/tools/aubinator.c  | 23 +++++++++++++++++------
 src/intel/tools/disasm.c     |  7 ++-----
 src/intel/tools/gen_disasm.h |  2 +-
 3 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c
index e2bec8f9494..901d427657b 100644
--- a/src/intel/tools/aubinator.c
+++ b/src/intel/tools/aubinator.c
@@ -314,6 +314,17 @@ dump_samplers(struct gen_spec *spec, uint32_t offset)
 }
 
 static void
+print_gen_disassembly(struct gen_disasm *disasm, void *assembly, int start)
+{
+   char *disasm_str;
+   gen_disasm_disassemble(disasm, assembly, start, &disasm_str);
+   if (disasm_str) {
+      fputs(disasm_str, stdout);
+      free(disasm_str);
+   }
+}
+
+static void
 handle_media_interface_descriptor_load(struct gen_spec *spec, uint32_t *p)
 {
    int i, length = p[2] / 32;
@@ -344,7 +355,7 @@ handle_media_interface_descriptor_load(struct gen_spec *spec, uint32_t *p)
       }
 
       insns = (struct brw_instruction *) (gtt + start);
-      gen_disasm_disassemble(disasm, insns, 0, stdout);
+      print_gen_disassembly(disasm, insns, 0);
 
       dump_samplers(spec, descriptors[3] & ~0x1f);
       dump_binding_table(spec, descriptors[4] & ~0x1f);
@@ -442,7 +453,7 @@ handle_3dstate_vs(struct gen_spec *spec, uint32_t *p)
              instruction_base, start);
 
       insns = (struct brw_instruction *) (gtt + instruction_base + start);
-      gen_disasm_disassemble(disasm, insns, 0, stdout);
+      print_gen_disassembly(disasm, insns, 0);
    }
 }
 
@@ -466,7 +477,7 @@ handle_3dstate_hs(struct gen_spec *spec, uint32_t *p)
              instruction_base, start);
 
       insns = (struct brw_instruction *) (gtt + instruction_base + start);
-      gen_disasm_disassemble(disasm, insns, 0, stdout);
+      print_gen_disassembly(disasm, insns, 0);
    }
 }
 
@@ -560,21 +571,21 @@ handle_3dstate_ps(struct gen_spec *spec, uint32_t *p)
    printf("  Kernel[0] %s\n", k0);
    if (k0 != unused) {
       insns = (struct brw_instruction *) (gtt + start);
-      gen_disasm_disassemble(disasm, insns, 0, stdout);
+      print_gen_disassembly(disasm, insns, 0);
    }
 
    start = instruction_base + (p[k1_offset] & mask);
    printf("  Kernel[1] %s\n", k1);
    if (k1 != unused) {
       insns = (struct brw_instruction *) (gtt + start);
-      gen_disasm_disassemble(disasm, insns, 0, stdout);
+      print_gen_disassembly(disasm, insns, 0);
    }
 
    start = instruction_base + (p[k2_offset] & mask);
    printf("  Kernel[2] %s\n", k2);
    if (k2 != unused) {
       insns = (struct brw_instruction *) (gtt + start);
-      gen_disasm_disassemble(disasm, insns, 0, stdout);
+      print_gen_disassembly(disasm, insns, 0);
    }
 }
 
diff --git a/src/intel/tools/disasm.c b/src/intel/tools/disasm.c
index af914243750..aacd81fec80 100644
--- a/src/intel/tools/disasm.c
+++ b/src/intel/tools/disasm.c
@@ -37,16 +37,13 @@ struct gen_disasm {
 
 void
 gen_disasm_disassemble(struct gen_disasm *disasm, void *assembly,
-                       int start, FILE *out)
+                       int start, char **out)
 {
    struct gen_device_info *devinfo = &disasm->devinfo;
    char *prog_disasm;
 
    brw_disassemble_prog(&prog_disasm, devinfo, assembly, start);
-   if (prog_disasm) {
-      fputs(prog_disasm, out);
-      free(prog_disasm);
-   }
+   *out = prog_disasm;
 }
 
 struct gen_disasm *
diff --git a/src/intel/tools/gen_disasm.h b/src/intel/tools/gen_disasm.h
index 24b56c9a8e1..f5c224fadcf 100644
--- a/src/intel/tools/gen_disasm.h
+++ b/src/intel/tools/gen_disasm.h
@@ -28,7 +28,7 @@ struct gen_disasm;
 
 struct gen_disasm *gen_disasm_create(int pciid);
 void gen_disasm_disassemble(struct gen_disasm *disasm,
-                            void *assembly, int start, FILE *out);
+                            void *assembly, int start, char **out);
 
 void gen_disasm_destroy(struct gen_disasm *disasm);
 
-- 
2.11.0



More information about the mesa-dev mailing list