summaryrefslogtreecommitdiff
path: root/gdb/symfile.c
diff options
context:
space:
mode:
authormbilal <mbilal>2013-09-04 06:17:07 +0000
committermbilal <mbilal>2013-09-04 06:17:07 +0000
commit9706cb14337d2ecdc46262697ecd4984378304f9 (patch)
tree00ba35fad9a84cfc17e08b513afdc8a982b8d9e0 /gdb/symfile.c
parent7191955124335b76696ac93c8beee66b9d7b8e7e (diff)
downloadgdb-9706cb14337d2ecdc46262697ecd4984378304f9.tar.gz
2013-09-04 Muhammad Bilal <mbilal@codesourcery.com>
Pedro Alves <palves@redhat.com> * symfile.c (add_symbol_file_command): Error out on unknown option. Handle EXPECTING_SEC_ADDR/EXPECTING_SEC_NAME before '-' options and collapse into single conditional branch. 2013-09-13 Muhammad Bilal <mbilal@codesourcery.com> Pedro Alves <palves@redhat.com> * gdb.base/relocate.exp: Check that invalid options are rejected.
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r--gdb/symfile.c104
1 files changed, 48 insertions, 56 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c
index b95721eae48..67206cdf239 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2214,63 +2214,55 @@ add_symbol_file_command (char *args, int from_tty)
filename = tilde_expand (arg);
make_cleanup (xfree, filename);
}
+ else if (argcnt == 1)
+ {
+ /* The second argument is always the text address at which
+ to load the program. */
+ sect_opts[section_index].name = ".text";
+ sect_opts[section_index].value = arg;
+ if (++section_index >= num_sect_opts)
+ {
+ num_sect_opts *= 2;
+ sect_opts = ((struct sect_opt *)
+ xrealloc (sect_opts,
+ num_sect_opts
+ * sizeof (struct sect_opt)));
+ }
+ }
else
- if (argcnt == 1)
- {
- /* The second argument is always the text address at which
- to load the program. */
- sect_opts[section_index].name = ".text";
- sect_opts[section_index].value = arg;
- if (++section_index >= num_sect_opts)
- {
- num_sect_opts *= 2;
- sect_opts = ((struct sect_opt *)
- xrealloc (sect_opts,
- num_sect_opts
- * sizeof (struct sect_opt)));
- }
- }
- else
- {
- /* It's an option (starting with '-') or it's an argument
- to an option. */
-
- if (*arg == '-')
- {
- if (strcmp (arg, "-readnow") == 0)
- flags |= OBJF_READNOW;
- else if (strcmp (arg, "-s") == 0)
- {
- expecting_sec_name = 1;
- expecting_sec_addr = 1;
- }
- }
- else
- {
- if (expecting_sec_name)
- {
- sect_opts[section_index].name = arg;
- expecting_sec_name = 0;
- }
- else
- if (expecting_sec_addr)
- {
- sect_opts[section_index].value = arg;
- expecting_sec_addr = 0;
- if (++section_index >= num_sect_opts)
- {
- num_sect_opts *= 2;
- sect_opts = ((struct sect_opt *)
- xrealloc (sect_opts,
- num_sect_opts
- * sizeof (struct sect_opt)));
- }
- }
- else
- error (_("USAGE: add-symbol-file <filename> <textaddress>"
- " [-readnow] [-s <secname> <addr>]*"));
- }
- }
+ {
+ /* It's an option (starting with '-') or it's an argument
+ to an option. */
+
+ if (expecting_sec_name)
+ {
+ sect_opts[section_index].name = arg;
+ expecting_sec_name = 0;
+ }
+ else if (expecting_sec_addr)
+ {
+ sect_opts[section_index].value = arg;
+ expecting_sec_addr = 0;
+ if (++section_index >= num_sect_opts)
+ {
+ num_sect_opts *= 2;
+ sect_opts = ((struct sect_opt *)
+ xrealloc (sect_opts,
+ num_sect_opts
+ * sizeof (struct sect_opt)));
+ }
+ }
+ else if (strcmp (arg, "-readnow") == 0)
+ flags |= OBJF_READNOW;
+ else if (strcmp (arg, "-s") == 0)
+ {
+ expecting_sec_name = 1;
+ expecting_sec_addr = 1;
+ }
+ else
+ error (_("USAGE: add-symbol-file <filename> <textaddress>"
+ " [-readnow] [-s <secname> <addr>]*"));
+ }
}
/* This command takes at least two arguments. The first one is a