This is the mail archive of the gdb-patches@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]

[commit] Fix an ordering goof with code_ptr


There's a comment in tdesc_named_type that says to be careful and not
include anything that's swapped along with the current gdbarch.  Then
I added void * and void (*)() there.  Whoops!  This moves them down to
the right place.

I'm not thrilled with it, so I've been thinking about ways to redesign
the mechanism out of existance... but I haven't come up with one yet.
Ideally the description ought to be able to say <pointer
target="int8"/> and get a pointer of the correct size.  That would
require parsing the whole thing twice, using dummy types the first
time.

Anyway, tested (x86_64-linux and arm-linux) and checked in.  Now that
code_ptr and data_ptr work correctly, I applied them to the existing
ARM XML definition.

-- 
Daniel Jacobowitz
CodeSourcery

2007-02-13  Daniel Jacobowitz  <dan@codesourcery.com>

	* target-descriptions.c (tdesc_named_type): Move code_ptr and data_ptr
	handling from here...
	(tdesc_register_type): ...to here.
	* xml-tdesc.c (tdesc_start_reg): Allow code_ptr and data_ptr.
	* features/arm-core.xml: Use code_ptr and data_ptr.

---
 gdb/features/arm-core.xml |    4 ++--
 gdb/target-descriptions.c |   10 ++++------
 gdb/xml-tdesc.c           |    2 ++
 3 files changed, 8 insertions(+), 8 deletions(-)

Index: src/gdb/target-descriptions.c
===================================================================
--- src.orig/gdb/target-descriptions.c	2007-02-12 16:49:15.000000000 -0500
+++ src/gdb/target-descriptions.c	2007-02-12 16:49:30.000000000 -0500
@@ -382,12 +382,6 @@ tdesc_named_type (const struct tdesc_fea
   if (strcmp (id, "uint64") == 0)
     return builtin_type_uint64;
 
-  if (strcmp (id, "code_ptr") == 0)
-    return builtin_type_void_func_ptr;
-
-  if (strcmp (id, "data_ptr") == 0)
-    return builtin_type_void_data_ptr;
-
   if (strcmp (id, "arm_fpa_ext") == 0)
     return builtin_type_arm_ext;
 
@@ -555,6 +549,10 @@ tdesc_register_type (struct gdbarch *gdb
 	/* A bit desperate by this point... */
 	return builtin_type_void_data_ptr;
     }
+  else if (strcmp (reg->type, "code_ptr") == 0)
+    return builtin_type_void_func_ptr;
+  else if (strcmp (reg->type, "data_ptr") == 0)
+    return builtin_type_void_data_ptr;
   else
     internal_error (__FILE__, __LINE__,
 		    "Register \"%s\" has an unknown type \"%s\"",
Index: src/gdb/xml-tdesc.c
===================================================================
--- src.orig/gdb/xml-tdesc.c	2007-02-12 16:49:15.000000000 -0500
+++ src/gdb/xml-tdesc.c	2007-02-12 16:49:16.000000000 -0500
@@ -163,6 +163,8 @@ tdesc_start_reg (struct gdb_xml_parser *
 
   if (strcmp (type, "int") != 0
       && strcmp (type, "float") != 0
+      && strcmp (type, "code_ptr") != 0
+      && strcmp (type, "data_ptr") != 0
       && tdesc_named_type (data->current_feature, type) == NULL)
     gdb_xml_error (parser, _("Register \"%s\" has unknown type \"%s\""),
 		   name, type);
Index: src/gdb/features/arm-core.xml
===================================================================
--- src.orig/gdb/features/arm-core.xml	2007-02-12 16:49:15.000000000 -0500
+++ src/gdb/features/arm-core.xml	2007-02-12 16:49:16.000000000 -0500
@@ -20,9 +20,9 @@
   <reg name="r10" bitsize="32"/>
   <reg name="r11" bitsize="32"/>
   <reg name="r12" bitsize="32"/>
-  <reg name="sp" bitsize="32"/>
+  <reg name="sp" bitsize="32" type="data_ptr"/>
   <reg name="lr" bitsize="32"/>
-  <reg name="pc" bitsize="32"/>
+  <reg name="pc" bitsize="32" type="code_ptr"/>
 
   <!-- The CPSR is register 25, rather than register 16, because
        the FPA registers historically were placed between the PC


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