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

[patch/mi] Update register-names to a list


Hello,

The attatched updates the register-names command to a list.  For that 
list to make any sense it can't contain holes.  Consequently, it also 
extends the list to include pseudo registers and invalid registers.

	Andrew

2001-06-25  Andrew Cagney  <ac131313@redhat.com>

	* mi-main.c (mi_cmd_data_list_register_names): Output a list of
	register names.
	(mi_cmd_data_list_register_names): Include the pseudo registers.
	(mi_cmd_data_list_register_names): Don't leave holes in the list,
	output "" for NULL registers.
	* gdbmi.texinfo (data-list-register-names): Update documentation.

Index: testsuite/gdb.mi/ChangeLog
2001-06-25  Andrew Cagney  <ac131313@redhat.com>

	* mi-regs.exp: Update patters matching register-names.  Now
	outputs a list.

Index: mi/gdbmi.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
retrieving revision 1.14
diff -p -r1.14 gdbmi.texinfo
*** gdbmi.texinfo	2001/06/25 18:34:24	1.14
--- gdbmi.texinfo	2001/06/25 18:53:34
*************** args=@{@},file="try.c",line="5"@}
*** 1253,1259 ****
  Show a list of register names for the current target.  If no arguments
  are given, it shows a list of the names of all the registers.  If
  integer numbers are given as arguments, it will print a list of the
! names of the registers corresponding to the arguments.
  
  @subsubheading @value{GDBN} Command
  
--- 1253,1261 ----
  Show a list of register names for the current target.  If no arguments
  are given, it shows a list of the names of all the registers.  If
  integer numbers are given as arguments, it will print a list of the
! names of the registers corresponding to the arguments.  To ensure
! consistency between a register name and its number, the output list may
! include empty register names.
  
  @subsubheading @value{GDBN} Command
  
*************** For the PPC MBX board:
*** 1267,1282 ****
  @smallexample
  (@value{GDBP})
  -data-list-register-names
! ^done,register-names=@{"r0","r1","r2","r3","r4","r5","r6","r7",
  "r8","r9","r10","r11","r12","r13","r14","r15","r16","r17","r18",
  "r19","r20","r21","r22","r23","r24","r25","r26","r27","r28","r29",
  "r30","r31","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9",
  "f10","f11","f12","f13","f14","f15","f16","f17","f18","f19","f20",
  "f21","f22","f23","f24","f25","f26","f27","f28","f29","f30","f31",
! "pc","ps","cr","lr","ctr","xer"@}
  (@value{GDBP})
  -data-list-register-names 1 2 3
! ^done,register-names=@{"r1","r2","r3"@}
  (@value{GDBP})
  @end smallexample
  
--- 1269,1284 ----
  @smallexample
  (@value{GDBP})
  -data-list-register-names
! ^done,register-names=["r0","r1","r2","r3","r4","r5","r6","r7",
  "r8","r9","r10","r11","r12","r13","r14","r15","r16","r17","r18",
  "r19","r20","r21","r22","r23","r24","r25","r26","r27","r28","r29",
  "r30","r31","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9",
  "f10","f11","f12","f13","f14","f15","f16","f17","f18","f19","f20",
  "f21","f22","f23","f24","f25","f26","f27","f28","f29","f30","f31",
! "", "pc","ps","cr","lr","ctr","xer"]
  (@value{GDBP})
  -data-list-register-names 1 2 3
! ^done,register-names=["r1","r2","r3"]
  (@value{GDBP})
  @end smallexample
  
Index: mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.16
diff -p -r1.16 mi-main.c
*** mi-main.c	2001/06/25 18:34:24	1.16
--- mi-main.c	2001/06/25 18:53:34
*************** mi_cmd_data_list_register_names (char *c
*** 271,279 ****
       case, some entries of REGISTER_NAME will change depending upon
       the particular processor being debugged.  */
  
!   numregs = NUM_REGS;
  
!   ui_out_tuple_begin (uiout, "register-names");
  
    if (argc == 0)		/* No args, just do all the regs */
      {
--- 271,279 ----
       case, some entries of REGISTER_NAME will change depending upon
       the particular processor being debugged.  */
  
!   numregs = NUM_REGS + NUM_PSEUDO_REGS;
  
!   ui_out_list_begin (uiout, "register-names");
  
    if (argc == 0)		/* No args, just do all the regs */
      {
*************** mi_cmd_data_list_register_names (char *c
*** 283,291 ****
  	{
  	  if (REGISTER_NAME (regnum) == NULL
  	      || *(REGISTER_NAME (regnum)) == '\0')
! 	    continue;
! 
! 	  ui_out_field_string (uiout, NULL, REGISTER_NAME (regnum));
  	}
      }
  
--- 283,291 ----
  	{
  	  if (REGISTER_NAME (regnum) == NULL
  	      || *(REGISTER_NAME (regnum)) == '\0')
! 	    ui_out_field_string (uiout, NULL, "");
! 	  else
! 	    ui_out_field_string (uiout, NULL, REGISTER_NAME (regnum));
  	}
      }
  
*************** mi_cmd_data_list_register_names (char *c
*** 293,311 ****
    for (i = 0; i < argc; i++)
      {
        regnum = atoi (argv[i]);
! 
!       if (regnum >= 0
! 	  && regnum < numregs
! 	  && REGISTER_NAME (regnum) != NULL
! 	  && *REGISTER_NAME (regnum) != '\000')
! 	ui_out_field_string (uiout, NULL, REGISTER_NAME (regnum));
!       else
  	{
  	  xasprintf (&mi_error_message, "bad register number");
  	  return MI_CMD_ERROR;
  	}
      }
!   ui_out_tuple_end (uiout);
    return MI_CMD_DONE;
  }
  
--- 293,310 ----
    for (i = 0; i < argc; i++)
      {
        regnum = atoi (argv[i]);
!       if (regnum < 0 || regnum >= numregs)
  	{
  	  xasprintf (&mi_error_message, "bad register number");
  	  return MI_CMD_ERROR;
  	}
+       if (REGISTER_NAME (regnum) == NULL
+ 	  || *(REGISTER_NAME (regnum)) == '\0')
+ 	ui_out_field_string (uiout, NULL, "");
+       else
+ 	ui_out_field_string (uiout, NULL, REGISTER_NAME (regnum));
      }
!   ui_out_list_end (uiout);
    return MI_CMD_DONE;
  }
  
Index: testsuite/gdb.mi/mi-regs.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-regs.exp,v
retrieving revision 1.5
diff -p -r1.5 mi-regs.exp
*** mi-regs.exp	2001/06/25 18:34:25	1.5
--- mi-regs.exp	2001/06/25 18:53:34
*************** proc sparc_register_tests { } {
*** 116,122 ****
      set float2 "\-?\[0-9\]+"
  
      mi_gdb_test "111-data-list-register-names" \
! 	    "111\\^done,register-names=\{\"g0\",\"g1\",\"g2\",\"g3\",\"g4\",\"g5\",\"g6\",\"g7\",\"o0\",\"o1\",\"o2\",\"o3\",\"o4\",\"o5\",\"sp\",\"o7\",\"l0\",\"l1\",\"l2\",\"l3\",\"l4\",\"l5\",\"l6\",\"l7\",\"i0\",\"i1\",\"i2\",\"i3\",\"i4\",\"i5\",\"fp\",\"i7\",\"f0\",\"f1\",\"f2\",\"f3\",\"f4\",\"f5\",\"f6\",\"f7\",\"f8\",\"f9\",\"f10\",\"f11\",\"f12\",\"f13\",\"f14\",\"f15\",\"f16\",\"f17\",\"f18\",\"f19\",\"f20\",\"f21\",\"f22\",\"f23\",\"f24\",\"f25\",\"f26\",\"f27\",\"f28\",\"f29\",\"f30\",\"f31\",\"y\",\"psr\",\"wim\",\"tbr\",\"pc\",\"npc\",\"fpsr\",\"cpsr\"\}" \
  	    "list register names"
  
      mi_gdb_test "222-data-list-register-values x" \
--- 116,122 ----
      set float2 "\-?\[0-9\]+"
  
      mi_gdb_test "111-data-list-register-names" \
! 	    "111\\^done,register-names=\\\[\"g0\",\"g1\",\"g2\",\"g3\",\"g4\",\"g5\",\"g6\",\"g7\",\"o0\",\"o1\",\"o2\",\"o3\",\"o4\",\"o5\",\"sp\",\"o7\",\"l0\",\"l1\",\"l2\",\"l3\",\"l4\",\"l5\",\"l6\",\"l7\",\"i0\",\"i1\",\"i2\",\"i3\",\"i4\",\"i5\",\"fp\",\"i7\",\"f0\",\"f1\",\"f2\",\"f3\",\"f4\",\"f5\",\"f6\",\"f7\",\"f8\",\"f9\",\"f10\",\"f11\",\"f12\",\"f13\",\"f14\",\"f15\",\"f16\",\"f17\",\"f18\",\"f19\",\"f20\",\"f21\",\"f22\",\"f23\",\"f24\",\"f25\",\"f26\",\"f27\",\"f28\",\"f29\",\"f30\",\"f31\",\"y\",\"psr\",\"wim\",\"tbr\",\"pc\",\"npc\",\"fpsr\",\"cpsr\"\\\]" \
  	    "list register names"
  
      mi_gdb_test "222-data-list-register-values x" \
*************** proc sparc_register_tests { } {
*** 150,156 ****
  	    "register values r"
  
      mi_gdb_test "999-data-list-register-names 68 69 70 71" \
! 	    "999\\^done,register-names=\{\"pc\",\"npc\",\"fpsr\",\"cpsr\"\}" \
  	    "list names of some regs"
  
      mi_gdb_test "001-data-list-register-values x 68 69 70 71" \
--- 150,156 ----
  	    "register values r"
  
      mi_gdb_test "999-data-list-register-names 68 69 70 71" \
! 	    "999\\^done,register-names=\\\[\"pc\",\"npc\",\"fpsr\",\"cpsr\"\\\]" \
  	    "list names of some regs"
  
      mi_gdb_test "001-data-list-register-values x 68 69 70 71" \

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