Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Gary Benson <gbenson@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 8/8] Unify startup and option-parsing warnings
Date: Wed, 06 Aug 2014 10:12:00 -0000	[thread overview]
Message-ID: <1407319948-2264-9-git-send-email-gbenson@redhat.com> (raw)
In-Reply-To: <1407319948-2264-1-git-send-email-gbenson@redhat.com>

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  <gbenson@redhat.com>

	* 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.
-- 
1.7.1


  reply	other threads:[~2014-08-06 10:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-06 10:12 [PATCH 0/8] Error handling cleanups Gary Benson
2014-08-06 10:12 ` Gary Benson [this message]
2014-08-06 10:12 ` [PATCH 4/8] Replace hardwired error handlers in tui_initialize_io Gary Benson
2014-08-06 10:12 ` [PATCH 3/8] Make warning usable earlier Gary Benson
2014-08-06 10:12 ` [PATCH 2/8] Make error " Gary Benson
2014-08-06 10:25 ` [PATCH 7/8] Replace all usage errors with calls to error Gary Benson
2014-08-06 10:25 ` [PATCH 5/8] Replace hardwired error handler in captured_main Gary Benson
2014-08-06 10:34 ` [PATCH 1/8] Make internal_vproblem always work Gary Benson
2014-08-06 10:52 ` [PATCH 6/8] Replace hardwired error handler in go32_create_inferior Gary Benson
2014-08-06 16:59   ` Eli Zaretskii
2014-08-08 11:38     ` Gary Benson
2014-08-28 14:09 ` [PATCH 0/8] Error handling cleanups Pedro Alves
2014-08-29  9:19   ` [COMMITTED PATCH " Gary Benson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1407319948-2264-9-git-send-email-gbenson@redhat.com \
    --to=gbenson@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox