[PATCH] Make 'symbol-file' not care about the position of command line arguments

Sergio Durigan Junior
2017-11-29T21:45:04Z

This is a bug that's been detected while doing the readnever work.
Currently if you use the 'symbol-file' command you have to be careful
about the position of each argument you pass on the command line.
This is because while parsing its arguments, if the command detects a
filename, it promptly calls 'symbol_file_add_main_1' without waiting
to see if there are other args on the line. This only affects the
'-readnow' argument so far, but while implementing the '-readnever'
command it also affected it.

gdb/ChangeLog:

2017-11-29 Sergio Durigan Junior <sergiodj@redhat.com>

* symfile.c (symbol_file_command): Call
'symbol_file_add_main_1' only after processing all command
line options.
---
gdb/symfile.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/gdb/symfile.c b/gdb/symfile.c
index 4bbe0b5a62..9565570734 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1634,14 +1634,13 @@ symbol_file_command (const char *args, int from_tty)
else if (*arg == '-')
error (_("unknown option `%s'"), arg);
else
- {
- symbol_file_add_main_1 (arg, add_flags, flags);
- name = arg;
- }
+ name = arg;
}

if (name == NULL)
error (_("no symbol file name was specified"));
+
+ symbol_file_add_main_1 (arg, add_flags, flags);
}
}

--
2.13.3