Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Luis Machado <luisgpm@linux.vnet.ibm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Listing cpp source code in mainless binaries
Date: Tue, 10 Jun 2008 22:04:00 -0000	[thread overview]
Message-ID: <1213122525.10042.148.camel@gargoyle> (raw)

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 "<<C++-namespaces>>" symtab entry for, i believe, global
namespaces. Thus, GDB won't list the source code (below). This small
patch fixes this.


(gdb) l
1       <<C++-namespaces>>: No such file or directory.
        in <<C++-namespaces>>

Regards,
Luis


2008-10-06  Luis Machado  <luisgpm@br.ibm.com>

	* 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, "<<C++-namespaces>>") == 0)))
 	    current_source_symtab = s;
 	}
     }



             reply	other threads:[~2008-06-10 18:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-10 22:04 Luis Machado [this message]
2008-06-26 14:42 ` Daniel Jacobowitz
2008-06-30 14:13   ` Luis Machado
2008-06-30 18:04     ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1213122525.10042.148.camel@gargoyle \
    --to=luisgpm@linux.vnet.ibm.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox