diff options
author | Elena Zannoni <ezannoni@kwikemart.cygnus.com> | 2004-03-23 20:41:49 +0000 |
---|---|---|
committer | Elena Zannoni <ezannoni@kwikemart.cygnus.com> | 2004-03-23 20:41:49 +0000 |
commit | 00687ffd41edb1fe6a9a95e2829028cb76fe876c (patch) | |
tree | 4c52196ee5d91da73744d9260bc180ae3ef36ee7 | |
parent | c91b2753f60a854d8f3517630465e7fc4d4490a9 (diff) | |
download | fsf-binutils-gdb-ezannoni_pie-20030916-branch.zip fsf-binutils-gdb-ezannoni_pie-20030916-branch.tar.gz fsf-binutils-gdb-ezannoni_pie-20030916-branch.tar.bz2 |
merge mainline changes into branchezannoni_pie-20030916-branch
-rw-r--r-- | gdb/cli/cli-cmds.c | 73 | ||||
-rw-r--r-- | gdb/cli/cli-decode.c | 26 | ||||
-rw-r--r-- | gdb/cli/cli-dump.c | 32 | ||||
-rw-r--r-- | gdb/cli/cli-script.c | 49 | ||||
-rw-r--r-- | gdb/cli/cli-script.h | 2 | ||||
-rw-r--r-- | gdb/cli/cli-setshow.c | 2 |
6 files changed, 85 insertions, 99 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 45794f7..9378ac8 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -1,6 +1,6 @@ /* GDB CLI commands. - Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of GDB. @@ -20,7 +20,8 @@ Boston, MA 02111-1307, USA. */ #include "defs.h" -#include <readline/tilde.h> +#include "readline/readline.h" +#include "readline/tilde.h" #include "completer.h" #include "target.h" /* For baud_rate, remote_debug and remote_timeout */ #include "gdb_wait.h" /* For shell escape implementation */ @@ -45,6 +46,10 @@ #include "cli/cli-setshow.h" #include "cli/cli-cmds.h" +#ifdef TUI +#include "tui/tui.h" /* For tui_active et.al. */ +#endif + #ifndef GDBINIT_FILENAME #define GDBINIT_FILENAME ".gdbinit" #endif @@ -59,8 +64,6 @@ static void pwd_command (char *, int); static void show_version (char *, int); -static void validate_comname (char *); - static void help_command (char *, int); static void show_command (char *, int); @@ -184,7 +187,6 @@ error_no_arg (char *why) /* The "info" command is defined as a prefix, with allow_unknown = 0. Therefore, its own definition is called only for "info" with no args. */ -/* ARGSUSED */ static void info_command (char *arg, int from_tty) { @@ -194,7 +196,6 @@ info_command (char *arg, int from_tty) /* The "show" command with no arguments shows all the settings. */ -/* ARGSUSED */ static void show_command (char *arg, int from_tty) { @@ -204,7 +205,6 @@ show_command (char *arg, int from_tty) /* Provide documentation on command or list given by COMMAND. FROM_TTY is ignored. */ -/* ARGSUSED */ static void help_command (char *command, int from_tty) { @@ -222,13 +222,12 @@ compare_strings (const void *arg1, const void *arg2) /* The "complete" command is used by Emacs to implement completion. */ -/* ARGSUSED */ static void complete_command (char *arg, int from_tty) { int i; int argpoint; - char **completions; + char **completions, *point, *arg_prefix; dont_repeat (); @@ -236,7 +235,23 @@ complete_command (char *arg, int from_tty) arg = ""; argpoint = strlen (arg); - completions = complete_line (arg, arg, argpoint); + /* complete_line assumes that its first argument is somewhere within, + and except for filenames at the beginning of, the word to be completed. + The following crude imitation of readline's word-breaking tries to + accomodate this. */ + point = arg + argpoint; + while (point > arg) + { + if (strchr (rl_completer_word_break_characters, point[-1]) != 0) + break; + point--; + } + + arg_prefix = alloca (point - arg + 1); + memcpy (arg_prefix, arg, point - arg); + arg_prefix[point - arg] = 0; + + completions = complete_line (point, arg, argpoint); if (completions) { @@ -252,7 +267,7 @@ complete_command (char *arg, int from_tty) while (item < size) { int next_item; - printf_unfiltered ("%s\n", completions[item]); + printf_unfiltered ("%s%s\n", arg_prefix, completions[item]); next_item = item + 1; while (next_item < size && ! strcmp (completions[item], completions[next_item])) @@ -275,7 +290,6 @@ is_complete_command (struct cmd_list_element *c) return cmd_cfunc_eq (c, complete_command); } -/* ARGSUSED */ static void show_version (char *args, int from_tty) { @@ -295,7 +309,6 @@ quit_command (char *args, int from_tty) quit_force (args, from_tty); } -/* ARGSUSED */ static void pwd_command (char *args, int from_tty) { @@ -303,7 +316,7 @@ pwd_command (char *args, int from_tty) error ("The \"pwd\" command does not take an argument: %s", args); getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)); - if (!STREQ (gdb_dirbuf, current_directory)) + if (strcmp (gdb_dirbuf, current_directory) != 0) printf_unfiltered ("Working directory %s\n (canonically %s).\n", current_directory, gdb_dirbuf); else @@ -439,12 +452,11 @@ source_command (char *args, int from_tty) do_cleanups (old_cleanups); } -/* ARGSUSED */ static void echo_command (char *text, int from_tty) { char *p = text; - register int c; + int c; if (text) while ((c = *p++) != '\0') @@ -469,7 +481,6 @@ echo_command (char *text, int from_tty) gdb_flush (gdb_stdout); } -/* ARGSUSED */ static void shell_escape (char *arg, int from_tty) { @@ -514,9 +525,9 @@ shell_escape (char *arg, int from_tty) p++; /* Get past '/' */ if (!arg) - execl (user_shell, p, 0); + execl (user_shell, p, (char *) 0); else - execl (user_shell, p, "-c", arg, 0); + execl (user_shell, p, "-c", arg, (char *) 0); fprintf_unfiltered (gdb_stderr, "Cannot execute %s: %s\n", user_shell, safe_strerror (errno)); @@ -565,7 +576,7 @@ edit_command (char *arg, int from_tty) /* Now should only be one argument -- decode it in SAL */ arg1 = arg; - sals = decode_line_1 (&arg1, 0, 0, 0, 0); + sals = decode_line_1 (&arg1, 0, 0, 0, 0, 0); if (! sals.nelts) return; /* C++ */ if (sals.nelts > 1) { @@ -659,7 +670,7 @@ list_command (char *arg, int from_tty) /* "l" or "l +" lists next ten lines. */ - if (arg == 0 || STREQ (arg, "+")) + if (arg == 0 || strcmp (arg, "+") == 0) { print_source_lines (cursal.symtab, cursal.line, cursal.line + get_lines_to_list (), 0); @@ -667,7 +678,7 @@ list_command (char *arg, int from_tty) } /* "l -" lists previous ten lines, the ones before the ten just listed. */ - if (STREQ (arg, "-")) + if (strcmp (arg, "-") == 0) { print_source_lines (cursal.symtab, max (get_first_line_listed () - get_lines_to_list (), 1), @@ -689,7 +700,7 @@ list_command (char *arg, int from_tty) dummy_beg = 1; else { - sals = decode_line_1 (&arg1, 0, 0, 0, 0); + sals = decode_line_1 (&arg1, 0, 0, 0, 0, 0); if (!sals.nelts) return; /* C++ */ @@ -722,9 +733,9 @@ list_command (char *arg, int from_tty) else { if (dummy_beg) - sals_end = decode_line_1 (&arg1, 0, 0, 0, 0); + sals_end = decode_line_1 (&arg1, 0, 0, 0, 0, 0); else - sals_end = decode_line_1 (&arg1, 0, sal.symtab, sal.line, 0); + sals_end = decode_line_1 (&arg1, 0, sal.symtab, sal.line, 0, 0); if (sals_end.nelts == 0) return; if (sals_end.nelts > 1) @@ -820,7 +831,6 @@ list_command (char *arg, int from_tty) Two arguments are interpeted as bounds within which to dump assembly. */ -/* ARGSUSED */ static void disassemble_command (char *arg, int from_tty) { @@ -844,8 +854,9 @@ disassemble_command (char *arg, int from_tty) #if defined(TUI) /* NOTE: cagney/2003-02-13 The `tui_active' was previously `tui_version'. */ - else if (tui_active) - low = tuiGetLowDisassemblyAddress (low, pc); + if (tui_active) + /* FIXME: cagney/2004-02-07: This should be an observer. */ + low = tui_get_low_disassembly_address (low, pc); #endif low += FUNCTION_START_OFFSET; } @@ -858,8 +869,9 @@ disassemble_command (char *arg, int from_tty) #if defined(TUI) /* NOTE: cagney/2003-02-13 The `tui_active' was previously `tui_version'. */ - else if (tui_active) - low = tuiGetLowDisassemblyAddress (low, pc); + if (tui_active) + /* FIXME: cagney/2004-02-07: This should be an observer. */ + low = tui_get_low_disassembly_address (low, pc); #endif low += FUNCTION_START_OFFSET; } @@ -920,7 +932,6 @@ make_command (char *arg, int from_tty) shell_escape (p, from_tty); } -/* ARGSUSED */ static void show_user (char *args, int from_tty) { diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 8a0d057..43f2f25 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -29,6 +29,10 @@ #include "cli/cli-cmds.h" #include "cli/cli-decode.h" +#ifdef TUI +#include "tui/tui.h" /* For tui_active et.al. */ +#endif + #include "gdb_assert.h" /* Prototypes for local functions */ @@ -133,7 +137,7 @@ struct cmd_list_element * add_cmd (char *name, enum command_class class, void (*fun) (char *, int), char *doc, struct cmd_list_element **list) { - register struct cmd_list_element *c + struct cmd_list_element *c = (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element)); struct cmd_list_element *p; @@ -212,8 +216,8 @@ add_alias_cmd (char *name, char *oldname, enum command_class class, { /* Must do this since lookup_cmd tries to side-effect its first arg */ char *copied_name; - register struct cmd_list_element *old; - register struct cmd_list_element *c; + struct cmd_list_element *old; + struct cmd_list_element *c; copied_name = (char *) alloca (strlen (oldname) + 1); strcpy (copied_name, oldname); old = lookup_cmd (&copied_name, *list, "", 1, 1); @@ -247,7 +251,7 @@ add_prefix_cmd (char *name, enum command_class class, void (*fun) (char *, int), char *prefixname, int allow_unknown, struct cmd_list_element **list) { - register struct cmd_list_element *c = add_cmd (name, class, fun, doc, list); + struct cmd_list_element *c = add_cmd (name, class, fun, doc, list); c->prefixlist = prefixlist; c->prefixname = prefixname; c->allow_unknown = allow_unknown; @@ -262,7 +266,7 @@ add_abbrev_prefix_cmd (char *name, enum command_class class, struct cmd_list_element **prefixlist, char *prefixname, int allow_unknown, struct cmd_list_element **list) { - register struct cmd_list_element *c = add_cmd (name, class, fun, doc, list); + struct cmd_list_element *c = add_cmd (name, class, fun, doc, list); c->prefixlist = prefixlist; c->prefixname = prefixname; c->allow_unknown = allow_unknown; @@ -500,10 +504,10 @@ add_show_from_set (struct cmd_list_element *setcmd, void delete_cmd (char *name, struct cmd_list_element **list) { - register struct cmd_list_element *c; + struct cmd_list_element *c; struct cmd_list_element *p; - while (*list && STREQ ((*list)->name, name)) + while (*list && strcmp ((*list)->name, name) == 0) { if ((*list)->hookee_pre) (*list)->hookee_pre->hook_pre = 0; /* Hook slips out of its mouth */ @@ -517,7 +521,7 @@ delete_cmd (char *name, struct cmd_list_element **list) if (*list) for (c = *list; c->next;) { - if (STREQ (c->next->name, name)) + if (strcmp (c->next->name, name) == 0) { if (c->next->hookee_pre) c->next->hookee_pre->hook_pre = 0; /* hooked cmd gets away. */ @@ -577,7 +581,7 @@ void apropos_cmd (struct ui_file *stream, struct cmd_list_element *commandlist, struct re_pattern_buffer *regex, char *prefix) { - register struct cmd_list_element *c; + struct cmd_list_element *c; int returnvalue=1; /*Needed to avoid double printing*/ /* Walk through the commands */ for (c=commandlist;c;c=c->next) @@ -786,7 +790,7 @@ print_doc_line (struct ui_file *stream, char *str) { static char *line_buffer = 0; static int line_size; - register char *p; + char *p; if (!line_buffer) { @@ -830,7 +834,7 @@ void help_cmd_list (struct cmd_list_element *list, enum command_class class, char *prefix, int recurse, struct ui_file *stream) { - register struct cmd_list_element *c; + struct cmd_list_element *c; for (c = list; c; c = c->next) { diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c index 7b88975..ac54aa6 100644 --- a/gdb/cli/cli-dump.c +++ b/gdb/cli/cli-dump.c @@ -31,7 +31,7 @@ #include "gdb_assert.h" #include <ctype.h> #include "target.h" -#include <readline/readline.h> +#include "readline/readline.h" #define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE))) @@ -331,36 +331,6 @@ dump_value_command (char *cmd, char *mode) } static void -dump_filetype (char *cmd, char *mode, char *filetype) -{ - char *suffix = cmd; - - if (cmd == NULL || *cmd == '\0') - error ("Missing subcommand: try 'help %s %s'.", - mode[0] == 'a' ? "append" : "dump", - filetype); - - suffix += strcspn (cmd, " \t"); - - if (suffix != cmd) - { - if (strncmp ("memory", cmd, suffix - cmd) == 0) - { - dump_memory_to_file (suffix, mode, filetype); - return; - } - else if (strncmp ("value", cmd, suffix - cmd) == 0) - { - dump_value_to_file (suffix, mode, filetype); - return; - } - } - - error ("dump %s: unknown subcommand '%s' -- try 'value' or 'memory'.", - filetype, cmd); -} - -static void dump_srec_memory (char *args, int from_tty) { dump_memory_to_file (args, FOPEN_WB, "srec"); diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index ab69ca4..ca0c14f 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -36,9 +36,6 @@ /* Prototypes for local functions */ -static struct cleanup * - make_cleanup_free_command_lines (struct command_line **arg); - static enum command_control_type recurse_read_control_structure (struct command_line *current_cmd); @@ -255,7 +252,7 @@ do_restore_user_call_depth (void * call_depth) void execute_user_command (struct cmd_list_element *c, char *args) { - register struct command_line *cmdlines; + struct command_line *cmdlines; struct cleanup *old_chain; enum command_control_type ret; static int user_call_depth = 0; @@ -297,21 +294,25 @@ execute_control_command (struct command_line *cmd) { struct expression *expr; struct command_line *current; - struct cleanup *old_chain = 0; + struct cleanup *old_chain = make_cleanup (null_cleanup, 0); struct value *val; struct value *val_mark; int loop; enum command_control_type ret; char *new_line; + /* Start by assuming failure, if a problem is detected, the code + below will simply "break" out of the switch. */ + ret = invalid_control; + switch (cmd->control_type) { case simple_control: /* A simple command, execute it and return. */ new_line = insert_args (cmd->line); if (!new_line) - return invalid_control; - old_chain = make_cleanup (free_current_contents, &new_line); + break; + make_cleanup (free_current_contents, &new_line); execute_command (new_line, 0); ret = cmd->control_type; break; @@ -328,8 +329,8 @@ execute_control_command (struct command_line *cmd) /* Parse the loop control expression for the while statement. */ new_line = insert_args (cmd->line); if (!new_line) - return invalid_control; - old_chain = make_cleanup (free_current_contents, &new_line); + break; + make_cleanup (free_current_contents, &new_line); expr = parse_expression (new_line); make_cleanup (free_current_contents, &expr); @@ -388,8 +389,8 @@ execute_control_command (struct command_line *cmd) { new_line = insert_args (cmd->line); if (!new_line) - return invalid_control; - old_chain = make_cleanup (free_current_contents, &new_line); + break; + make_cleanup (free_current_contents, &new_line); /* Parse the conditional for the if statement. */ expr = parse_expression (new_line); make_cleanup (free_current_contents, &expr); @@ -427,11 +428,10 @@ execute_control_command (struct command_line *cmd) default: warning ("Invalid control type in command structure."); - return invalid_control; + break; } - if (old_chain) - do_cleanups (old_chain); + do_cleanups (old_chain); return ret; } @@ -974,8 +974,8 @@ read_command_lines (char *prompt_arg, int from_tty) void free_command_lines (struct command_line **lptr) { - register struct command_line *l = *lptr; - register struct command_line *next; + struct command_line *l = *lptr; + struct command_line *next; struct command_line **blist; int i; @@ -1001,7 +1001,7 @@ do_free_command_lines_cleanup (void *arg) free_command_lines (arg); } -static struct cleanup * +struct cleanup * make_cleanup_free_command_lines (struct command_line **arg) { return make_cleanup (do_free_command_lines_cleanup, arg); @@ -1040,7 +1040,7 @@ copy_command_lines (struct command_line *cmds) static void validate_comname (char *comname) { - register char *p; + char *p; if (comname == 0) error_no_arg ("name of command to define"); @@ -1070,8 +1070,8 @@ define_command (char *comname, int from_tty) CMD_PRE_HOOK, CMD_POST_HOOK }; - register struct command_line *cmds; - register struct cmd_list_element *c, *newc, *oldc, *hookc = 0; + struct command_line *cmds; + struct cmd_list_element *c, *newc, *oldc, *hookc = 0; char *tem = comname; char *tem2; char tmpbuf[MAX_TMPBUF]; @@ -1176,7 +1176,7 @@ void document_command (char *comname, int from_tty) { struct command_line *doclines; - register struct cmd_list_element *c; + struct cmd_list_element *c; char *tem = comname; char tmpbuf[128]; @@ -1194,8 +1194,8 @@ document_command (char *comname, int from_tty) xfree (c->doc); { - register struct command_line *cl1; - register int len = 0; + struct command_line *cl1; + int len = 0; for (cl1 = doclines; cl1; cl1 = cl1->next) len += strlen (cl1->line) + 1; @@ -1233,7 +1233,6 @@ source_cleanup_lines (void *args) error_pre_print = p->old_error_pre_print; } -/* ARGSUSED */ static void do_fclose_cleanup (void *stream) { @@ -1290,7 +1289,7 @@ script_from_file (FILE *stream, char *file) void show_user_1 (struct cmd_list_element *c, struct ui_file *stream) { - register struct command_line *cmdlines; + struct command_line *cmdlines; cmdlines = c->user_commands; if (!cmdlines) diff --git a/gdb/cli/cli-script.h b/gdb/cli/cli-script.h index 03cb841..fc5c203 100644 --- a/gdb/cli/cli-script.h +++ b/gdb/cli/cli-script.h @@ -47,6 +47,8 @@ extern void print_command_lines (struct ui_out *, extern struct command_line * copy_command_lines (struct command_line *cmds); +struct cleanup *make_cleanup_free_command_lines (struct command_line **arg); + /* Exported to gdb/infrun.c */ extern void execute_user_command (struct cmd_list_element *c, char *args); diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index 64a0d73..62fe36f 100644 --- a/gdb/cli/cli-setshow.c +++ b/gdb/cli/cli-setshow.c @@ -18,7 +18,7 @@ Boston, MA 02111-1307, USA. */ #include "defs.h" -#include <readline/tilde.h> +#include "readline/tilde.h" #include "value.h" #include <ctype.h> #include "gdb_string.h" |