aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@vmware.com>2010-05-17 19:28:12 +0000
committerMichael Snyder <msnyder@vmware.com>2010-05-17 19:28:12 +0000
commitcdb27c12f30352674694895e06f615fd28ebdbec (patch)
treee06dae1fdd988cb5d4c558996118833dda427f0e /gdb
parenta109c7c1042127edfe32cbc50f315c3dc40f8607 (diff)
downloadgdb-cdb27c12f30352674694895e06f615fd28ebdbec.zip
gdb-cdb27c12f30352674694895e06f615fd28ebdbec.tar.gz
gdb-cdb27c12f30352674694895e06f615fd28ebdbec.tar.bz2
2010-05-17 Michael Snyder <msnyder@vmware.com>
* cli/cli-cmds.c: White space. * cli/cli-decode.c: White space. * cli/cli-dump.c: White space. * cli/cli-interp.c: White space. * cli/cli-logging.c: White space. * cli/cli-script.c: White space. * cli/cli-setshow.c: White space.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/cli/cli-cmds.c8
-rw-r--r--gdb/cli/cli-decode.c93
-rw-r--r--gdb/cli/cli-dump.c4
-rw-r--r--gdb/cli/cli-interp.c2
-rw-r--r--gdb/cli/cli-logging.c2
-rw-r--r--gdb/cli/cli-script.c28
-rw-r--r--gdb/cli/cli-setshow.c7
8 files changed, 103 insertions, 49 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1c1cb81..c5c3d7e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
2010-05-17 Michael Snyder <msnyder@vmware.com>
+ * cli/cli-cmds.c: White space.
+ * cli/cli-decode.c: White space.
+ * cli/cli-dump.c: White space.
+ * cli/cli-interp.c: White space.
+ * cli/cli-logging.c: White space.
+ * cli/cli-script.c: White space.
+ * cli/cli-setshow.c: White space.
+
* valarith.c: White space.
* valops.c: White space.
* valprint.c: White space.
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 6b2064b..16506d1 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -247,6 +247,7 @@ compare_strings (const void *arg1, const void *arg2)
{
const char **s1 = (const char **) arg1;
const char **s2 = (const char **) arg2;
+
return strcmp (*s1, *s2);
}
@@ -296,6 +297,7 @@ complete_command (char *arg, int from_tty)
while (item < size)
{
int next_item;
+
printf_unfiltered ("%s%s\n", arg_prefix, completions[item]);
next_item = item + 1;
while (next_item < size
@@ -427,6 +429,7 @@ cd_command (char *dir, int from_tty)
/* Search backwards for the directory just before the "/.."
and obliterate it and the "/..". */
char *q = p;
+
while (q != current_directory && !IS_DIR_SEPARATOR (q[-1]))
--q;
@@ -780,7 +783,6 @@ edit_command (char *arg, int from_tty)
}
else
{
-
/* Now should only be one argument -- decode it in SAL. */
arg1 = arg;
@@ -811,6 +813,7 @@ edit_command (char *arg, int from_tty)
if (*arg == '*')
{
struct gdbarch *gdbarch;
+
if (sal.symtab == 0)
/* FIXME-32x64--assumes sal.pc fits in long. */
error (_("No source file for address %s."),
@@ -976,6 +979,7 @@ list_command (char *arg, int from_tty)
if (*arg == '*')
{
struct gdbarch *gdbarch;
+
if (sal.symtab == 0)
/* FIXME-32x64--assumes sal.pc fits in long. */
error (_("No source file for address %s."),
@@ -1209,6 +1213,7 @@ show_user (char *args, int from_tty)
if (args)
{
char *comname = args;
+
c = lookup_cmd (&comname, cmdlist, "", 0, 1);
if (c->class != class_user)
error (_("Not a user command."));
@@ -1234,6 +1239,7 @@ apropos_command (char *searchstr, int from_tty)
regex_t pattern;
char *pattern_fastmap;
char errorbuffer[512];
+
pattern_fastmap = xcalloc (256, sizeof (char));
if (searchstr == NULL)
error (_("REGEXP string is empty"));
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 259163a..374bd19 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -149,7 +149,7 @@ add_cmd (char *name, enum command_class class, void (*fun) (char *, int),
char *doc, struct cmd_list_element **list)
{
struct cmd_list_element *c
- = (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element));
+ = (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element));
struct cmd_list_element *p, *iter;
/* Turn each alias of the old command into an alias of the new
@@ -240,6 +240,7 @@ add_alias_cmd (char *name, char *oldname, enum command_class class,
char *copied_name;
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);
@@ -250,6 +251,7 @@ add_alias_cmd (char *name, char *oldname, enum command_class class,
struct cmd_list_element *aliases = delete_cmd (name, list,
&prehook, &prehookee,
&posthook, &posthookee);
+
/* If this happens, it means a programmer error somewhere. */
gdb_assert (!aliases && !prehook && !prehookee
&& !posthook && ! posthookee);
@@ -282,6 +284,7 @@ add_prefix_cmd (char *name, enum command_class class, void (*fun) (char *, int),
struct cmd_list_element **list)
{
struct cmd_list_element *c = add_cmd (name, class, fun, doc, list);
+
c->prefixlist = prefixlist;
c->prefixname = prefixname;
c->allow_unknown = allow_unknown;
@@ -297,6 +300,7 @@ add_abbrev_prefix_cmd (char *name, enum command_class class,
int allow_unknown, struct cmd_list_element **list)
{
struct cmd_list_element *c = add_cmd (name, class, fun, doc, list);
+
c->prefixlist = prefixlist;
c->prefixname = prefixname;
c->allow_unknown = allow_unknown;
@@ -336,6 +340,7 @@ add_set_or_show_cmd (char *name,
struct cmd_list_element **list)
{
struct cmd_list_element *c = add_cmd (name, class, NULL, doc, list);
+
gdb_assert (type == set_cmd || type == show_cmd);
c->type = type;
c->var_type = var_type;
@@ -416,6 +421,7 @@ add_setshow_enum_cmd (char *name,
struct cmd_list_element **show_list)
{
struct cmd_list_element *c;
+
add_setshow_cmd_full (name, class, var_enum, var,
set_doc, show_doc, help_doc,
set_func, show_func,
@@ -441,6 +447,7 @@ add_setshow_auto_boolean_cmd (char *name,
{
static const char *auto_boolean_enums[] = { "on", "off", "auto", NULL };
struct cmd_list_element *c;
+
add_setshow_cmd_full (name, class, var_auto_boolean, var,
set_doc, show_doc, help_doc,
set_func, show_func,
@@ -464,6 +471,7 @@ add_setshow_boolean_cmd (char *name, enum command_class class, int *var,
{
static const char *boolean_enums[] = { "on", "off", NULL };
struct cmd_list_element *c;
+
add_setshow_cmd_full (name, class, var_boolean, var,
set_doc, show_doc, help_doc,
set_func, show_func,
@@ -485,6 +493,7 @@ add_setshow_filename_cmd (char *name, enum command_class class,
struct cmd_list_element **show_list)
{
struct cmd_list_element *set_result;
+
add_setshow_cmd_full (name, class, var_filename, var,
set_doc, show_doc, help_doc,
set_func, show_func,
@@ -752,10 +761,11 @@ add_com_alias (char *name, char *oldname, enum command_class class,
*/
void
apropos_cmd (struct ui_file *stream, struct cmd_list_element *commandlist,
- struct re_pattern_buffer *regex, char *prefix)
+ struct re_pattern_buffer *regex, char *prefix)
{
struct cmd_list_element *c;
int returnvalue;
+
/* Walk through the commands */
for (c=commandlist;c;c=c->next)
{
@@ -763,7 +773,8 @@ apropos_cmd (struct ui_file *stream, struct cmd_list_element *commandlist,
if (c->name != NULL)
{
/* Try to match against the name*/
- returnvalue=re_search(regex,c->name,strlen(c->name),0,strlen(c->name),NULL);
+ returnvalue = re_search (regex, c->name, strlen(c->name),
+ 0, strlen (c->name), NULL);
if (returnvalue >= 0)
{
print_help_for_command (c, prefix,
@@ -1195,6 +1206,7 @@ lookup_cmd_1 (char **text, struct cmd_list_element *clist,
for (tmp = 0; tmp < len; tmp++)
{
char x = command[tmp];
+
command[tmp] = isupper (x) ? tolower (x) : x;
}
found = find_cmd (command, len, clist, ignore_help_classes, &nfound);
@@ -1336,7 +1348,7 @@ lookup_cmd (char **line, struct cmd_list_element *list, char *cmdtype,
allow_unknown);
char *local_cmdtype = last_list ? last_list->prefixname : cmdtype;
struct cmd_list_element *local_list =
- (last_list ? *(last_list->prefixlist) : list);
+ (last_list ? *(last_list->prefixlist) : list);
if (local_allow_unknown < 0)
{
@@ -1450,22 +1462,22 @@ deprecated_cmd_warning (char **text)
printf_filtered ("' is deprecated.\n");
- /* if it is only the alias that is deprecated, we want to indicate the
- new alias, otherwise we'll indicate the new command */
+ /* If it is only the alias that is deprecated, we want to indicate the
+ new alias, otherwise we'll indicate the new command. */
if (alias && !(cmd->flags & CMD_DEPRECATED))
{
if (alias->replacement)
- printf_filtered ("Use '%s'.\n\n", alias->replacement);
+ printf_filtered ("Use '%s'.\n\n", alias->replacement);
else
- printf_filtered ("No alternative known.\n\n");
+ printf_filtered ("No alternative known.\n\n");
}
else
{
if (cmd->replacement)
- printf_filtered ("Use '%s'.\n\n", cmd->replacement);
+ printf_filtered ("Use '%s'.\n\n", cmd->replacement);
else
- printf_filtered ("No alternative known.\n\n");
+ printf_filtered ("No alternative known.\n\n");
}
/* We've warned you, now we'll keep quiet */
@@ -1501,6 +1513,7 @@ lookup_cmd_composition (char *text,
int len, tmp, nfound;
struct cmd_list_element *cur_list;
struct cmd_list_element *prev_cmd;
+
*alias = NULL;
*prefix_cmd = NULL;
*cmd = NULL;
@@ -1510,12 +1523,12 @@ lookup_cmd_composition (char *text,
while (1)
{
/* Go through as many command lists as we need to
- to find the command TEXT refers to. */
+ to find the command TEXT refers to. */
prev_cmd = *cmd;
while (*text == ' ' || *text == '\t')
- (text)++;
+ (text)++;
/* Identify the name of the command. */
len = find_command_name_length (text);
@@ -1524,8 +1537,8 @@ lookup_cmd_composition (char *text,
if (len == 0)
return 0;
- /* text is the start of the first command word to lookup (and
- it's length is len). We copy this into a local temporary */
+ /* Text is the start of the first command word to lookup (and
+ it's length is len). We copy this into a local temporary. */
command = (char *) alloca (len + 1);
memcpy (command, text, len);
@@ -1537,41 +1550,41 @@ lookup_cmd_composition (char *text,
*cmd = find_cmd (command, len, cur_list, 1, &nfound);
/* We didn't find the command in the entered case, so lower case it
- and search again.
+ and search again.
*/
if (!*cmd || nfound == 0)
- {
- for (tmp = 0; tmp < len; tmp++)
- {
- char x = command[tmp];
- command[tmp] = isupper (x) ? tolower (x) : x;
- }
- *cmd = find_cmd (command, len, cur_list, 1, &nfound);
- }
+ {
+ for (tmp = 0; tmp < len; tmp++)
+ {
+ char x = command[tmp];
+
+ command[tmp] = isupper (x) ? tolower (x) : x;
+ }
+ *cmd = find_cmd (command, len, cur_list, 1, &nfound);
+ }
if (*cmd == (struct cmd_list_element *) -1)
- {
- return 0; /* ambiguous */
- }
+ {
+ return 0; /* ambiguous */
+ }
if (*cmd == NULL)
- return 0; /* nothing found */
+ return 0; /* nothing found */
else
- {
- if ((*cmd)->cmd_pointer)
- {
- /* cmd was actually an alias, we note that an alias was used
- (by assigning *alais) and we set *cmd.
- */
- *alias = *cmd;
- *cmd = (*cmd)->cmd_pointer;
- }
- *prefix_cmd = prev_cmd;
- }
+ {
+ if ((*cmd)->cmd_pointer)
+ {
+ /* cmd was actually an alias, we note that an alias was used
+ (by assigning *alais) and we set *cmd. */
+ *alias = *cmd;
+ *cmd = (*cmd)->cmd_pointer;
+ }
+ *prefix_cmd = prev_cmd;
+ }
if ((*cmd)->prefixlist)
- cur_list = *(*cmd)->prefixlist;
+ cur_list = *(*cmd)->prefixlist;
else
- return 1;
+ return 1;
text += len;
}
diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c
index fabca56..34d805c 100644
--- a/gdb/cli/cli-dump.c
+++ b/gdb/cli/cli-dump.c
@@ -52,6 +52,7 @@ scan_expression_with_cleanup (char **cmd, const char *def)
if ((*cmd) == NULL || (**cmd) == '\0')
{
char *exp = xstrdup (def);
+
make_cleanup (xfree, exp);
return exp;
}
@@ -108,6 +109,7 @@ FILE *
fopen_with_cleanup (const char *filename, const char *mode)
{
FILE *file = fopen (filename, mode);
+
if (file == NULL)
perror_with_name (filename);
make_cleanup_fclose (file);
@@ -389,6 +391,7 @@ static void
call_dump_func (struct cmd_list_element *c, char *args, int from_tty)
{
struct dump_context *d = get_cmd_context (c);
+
d->func (args, d->mode);
}
@@ -664,6 +667,7 @@ void
_initialize_cli_dump (void)
{
struct cmd_list_element *c;
+
add_prefix_cmd ("dump", class_vars, dump_command, _("\
Dump target code/data to a local file."),
&dump_cmdlist, "dump ",
diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c
index 7ed465c..fd75c7a 100644
--- a/gdb/cli/cli-interp.c
+++ b/gdb/cli/cli-interp.c
@@ -118,6 +118,7 @@ do_captured_execute_command (struct ui_out *uiout, void *data)
{
struct captured_execute_command_args *args =
(struct captured_execute_command_args *) data;
+
execute_command (args->command, args->from_tty);
}
@@ -126,6 +127,7 @@ safe_execute_command (struct ui_out *uiout, char *command, int from_tty)
{
struct gdb_exception e;
struct captured_execute_command_args args;
+
args.command = command;
args.from_tty = from_tty;
e = catch_exception (uiout, do_captured_execute_command, &args,
diff --git a/gdb/cli/cli-logging.c b/gdb/cli/cli-logging.c
index bb58c3b..497a7a3 100644
--- a/gdb/cli/cli-logging.c
+++ b/gdb/cli/cli-logging.c
@@ -138,6 +138,7 @@ static void
set_logging_on (char *args, int from_tty)
{
char *rest = args;
+
if (rest && *rest)
{
xfree (logging_filename);
@@ -200,7 +201,6 @@ _initialize_cli_logging (void)
{
static struct cmd_list_element *set_logging_cmdlist, *show_logging_cmdlist;
-
add_prefix_cmd ("logging", class_support, set_logging_command,
_("Set logging options"), &set_logging_cmdlist,
"set logging ", 0, &setlist);
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 95dc567..9056773 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -142,7 +142,6 @@ print_command_lines (struct ui_out *uiout, struct command_line *cmd,
list = cmd;
while (list)
{
-
if (depth)
ui_out_spaces (uiout, 2 * depth);
@@ -263,6 +262,7 @@ static void
clear_hook_in_cleanup (void *data)
{
struct cmd_list_element *c = data;
+
c->hook_in = 0; /* Allow hook to work again once it is complete */
}
@@ -284,6 +284,7 @@ execute_cmd_post_hook (struct cmd_list_element *c)
if ((c->hook_post) && (!c->hook_in))
{
struct cleanup *cleanups = make_cleanup (clear_hook_in_cleanup, c);
+
c->hook_in = 1; /* Prevent recursive hooking */
execute_user_command (c->hook_post, (char *) 0);
do_cleanups (cleanups);
@@ -294,7 +295,8 @@ execute_cmd_post_hook (struct cmd_list_element *c)
static void
do_restore_user_call_depth (void * call_depth)
{
- int * depth = call_depth;
+ int *depth = call_depth;
+
(*depth)--;
if ((*depth) == 0)
in_user_command = 0;
@@ -433,6 +435,7 @@ execute_control_command (struct command_line *cmd)
case while_control:
{
char *buffer = alloca (strlen (cmd->line) + 7);
+
sprintf (buffer, "while %s", cmd->line);
print_command_trace (buffer);
@@ -500,6 +503,7 @@ execute_control_command (struct command_line *cmd)
case if_control:
{
char *buffer = alloca (strlen (cmd->line) + 4);
+
sprintf (buffer, "if %s", cmd->line);
print_command_trace (buffer);
@@ -623,6 +627,7 @@ static void
arg_cleanup (void *ignore)
{
struct user_args *oargs = user_args;
+
if (!user_args)
internal_error (__FILE__, __LINE__,
_("arg_cleanup called with no user args.\n"));
@@ -808,10 +813,10 @@ insert_args (char *line)
i = p[4] - '0';
len = user_args->a[i].len;
if (len)
- {
- memcpy (new_line, user_args->a[i].arg, len);
- new_line += len;
- }
+ {
+ memcpy (new_line, user_args->a[i].arg, len);
+ new_line += len;
+ }
}
line = p + 5;
}
@@ -950,6 +955,7 @@ process_next_line (char *p, struct command_line **command, int parse_commands,
else if (p_end - p > 5 && !strncmp (p, "while", 5))
{
char *first_arg;
+
first_arg = p + 5;
while (first_arg < p_end && isspace (*first_arg))
first_arg++;
@@ -958,6 +964,7 @@ process_next_line (char *p, struct command_line **command, int parse_commands,
else if (p_end - p > 2 && !strncmp (p, "if", 2))
{
char *first_arg;
+
first_arg = p + 2;
while (first_arg < p_end && isspace (*first_arg))
first_arg++;
@@ -966,6 +973,7 @@ process_next_line (char *p, struct command_line **command, int parse_commands,
else if (p_end - p >= 8 && !strncmp (p, "commands", 8))
{
char *first_arg;
+
first_arg = p + 8;
while (first_arg < p_end && isspace (*first_arg))
first_arg++;
@@ -1016,6 +1024,7 @@ process_next_line (char *p, struct command_line **command, int parse_commands,
if (validator)
{
volatile struct gdb_exception ex;
+
TRY_CATCH (ex, RETURN_MASK_ALL)
{
validator ((*command)->line, closure);
@@ -1430,6 +1439,7 @@ define_command (char *comname, int from_tty)
if (c)
{
int q;
+
if (c->class == class_user || c->class == class_alias)
q = query (_("Redefine command \"%s\"? "), c->name);
else
@@ -1563,7 +1573,8 @@ static void
source_cleanup_lines (void *args)
{
struct source_cleanup_lines_args *p =
- (struct source_cleanup_lines_args *) args;
+ (struct source_cleanup_lines_args *) args;
+
source_line_number = p->old_line;
source_file_name = p->old_file;
}
@@ -1577,6 +1588,7 @@ static void
wrapped_read_command_file (struct ui_out *uiout, void *data)
{
struct wrapped_read_command_file_args *args = data;
+
read_command_file (args->stream);
}
@@ -1605,6 +1617,7 @@ script_from_file (FILE *stream, const char *file)
{
struct gdb_exception e;
struct wrapped_read_command_file_args args;
+
args.stream = stream;
e = catch_exception (uiout, wrapped_read_command_file, &args,
RETURN_MASK_ERROR);
@@ -1639,6 +1652,7 @@ show_user_1 (struct cmd_list_element *c, char *prefix, char *name,
if (c->prefixlist != NULL)
{
char *prefixname = c->prefixname;
+
for (c = *c->prefixlist; c != NULL; c = c->next)
if (c->class == class_user || c->prefixlist != NULL)
show_user_1 (c, prefixname, c->name, gdb_stdout);
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index d8ec100..37f7918 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -40,6 +40,7 @@ parse_auto_binary_operation (const char *arg)
if (arg != NULL && *arg != '\0')
{
int length = strlen (arg);
+
while (isspace (arg[length - 1]) && length > 0)
length--;
if (strncmp (arg, "on", length) == 0
@@ -195,6 +196,7 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
{
/* Clear trailing whitespace of filename. */
char *ptr = arg + strlen (arg) - 1;
+
while (ptr >= arg && (*ptr == ' ' || *ptr == '\t'))
ptr--;
*(ptr + 1) = '\0';
@@ -217,6 +219,7 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
case var_integer:
{
unsigned int val;
+
if (arg == NULL)
error_no_arg (_("integer to set it to."));
val = parse_and_eval_long (arg);
@@ -251,6 +254,7 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
{
char *msg;
int msg_len = 0;
+
for (i = 0; c->enums[i]; i++)
msg_len += strlen (c->enums[i]) + 2;
@@ -385,6 +389,7 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
else
{
char *value = ui_file_xstrdup (stb->stream, NULL);
+
make_cleanup (xfree, value);
if (c->show_value_func != NULL)
c->show_value_func (gdb_stdout, from_tty, c, value);
@@ -417,6 +422,7 @@ cmd_show_list (struct cmd_list_element *list, int from_tty, char *prefix)
struct cleanup *optionlist_chain
= make_cleanup_ui_out_tuple_begin_end (uiout, "optionlist");
char *new_prefix = strstr (list->prefixname, "show ") + 5;
+
if (ui_out_is_mi_like_p (uiout))
ui_out_field_string (uiout, "prefix", new_prefix);
cmd_show_list (*list->prefixlist, from_tty, new_prefix);
@@ -427,6 +433,7 @@ cmd_show_list (struct cmd_list_element *list, int from_tty, char *prefix)
{
struct cleanup *option_chain
= make_cleanup_ui_out_tuple_begin_end (uiout, "option");
+
ui_out_text (uiout, prefix);
ui_out_field_string (uiout, "name", list->name);
ui_out_text (uiout, ": ");