diff options
-rw-r--r-- | gdb/ChangeLog | 10 | ||||
-rw-r--r-- | gdb/disasm.c | 13 | ||||
-rw-r--r-- | gdb/disasm.h | 1 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/all-architectures.exp.in | 5 |
5 files changed, 32 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2e8a96f..4e85fcd 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,4 +1,14 @@ 2017-01-26 Yao Qi <yao.qi@linaro.org> + Pedro Alves <palves@redhat.com> + + PR gdb/20939 + * disasm.c (gdb_disassembler::dis_asm_memory_error): Don't + call memory_error, save memaddr instead. + (gdb_disassembler::print_insn): If gdbarch_print_insn returns + negative, cal memory_error. + * disasm.h (gdb_disassembler) <m_err_memaddr>: New field. + +2017-01-26 Yao Qi <yao.qi@linaro.org> * disasm-selftests.c (memory_error_test): New function. (_initialize_disasm_selftests): Register memory_error_test. diff --git a/gdb/disasm.c b/gdb/disasm.c index b58da0f..897f2f1 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -135,7 +135,10 @@ void gdb_disassembler::dis_asm_memory_error (int err, bfd_vma memaddr, struct disassemble_info *info) { - memory_error (TARGET_XFER_E_IO, memaddr); + gdb_disassembler *self + = static_cast<gdb_disassembler *>(info->application_data); + + self->m_err_memaddr = memaddr; } /* Wrapper of print_address. */ @@ -765,7 +768,8 @@ fprintf_disasm (void *stream, const char *format, ...) gdb_disassembler::gdb_disassembler (struct gdbarch *gdbarch, struct ui_file *file, di_read_memory_ftype read_memory_func) - : m_gdbarch (gdbarch) + : m_gdbarch (gdbarch), + m_err_memaddr (0) { init_disassemble_info (&m_di, file, fprintf_disasm); m_di.flavour = bfd_target_unknown_flavour; @@ -792,8 +796,13 @@ int gdb_disassembler::print_insn (CORE_ADDR memaddr, int *branch_delay_insns) { + m_err_memaddr = 0; + int length = gdbarch_print_insn (arch (), memaddr, &m_di); + if (length < 0) + memory_error (TARGET_XFER_E_IO, m_err_memaddr); + if (branch_delay_insns != NULL) { if (m_di.insn_info_valid) diff --git a/gdb/disasm.h b/gdb/disasm.h index c6cb13b..7bbfa31 100644 --- a/gdb/disasm.h +++ b/gdb/disasm.h @@ -66,6 +66,7 @@ private: /* Stores data required for disassembling instructions in opcodes. */ struct disassemble_info m_di; + CORE_ADDR m_err_memaddr; static int dis_asm_read_memory (bfd_vma memaddr, gdb_byte *myaddr, unsigned int len, diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 28e337a..404b408 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-01-26 Yao Qi <yao.qi@linaro.org> + + * gdb.base/all-architectures.exp.in (do_arch_tests): Test + disassemble on address 0. + 2017-01-25 Andreas Arnez <arnez@linux.vnet.ibm.com> Yao Qi <yao.qi@linaro.org> diff --git a/gdb/testsuite/gdb.base/all-architectures.exp.in b/gdb/testsuite/gdb.base/all-architectures.exp.in index c7615ac..b07caf5 100644 --- a/gdb/testsuite/gdb.base/all-architectures.exp.in +++ b/gdb/testsuite/gdb.base/all-architectures.exp.in @@ -152,6 +152,11 @@ proc print_floats {} { proc do_arch_tests {} { print_floats + + # GDB can't access memory because there is no loaded executable + # nor live inferior. + gdb_test_internal "disassemble 0x0,+4" \ + "Cannot access memory at address 0x0" } # Given we can't change arch, osabi, endianness, etc. atomically, we |