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]

Re: [patch] Can't connect to simulator that doesn't have bi-endian


On Wed, Jan 24, 2007 at 12:22:14PM +0900, Masaki Muranaka wrote:
> Hello Daniel,
> 
> I see my patch is not reasonable.
> 
> I read man1/*-*-run.1 again and there is no description about -E.
> Simulators have no responsibility to implement -E option, right?
> If this is true, GDB should not expect that all simulators have -E.

I think that's exactly right.  But, for those simulators which support
two endiannesses, how do they decide which one to use?  The answer
seems to be, from the executable file.  And we'll always have a file
for simulators.

The code was originally written to support using a big-endian file with
"set endian little".  Then it broke, and did nothing for a while; then
I tried to fix it, but misunderstood what it did, and changed it to use
the current endianness (even if it was automatic).

Could you try this, which puts things back the way they were?

-- 
Daniel Jacobowitz
CodeSourcery

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

	* arch-utils.c (selected_byte_order): New.
	* arch-utils.h (selected_byte_order): New prototype.
	* remote-sim.c (gdbsim_open): Use selected_byte_order.

Index: arch-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.c,v
retrieving revision 1.141
diff -u -p -r1.141 arch-utils.c
--- arch-utils.c	29 Jan 2007 17:31:05 -0000	1.141
+++ arch-utils.c	8 Feb 2007 15:00:24 -0000
@@ -280,6 +280,15 @@ static const char *endian_enum[] =
 };
 static const char *set_endian_string;
 
+enum bfd_endian
+selected_byte_order (void)
+{
+  if (target_byte_order_user)
+    return TARGET_BYTE_ORDER;
+  else
+    return BFD_ENDIAN_UNKNOWN;
+}
+
 /* Called by ``show endian''.  */
 
 static void
Index: arch-utils.h
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.h,v
retrieving revision 1.84
diff -u -p -r1.84 arch-utils.h
--- arch-utils.h	29 Jan 2007 17:31:05 -0000	1.84
+++ arch-utils.h	8 Feb 2007 15:00:24 -0000
@@ -115,6 +115,10 @@ extern int generic_instruction_nullified
 
 extern int legacy_register_sim_regno (int regnum);
 
+/* Return the selected byte order, or BFD_ENDIAN_UNKNOWN if no byte
+   order was explicitly selected.  */
+extern enum bfd_endian selected_byte_order (void);
+
 /* Return the selected architecture's name, or NULL if no architecture
    was explicitly selected.  */
 extern const char *selected_architecture_name (void);
Index: remote-sim.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-sim.c,v
retrieving revision 1.57
diff -u -p -r1.57 remote-sim.c
--- remote-sim.c	9 Jan 2007 17:58:56 -0000	1.57
+++ remote-sim.c	8 Feb 2007 15:00:24 -0000
@@ -504,9 +504,9 @@ gdbsim_open (char *args, int from_tty)
 	 + 50) /* slack */ ;
   arg_buf = (char *) alloca (len);
   strcpy (arg_buf, "gdbsim");	/* 7 */
-  /* Specify the byte order for the target when it is both selectable
-     and explicitly specified by the user (not auto detected). */
-  switch (TARGET_BYTE_ORDER)
+  /* Specify the byte order for the target when it is explicitly
+     specified by the user (not auto detected). */
+  switch (selected_byte_order ())
     {
     case BFD_ENDIAN_BIG:
       strcat (arg_buf, " -E big");


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