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]

[1/3] Remove gdbarch-swapping of remote_address_masked


Hello,

remote.c contains a gdbarch-swapped variable "remote_address_masked".  The
swap function in fact re-sets the variable to the default address size of
the target.

This patch attempts to decouple changes to the variable by the user
(via "set remoteaddresssize") from changes due to architecture switches:

- If the user sets the variable, that value is subsequently used (even
  if the architecture switches).

- If the user never used "set remoteaddresssize" (i.e. the variable
  reads 0), remote_address_masked implicitly uses the current target's
  address size instead.


Now this is certainly a change in behaviour, but I'd think the new way
should actually be more useful ...

Any comments from users of that functionality?  Does this make sense?

Bye,
Ulrich



ChangeLog:

	* remote.c (remote_address_masked): If remote_address_size is zero,
	default to target address size.
	(build_remote_gdbarch_data): Remove.
	(_initialize_remote): Do not swap remote_address_size.

diff -urNp gdb-orig/gdb/remote.c gdb-head/gdb/remote.c
--- gdb-orig/gdb/remote.c	2007-06-08 13:48:41.294606000 +0200
+++ gdb-head/gdb/remote.c	2007-06-08 20:15:01.825476499 +0200
@@ -3919,13 +3919,18 @@ hexnumnstr (char *buf, ULONGEST num, int
 static CORE_ADDR
 remote_address_masked (CORE_ADDR addr)
 {
-  if (remote_address_size > 0
-      && remote_address_size < (sizeof (ULONGEST) * 8))
+  int address_size = remote_address_size;
+  /* If "remoteaddresssize" was not set, default to target address size.  */
+  if (!address_size)
+    address_size = TARGET_ADDR_BIT;
+
+  if (address_size > 0
+      && address_size < (sizeof (ULONGEST) * 8))
     {
       /* Only create a mask when that mask can safely be constructed
          in a ULONGEST variable.  */
       ULONGEST mask = 1;
-      mask = (mask << remote_address_size) - 1;
+      mask = (mask << address_size) - 1;
       addr &= mask;
     }
   return addr;
@@ -6347,12 +6352,6 @@ show_remote_cmd (char *args, int from_tt
   do_cleanups (showlist_chain);
 }
 
-static void
-build_remote_gdbarch_data (void)
-{
-  remote_address_size = TARGET_ADDR_BIT;
-}
-
 /* Function to be called whenever a new objfile (shlib) is detected.  */
 static void
 remote_new_objfile (struct objfile *objfile)
@@ -6372,11 +6371,6 @@ _initialize_remote (void)
   remote_g_packet_data_handle =
     gdbarch_data_register_pre_init (remote_g_packet_data_init);
 
-  /* Old tacky stuff.  NOTE: This comes after the remote protocol so
-     that the remote protocol has been initialized.  */
-  DEPRECATED_REGISTER_GDBARCH_SWAP (remote_address_size);
-  deprecated_register_gdbarch_swap (NULL, 0, build_remote_gdbarch_data);
-
   /* Initialize the per-target state.  At the moment there is only one
      of these, not one per target.  Only one target is active at a
      time.  The default buffer size is unimportant; it will be expanded
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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