From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6377 invoked by alias); 4 Mar 2010 06:50:50 -0000 Received: (qmail 6367 invoked by uid 22791); 4 Mar 2010 06:50:48 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40 X-Spam-Check-By: sourceware.org Received: from mail-pv0-f169.google.com (HELO mail-pv0-f169.google.com) (74.125.83.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 04 Mar 2010 06:50:44 +0000 Received: by pvh11 with SMTP id 11so743757pvh.0 for ; Wed, 03 Mar 2010 22:50:43 -0800 (PST) MIME-Version: 1.0 Received: by 10.142.1.24 with SMTP id 24mr391361wfa.195.1267685443081; Wed, 03 Mar 2010 22:50:43 -0800 (PST) From: Hui Zhu Date: Thu, 04 Mar 2010 06:50:00 -0000 Message-ID: Subject: [RFA] Fix "Segmentation fault" when "gdb -v" To: gdb-patches ml Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-03/txt/msg00159.txt.bz2 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 * 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 \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); } }