Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Fwd: Re: [patch] Add support for ARMv7M devices.
@ 2012-03-09  4:25 Jonathan Larmour
  2012-03-09 11:44 ` Pedro Alves
  2012-03-09 15:39 ` Yao Qi
  0 siblings, 2 replies; 18+ messages in thread
From: Jonathan Larmour @ 2012-03-09  4:25 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1326 bytes --]

Over a year ago, after discussion and some helpful pointers from Daniel, I
submitted this patch:

http://sourceware.org/ml/gdb-patches/2010-11/msg00142.html

Unfortunately it fell by the wayside.

This issue is coming to a head for the eCos project as we are updating our
ARM toolchain (we avoid the bleeding edge). However that means we really
need GDB to preserve backward compatibility, which it presently fails to do.

We don't want to break backward compatibility with installed GDB stubs,
and the XML solution is complicated for users, opaque, not really suitable
for Eclipse (although there may be proprietary plugins around which try to
solve this, that isn't relevant for public GDB). Most importantly the
attached patch should flexibly work everywhere, and not break anyone's
compatibility. And furthermore, it allows us a clean migration path to the
changed 'g' packet length.

So I'm attaching an updated version of the patch for current GDB trunk. If
it helps, I do have an FSF assignment and, from prehistory, commit
permissions.

Jifl
-- 
eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["Si fractum non sit, noli id reficere"]------       Opinions==mine


[-- Attachment #2: mprofile-backcompat.20120309.patch --]
[-- Type: text/plain, Size: 6653 bytes --]

Index: arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.358
diff -u -5 -p -r1.358 arm-tdep.c
--- arm-tdep.c	2 Feb 2012 20:19:12 -0000	1.358
+++ arm-tdep.c	9 Mar 2012 04:19:39 -0000
@@ -41,10 +41,11 @@
 #include "gdbtypes.h"
 #include "prologue-value.h"
 #include "target-descriptions.h"
 #include "user-regs.h"
 #include "observer.h"
+#include "remote.h"
 
 #include "arm-tdep.h"
 #include "gdb/sim-arm.h"
 
 #include "elf-bfd.h"
@@ -53,10 +54,11 @@
 
 #include "gdb_assert.h"
 #include "vec.h"
 
 #include "features/arm-with-m.c"
+#include "features/arm-with-m-fpa.c"
 #include "features/arm-with-iwmmxt.c"
 #include "features/arm-with-vfpv2.c"
 #include "features/arm-with-vfpv3.c"
 #include "features/arm-with-neon.c"
 
@@ -9796,11 +9798,11 @@ arm_gdbarch_init (struct gdbarch_info in
 		 numerically greater than TAG_CPU_ARCH_V7).  */
 	      if (!tdesc_has_registers (tdesc)
 		  && (attr_arch == TAG_CPU_ARCH_V6_M
 		      || attr_arch == TAG_CPU_ARCH_V6S_M
 		      || attr_profile == 'M'))
-		tdesc = tdesc_arm_with_m;
+		is_m = 1;
 #endif
 	    }
 
 	  if (fp_model == ARM_FLOAT_AUTO)
 	    {
@@ -9858,10 +9860,12 @@ arm_gdbarch_init (struct gdbarch_info in
 	  if (feature == NULL)
 	    return NULL;
 	  else
 	    is_m = 1;
 	}
+      else
+        is_m = 0;
 
       tdesc_data = tdesc_data_alloc ();
 
       valid_p = 1;
       for (i = 0; i < ARM_SP_REGNUM; i++)
@@ -10241,10 +10245,33 @@ arm_gdbarch_init (struct gdbarch_info in
      and does no harm, since nothing ever lists user registers.  */
   for (i = 0; i < ARRAY_SIZE (arm_register_aliases); i++)
     user_reg_add (gdbarch, arm_register_aliases[i].name,
 		  value_of_arm_user_reg, &arm_register_aliases[i].regnum);
 
+  if (is_m)
+    {
+      /* For backward-compatibility we allow two 'g' packet lengths with
+         the remote protocol depending on whether FPA registers are
+         supplied. M-profile targets do not have FPA registers, but some
+         stubs already exist in the wild which use a 'g' packet which
+         supplies them albeit with dummy values. The packet format which
+         includes FPA registers should be considered deprecated for
+         M-profile targets.
+
+         The register sizes are fixed for these target descriptions in the
+         XML files, so we can hard-code them: r0-12,sp,lr,pc,xpsr for
+         tdesc_arm_with_m; and additionally f0-f7 and fps for
+         tdesc_arm_with_m_fpa.  */
+      
+      register_remote_g_packet_guess (gdbarch,
+                                      17 * INT_REGISTER_SIZE,
+                                      tdesc_arm_with_m);
+      register_remote_g_packet_guess (gdbarch,
+                                      18 * INT_REGISTER_SIZE +
+                                      8 * FP_REGISTER_SIZE,
+                                      tdesc_arm_with_m_fpa);
+    }
   return gdbarch;
 }
 
 static void
 arm_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
@@ -10289,10 +10316,11 @@ _initialize_arm_tdep (void)
 				  bfd_target_elf_flavour,
 				  arm_elf_osabi_sniffer);
 
   /* Initialize the standard target descriptions.  */
   initialize_tdesc_arm_with_m ();
+  initialize_tdesc_arm_with_m_fpa ();
   initialize_tdesc_arm_with_iwmmxt ();
   initialize_tdesc_arm_with_vfpv2 ();
   initialize_tdesc_arm_with_vfpv3 ();
   initialize_tdesc_arm_with_neon ();
 
Index: features/arm-with-m-fpa.c
===================================================================
RCS file: features/arm-with-m-fpa.c
diff -N features/arm-with-m-fpa.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ features/arm-with-m-fpa.c	9 Mar 2012 04:19:39 -0000
@@ -0,0 +1,46 @@
+/* THIS FILE IS GENERATED.  Original: arm-with-m-fpa.xml */
+
+#include "defs.h"
+#include "osabi.h"
+#include "target-descriptions.h"
+
+struct target_desc *tdesc_arm_with_m_fpa;
+static void
+initialize_tdesc_arm_with_m_fpa (void)
+{
+  struct target_desc *result = allocate_target_description ();
+  struct tdesc_feature *feature;
+  struct tdesc_type *field_type, *type;
+
+  feature = tdesc_create_feature (result, "org.gnu.gdb.arm.m-profile");
+  tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "int");
+  tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "int");
+  tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "int");
+  tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "int");
+  tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "int");
+  tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "int");
+  tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "int");
+  tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "int");
+  tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "int");
+  tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "int");
+  tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "int");
+  tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "int");
+  tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "int");
+  tdesc_create_reg (feature, "sp", 13, 1, NULL, 32, "data_ptr");
+  tdesc_create_reg (feature, "lr", 14, 1, NULL, 32, "int");
+  tdesc_create_reg (feature, "pc", 15, 1, NULL, 32, "code_ptr");
+  tdesc_create_reg (feature, "xpsr", 25, 1, NULL, 32, "int");
+
+  feature = tdesc_create_feature (result, "org.gnu.gdb.arm.fpa");
+  tdesc_create_reg (feature, "f0", 16, 1, NULL, 96, "arm_fpa_ext");
+  tdesc_create_reg (feature, "f1", 17, 1, NULL, 96, "arm_fpa_ext");
+  tdesc_create_reg (feature, "f2", 18, 1, NULL, 96, "arm_fpa_ext");
+  tdesc_create_reg (feature, "f3", 19, 1, NULL, 96, "arm_fpa_ext");
+  tdesc_create_reg (feature, "f4", 20, 1, NULL, 96, "arm_fpa_ext");
+  tdesc_create_reg (feature, "f5", 21, 1, NULL, 96, "arm_fpa_ext");
+  tdesc_create_reg (feature, "f6", 22, 1, NULL, 96, "arm_fpa_ext");
+  tdesc_create_reg (feature, "f7", 23, 1, NULL, 96, "arm_fpa_ext");
+  tdesc_create_reg (feature, "fps", 24, 1, NULL, 32, "int");
+
+  tdesc_arm_with_m_fpa = result;
+}
Index: features/arm-with-m-fpa.xml
===================================================================
RCS file: features/arm-with-m-fpa.xml
diff -N features/arm-with-m-fpa.xml
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ features/arm-with-m-fpa.xml	9 Mar 2012 04:19:39 -0000
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2010 Free Software Foundation, Inc.
+
+     Copying and distribution of this file, with or without modification,
+     are permitted in any medium without royalty provided the copyright
+     notice and this notice are preserved.  -->
+
+<!DOCTYPE target SYSTEM "gdb-target.dtd">
+<target>
+  <xi:include href="arm-m-profile.xml"/>
+  <xi:include href="arm-fpa.xml"/>
+</target>

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2012-04-17  1:56 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-09  4:25 Fwd: Re: [patch] Add support for ARMv7M devices Jonathan Larmour
2012-03-09 11:44 ` Pedro Alves
2012-03-09 15:53   ` Jonathan Larmour
2012-03-09 16:06     ` Pedro Alves
2012-04-16  7:56   ` Terry Guo
2012-04-16 14:40     ` Jonathan Larmour
2012-04-17  4:06       ` Terry Guo
2012-03-09 15:39 ` Yao Qi
2012-03-09 16:13   ` Jonathan Larmour
2012-03-09 16:29     ` Pedro Alves
2012-03-11  3:37       ` Jonathan Larmour
2012-03-14 16:06         ` Pedro Alves
2012-03-15  6:27           ` Jonathan Larmour
2012-03-15 17:09             ` Pedro Alves
2012-03-15 18:33               ` Jonathan Larmour
2012-03-15 18:43                 ` Pedro Alves
2012-03-15 18:56                   ` Jonathan Larmour
2012-03-15 18:58                     ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox