This is the mail archive of the gdb@sources.redhat.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: remote protocol extension for step out of range


>>>>> "jtc" == J T Conklin <jtc@redback.com> writes:
jtc> Step-out-of-range only commands might look like:
jtc>
jtc>         ENN,SS..SS,EE..EE[,AA...AA]
jtc> or:
jtc>         eSS...SS,EE..EE[,AA..AA]
jtc>
jtc> Which would step from the PC and repeat until it moved out of the
jtc> range described by SS..SS and EE..EE.  I've also preserved the ability
jtc> to set the initial PC like the existing step commands for parallelism;
jtc> I don't expect that GDB will use it either.
jtc>
jtc> To be able to successfully probe for this command, there should be a
jtc> return value.  An OK or EXX response should do.  Older stubs would
jtc> return "" as they do for all unrecognized commands.

It turned out to be trival to implement the above.  I've enclosed a
patch for review.  The guts are ~50 lines, including comments.  The
rest is required for the CLI so the user can enable and disable the
new packets.

I welcome any comments,

        --jtc


Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.35
diff -c -r1.35 remote.c
*** remote.c	2001/01/23 22:48:56	1.35
--- remote.c	2001/01/31 04:20:08
***************
*** 662,667 ****
--- 662,701 ----
      }
  }
  
+ /* Should we try the 'e' (step over range) request? */
+ static struct packet_config remote_protocol_e;
+ 
+ static void
+ set_remote_protocol_e_packet_cmd (char *args, int from_tty,
+ 				  struct cmd_list_element *c)
+ {
+   update_packet_config (&remote_protocol_e);
+ }
+ 
+ static void
+ show_remote_protocol_e_packet_cmd (char *args, int from_tty)
+ {
+   show_packet_config_cmd (&remote_protocol_e);
+ }
+   
+ 
+ /* Should we try the 'E' (step over range / w signal #) request? */
+ static struct packet_config remote_protocol_E;
+ 
+ static void
+ set_remote_protocol_E_packet_cmd (char *args, int from_tty,
+ 				  struct cmd_list_element *c)
+ {
+   update_packet_config (&remote_protocol_E);
+ }
+ 
+ static void
+ show_remote_protocol_E_packet_cmd (char *args, int from_tty)
+ {
+   show_packet_config_cmd (&remote_protocol_E);
+ }
+   
+ 
  /* Should we try the 'P' (set register) request?  */
  
  static struct packet_config remote_protocol_P;
***************
*** 2030,2035 ****
--- 2064,2071 ----
  init_all_packet_configs (void)
  {
    int i;
+   update_packet_config (&remote_protocol_e);
+   update_packet_config (&remote_protocol_E);
    update_packet_config (&remote_protocol_P);
    for (i = 0; i < NR_Z_PACKET_TYPES; i++)
      update_packet_config (&remote_protocol_Z[i]);
***************
*** 2293,2298 ****
--- 2329,2335 ----
  remote_resume (int pid, int step, enum target_signal siggnal)
  {
    char *buf = alloca (PBUFSIZ);
+   char *p;
  
    if (pid == -1)
      set_thread (0, 0);		/* run any thread */
***************
*** 2307,2317 ****
    if (target_resume_hook)
      (*target_resume_hook) ();
  
    if (siggnal != TARGET_SIGNAL_0)
      {
        buf[0] = step ? 'S' : 'C';
        buf[1] = tohex (((int) siggnal >> 4) & 0xf);
!       buf[2] = tohex ((int) siggnal & 0xf);
        buf[3] = '\0';
      }
    else
--- 2344,2409 ----
    if (target_resume_hook)
      (*target_resume_hook) ();
  
+ 
+   /* The s/S/c/C packets do not return status.  So if the target does
+      not support the S or C packets, the debug agent returns an empty
+      string which is detected in remote_wait().  This protocol defect
+      is fixed in the e/E packets. */
+ 
+   if (step && step_range_end)
+     {
+       /* If the target does not support the 'E' packet, we try the 'S'
+ 	 packet.  Ideally we would fall back to the 'e' packet if that
+ 	 too is not supported.  But that would require another copy of
+ 	 the code to issue the 'e' packet (and fall back to 's' if not
+ 	 supported) in remote_wait().  */
+       
+       if (siggnal != TARGET_SIGNAL_0)
+ 	{
+ 	  if (remote_protocol_E.support != PACKET_DISABLE)
+ 	    {
+ 	      p = buf;
+ 	      *p++ = 'E';
+ 	      *p++ = tohex (((int) siggnal >> 4) & 0xf);
+ 	      *p++ = tohex (((int) siggnal) & 0xf);
+ 	      *p++ = ',';
+ 	      p += hexnumstr (p, (ULONGEST) step_range_start);
+ 	      *p++ = ',';
+ 	      p += hexnumstr (p, (ULONGEST) step_range_end);
+ 	      *p++ = 0;
+ 
+ 	      putpkt (buf);
+ 	      getpkt (buf, PBUFSIZ, 0);
+ 
+ 	      if (packet_ok(buf, &remote_protocol_E) == PACKET_OK)
+ 		return;
+ 	    }
+ 	}
+       else
+ 	{
+ 	  if (remote_protocol_e.support != PACKET_DISABLE)
+ 	    {
+ 	      p = buf;
+ 	      *p++ = 'e';
+ 	      p += hexnumstr (p, (ULONGEST) step_range_start);
+ 	      *p++ = ',';
+ 	      p += hexnumstr (p, (ULONGEST) step_range_end);
+ 	      *p++ = 0;
+ 
+ 	      putpkt (buf);
+ 	      getpkt (buf, PBUFSIZ, 0);
+ 
+ 	      if (packet_ok(buf, &remote_protocol_e) == PACKET_OK)
+ 		return;
+ 	    }
+ 	}
+     }
+ 
    if (siggnal != TARGET_SIGNAL_0)
      {
        buf[0] = step ? 'S' : 'C';
        buf[1] = tohex (((int) siggnal >> 4) & 0xf);
!       buf[2] = tohex (((int) siggnal) & 0xf);
        buf[3] = '\0';
      }
    else
***************
*** 5497,5503 ****
--- 5589,5598 ----
  static void
  show_remote_cmd (char *args, int from_tty)
  {
+   
    show_remote_protocol_Z_packet_cmd (args, from_tty);
+   show_remote_protocol_e_packet_cmd (args, from_tty);
+   show_remote_protocol_E_packet_cmd (args, from_tty);
    show_remote_protocol_P_packet_cmd (args, from_tty);
    show_remote_protocol_binary_download_cmd (args, from_tty);
  }
***************
*** 5641,5646 ****
--- 5736,5755 ----
  
    add_info ("remote-process", remote_info_process,
  	    "Query the remote system for process info.");
+ 
+   add_packet_config_cmd (&remote_protocol_e,
+ 			 "e", "step-over-range",
+ 			 set_remote_protocol_e_packet_cmd,
+ 			 show_remote_protocol_e_packet_cmd,
+ 			 &remote_set_cmdlist, &remote_show_cmdlist,
+ 			 0);
+ 
+   add_packet_config_cmd (&remote_protocol_E,
+ 			 "E", "step-over-range-w-signal",
+ 			 set_remote_protocol_E_packet_cmd,
+ 			 show_remote_protocol_E_packet_cmd,
+ 			 &remote_set_cmdlist, &remote_show_cmdlist,
+ 			 0);
  
    add_packet_config_cmd (&remote_protocol_P,
  			 "P", "set-register",


-- 
J.T. Conklin
RedBack Networks

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