Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Robert Picco <Robert.Picco@hp.com>
To: Andrew Cagney <cagney@gnu.org>
Cc: gdb-patches@sources.redhat.com
Subject: Re: new gdb remote packet type
Date: Thu, 06 May 2004 19:41:00 -0000	[thread overview]
Message-ID: <409A95AB.6020101@hp.com> (raw)
In-Reply-To: <40993C21.1040500@gnu.org>

Andrew Cagney wrote:

>
> Anyway, it sounds like you might (dig dig) be more interested  in the 
> attached patch+hack (fernando nasser gets credit for the patch, I deny 
> responsibility for the hack bit :-).  It adds a P packet for fetching 
> individual registers which is something the existing remote protocol 
> spec doco hints at.
>
> Andrew

Seems remote.c currently supports "P" packet for storing a single 
register would you find a patch supporting the "p" packet for fetching a 
single register to be acceptable?  This would put the minimum payload on 
the wire and complement the "P" packet.   It's similar to the patch 
(hack) you forwarded but a complete implementation.

Bob

*** gdb-6.1-orig/gdb/remote.c	2004-02-25 15:41:00.000000000 -0500
--- gdb-6.1/gdb/remote.c	2004-05-06 14:05:47.000000000 -0400
***************
*** 809,814 ****
--- 809,831 ----
    show_packet_config_cmd (&remote_protocol_E);
  }
  
+ static struct packet_config remote_protocol_p;
+ 
+ static void
+ set_remote_protocol_p_packet_cmd (char *args, int from_tty,
+ 				  struct cmd_list_element *c)
+ {
+   update_packet_config (&remote_protocol_p);
+ }
+ 
+ static void
+ show_remote_protocol_p_packet_cmd (char *args, int from_tty,
+ 				   struct cmd_list_element *c)
+ {
+   show_packet_config_cmd (&remote_protocol_p);
+ }
+ 
+ 
  
  /* Should we try the 'P' (set register) request?  */
  
***************
*** 2080,2085 ****
--- 2097,2103 ----
    update_packet_config (&remote_protocol_e);
    update_packet_config (&remote_protocol_E);
    update_packet_config (&remote_protocol_P);
+   update_packet_config (&remote_protocol_p);
    update_packet_config (&remote_protocol_qSymbol);
    update_packet_config (&remote_protocol_vcont);
    for (i = 0; i < NR_Z_PACKET_TYPES; i++)
***************
*** 3240,3245 ****
--- 3258,3293 ----
  /* Read the remote registers into the block REGS.  */
  /* Currently we just read all the registers, so we don't use regnum.  */
  
+ static int
+ fetch_register_using_p (int regnum)
+ {
+   struct remote_state *rs = get_remote_state ();
+   char *buf = alloca (rs->remote_packet_size), *p;
+   char regp[MAX_REGISTER_SIZE];
+   int i;
+ 
+   buf[0] = 'p';
+   bin2hex((char *) &regnum, &buf[1], sizeof(regnum));
+   buf[9] = 0;
+   remote_send (buf, rs->remote_packet_size);
+   if (buf[0] != 0 && buf[0] != 'E') {
+      p = buf;
+      i = 0;
+      while (p[0] != 0) {
+ 	if (p[1] == 0) {
+ 		error("fetch_register_using_p: early buf termination");
+ 		return 0;
+ 	}
+ 	regp[i++] = fromhex (p[0]) * 16 + fromhex (p[1]);
+         p += 2;
+     }
+     regcache_raw_supply (current_regcache, regnum, regp);
+     return 1;
+  }
+ 
+  return 0;
+ }
+ 
  static void
  remote_fetch_registers (int regnum)
  {
***************
*** 3260,3265 ****
--- 3308,3338 ----
  			"Attempt to fetch a non G-packet register when this "
  			"remote.c does not support the p-packet.");
      }
+       switch (remote_protocol_p.support)
+ 	{
+ 	case PACKET_DISABLE:
+ 	  break;
+ 	case PACKET_ENABLE:
+ 	  if (fetch_register_using_p (regnum))
+ 	    return;
+ 	  else
+ 	    error ("Protocol error: p packet not recognized by stub");
+ 	case PACKET_SUPPORT_UNKNOWN:
+ 	  if (fetch_register_using_p (regnum))
+ 	    {
+ 	      /* The stub recognized the 'p' packet.  Remember this.  */
+ 	      remote_protocol_p.support = PACKET_ENABLE;
+ 	      return;
+ 	    }
+ 	  else
+ 	    {
+ 	      /* The stub does not support the 'P' packet.  Use 'G'
+ 	         instead, and don't try using 'P' in the future (it
+ 	         will just waste our time).  */
+ 	      remote_protocol_p.support = PACKET_DISABLE;
+ 	      break;
+ 	    }
+ 	}
  
    sprintf (buf, "g");
    remote_send (buf, (rs->remote_packet_size));
***************
*** 5419,5424 ****
--- 5492,5498 ----
    show_remote_protocol_e_packet_cmd (args, from_tty, NULL);
    show_remote_protocol_E_packet_cmd (args, from_tty, NULL);
    show_remote_protocol_P_packet_cmd (args, from_tty, NULL);
+   show_remote_protocol_p_packet_cmd (args, from_tty, NULL);
    show_remote_protocol_qSymbol_packet_cmd (args, from_tty, NULL);
    show_remote_protocol_vcont_packet_cmd (args, from_tty, NULL);
    show_remote_protocol_binary_download_cmd (args, from_tty, NULL);
***************
*** 5631,5636 ****
--- 5705,5717 ----
  			 &remote_set_cmdlist, &remote_show_cmdlist,
  			 1);
  
+   add_packet_config_cmd (&remote_protocol_p,
+ 			 "p", "fetch-register",
+ 			 set_remote_protocol_p_packet_cmd,
+ 			 show_remote_protocol_p_packet_cmd,
+ 			 &remote_set_cmdlist, &remote_show_cmdlist,
+ 			 1);
+ 
    add_packet_config_cmd (&remote_protocol_Z[Z_PACKET_SOFTWARE_BP],
  			 "Z0", "software-breakpoint",
  			 set_remote_protocol_Z_software_bp_packet_cmd,





  reply	other threads:[~2004-05-06 19:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-16  0:45 Robert Picco
2004-04-16 18:33 ` Andrew Cagney
2004-04-22 15:45   ` Robert Picco
2004-04-22 16:09     ` Andrew Cagney
2004-04-29 15:31       ` Robert Picco
2004-04-30 17:31         ` Andrew Cagney
2004-05-04 17:56           ` Robert Picco
2004-05-05 19:10             ` Andrew Cagney
2004-05-06 19:41               ` Robert Picco [this message]
2004-05-11 17:31                 ` Robert Picco
2004-05-12 18:20                 ` Andrew Cagney
2004-05-12 18:31                   ` Daniel Jacobowitz
2004-05-12 18:59                     ` Robert Picco
2004-05-12 20:55                       ` Daniel Jacobowitz
2004-05-12 22:16                         ` Robert Picco
     [not found]                     ` <40A279AF.30603@gnu.org>
2004-05-12 20:53                       ` Daniel Jacobowitz
2004-08-02 15:51                   ` Robert Picco
2004-09-24 20:07                     ` Andrew Cagney
2004-09-25 16:33                       ` Eli Zaretskii
2004-09-27 19:21                       ` Andrew Cagney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=409A95AB.6020101@hp.com \
    --to=robert.picco@hp.com \
    --cc=cagney@gnu.org \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox