[PATCH]*3 Re: [RFC] "info powerpc"

Paul Gilliam
2005-09-15T00:11:38Z

[-- Attachment #1: Type: text/plain, Size: 1945 bytes --]

On Friday 09 September 2005 16:33, Paul Gilliam wrote:
> The "Info powerpc" command has no subcommands and does nothing.
>
> The testsuit tests "info powerpc altivec"
>
> So, should I depreciate 'info powerpc', just get rid of it, or add the 'altivec' subcommand and just point it to 'info vector'?
>
> -=# Paul #=-
>
>

Attached are three patches, each a different way to deal with this problem:

The first is 'easy_altivec.patch'. It adds the "info powerpc altivec" sub-command and has it call the same
routine as "info vector" does. The only down-side is that the routine 'vector_info' in infcmd.c has to be made global.

The second, 'altivec_alias.patch', functions like the first, except that infcmd.c is not touched. Instead, an 'info powerpc altivec' command
is added that turns itself into an alias for "info vector" the first time it's called. This can't be done with add_com_alias because the alias and
the command being aliased are on different command chains.

The final patch, 'no_more_altivec.patch' depreciates the "info powerpc" command prefix and changes the testsuite to use "info vector". To make
this work, 'lookup_cmd_composition' in cli/cli-decode.c had to be changed so that a prefix command that has no sub-commands
can be depreciated.

My personel favorite is the first one. It does the right thing while leaving "info powerpc" useable for other sub-commands. And it's simple.

My second favorite is the second one. It's like the first, except only the rs6000-tdep.c file need be changed. Well, maybe it's not so simple.

My least favorite is the third one. While it's a clean fix to the problem, it slams the door on any future 'info powerpc' sub-commands. It also
requires a fix so that prefix commands without any sub-commands can be depreciated. Of course, we could just get rid of the "info powerpc"
command without depreciating it for a while first....

Let me know what you think.

-=# Paul #=-

[-- Attachment #2: easy_altivec.patch --]
[-- Type: text/x-diff, Size: 1500 bytes --]

2005-09-14 Paul Gilliam <pgilliam@us.ibm.com>

* infcmd.c (vector_info): Make global.
* rs6000-tdep.c (_initialize_rs6000_tdep): Add the 'altivec' subcommand
of 'info powerpc', pointing it to 'info vector' to do the work.

Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.140
diff -u -a -r1.140 infcmd.c
--- infcmd.c 17 Aug 2005 15:08:33 -0000 1.140
+++ infcmd.c 14 Sep 2005 21:52:00 -0000
@@ -1768,7 +1768,7 @@
}
}

-static void
+void
vector_info (char *args, int from_tty)
{
print_vector_info (current_gdbarch, gdb_stdout, deprecated_selected_frame, args);
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.242
diff -u -a -r1.242 rs6000-tdep.c
--- rs6000-tdep.c 1 Sep 2005 18:09:41 -0000 1.242
+++ rs6000-tdep.c 14 Sep 2005 21:52:00 -0000
@@ -3409,6 +3409,7 @@
/* Initialization code. */

extern initialize_file_ftype _initialize_rs6000_tdep; /* -Wmissing-prototypes */
+extern void vector_info (char *, int);

void
_initialize_rs6000_tdep (void)
@@ -3420,4 +3421,6 @@
add_prefix_cmd ("powerpc", class_info, rs6000_info_powerpc_command,
_("Various POWERPC info specific commands."),
&info_powerpc_cmdlist, "info powerpc ", 0, &infolist);
+ add_cmd ("altivec", class_info, vector_info,_("\
+Print the status of the altivec unit.\n") , &info_powerpc_cmdlist);
}

[-- Attachment #3: no_more_altivec.patch --]
[-- Type: text/x-diff, Size: 2546 bytes --]

2005-09-14 Paul Gilliam <pgilliam@us.ibm.com>

* rs6000-tdep.c (_initialize_rs6000_tdep): Mark 'info powerpc' as
deprecated.
* cli/cli-decode.c (lookup_cmd_composition): Only loop on the new
prefix list if it is non-empty.
* testsuite/gdb.arch/altivec-regs.exp ('info powerpc altivec' test):
Changed to 'info vector'.

Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.242
diff -a -u -r1.242 rs6000-tdep.c
--- rs6000-tdep.c 1 Sep 2005 18:09:41 -0000 1.242
+++ rs6000-tdep.c 14 Sep 2005 23:27:22 -0000
@@ -3417,7 +3417,9 @@
gdbarch_register (bfd_arch_powerpc, rs6000_gdbarch_init, rs6000_dump_tdep);

/* Add root prefix command for "info powerpc" commands */
- add_prefix_cmd ("powerpc", class_info, rs6000_info_powerpc_command,
- _("Various POWERPC info specific commands."),
- &info_powerpc_cmdlist, "info powerpc ", 0, &infolist);
+ deprecate_cmd (add_prefix_cmd ("powerpc", class_info,
+ rs6000_info_powerpc_command,
+ _("Various POWERPC info specific commands."),
+ &info_powerpc_cmdlist, "info powerpc ", 0,
+ &infolist), "info vector");
}
Index: cli/cli-decode.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v
retrieving revision 1.55
diff -a -u -r1.55 cli-decode.c
--- cli/cli-decode.c 26 May 2005 20:49:02 -0000 1.55
+++ cli/cli-decode.c 14 Sep 2005 23:27:22 -0000
@@ -1468,10 +1468,10 @@
}
*prefix_cmd = prev_cmd;
}
- if ((*cmd)->prefixlist)
- cur_list = *(*cmd)->prefixlist;
+ if ((*cmd)->prefixlist && *((*cmd)->prefixlist))
+ cur_list = *(*cmd)->prefixlist;
else
- return 1;
+ return 1;

text = p;
}
Index: testsuite/gdb.arch/altivec-regs.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.arch/altivec-regs.exp,v
retrieving revision 1.6
diff -a -u -r1.6 altivec-regs.exp
--- testsuite/gdb.arch/altivec-regs.exp 13 Sep 2005 23:13:50 -0000 1.6
+++ testsuite/gdb.arch/altivec-regs.exp 14 Sep 2005 23:27:22 -0000
@@ -140,8 +140,8 @@
append pattern$i $vector_register
}

-send_gdb "info powerpc altivec\n"
-gdb_expect_list "info powerpc altivec" ".*$gdb_prompt $" {
+send_gdb "info vector\n"
+gdb_expect_list "info vector" ".*$gdb_prompt $" {
[$pattern0]
[$pattern1]
[$pattern2]

[-- Attachment #4: altivec_alias.patch --]
[-- Type: text/x-diff, Size: 2572 bytes --]

2005-09-14 Paul Gilliam <pgilliam@us.ibm.com>

* rs6000-tdep.c (_initialize_rs6000_tdep): Remember the cmd_list_element
for the 'info powerpc altivec' command.
(rs6000_info_powerpc_altivec_command): New. Replaces itself with 'info
vector'.

Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.242
diff -u -a -r1.242 rs6000-tdep.c
--- rs6000-tdep.c 1 Sep 2005 18:09:41 -0000 1.242
+++ rs6000-tdep.c 14 Sep 2005 21:29:04 -0000
@@ -59,6 +59,8 @@
#include "frame-unwind.h"
#include "frame-base.h"

+#include "cli/cli-decode.h"
+
#include "reggroups.h"

/* If the kernel has to deliver a signal, it pushes a sigcontext
@@ -3399,6 +3401,8 @@
}

static struct cmd_list_element *info_powerpc_cmdlist = NULL;
+static char inf_vec_name[] = "vector";
+static struct cmd_list_element *inf_ppc_altivec_cmd;

static void
rs6000_info_powerpc_command (char *args, int from_tty)
@@ -3406,6 +3410,32 @@
help_list (info_powerpc_cmdlist, "info powerpc ", class_info, gdb_stdout);
}

+static void
+rs6000_info_powerpc_altivec_command (char *args, int from_tty)
+{
+ char *copied_name;
+ struct cmd_list_element *inf_vec_cmd;
+ copied_name = (char *) alloca (strlen (inf_vec_name) + 1);
+ strcpy (copied_name, inf_vec_name);
+ inf_vec_cmd = lookup_cmd (&copied_name, infolist, "", 1, 1);
+
+ if (!inf_vec_cmd) {
+ help_list (info_powerpc_cmdlist, "info powerpc ", class_info, gdb_stdout);
+ return;
+ }
+
+ /* NOTE: Both FUNC and all the FUNCTIONs need to be copied. */
+ inf_ppc_altivec_cmd->func = inf_vec_cmd->func;
+ inf_ppc_altivec_cmd->function = inf_vec_cmd->function;
+ inf_ppc_altivec_cmd->prefixlist = inf_vec_cmd->prefixlist;
+ inf_ppc_altivec_cmd->prefixname = inf_vec_cmd->prefixname;
+ inf_ppc_altivec_cmd->allow_unknown = inf_vec_cmd->allow_unknown;
+ inf_ppc_altivec_cmd->abbrev_flag = 0;
+ inf_ppc_altivec_cmd->cmd_pointer = inf_vec_cmd;
+
+ (*inf_vec_cmd->func)(inf_vec_cmd, args, from_tty);
+}
+
/* Initialization code. */

extern initialize_file_ftype _initialize_rs6000_tdep; /* -Wmissing-prototypes */
@@ -3420,4 +3450,7 @@
add_prefix_cmd ("powerpc", class_info, rs6000_info_powerpc_command,
_("Various POWERPC info specific commands."),
&info_powerpc_cmdlist, "info powerpc ", 0, &infolist);
+ inf_ppc_altivec_cmd = add_cmd ("altivec", class_info,
+ rs6000_info_powerpc_altivec_command,
+ _("See 'info vector'"), &info_powerpc_cmdlist);
}