diff options
Diffstat (limited to 'gdb/mi/mi-cmds.c')
-rw-r--r-- | gdb/mi/mi-cmds.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c index 81648a7..9152489 100644 --- a/gdb/mi/mi-cmds.c +++ b/gdb/mi/mi-cmds.c @@ -1,5 +1,4 @@ /* MI Command Set for GDB, the GNU debugger. - Copyright (C) 2000-2001, 2003, 2007-2012 Free Software Foundation, Inc. @@ -26,11 +25,11 @@ #include "gdb_string.h" extern void _initialize_mi_cmds (void); + struct mi_cmd; static struct mi_cmd **lookup_table (const char *command); static void build_table (struct mi_cmd *commands); - struct mi_cmd mi_cmds[] = { { "ada-task-info", { NULL, 0 }, mi_cmd_ada_task_info }, @@ -140,24 +139,25 @@ struct mi_cmd mi_cmds[] = { NULL, } }; -/* Pointer to the mi command table (built at run time) */ +/* Pointer to the mi command table (built at run time). */ static struct mi_cmd **mi_table; -/* A prime large enough to accomodate the entire command table */ +/* A prime large enough to accomodate the entire command table. */ enum { MI_TABLE_SIZE = 227 }; -/* Exported function used to obtain info from the table */ +/* Exported function used to obtain info from the table. */ struct mi_cmd * mi_lookup (const char *command) { return *lookup_table (command); } -/* stat collecting */ +/* Used for collecting hash hit/miss statistics. */ + struct mi_cmd_stats { int hit; @@ -166,20 +166,21 @@ struct mi_cmd_stats }; struct mi_cmd_stats stats; -/* our lookup function */ +/* Look up a command. */ + static struct mi_cmd ** lookup_table (const char *command) { const char *chp; unsigned int index = 0; - /* compute our hash */ + /* Compute our hash. */ for (chp = command; *chp; chp++) { - /* some what arbitrary */ + /* We use a somewhat arbitrary formula. */ index = ((index << 6) + (unsigned int) *chp) % MI_TABLE_SIZE; } - /* look it up */ + while (1) { struct mi_cmd **entry = &mi_table[index]; @@ -218,6 +219,7 @@ build_table (struct mi_cmd *commands) _("command `%s' appears to be duplicated"), command->name); *entry = command; + /* FIXME lose these prints */ if (0) { fprintf_unfiltered (gdb_stdlog, "%-30s %2d\n", |