Simple Image Access Language
An embedded C interpreter [C syntax with a few twists].
Start with Dave's page, there are a couple of URLs to more info from
there.
http://people.redhat.com/anderson/extensions.html
-Luc
-----Original Message-----
From: crash-utility-bounces(a)redhat.com
[mailto:crash-utility-bounces@redhat.com] On Behalf Of Jun Koi
Sent: Monday, September 15, 2008 1:35 AM
To: Discussion list for crash utility usage,maintenance and development
Subject: Re: [Crash-utility] [PATCH] help screen indication of
extensioncommands
Hi,
Sorry but could you explain a bit about that "SIAL" feature? Where can
I have some information on the "SIAL"?
Thanks,
Jun
On Sun, Sep 14, 2008 at 3:11 PM, Cliff Wickman <cpw(a)sgi.com> wrote:
From: Cliff Wickman <cpw(a)sgi.com>
It would be nice if the help screen differentiated between built-in
commands and extension commands.
Particularly in the case of sial extensions, as you can edit them
in your crash session. If you know that the command is sial you
can fix or enhance it if necessary.
This patch implements that by changing the pc->cmdlist from a list
of name pointers to a list of struct command_table_entry pointers.
Then the help screen can highlight those containing a new flag:
if (cp->flags & EXTENSION)
Diffed against crash-4.0-4.7
Signed-off-by: Cliff Wickman <cpw(a)sgi.com>
---
defs.h | 4 ++-
help.c | 66
++++++++++++++++++++++++++++++++++++++++-------------------------
2 files changed, 44 insertions(+), 26 deletions(-)
Index: crash-4.0-4.7/help.c
===================================================================
--- crash-4.0-4.7.orig/help.c
+++ crash-4.0-4.7/help.c
@@ -154,19 +154,23 @@ help_init(void)
for (cp = ext->command_table; cp->name; cp++) {
if (!(cp->flags & (CLEANUP|HIDDEN_COMMAND)))
pc->ncmds++;
+ cp->flags |= EXTENSION;
}
}
if (!pc->cmdlist) {
pc->cmdlistsz = pc->ncmds;
- if ((pc->cmdlist = (char **)
- malloc(sizeof(char *) * pc->cmdlistsz)) ==
NULL)
+ if ((pc->cmdlist = (struct command_table_entry
**)
+ malloc(sizeof(struct command_table_entry *) *
+ pc->cmdlistsz)) == NULL)
error(FATAL,
"cannot malloc command list
space\n");
} else if (pc->ncmds > pc->cmdlistsz) {
pc->cmdlistsz = pc->ncmds;
- if ((pc->cmdlist = (char **)realloc(pc->cmdlist,
- sizeof(char *) * pc->cmdlistsz)) == NULL)
+ if ((pc->cmdlist = (struct command_table_entry **)
+ realloc(pc->cmdlist,
+ sizeof(struct command_table_entry *) *
+ pc->cmdlistsz)) == NULL)
error(FATAL,
"cannot realloc command list
space\n");
}
@@ -190,13 +194,13 @@ reshuffle_cmdlist(void)
for (cnt = 0, cp = pc->cmd_table; cp->name; cp++) {
if (!(cp->flags & HIDDEN_COMMAND))
- pc->cmdlist[cnt++] = cp->name;
+ pc->cmdlist[cnt++] = cp;
}
for (ext = extension_table; ext; ext = ext->next) {
for (cp = ext->command_table; cp->name; cp++) {
if (!(cp->flags & (CLEANUP|HIDDEN_COMMAND)))
- pc->cmdlist[cnt++] = cp->name;
+ pc->cmdlist[cnt++] = cp;
}
}
@@ -212,19 +216,21 @@ reshuffle_cmdlist(void)
* The help list is in alphabetical order, with exception of the "q"
command,
* which has historically always been the last command in the list.
*/
-
+/*
+ * the pointers are pointers to struct command_table_entry
+ */
static int
-sort_command_name(const void *name1, const void *name2)
+sort_command_name(const void *struct1, const void *struct2)
{
- char **s1, **s2;
+ char *s1, *s2;
- s1 = (char **)name1;
- s2 = (char **)name2;
+ s1 = (*(struct command_table_entry **)struct1)->name;
+ s2 = (*(struct command_table_entry **)struct2)->name;
- if (STREQ(*s1, "q"))
+ if (STREQ(s1, "q"))
return 1;
- return strcmp(*s1, *s2);
+ return strcmp(s1, s2);
}
@@ -408,8 +414,9 @@ cmd_help(void)
void
display_help_screen(char *indent)
{
- int i, j, rows;
+ int i, j, rows, ext_count=0;
char **namep;
+ struct command_table_entry **cpp, *cp;
help_init();
@@ -418,15 +425,23 @@ display_help_screen(char *indent)
rows = (pc->ncmds + (HELP_COLUMNS-1)) / HELP_COLUMNS;
for (i = 0; i < rows; i++) {
- namep = &pc->cmdlist[i];
+ cpp = &(pc->cmdlist[i]);
for (j = 0; j < HELP_COLUMNS; j++) {
- fprintf(fp,"%-15s", *namep);
- namep += rows;
- if ((namep - pc->cmdlist) >= pc->ncmds)
+ cp = *cpp;
+ if (cp->flags & EXTENSION) {
+ fprintf(fp,"+%-15s", cp->name);
+ ext_count++;
+ } else {
+ fprintf(fp," %-15s", cp->name);
+ }
+ cpp += rows;
+ if ((cpp - pc->cmdlist) >= pc->ncmds)
break;
}
fprintf(fp,"\n%s", indent);
}
+ if (ext_count)
+ fprintf(fp,"+ denotes an extension command\n%s",
indent);
fprintf(fp, "\n%s%s version: %-6s gdb version: %s\n",
indent,
pc->program_name, pc->program_version,
pc->gdb_version);
@@ -454,17 +469,16 @@ static void
display_commands(void)
{
int i, j, rows;
- char **namep;
+ struct command_table_entry **cp;
help_init();
rows = (pc->ncmds + (HELP_COLUMNS-1)) / HELP_COLUMNS;
for (i = 0; i < rows; i++) {
- namep = &pc->cmdlist[i];
+ cp = &pc->cmdlist[i];
for (j = 0; j < HELP_COLUMNS; j++) {
- fprintf(fp,"%s\n", *namep);
- namep += rows;
- if ((namep - pc->cmdlist) >= pc->ncmds) {
+ cp += rows;
+ if ((cp - pc->cmdlist) >= pc->ncmds) {
fprintf(fp, "BREAK\n");
break;
}
@@ -4957,8 +4971,10 @@ cmd_usage(char *cmd, int helpflag)
display_input_info();
display_output_info();
help_init();
- for (i = 0; i < pc->ncmds; i++)
- cmd_usage(pc->cmdlist[i], COMPLETE_HELP);
+ for (i = 0; i < pc->ncmds; i++) {
+ cp = *(&(pc->cmdlist[i]));
+ cmd_usage(cp->name, COMPLETE_HELP);
+ }
display_warranty_info();
display_copying_info();
goto done_usage;
Index: crash-4.0-4.7/defs.h
===================================================================
--- crash-4.0-4.7.orig/defs.h
+++ crash-4.0-4.7/defs.h
@@ -383,7 +383,8 @@ struct program_context {
struct termios termios_orig; /* non-raw settings */
struct termios termios_raw; /* while gathering command
input */
int ncmds; /* number of commands in menu
*/
- char **cmdlist; /* current list of available
commands */
+ struct command_table_entry **cmdlist;
+ /* current list of available
commands */
int cmdlistsz; /* space available in cmdlist
*/
unsigned output_radix; /* current gdb output_radix
*/
void *sbrk; /* current sbrk value */
@@ -409,6 +410,7 @@ struct command_table_entry {
#define REFRESH_TASK_TABLE (0x1) /* command_table_entry
flags */
#define HIDDEN_COMMAND (0x2)
#define CLEANUP (0x4) /* for extensions only */
+#define EXTENSION (0x8) /* is an extension */
/*
* A linked list of extension table structures keeps track of the
current
--
Crash-utility mailing list
Crash-utility(a)redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
--
Crash-utility mailing list
Crash-utility(a)redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility