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

Re: RFA: remote_address_size changes


Kevin Buettner wrote:
> 
> Andrew,
> 
> As you know, I'm working on a port for a 64 bit target and am using
> the gdbarch machinery.
> 
> When connecting to my remote target, remote_address_size was not
> being set properly.  The reason for this is because at the time
> of initialization in _initialize_remote(), TARGET_PTR_BIT refers
> to the ptr_bit field in default_gdbarch instead of in a gdbarch
> struct created for the target.  As a result, remote_address_size
> was set to the pointer size of the host and not the target.

Good catch!

Have a look at how remote.c registers and then updates the variable
tty_input.  When ever the user selects a new target, that variable is
switched (brutal yes).

For remote_address_size you would probably want to do something similar.

However:

> The other thing that bothers me is that if the user uses the same gdb
> session to connect to several different targets with different address
> sizes [does anyone ever do this?], the conditional initialization
> 
>       if (remote_address_size == 0)
>         remote_address_size = TARGET_PTR_BIT;
> 
> will not set remote_address_size correctly.

The above mechanism binds ``remote_address_size'' to the architecture. 
If the architecture changes - new binary of a different type then the
old selection is lost.  Is this a good thing or a  dangerous thing?

Consider the sequence:

	set remote address-size 16
	file xyz

which can have different semantics to:

	file xyz
	set remote address-size 16

Making their behavour identical isn't trivial (fortunatly it isn't
difficult either).  The problem is figuring out exactly what reasonable
behavour is - I have no opinion.

	Andrew

> 
> Kevin
> 
>         * remote.c (_initialize_remote): Initialize remote_address_size
>         to zero.
>         (remote_open_1, remote_async_open_1): Set remote_address_size
>         to TARGET_PTR_BIT if not already set by the user (or by
>         already opening a target).
> 
> Index: remote.c
> ===================================================================
> RCS file: /cvs/cvsfiles/devo/gdb/remote.c,v
> retrieving revision 1.253
> diff -u -r1.253 remote.c
> --- remote.c    1999/10/25 08:36:49     1.253
> +++ remote.c    1999/11/03 17:08:38
> @@ -1775,6 +1775,9 @@
>    general_thread = -2;
>    continue_thread = -2;
> 
> +  if (remote_address_size == 0)
> +    remote_address_size = TARGET_PTR_BIT;
> +
>    /* Force remote_write_bytes to check whether target supports
>       binary downloading. */
>    init_packet_config (&remote_protocol_binary_download);
> @@ -1859,6 +1862,9 @@
>    general_thread = -2;
>    continue_thread = -2;
> 
> +  if (remote_address_size == 0)
> +    remote_address_size = TARGET_PTR_BIT;
> +
>    /* Force remote_write_bytes to check whether target supports
>       binary downloading. */
>    init_packet_config (&remote_protocol_binary_download);
> @@ -5305,7 +5311,7 @@
>                   &setlist),
>       &showlist);
> 
> -  remote_address_size = TARGET_PTR_BIT;
> +  remote_address_size = 0;
>    add_show_from_set
>      (add_set_cmd ("remoteaddresssize", class_obscure,
>                   var_integer, (char *) &remote_address_size,

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