From 56d704daee44b036d1eff86123de6dec0c55f61b Mon Sep 17 00:00:00 2001 From: Anton Kolesov Date: Tue, 27 Jun 2017 19:12:14 +0300 Subject: arc: Pass proper CPU value to the disassembler There was a problem with generation of the disassembler options for ARC in GDB, because a BFD architecture name was used as a CPU name, but they have different meaning even if some architectures have same name as respective CPUs. Target description specifies a BFD architecture, which is different from ARC CPU, as accepted by the disassembler (and most other ARC tools), because CPU values are much more fine grained - there can be multiple CPU values per single BFD architecture. As a result this code should translate architecture to some CPU value. Since there is no info on exact CPU configuration, it is best to use the most feature-rich CPU, so that the disassembler will recognize all instructions available to the specified architecture. gdb/ChangeLog yyyy-mm-dd Anton Kolesov * arc-tdep.c (arc_gdbarch_init): Pass proper cpu value to disassembler. * arc-tdep.h (arc_arch_is_em): New function. (arc_arch_is_hs): Likewise. gdb/testsuite/ChangeLog yyyy-mm-dd Anton Kolesov * gdb.arch/arc-tdesc-cpu.exp: New file. * gdb.arch/arc-tdesc-cpu.xml: Likewise. --- gdb/arc-tdep.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'gdb/arc-tdep.c') diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c index 1d05c5a..771d6df 100644 --- a/gdb/arc-tdep.c +++ b/gdb/arc-tdep.c @@ -2085,8 +2085,38 @@ arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) existing gdbarches, which also can be problematic, if arc_gdbarch_init will start reusing existing gdbarch instances. */ - arc_disassembler_options = xstrprintf ("cpu=%s", - tdesc_arch->printable_name); + /* Target description specifies a BFD architecture, which is + different from ARC cpu, as accepted by disassembler (and most + other ARC tools), because cpu values are much more fine grained - + there can be multiple cpu values per single BFD architecture. As + a result this code should translate architecture to some cpu + value. Since there is no info on exact cpu configuration, it is + best to use the most feature-rich CPU, so that disassembler will + recognize all instructions available to the specified + architecture. */ + switch (tdesc_arch->mach) + { + case bfd_mach_arc_arc601: + arc_disassembler_options = xstrdup ("cpu=arc601"); + break; + case bfd_mach_arc_arc600: + arc_disassembler_options = xstrdup ("cpu=arc600"); + break; + case bfd_mach_arc_arc700: + arc_disassembler_options = xstrdup ("cpu=arc700"); + break; + case bfd_mach_arc_arcv2: + /* Machine arcv2 has three arches: ARCv2, EM and HS; where ARCv2 + is treated as EM. */ + if (arc_arch_is_hs (tdesc_arch)) + arc_disassembler_options = xstrdup ("cpu=hs38_linux"); + else + arc_disassembler_options = xstrdup ("cpu=em4_fpuda"); + break; + default: + arc_disassembler_options = NULL; + break; + } set_gdbarch_disassembler_options (gdbarch, &arc_disassembler_options); } -- cgit v1.1