Fix gdb.base/all-architectures-2.exp failures
authorLaurent Morichetti <laurent.morichetti@amd.com>
Sun, 22 Dec 2019 05:52:59 +0000 (21:52 -0800)
committerLaurent Morichetti <laurent.morichetti@amd.com>
Sun, 22 Dec 2019 06:02:15 +0000 (22:02 -0800)
print_insn_amdgcn fails to report an error if the memory is not mapped.

disassemble 0x0,+4 returns:
Dump of assembler code from 0x0 to 0x4:
   0x0000000000000000:  v_cndmask_b32_e32 v0, s0, v0, vcc

instead of:
Dump of assembler code from 0x0 to 0x4:
   0x0000000000000000:  Cannot access memory at address 0x0

print_insn_amdgcn should return -1 if target_read returns 0 or
TARGET_XFER_E_IO. Also, use TARGET_OBJECT_CODE_MEMORY since we are
disassembling code memory.

gdb/ChangeLog:

        * amdgcn-rocm-tdep.c (print_insn_amdgcn): Check target_read's
        return value and return -1 if it is 0 or TARGET_XFER_E_IO.
        (amdgcn_rocm_displaced_step_fixup): Fix indentation.
        (amdgcn_gdbarch_init): Fix indentation.

Change-Id: Iff607a45efd0d369d44e7a8b34c8eb612985b5de

gdb/amdgcn-rocm-tdep.c

index ae79ff1f0c472766a77d84f1fa270b279e676486..44166db7f69f1cb7cb8b04f655a3f817c630b30a 100644 (file)
@@ -303,7 +303,8 @@ amdgcn_rocm_displaced_step_fixup (struct gdbarch *gdbarch,
       closure->process_id, closure->wave_id, closure->displaced_stepping_id);
 
   if (status != AMD_DBGAPI_STATUS_SUCCESS)
-    error (_ ("amd_dbgapi_displaced_stepping_complete failed (rc=%d)"), status);
+    error (_ ("amd_dbgapi_displaced_stepping_complete failed (rc=%d)"),
+           status);
 
   /* We may have written some registers, so flush the register cache.  */
   registers_changed_ptid (regcache->ptid ());
@@ -322,9 +323,9 @@ print_insn_amdgcn (bfd_vma memaddr, struct disassemble_info *di)
       (gdb_byte *)xmalloc (instruction_size));
 
   instruction_size
-      = target_read (current_top_target (), TARGET_OBJECT_MEMORY, NULL,
+      = target_read (current_top_target (), TARGET_OBJECT_CODE_MEMORY, NULL,
                      buffer.get (), memaddr, instruction_size);
-  if (!instruction_size)
+  if (instruction_size == TARGET_XFER_E_IO || instruction_size == 0)
     {
       (*di->memory_error_func) (-1, memaddr, di);
       return -1;
@@ -582,8 +583,7 @@ amdgcn_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   gdb_byte *breakpoint_instruction_bytes;
   if (amd_dbgapi_architecture_get_info (
           architecture_id, AMD_DBGAPI_ARCHITECTURE_INFO_BREAKPOINT_INSTRUCTION,
-          sizeof (breakpoint_instruction_bytes),
-          &breakpoint_instruction_bytes)
+          sizeof (breakpoint_instruction_bytes), &breakpoint_instruction_bytes)
       != AMD_DBGAPI_STATUS_SUCCESS)
     error (_ ("amd_dbgapi_architecture_get_info failed"));
 
This page took 0.037238 seconds and 4 git commands to generate.