This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] Fix "Segmentation fault" when "gdb -v"


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);
     }
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]