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.
This commit is contained in:
Muhammad Bilal 2013-09-04 06:17:08 +00:00
parent 4cb70f9a2f
commit 41dc8db876
4 changed files with 68 additions and 56 deletions

View File

@ -1,3 +1,10 @@
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-03 Luis Machado <lgustavo@codesourcery.com> 2013-09-03 Luis Machado <lgustavo@codesourcery.com>
* inf-child.c (inf_child_follow_fork) New parameter * inf-child.c (inf_child_follow_fork) New parameter

View File

@ -2214,63 +2214,55 @@ add_symbol_file_command (char *args, int from_tty)
filename = tilde_expand (arg); filename = tilde_expand (arg);
make_cleanup (xfree, filename); 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 else
if (argcnt == 1) {
{ /* It's an option (starting with '-') or it's an argument
/* The second argument is always the text address at which to an option. */
to load the program. */
sect_opts[section_index].name = ".text"; if (expecting_sec_name)
sect_opts[section_index].value = arg; {
if (++section_index >= num_sect_opts) sect_opts[section_index].name = arg;
{ expecting_sec_name = 0;
num_sect_opts *= 2; }
sect_opts = ((struct sect_opt *) else if (expecting_sec_addr)
xrealloc (sect_opts, {
num_sect_opts sect_opts[section_index].value = arg;
* sizeof (struct sect_opt))); expecting_sec_addr = 0;
} if (++section_index >= num_sect_opts)
} {
else num_sect_opts *= 2;
{ sect_opts = ((struct sect_opt *)
/* It's an option (starting with '-') or it's an argument xrealloc (sect_opts,
to an option. */ num_sect_opts
* sizeof (struct sect_opt)));
if (*arg == '-') }
{ }
if (strcmp (arg, "-readnow") == 0) else if (strcmp (arg, "-readnow") == 0)
flags |= OBJF_READNOW; flags |= OBJF_READNOW;
else if (strcmp (arg, "-s") == 0) else if (strcmp (arg, "-s") == 0)
{ {
expecting_sec_name = 1; expecting_sec_name = 1;
expecting_sec_addr = 1; expecting_sec_addr = 1;
} }
} else
else error (_("USAGE: add-symbol-file <filename> <textaddress>"
{ " [-readnow] [-s <secname> <addr>]*"));
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>]*"));
}
}
} }
/* This command takes at least two arguments. The first one is a /* This command takes at least two arguments. The first one is a

View File

@ -1,3 +1,9 @@
2013-09-13 Muhammad Bilal <mbilal@codesourcery.com>
Pedro Alves <palves@redhat.com>
* gdb.base/relocate.exp: Check that invalid options are
rejected.
2013-08-30 Andrew Burgess <aburgess@broadcom.com> 2013-08-30 Andrew Burgess <aburgess@broadcom.com>
* gdb.base/code_elim1.c (my_bss_symbol): New variable added. * gdb.base/code_elim1.c (my_bss_symbol): New variable added.

View File

@ -52,6 +52,13 @@ gdb_exit
gdb_start gdb_start
gdb_reinitialize_dir $srcdir/$subdir gdb_reinitialize_dir $srcdir/$subdir
#Check that invalid options are rejected.
foreach x {"-raednow" "readnow" "foo" "-readnow s"} {
gdb_test "add-symbol-file ${binfile} 0 $x" \
"USAGE: add-symbol-file <filename> <textaddress>.*-readnow.*-s <secname> <addr>.*" \
"add-symbol-file: unknown option $x"
}
# Load the object file. # Load the object file.
gdb_test "add-symbol-file ${binfile} 0" \ gdb_test "add-symbol-file ${binfile} 0" \
"Reading symbols from .*${testfile}\\.o\\.\\.\\.done\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \ "Reading symbols from .*${testfile}\\.o\\.\\.\\.done\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \