🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #8810

multiple source files with the same name not distinguished

#8810
From: Kevin Rodgers
Date: Mon, 19 Oct 1992 23:01
65 lines
3563 bytes
Configuration: gdb 4.6, SunOS 4.1.1 (debugging C source compiled with gcc 2.2.2)

If I run 'gdb' on an executable derived from two source files with the
same name, then try to set a breakpoint or list some source lines using
the file:line syntax, only information about the last source file is
retained, as evidenced by 'No line N in file "F"' and 'Line number N out
of range; F has M lines') messages.

According to the following comment in gdb/partial-stab.h (corroborated
by examining the output from 'nm -opa'), 'gcc -g' emits pairs of SO
entries that could be used to distinguish source files with the same
name in different directories:

	  /* Some compilers (including gcc) emit a pair of initial N_SOs.
	     The first one is a directory name; the second the file name.
	     If pst exists, is empty, and has a filename ending in '/',
	     we assume the previous N_SO was a directory name. */

However, the code fragment that immediately follows indicates that the
directory information is ignored:

	  p = strrchr (namestring, '/');
	  if (p && *(p+1) == '\000')
	    {
	      dir_so_symnum = symnum;
	      continue;		/* Simply ignore directory name SOs */
	    }

I'm considering patching partial-stab.h to use the entire pathname (i.e.
directory name and file name) as the third argument to START_PSYMTAB().
This would allow the different source files to be referenced by their
complete name, but would also have the unfortunate effect of requiring
all source files, including uniquely named files, to be referenced by
their complete pathnames...

While attempting to verify that last statement, I came across these
comments in gdb/symtab.c, describing first lookup_symtab_1() and then
lookup_partial_symtab():

/* Check for a symtab of a specific name; first in symtabs, then in
   psymtabs.  *If* there is no '/' in the name, a match after a '/'
   in the symtab filename will also work.  */

/* Lookup the partial symbol table of a source file named NAME.  This
   only returns true on an exact match (ie. this semantics are
   different from lookup_symtab.  */

The first comment indicates that my proposed patch would still allow
source files to be referenced by file name only, but the second
indicates that some things might break.

Sorry for all that speculation; here's the point of my message:

1. Should complete pathnames be used to name source files?  Can this be
   implemented by fixing partial-stab.h?

2. How can file names (without qualifying directory names) still be used
   to reference source files?  Ideally, such references to multiple
   files with the same name would elicit a warning, and/or be
   interpreted according to the source path (GDB 'dir' param).
---
Kevin Rodgers				kevin@traffic.den.mmc.com
Martin Marietta MS A16401		(303) 790-3971
116 Inverness Dr. East
Englewood CO 80112 USA			GO BUFFS!
Technical Details
Message-ID: <9210192301.AA11254@traffic>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!traffic.den.mmc.com!kevin

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5053,f29585fe966fc010,start
X-Google-Attributes: gidf5053,public
X-Google-ArrivalTime: 1992-10-20 14:47:14 PST
Newsgroups: gnu.gdb.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!traffic.den.mmc.com!kevin
From: kevin@traffic.den.mmc.com (Kevin Rodgers)
Subject: multiple source files with the same name not distinguished
Message-ID: <9210192301.AA11254@traffic>
Sender: gnulists@ai.mit.edu
Reply-To: kevin@traffic.den.mmc.com
Organization: GNUs Not Usenet
Distribution: gnu
Date: Mon, 19 Oct 1992 23:01:13 GMT
Approved: bug-gdb@prep.ai.mit.edu
Lines: 66