Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Hui Zhu <teawater@gmail.com>
To: gdb-patches ml <gdb-patches@sourceware.org>
Subject: [RFA] Fix "Segmentation fault" when "gdb -v"
Date: Thu, 04 Mar 2010 06:50:00 -0000	[thread overview]
Message-ID: <daef60381003032250j42f46f4cqacf0ba2975fb9b6d@mail.gmail.com> (raw)

Hi,

I found that when "gdb -v", it "Segmentation fault".

This is because:
  if (print_version)
    {
      print_gdb_version (gdb_stdout);
      wrap_here ("");
      printf_filtered ("\n");
      exit (0);
    }
All of this code use "printf_filtered".  But this function must be
call after "interp_set".
But this part of code call before "interp_set".
So I make a patch to change "printf_filtered" to "printf_unfiltered"
in this part of code.

Please help me review it.

Thanks,
Hui

2010-03-04  Hui Zhu  <teawater@gmail.com>

	* main.c (captured_main): Change "printf_filtered" to
	"printf_unfiltered".
	* top.c (print_gdb_version): Ditto.

---
 main.c |    2 +-
 top.c  |   18 +++++++++---------
 2 files changed, 10 insertions(+), 10 deletions(-)

--- a/main.c
+++ b/main.c
@@ -704,7 +704,7 @@ Excess command line arguments ignored. (
     {
       print_gdb_version (gdb_stdout);
       wrap_here ("");
-      printf_filtered ("\n");
+      printf_unfiltered ("\n");
       exit (0);
     }

--- a/top.c
+++ b/top.c
@@ -1054,18 +1054,18 @@ print_gdb_version (struct ui_file *strea
      program to parse, and is just canonical program name and version
      number, which starts after last space. */

-  fprintf_filtered (stream, "GNU gdb %s%s\n", PKGVERSION, version);
+  fprintf_unfiltered (stream, "GNU gdb %s%s\n", PKGVERSION, version);

   /* Second line is a copyright notice. */

-  fprintf_filtered (stream, "Copyright (C) 2010 Free Software
Foundation, Inc.\n");
+  fprintf_unfiltered (stream, "Copyright (C) 2010 Free Software
Foundation, Inc.\n");

   /* Following the copyright is a brief statement that the program is
      free software, that users are free to copy and change it on
      certain conditions, that it is covered by the GNU GPL, and that
      there is no warranty. */

-  fprintf_filtered (stream, "\
+  fprintf_unfiltered (stream, "\
 License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>\n\
 This is free software: you are free to change and redistribute it.\n\
 There is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\n\
@@ -1073,22 +1073,22 @@ and \"show warranty\" for details.\n");

   /* After the required info we print the configuration information. */

-  fprintf_filtered (stream, "This GDB was configured as \"");
+  fprintf_unfiltered (stream, "This GDB was configured as \"");
   if (strcmp (host_name, target_name) != 0)
     {
-      fprintf_filtered (stream, "--host=%s --target=%s", host_name,
target_name);
+      fprintf_unfiltered (stream, "--host=%s --target=%s", host_name,
target_name);
     }
   else
     {
-      fprintf_filtered (stream, "%s", host_name);
+      fprintf_unfiltered (stream, "%s", host_name);
     }
-  fprintf_filtered (stream, "\".");
+  fprintf_unfiltered (stream, "\".");

   if (REPORT_BUGS_TO[0])
     {
-      fprintf_filtered (stream,
+      fprintf_unfiltered (stream,
 			_("\nFor bug reporting instructions, please see:\n"));
-      fprintf_filtered (stream, "%s.", REPORT_BUGS_TO);
+      fprintf_unfiltered (stream, "%s.", REPORT_BUGS_TO);
     }
 }


             reply	other threads:[~2010-03-04  6:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-04  6:50 Hui Zhu [this message]
2010-03-04  7:26 ` Joel Brobecker
2010-03-04  8:06   ` Hui Zhu
2010-03-04 13:45     ` Daniel Jacobowitz
2010-03-04 14:02   ` Pedro Alves
2010-03-04 14:59     ` Pedro Alves
2010-03-05  4:59       ` Joel Brobecker

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=daef60381003032250j42f46f4cqacf0ba2975fb9b6d@mail.gmail.com \
    --to=teawater@gmail.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