This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
set remotebinarydownload -> set remote X-packet
- To: gdb-patches@sourceware.cygnus.com
- Subject: set remotebinarydownload -> set remote X-packet
- From: Andrew Cagney <ac131313@cygnus.com>
- Date: Thu, 05 Aug 1999 14:16:09 +1000
- DJ-Gateway: from newsgroup cygnus.patches.gdb
- Newsgroups: cygnus.patches.gdb
- Organization: Cygnus Solutions
FYI,
I've applied the attached patch. It replaces the ``set
remotebinarydownload'' command with a more feature full ``set remote
X-packet'' command. The latter allows more complete control over how
thet `X' (binary-download) packet is used.
With this patch applied, there are two possible additional changes:
o add ``set remote binary-download'' as an alias
for ``set remote X-packet''.
(I've figured out how to do this).
o add ``set remotebinarydownload'' as a backward
compatible command for ``set remote X-packet''.
(In this case I'm open to hints on how it can
easily be implemented).
Hmm, I'll update the news file as well.
enjoy,
Andrew
Thu Aug 5 11:59:06 1999 Andrew Cagney <cagney@b1.cygnus.com>
* remote.c (remote_protocol_binary_download): New variable.
Replace ``remote_binary_download'' and
``remote_binary_checked''.
(set_remote_protocol_binary_download_cmd,
show_remote_protocol_binary_download_cmd): New functions.
(remote_open_1, remote_async_open_1, remote_cisco_open):
Initialize ``remote_protocol_binary_download'' instead of
``remote_binary_download''.
(check_binary_download): Re-write.
(remote_write_bytes): Ditto.
(_initialize_remote): Add ``set remote X-packet'' and ``show
remote X-packet'' commands. Disable old ``set
remotebinarydownload'' command.
? diffs
Index: remote.c
===================================================================
RCS file: /cvs/gdb/gdb/gdb/remote.c,v
retrieving revision 1.1.1.13
diff -p -r1.1.1.13 remote.c
*** remote.c 1999/07/27 00:51:01 1.1.1.13
--- remote.c 1999/08/05 04:06:36
*************** static serial_t remote_desc = NULL;
*** 447,463 ****
to denote that the target is in kernel mode. */
static int cisco_kernel_mode = 0;
- /* This variable (available to the user via "set remotebinarydownload")
- dictates whether downloads are sent in binary (via the 'X' packet).
- We assume that the stub can, and attempt to do it. This will be cleared if
- the stub does not understand it. This switch is still needed, though
- in cases when the packet is supported in the stub, but the connection
- does not allow it (i.e., 7-bit serial connection only). */
- static int remote_binary_download = 1;
-
- /* Have we already checked whether binary downloads work? */
- static int remote_binary_checked;
-
/* Maximum number of bytes to read/write at once. The value here
is chosen to fill up a packet (the headers account for the 32). */
#define MAXBUFBYTES(N) (((N)-32)/2)
--- 447,452 ----
*************** show_remote_protocol_P_packet_cmd (args,
*** 658,663 ****
--- 647,680 ----
}
+ /* Should we try the 'X' (remote binary download) packet?
+
+ This variable (available to the user via "set remote X-packet")
+ dictates whether downloads are sent in binary (via the 'X' packet).
+ We assume that the stub can, and attempt to do it. This will be
+ cleared if the stub does not understand it. This switch is still
+ needed, though in cases when the packet is supported in the stub,
+ but the connection does not allow it (i.e., 7-bit serial connection
+ only). */
+
+ static struct packet_config remote_protocol_binary_download;
+
+ static void
+ set_remote_protocol_binary_download_cmd (char *args,
+ int from_tty,
+ struct cmd_list_element *c)
+ {
+ set_packet_config_cmd (&remote_protocol_binary_download, c);
+ }
+
+ static void
+ show_remote_protocol_binary_download_cmd (char *args,
+ int from_tty)
+ {
+ show_packet_config_cmd (&remote_protocol_binary_download);
+ }
+
+
/* Tokens for use by the asynchronous signal handlers for SIGINT */
PTR sigint_remote_twice_token;
PTR sigint_remote_token;
*************** serial device is attached to the remote
*** 1908,1914 ****
/* Force remote_write_bytes to check whether target supports
binary downloading. */
! remote_binary_checked = 0;
/* Without this, some commands which require an active target (such
as kill) won't work. This variable serves (at least) double duty
--- 1925,1931 ----
/* Force remote_write_bytes to check whether target supports
binary downloading. */
! init_packet_config (&remote_protocol_binary_download);
/* Without this, some commands which require an active target (such
as kill) won't work. This variable serves (at least) double duty
*************** serial device is attached to the remote
*** 1998,2004 ****
/* Force remote_write_bytes to check whether target supports
binary downloading. */
! remote_binary_checked = 0;
/* If running asynchronously, set things up for telling the target
to use the extended protocol. This will happen only after the
--- 2015,2021 ----
/* Force remote_write_bytes to check whether target supports
binary downloading. */
! init_packet_config (&remote_protocol_binary_download);
/* If running asynchronously, set things up for telling the target
to use the extended protocol. This will happen only after the
*************** remote_address_masked (addr)
*** 3102,3143 ****
to the target at the specified address. It does not suffice to send
the whole packet, since many stubs strip the eighth bit and subsequently
compute a wrong checksum, which causes real havoc with remote_write_bytes.
- NOTE: This can still lose if the serial line is not eight-bit clean. In
- cases like this, the user should clear "remotebinarydownload". */
static void
check_binary_download (addr)
CORE_ADDR addr;
{
! if (remote_binary_download && !remote_binary_checked)
{
! char *buf = alloca (PBUFSIZ);
! char *p;
! remote_binary_checked = 1;
!
! p = buf;
! *p++ = 'X';
! p += hexnumstr (p, (ULONGEST) addr);
! *p++ = ',';
! p += hexnumstr (p, (ULONGEST) 0);
! *p++ = ':';
! *p = '\0';
!
! putpkt_binary (buf, (int) (p - buf));
! getpkt (buf, 0);
!
! if (buf[0] == '\0')
! remote_binary_download = 0;
! }
! if (remote_debug)
! {
! if (remote_binary_download)
! fprintf_unfiltered (gdb_stdlog,
! "binary downloading suppported by target\n");
! else
! fprintf_unfiltered (gdb_stdlog,
! "binary downloading NOT suppported by target\n");
}
}
--- 3119,3171 ----
to the target at the specified address. It does not suffice to send
the whole packet, since many stubs strip the eighth bit and subsequently
compute a wrong checksum, which causes real havoc with remote_write_bytes.
+
+ NOTE: This can still lose if the serial line is not eight-bit
+ clean. In cases like this, the user should clear "remote
+ X-packet". */
static void
check_binary_download (addr)
CORE_ADDR addr;
{
! switch (remote_protocol_binary_download.support)
{
! case PACKET_DISABLE:
! break;
! case PACKET_ENABLE:
! break;
! case PACKET_SUPPORT_UNKNOWN:
! {
! char *buf = alloca (PBUFSIZ);
! char *p;
!
! p = buf;
! *p++ = 'X';
! p += hexnumstr (p, (ULONGEST) addr);
! *p++ = ',';
! p += hexnumstr (p, (ULONGEST) 0);
! *p++ = ':';
! *p = '\0';
!
! putpkt_binary (buf, (int) (p - buf));
! getpkt (buf, 0);
! if (buf[0] == '\0')
! {
! if (remote_debug)
! fprintf_unfiltered (gdb_stdlog,
! "binary downloading NOT suppported by target\n");
! remote_protocol_binary_download.support = PACKET_DISABLE;
! }
! else
! {
! if (remote_debug)
! fprintf_unfiltered (gdb_stdlog,
! "binary downloading suppported by target\n");
! remote_protocol_binary_download.support = PACKET_ENABLE;
! }
! break;
! }
}
}
*************** remote_write_bytes (memaddr, myaddr, len
*** 3182,3196 ****
/* sprintf (buf, "M%lx,%x:", (unsigned long) memaddr, todo); */
memaddr = remote_address_masked (memaddr);
p = buf;
! if (remote_binary_download)
{
*p++ = 'X';
todo = min (len, max_buf_size);
! }
! else
! {
*p++ = 'M';
todo = min (len, max_buf_size / 2); /* num bytes that will fit */
}
p += hexnumstr (p, (ULONGEST) memaddr);
--- 3210,3227 ----
/* sprintf (buf, "M%lx,%x:", (unsigned long) memaddr, todo); */
memaddr = remote_address_masked (memaddr);
p = buf;
! switch (remote_protocol_binary_download.support)
{
+ case PACKET_ENABLE:
*p++ = 'X';
todo = min (len, max_buf_size);
! break;
! case PACKET_DISABLE:
*p++ = 'M';
todo = min (len, max_buf_size / 2); /* num bytes that will fit */
+ break;
+ case PACKET_SUPPORT_UNKNOWN:
+ fatal ("remote_write_bytes: bad switch");
}
p += hexnumstr (p, (ULONGEST) memaddr);
*************** remote_write_bytes (memaddr, myaddr, len
*** 3204,3253 ****
/* We send target system values byte by byte, in increasing byte
addresses, each byte encoded as two hex characters (or one
binary character). */
! if (remote_binary_download)
{
! int escaped = 0;
! for (i = 0;
! (i < todo) && (i + escaped) < (max_buf_size - 2);
! i++)
! {
! switch (myaddr[i] & 0xff)
! {
! case '$':
! case '#':
! case 0x7d:
! /* These must be escaped */
! escaped++;
! *p++ = 0x7d;
! *p++ = (myaddr[i] & 0xff) ^ 0x20;
! break;
! default:
! *p++ = myaddr[i] & 0xff;
! break;
! }
! }
!
! if (i < todo)
! {
! /* Escape chars have filled up the buffer prematurely,
! and we have actually sent fewer bytes than planned.
! Fix-up the length field of the packet. */
!
! /* FIXME: will fail if new len is a shorter string than
! old len. */
!
! plen += hexnumstr (plen, (ULONGEST) i);
! *plen++ = ':';
! }
! }
! else
! {
! for (i = 0; i < todo; i++)
! {
! *p++ = tohex ((myaddr[i] >> 4) & 0xf);
! *p++ = tohex (myaddr[i] & 0xf);
! }
! *p = '\0';
}
putpkt_binary (buf, (int) (p - buf));
--- 3235,3291 ----
/* We send target system values byte by byte, in increasing byte
addresses, each byte encoded as two hex characters (or one
binary character). */
! switch (remote_protocol_binary_download.support)
{
! case PACKET_ENABLE:
! {
! int escaped = 0;
! for (i = 0;
! (i < todo) && (i + escaped) < (max_buf_size - 2);
! i++)
! {
! switch (myaddr[i] & 0xff)
! {
! case '$':
! case '#':
! case 0x7d:
! /* These must be escaped */
! escaped++;
! *p++ = 0x7d;
! *p++ = (myaddr[i] & 0xff) ^ 0x20;
! break;
! default:
! *p++ = myaddr[i] & 0xff;
! break;
! }
! }
!
! if (i < todo)
! {
! /* Escape chars have filled up the buffer prematurely,
! and we have actually sent fewer bytes than planned.
! Fix-up the length field of the packet. */
!
! /* FIXME: will fail if new len is a shorter string than
! old len. */
!
! plen += hexnumstr (plen, (ULONGEST) i);
! *plen++ = ':';
! }
! break;
! }
! case PACKET_DISABLE:
! {
! for (i = 0; i < todo; i++)
! {
! *p++ = tohex ((myaddr[i] >> 4) & 0xf);
! *p++ = tohex (myaddr[i] & 0xf);
! }
! *p = '\0';
! break;
! }
! case PACKET_SUPPORT_UNKNOWN:
! fatal ("remote_write_bytes: bad switch");
}
putpkt_binary (buf, (int) (p - buf));
*************** device is attached to the remote system
*** 4629,4635 ****
/* Force remote_write_bytes to check whether target supports
binary downloading. */
! remote_binary_checked = 0;
/* Without this, some commands which require an active target (such
as kill) won't work. This variable serves (at least) double duty
--- 4667,4673 ----
/* Force remote_write_bytes to check whether target supports
binary downloading. */
! init_packet_config (&remote_protocol_binary_download);
/* Without this, some commands which require an active target (such
as kill) won't work. This variable serves (at least) double duty
*************** in a memory packet.\n",
*** 5088,5098 ****
--- 5126,5145 ----
&setlist),
&showlist);
+ add_packet_config_cmd (&remote_protocol_binary_download,
+ "X", "binary-download",
+ set_remote_protocol_binary_download_cmd,
+ show_remote_protocol_binary_download_cmd,
+ &remote_set_cmdlist, &remote_show_cmdlist);
+ #if 0
+ /* XXXX - should ``set remotebinarydownload'' be retained for
+ compatibility. */
add_show_from_set
(add_set_cmd ("remotebinarydownload", no_class,
var_boolean, (char *) &remote_binary_download,
"Set binary downloads.\n", &setlist),
&showlist);
+ #endif
add_info ("remote-process", remote_info_process,
"Query the remote system for process info.");