This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] [ARM] Mark USER_SPECIFIED_MACHINE_TYPE in disassemble_info.flags


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e60eb2880368b4e4752577c626ab0dadf0499cb5

commit e60eb2880368b4e4752577c626ab0dadf0499cb5
Author: Yao Qi <yao.qi@linaro.org>
Date:   Fri Aug 18 09:30:12 2017 +0100

    [ARM] Mark USER_SPECIFIED_MACHINE_TYPE in disassemble_info.flags
    
    opcodes/arm-dis.c:print_insn may update disassemble_info.mach to
    bfd_mach_arm_unknown unless USER_SPECIFIED_MACHINE_TYPE is marked.
    When default_print_insn is called for the first time,
    disassemble_info.mach is correctly set in GDB, but arm-dis.c:print_insn
    sets it to bfd_mach_arm_unknown.  Then, when default_print_insn is
    called again (in a loop), it triggers the assert.
    
    The patch fixes the assert by marking USER_SPECIFIED_MACHINE_TYPE so that
    opcodes won't reset disassemble_info.mach.
    
    gdb:
    
    2017-08-18  Yao Qi  <yao.qi@linaro.org>
    
    	PR tdep/21818
    	* arm-tdep.c (gdb_print_insn_arm): Mark
    	USER_SPECIFIED_MACHINE_TYPE if exec_bfd isn't NULL.

Diff:
---
 gdb/ChangeLog  | 6 ++++++
 gdb/arm-tdep.c | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2581935..5929091 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
 2017-08-18  Yao Qi  <yao.qi@linaro.org>
 
+	PR tdep/21818
+	* arm-tdep.c (gdb_print_insn_arm): Mark
+	USER_SPECIFIED_MACHINE_TYPE if exec_bfd isn't NULL.
+
+2017-08-18  Yao Qi  <yao.qi@linaro.org>
+
 	* NEWS: Mention GDBserver's new option "--selftest".
 	* Makefile.in (SFILES): Remove selftest.c, add common/selftest.c.
 	* selftest.c: Move it to common/selftest.c.
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index a107584..0c1a0b3 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -7773,6 +7773,14 @@ gdb_print_insn_arm (bfd_vma memaddr, disassemble_info *info)
   else
     info->symbols = NULL;
 
+  /* GDB is able to get bfd_mach from the exe_bfd, info->mach is
+     accurate, so mark USER_SPECIFIED_MACHINE_TYPE bit.  Otherwise,
+     opcodes/arm-dis.c:print_insn reset info->mach, and it will trigger
+     the assert on the mismatch of info->mach and bfd_get_mach (exec_bfd)
+     in default_print_insn.  */
+  if (exec_bfd != NULL)
+    info->flags |= USER_SPECIFIED_MACHINE_TYPE;
+
   return default_print_insn (memaddr, info);
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]