diff options
-rw-r--r-- | gdb/disasm.c | 14 | ||||
-rw-r--r-- | gdb/disasm.h | 7 |
2 files changed, 15 insertions, 6 deletions
diff --git a/gdb/disasm.c b/gdb/disasm.c index c788f5b..dc64267 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -148,7 +148,7 @@ gdb_disassembler::dis_asm_memory_error (int err, bfd_vma memaddr, gdb_disassembler *self = static_cast<gdb_disassembler *>(info->application_data); - self->m_err_memaddr = memaddr; + self->m_err_memaddr.emplace (memaddr); } /* Wrapper of print_address. */ @@ -754,8 +754,7 @@ get_all_disassembler_options (struct gdbarch *gdbarch) gdb_disassembler::gdb_disassembler (struct gdbarch *gdbarch, struct ui_file *file, di_read_memory_ftype read_memory_func) - : m_gdbarch (gdbarch), - m_err_memaddr (0) + : m_gdbarch (gdbarch) { init_disassemble_info (&m_di, file, fprintf_disasm); m_di.flavour = bfd_target_unknown_flavour; @@ -790,12 +789,17 @@ int gdb_disassembler::print_insn (CORE_ADDR memaddr, int *branch_delay_insns) { - m_err_memaddr = 0; + m_err_memaddr.reset (); int length = gdbarch_print_insn (arch (), memaddr, &m_di); if (length < 0) - memory_error (TARGET_XFER_E_IO, m_err_memaddr); + { + if (m_err_memaddr.has_value ()) + memory_error (TARGET_XFER_E_IO, *m_err_memaddr); + else + error (_("unknown disassembler error (error = %d)"), length); + } if (branch_delay_insns != NULL) { diff --git a/gdb/disasm.h b/gdb/disasm.h index 6cbfdcd..d3642d8 100644 --- a/gdb/disasm.h +++ b/gdb/disasm.h @@ -75,7 +75,12 @@ private: using this field. */ std::string m_disassembler_options_holder; - CORE_ADDR m_err_memaddr; + /* This member variable is given a value by calling dis_asm_memory_error. + If after calling into the libopcodes disassembler we get back a + negative value (which indicates an error), then, if this variable has + a value, we report a memory error to the user, otherwise, we report a + non-memory error. */ + gdb::optional<CORE_ADDR> m_err_memaddr; static int dis_asm_read_memory (bfd_vma memaddr, gdb_byte *myaddr, unsigned int len, |