Update the amdgcn disassembler
authorLaurent Morichetti <laurent.morichetti@amd.com>
Tue, 5 May 2020 19:25:25 +0000 (12:25 -0700)
committerLaurent Morichetti <laurent.morichetti@amd.com>
Wed, 6 May 2020 20:50:58 +0000 (13:50 -0700)
The ROCdbgapi disassembler now uses a symbolizer to print address
operands.

Depends-On: I8f12a37ee4c2b9a196f111f454e9c2fd26961f2e
Change-Id: I145c8f2d99eab8071e0d02eb686f53e11d4afd8c

gdb/amdgcn-rocm-tdep.c

index 7580f2a2e8c909e883b723fee0fbda688adfff46..c0aef7dfe70ebaa2cfe1f7ef1d23e832d09fc2c8 100644 (file)
@@ -341,13 +341,21 @@ print_insn_amdgcn (bfd_vma memaddr, struct disassemble_info *di)
     return -1;
 
   char *instruction_text = nullptr;
-  amd_dbgapi_global_address_t *operands = nullptr;
-  amd_dbgapi_size_t operand_count = 0;
+
+  auto symbolizer
+      = [] (amd_dbgapi_symbolizer_id_t id, amd_dbgapi_global_address_t address,
+            char **symbol_text) -> amd_dbgapi_status_t {
+    string_file string;
+    print_address (reinterpret_cast<struct gdbarch *> (id), address, &string);
+    *symbol_text = xstrdup (string.c_str ());
+    return AMD_DBGAPI_STATUS_SUCCESS;
+  };
 
   if (amd_dbgapi_disassemble_instruction (
           architecture_id, static_cast<amd_dbgapi_global_address_t> (memaddr),
-          &instruction_size, buffer.get (), &instruction_text, &operand_count,
-          &operands)
+          &instruction_size, buffer.get (), &instruction_text,
+          reinterpret_cast<amd_dbgapi_symbolizer_id_t> (self->arch ()),
+          symbolizer)
       != AMD_DBGAPI_STATUS_SUCCESS)
     {
       size_t alignment;
@@ -366,16 +374,8 @@ print_insn_amdgcn (bfd_vma memaddr, struct disassemble_info *di)
   /* Print the instruction.  */
   (*di->fprintf_func) (di->stream, "%s", instruction_text);
 
-  /* Print the operands.  */
-  for (size_t i = 0; i < operand_count; ++i)
-    {
-      (*di->fprintf_func) (di->stream, (i == 0) ? "  # " : ", ");
-      (*di->print_address_func) (static_cast<bfd_vma> (operands[i]), di);
-    }
-
   /* Free the memory allocated by the amd-dbgapi.  */
   xfree (instruction_text);
-  xfree (operands);
 
   return static_cast<int> (instruction_size);
 }
This page took 0.024589 seconds and 4 git commands to generate.