From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30409 invoked by alias); 4 Mar 2010 08:06:30 -0000 Received: (qmail 30398 invoked by uid 22791); 4 Mar 2010 08:06:29 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40 X-Spam-Check-By: sourceware.org Received: from mail-px0-f203.google.com (HELO mail-px0-f203.google.com) (209.85.216.203) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 04 Mar 2010 08:06:21 +0000 Received: by pxi41 with SMTP id 41so867318pxi.23 for ; Thu, 04 Mar 2010 00:06:20 -0800 (PST) MIME-Version: 1.0 Received: by 10.142.1.6 with SMTP id 6mr1824742wfa.156.1267689980128; Thu, 04 Mar 2010 00:06:20 -0800 (PST) In-Reply-To: <20100304072620.GJ2832@adacore.com> References: <20100304072620.GJ2832@adacore.com> From: Hui Zhu Date: Thu, 04 Mar 2010 08:06:00 -0000 Message-ID: Subject: Re: [RFA] Fix "Segmentation fault" when "gdb -v" To: Joel Brobecker Cc: gdb-patches ml Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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/msg00166.txt.bz2 On Thu, Mar 4, 2010 at 15:26, Joel Brobecker wrote: >> All of this code use "printf_filtered". =A0But this function must be >> call after "interp_set". >> But this part of code call before "interp_set". > > I think that this was an unforseen side-effect of a recent change. > IMO, it's better to get rid of this side-effect (needing the interpreter > to be set) in printf_filtered. > > We should NOT change printf_filtered into printf_unfiltered in this case > because the same function is used in two different situations: > =A0- when the user uses -v > =A0- when the user types "show version" > In the latter case, the printf_filtered is appropriate. > > Now, we need to decide whether pagination should be enabled if > the interpreter is not set. I think it makes sense to disable pagination > in this case. =A0If the interpreter is not set yet, we're just printing > stuff on stdout, we haven't started the interactive session (if any) yet.= .. > The way is make it output after interp_set. Thanks, Hui 2010-03-04 Hui Zhu * main.c (captured_main): Change version output after interp_set. --- main.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) --- a/main.c +++ b/main.c @@ -695,19 +695,6 @@ Excess command line arguments ignored. ( gdb_init. */ get_init_files (&system_gdbinit, &home_gdbinit, &local_gdbinit); - /* Do these (and anything which might call wrap_here or *_filtered) - after initialize_all_files() but before the interpreter has been - installed. Otherwize the help/version messages will be eaten by - the interpreter's output handler. */ - - if (print_version) - { - print_gdb_version (gdb_stdout); - wrap_here (""); - printf_filtered ("\n"); - exit (0); - } - if (print_help) { print_gdb_help (gdb_stdout); @@ -750,6 +737,19 @@ Excess command line arguments ignored. ( } } + /* Do these (and anything which might call wrap_here or *_filtered) + after initialize_all_files() but before the interpreter has been + installed. Otherwize the help/version messages will be eaten by + the interpreter's output handler. */ + + if (print_version) + { + print_gdb_version (gdb_stdout); + wrap_here (""); + printf_filtered ("\n"); + exit (0); + } + /* FIXME: cagney/2003-02-03: The big hack (part 2 of 2) that lets GDB retain the old MI1 interpreter startup behavior. Output the copyright message after the interpreter is installed when it is