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)) {  remote_protocol_p.support = PACKET_ENABLE; return; } else {  remote_protocol_p.support = PACKET_DISABLE; break; } }
remote_fetch_registers (int regnum){  struct remote_state *rs = get_remote_state ();  char *buf = alloca (rs->remote_packet_size);  int i;  char *p;  char *regs = alloca (rs->sizeof_g_packet);  set_thread (PIDGET (inferior_ptid), 1);  if (regnum >= 0)    {      struct packet_reg *reg = packet_reg_from_regnum (rs, regnum);      gdb_assert (reg != NULL);      if (!reg->in_g_packet)	internal_error (__FILE__, __LINE__,			"Attempt to fetch a non G-packet register when this "			"remote.c does not support the p-packet.");    }  sprintf (buf, "g");  remote_send (buf, (rs->remote_packet_size));  /* Save the size of the packet sent to us by the target.  Its used     as a heuristic when determining the max size of packets that the     target can safely receive. */  if ((rs->actual_register_packet_size) == 0)    (rs->actual_register_packet_size) = strlen (buf);  /* Unimplemented registers read as all bits zero.  */  memset (regs, 0, rs->sizeof_g_packet);  /* We can get out of synch in various cases.  If the first character     in the buffer is not a hex character, assume that has happened     and try to fetch another packet to read.  */  while ((buf[0] < '0' || buf[0] > '9')	 && (buf[0] < 'a' || buf[0] > 'f')	 && buf[0] != 'x')	/* New: unavailable register value */    {      if (remote_debug)	fprintf_unfiltered (gdb_stdlog,			    "Bad register packet; fetching a new packet\n");      getpkt (buf, (rs->remote_packet_size), 0);    }  /* Reply describes registers byte by byte, each byte encoded as two     hex characters.  Suck them all up, then supply them to the     register cacheing/storage mechanism.  */  p = buf;  for (i = 0; i < rs->sizeof_g_packet; i++)    {      if (p[0] == 0)	break;      if (p[1] == 0)	{	  warning ("Remote reply is of odd length: %s", buf);	  /* Don't change register_bytes_found in this case, and don't	     print a second warning.  */	  goto supply_them;	}      if (p[0] == 'x' && p[1] == 'x')	regs[i] = 0;		/* 'x' */      else	regs[i] = fromhex (p[0]) * 16 + fromhex (p[1]);      p += 2;    }  if (i != register_bytes_found)    {      register_bytes_found = i;      if (REGISTER_BYTES_OK_P ()	  && !REGISTER_BYTES_OK (i))	warning ("Remote reply is too short: %s", buf);    } supply_them:  {    int i;    for (i = 0; i < NUM_REGS + NUM_PSEUDO_REGS; i++)      {	struct packet_reg *r = &rs->regs[i];	if (r->in_g_packet)	  {	    if (r->offset * 2 >= strlen (buf))	      /* A short packet that didn't include the register's                 value, this implies that the register is zero (and                 not that the register is unavailable).  Supply that                 zero value.  */	      regcache_raw_supply (current_regcache, r->regnum, NULL);	    else if (buf[r->offset * 2] == 'x')	      {		gdb_assert (r->offset * 2 < strlen (buf));		/* The register isn't available, mark it as such (at                   the same time setting the value to zero).  */		regcache_raw_supply (current_regcache, r->regnum, NULL);		set_register_cached (i, -1);	      }	    else	      regcache_raw_supply (current_regcache, r->regnum,				   regs + r->offset);	  }      }  }}