From patchwork Sat Nov 4 22:34:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 24100 Received: (qmail 89599 invoked by alias); 4 Nov 2017 22:35:29 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 89582 invoked by uid 89); 4 Nov 2017 22:35:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=silently, Hx-languages-length:3299 X-HELO: gateway22.websitewelcome.com Received: from gateway22.websitewelcome.com (HELO gateway22.websitewelcome.com) (192.185.47.109) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 04 Nov 2017 22:35:27 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway22.websitewelcome.com (Postfix) with ESMTP id A685668CC for ; Sat, 4 Nov 2017 17:34:57 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id B71lestvtpOTvB71ledy6O; Sat, 04 Nov 2017 17:34:57 -0500 Received: from 71-218-90-63.hlrn.qwest.net ([71.218.90.63]:33732 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1eB71l-004Ixc-FI; Sat, 04 Nov 2017 17:34:57 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 1/2] Fix add-symbol-file usage and errors Date: Sat, 4 Nov 2017 16:34:54 -0600 Message-Id: <20171104223455.539-2-tom@tromey.com> In-Reply-To: <20171104223455.539-1-tom@tromey.com> References: <20171104223455.539-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1eB71l-004Ixc-FI X-Source-Sender: 71-218-90-63.hlrn.qwest.net (bapiya.Home) [71.218.90.63]:33732 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This patch updaes add-symbol-file help and error text. It changes add-symbol-file to throw an exception if "-s" is seen but not all of the arguments are given. Previously this was silently ignored. It changes the unrecognized argument message to more clearly state what went wrong. Finally, it updates the usage line in the help text to follow GNU style regarding "metasyntactic variables"; a change I believe should be made to all gdb help messages. ChangeLog 2017-11-04 Tom Tromey * symfile.c (add_symbol_file_command): Error if some arguments to -s are missing. Change unrecognized-argument error message. (_initialize_symfile): Fix usage text for add-symbol-file. testsuite/ChangeLog 2017-11-04 Tom Tromey * gdb.base/relocate.exp: Update invalid argument test. --- gdb/ChangeLog | 6 ++++++ gdb/symfile.c | 12 ++++++++---- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.base/relocate.exp | 5 +++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/gdb/symfile.c b/gdb/symfile.c index 9afd9943d9..11e67e52b6 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2248,8 +2248,7 @@ add_symbol_file_command (const char *args, int from_tty) expecting_sec_addr = 1; } else - error (_("USAGE: add-symbol-file " - " [-readnow] [-s ]*")); + error (_("Unrecognized argument \"%s\""), arg); } } @@ -2261,6 +2260,11 @@ add_symbol_file_command (const char *args, int from_tty) error (_("The address where %s has been loaded is missing"), filename.get ()); + if (expecting_sec_name) + error (_("Missing section name after \"-s\"")); + else if (expecting_sec_addr) + error (_("Missing section address after \"-s\"")); + /* Print the prompt for the query below. And save the arguments into a sect_addr_info structure to be passed around to other functions. We have to split this up into separate print @@ -3883,8 +3887,8 @@ to execute."), &cmdlist); c = add_cmd ("add-symbol-file", class_files, add_symbol_file_command, _("\ Load symbols from FILE, assuming FILE has been dynamically loaded.\n\ -Usage: add-symbol-file FILE ADDR [-s -s \ - ...]\nADDR is the starting address of the file's text.\n\ +Usage: add-symbol-file FILE ADDR [-readnow | -s SECT SECT_ADDR]...\n\ +ADDR is the starting address of the file's text.\n\ The optional arguments are section-name section-address pairs and\n\ should be specified if the data and bss segments are not contiguous\n\ with the text. SECT is a section name to be loaded at SECT_ADDR."), diff --git a/gdb/testsuite/gdb.base/relocate.exp b/gdb/testsuite/gdb.base/relocate.exp index 5639cc8847..00327f5026 100644 --- a/gdb/testsuite/gdb.base/relocate.exp +++ b/gdb/testsuite/gdb.base/relocate.exp @@ -31,9 +31,10 @@ gdb_reinitialize_dir $srcdir/$subdir #Check that invalid options are rejected. foreach x {"-raednow" "readnow" "foo" "-readnow s"} { + set word [lindex $x [expr [llength $x]-1]] gdb_test "add-symbol-file ${binfile} 0 $x" \ - "USAGE: add-symbol-file .*-readnow.*-s .*" \ - "add-symbol-file: unknown option $x" + "Unrecognized argument \"$word\"" \ + "add-symbol-file: unknown option $word" } # Load the object file.