From 768f89bc8893662b043e4dc9b7a327eaddd093eb Mon Sep 17 00:00:00 2001 From: Laurent Morichetti Date: Sat, 21 Dec 2019 21:52:59 -0800 Subject: [PATCH] Fix gdb.base/all-architectures-2.exp failures 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 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gdb/amdgcn-rocm-tdep.c b/gdb/amdgcn-rocm-tdep.c index ae79ff1f0c..44166db7f6 100644 --- a/gdb/amdgcn-rocm-tdep.c +++ b/gdb/amdgcn-rocm-tdep.c @@ -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")); -- 2.34.1