From: Muhammad Bilal Date: Wed, 4 Sep 2013 06:17:08 +0000 (+0000) Subject: 2013-09-04 Muhammad Bilal X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=41dc8db876c8ee46687555fbff68b497b48d5ee4;p=binutils-gdb.git 2013-09-04 Muhammad Bilal Pedro Alves * 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 Pedro Alves * gdb.base/relocate.exp: Check that invalid options are rejected. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index caecc8d40ac..de171119e54 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2013-09-04 Muhammad Bilal + Pedro Alves + + * 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 * inf-child.c (inf_child_follow_fork) New parameter 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 " - " [-readnow] [-s ]*")); - } - } + { + /* 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 " + " [-readnow] [-s ]*")); + } } /* This command takes at least two arguments. The first one is a diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 0710472547f..62d26d2c610 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2013-09-13 Muhammad Bilal + Pedro Alves + + * gdb.base/relocate.exp: Check that invalid options are + rejected. + 2013-08-30 Andrew Burgess * gdb.base/code_elim1.c (my_bss_symbol): New variable added. diff --git a/gdb/testsuite/gdb.base/relocate.exp b/gdb/testsuite/gdb.base/relocate.exp index d69bca1947c..99ce83bc594 100644 --- a/gdb/testsuite/gdb.base/relocate.exp +++ b/gdb/testsuite/gdb.base/relocate.exp @@ -52,6 +52,13 @@ gdb_exit gdb_start 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 .*-readnow.*-s .*" \ + "add-symbol-file: unknown option $x" +} + # Load the object file. gdb_test "add-symbol-file ${binfile} 0" \ "Reading symbols from .*${testfile}\\.o\\.\\.\\.done\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \