From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20895 invoked by alias); 10 Jun 2008 18:44:18 -0000 Received: (qmail 20887 invoked by uid 22791); 10 Jun 2008 18:44:17 -0000 X-Spam-Check-By: sourceware.org Received: from igw2.br.ibm.com (HELO igw2.br.ibm.com) (32.104.18.25) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 10 Jun 2008 18:43:56 +0000 Received: from mailhub3.br.ibm.com (mailhub3 [9.18.232.110]) by igw2.br.ibm.com (Postfix) with ESMTP id 440C317F574 for ; Tue, 10 Jun 2008 15:32:17 -0300 (BRST) Received: from d24av02.br.ibm.com (d24av02.br.ibm.com [9.18.232.47]) by mailhub3.br.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id m5AISpVg4767804 for ; Tue, 10 Jun 2008 15:28:53 -0300 Received: from d24av02.br.ibm.com (loopback [127.0.0.1]) by d24av02.br.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m5AISlR0029408 for ; Tue, 10 Jun 2008 15:28:47 -0300 Received: from [9.18.238.151] ([9.18.238.151]) by d24av02.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id m5AISlb0029404 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 10 Jun 2008 15:28:47 -0300 Subject: [PATCH] Listing cpp source code in mainless binaries From: Luis Machado Reply-To: luisgpm@linux.vnet.ibm.com To: gdb-patches@sourceware.org Content-Type: text/plain Date: Tue, 10 Jun 2008 22:04:00 -0000 Message-Id: <1213122525.10042.148.camel@gargoyle> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 Content-Transfer-Encoding: 7bit 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: 2008-06/txt/msg00209.txt.bz2 An annoying situation occurs when trying to display CPP source code with the list command when we use a binary that does not have a main function. When selecting a random source file to display, GDB only skips header files, not the "<>" symtab entry for, i believe, global namespaces. Thus, GDB won't list the source code (below). This small patch fixes this. (gdb) l 1 <>: No such file or directory. in <> Regards, Luis 2008-10-06 Luis Machado * source.c (select_source_symtab): Make sure we skip namespace symtabs when showing cpp source code. Index: gdb/source.c =================================================================== --- gdb.orig/source.c 2008-05-19 08:50:10.000000000 -0700 +++ gdb/source.c 2008-06-10 11:15:01.000000000 -0700 @@ -250,7 +250,8 @@ return; } - /* All right; find the last file in the symtab list (ignoring .h's). */ + /* All right; find the last file in the symtab list (ignoring .h's) + and namespace symtabs. */ current_source_line = 1; @@ -260,7 +261,8 @@ { const char *name = s->filename; int len = strlen (name); - if (!(len > 2 && strcmp(&name[len - 2], ".h") == 0)) + if (!(len > 2 && (strcmp (&name[len - 2], ".h") == 0 + || strcmp (name, "<>") == 0))) current_source_symtab = s; } }