From patchwork Wed Aug 6 10:12:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Benson X-Patchwork-Id: 2317 Received: (qmail 18418 invoked by alias); 6 Aug 2014 10:12:44 -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 18234 invoked by uid 89); 6 Aug 2014 10:12:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 06 Aug 2014 10:12:41 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s76ACc89006684 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 6 Aug 2014 06:12:39 -0400 Received: from blade.nx (ovpn-116-90.ams2.redhat.com [10.36.116.90]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s76ACain016061 for ; Wed, 6 Aug 2014 06:12:38 -0400 Received: from blade.nx (localhost [127.0.0.1]) by blade.nx (Postfix) with ESMTP id 72D4A2640E5 for ; Wed, 6 Aug 2014 11:12:35 +0100 (BST) From: Gary Benson To: gdb-patches@sourceware.org Subject: [PATCH 8/8] Unify startup and option-parsing warnings Date: Wed, 6 Aug 2014 11:12:28 +0100 Message-Id: <1407319948-2264-9-git-send-email-gbenson@redhat.com> In-Reply-To: <1407319948-2264-1-git-send-email-gbenson@redhat.com> References: <1407319948-2264-1-git-send-email-gbenson@redhat.com> X-IsSubscribed: yes Various warnings are emitted during startup and option-parsing using fprintf_unfiltered. One warning is prefixed with the command name, the others are not. This commit replaces these hardwired warnings with calls to warning. It also sets warning_pre_print to prefix all warnings with the command name until option parsing is complete. gdb/ 2014-08-06 Gary Benson * main.c (captured_main): Use warning during startup. Prefix startup warning messages with command name. --- gdb/ChangeLog | 5 +++++ gdb/main.c | 31 ++++++++++--------------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/gdb/main.c b/gdb/main.c index a850edf..a15b3fd 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -519,14 +519,12 @@ captured_main (void *data) gdb_program_name = xstrdup (argv[0]); #endif + /* Prefix warning messages with the command name. */ + warning_pre_print = xstrprintf ("%s: warning: ", gdb_program_name); + if (! getcwd (gdb_dirbuf, sizeof (gdb_dirbuf))) - /* Don't use *_filtered or warning() (which relies on - current_target) until after initialize_all_files(). */ - fprintf_unfiltered (gdb_stderr, - _("%s: warning: error finding " - "working directory: %s\n"), - argv[0], safe_strerror (errno)); - + perror_warning_with_name (_("error finding working directory")); + current_directory = gdb_dirbuf; /* Set the sysroot path. */ @@ -809,13 +807,8 @@ captured_main (void *data) i = strtol (optarg, &p, 0); if (i == 0 && p == optarg) - - /* Don't use *_filtered or warning() (which relies on - current_target) until after initialize_all_files(). */ - - fprintf_unfiltered - (gdb_stderr, - _("warning: could not set baud rate to `%s'.\n"), optarg); + warning (_("could not set baud rate to `%s'."), + optarg); else baud_rate = i; } @@ -827,13 +820,8 @@ captured_main (void *data) i = strtol (optarg, &p, 0); if (i == 0 && p == optarg) - - /* Don't use *_filtered or warning() (which relies on - current_target) until after initialize_all_files(). */ - - fprintf_unfiltered (gdb_stderr, - _("warning: could not set " - "timeout limit to `%s'.\n"), optarg); + warning (_("could not set timeout limit to `%s'."), + optarg); else remote_timeout = i; } @@ -987,6 +975,7 @@ captured_main (void *data) } /* Set off error and warning messages with a blank line. */ + xfree (warning_pre_print); warning_pre_print = _("\nwarning: "); /* Read and execute the system-wide gdbinit file, if it exists.