From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16620 invoked by alias); 1 Dec 2005 18:04:05 -0000 Received: (qmail 16607 invoked by uid 22791); 1 Dec 2005 18:04:04 -0000 X-Spam-Check-By: sourceware.org Received: from fra-del-02.spheriq.net (HELO fra-del-02.spheriq.net) (195.46.51.98) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 01 Dec 2005 18:03:53 +0000 Received: from fra-out-03.spheriq.net (fra-out-03.spheriq.net [195.46.51.131]) by fra-del-02.spheriq.net with ESMTP id jB1I3ajk015938 for ; Thu, 1 Dec 2005 18:03:45 GMT Received: from fra-cus-02.spheriq.net (fra-cus-02.spheriq.net [195.46.51.38]) by fra-out-03.spheriq.net with ESMTP id jB1I3aBB005216 for ; Thu, 1 Dec 2005 18:03:36 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by fra-cus-02.spheriq.net with ESMTP id jB1I3ZuR013473 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK) for ; Thu, 1 Dec 2005 18:03:35 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0A0B0DA41 for ; Thu, 1 Dec 2005 18:03:35 +0000 (GMT) Received: by zeta.dmz-eu.st.com (STMicroelectronics, from userid 60012) id 368A54752A; Thu, 1 Dec 2005 18:06:35 +0000 (GMT) Received: from zeta.dmz-eu.st.com (localhost [127.0.0.1]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id CF1E375994 for ; Thu, 1 Dec 2005 18:06:34 +0000 (UTC) Received: from mail1.bri.st.com (mail1.bri.st.com [164.129.8.218]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4AF3C473C4 for ; Thu, 1 Dec 2005 18:06:34 +0000 (GMT) Received: from [164.129.15.13] (terrorhawk.bri.st.com [164.129.15.13]) by mail1.bri.st.com (MOS 3.5.8-GR) with ESMTP id CHA49049 (AUTH "andrew stubbs"); Thu, 1 Dec 2005 18:03:27 GMT Message-ID: <438F3A67.1070700@st.com> Date: Thu, 01 Dec 2005 18:04:00 -0000 From: Andrew STUBBS User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) MIME-Version: 1.0 To: GDB Patches Subject: [PATCH] fix symbol-file crash Content-Type: multipart/mixed; boundary="------------060006030808080608000208" X-O-Spoofed: Not Scanned X-O-General-Status: No X-O-Spam1-Status: Not Scanned X-O-Spam2-Status: Not Scanned X-O-URL-Status: Not Scanned X-O-Virus1-Status: No X-O-Virus2-Status: Not Scanned X-O-Virus3-Status: No X-O-Virus4-Status: No X-O-Virus5-Status: Not Scanned X-O-Image-Status: Not Scanned X-O-Attach-Status: Not Scanned X-SpheriQ-Ver: 4.2.0 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2005-12/txt/msg00021.txt.bz2 This is a multi-part message in MIME format. --------------060006030808080608000208 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1237 Hi, The attached patch fixes a bug which causes a crash clearing the symbol tables. The problem occurs as follows: (gdb) add-symbol-file ~/hello add symbol table from file "/home/afra/users/stubbsa/hello" at (y or n) y Reading symbols from /home/afra/users/stubbsa/hello...done. Using host libthread_db library "/lib/tls/libthread_db.so.1". (gdb) symbol-file Segmentation fault The problem does not occur when the commands are executed from a script. The cause is symbol-file asking permission to clear the symbol tables using the name of the object file without first checking there is an object file. If symbol-file was used to load the symbols then all is well. If add-symbol-file was used (which seems to work equally well in all other ways) then there is no main object file and it all goes horribly wrong. Note that this is the second problem mentioned in bug #858 and also in bug #878, which appears to be a duplicate. I have fixed this by testing the pointer before dereferencing it and using '' if there is no object file name. Perhaps there is something more intelligent that could be done here, but this fixes the problem at hand. I have also added a missing _() to the query string. Andrew Stubbs --------------060006030808080608000208 Content-Type: text/plain; name="symbol-file.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="symbol-file.patch" Content-length: 781 2005-12-01 Andrew Stubbs * symfile.c (symbol_file_clear): Test symfile_objfile is not NULL before dereferencing it. Gettextize the query. Index: src/gdb/symfile.c =================================================================== --- src.orig/gdb/symfile.c 2005-12-01 12:05:58.000000000 +0000 +++ src/gdb/symfile.c 2005-12-01 15:21:17.000000000 +0000 @@ -1085,8 +1085,8 @@ symbol_file_clear (int from_tty) { if ((have_full_symbols () || have_partial_symbols ()) && from_tty - && !query ("Discard symbol table from `%s'? ", - symfile_objfile->name)) + && !query (_("Discard symbol table from `%s'? "), + symfile_objfile ? symfile_objfile->name : _(""))) error (_("Not confirmed.")); free_all_objfiles (); --------------060006030808080608000208--