This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Partial symbol tables without symbols


I've had this patch in a local tree for a year and a half;
unfortunately, I forgot to save a testcase, but I think it makes sense
on its own.

To figure out what psymtab covers a certain pc, we look for every
psymtab that claims to cover that range.  We take the one with a symbol
closest to (but before) the specified PC.  This is a loop over all
psymtabs and a fearsome lot of symbol lookups; no wonder this function
is slow.  If we recorded live ranges for these things I'm sure we could
do much better.

But in any case, there's another problem here.  Gas creates debug info
for files which is only a placeholder for a line table; there are no
symbols.  This is a legitimate thing for it to do, since it doesn't
know their types.  We won't ever select that psymtab, if there's any
other claiming to cover that range, because it has no symbols.
This patch adds an implicit symbol, for the purposes of this search,
to the start of every psymtab.

Any thoughts?  Tested on x86_64-pc-linux-gnu, no change.

-- 
Daniel Jacobowitz
CodeSourcery

2006-12-01  Daniel Jacobowitz  <dan@codesourcery.com>

	* symtab.c (find_pc_sect_psymtab): Add comments.  Handle psymtabs
	with no symbols.

Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.149
diff -u -p -r1.149 symtab.c
--- symtab.c	28 Nov 2006 16:23:32 -0000	1.149
+++ symtab.c	1 Dec 2006 18:27:59 -0000
@@ -795,7 +795,7 @@ find_pc_sect_psymtab (CORE_ADDR pc, asec
       {
 	struct partial_symtab *tpst;
 	struct partial_symtab *best_pst = pst;
-	struct partial_symbol *best_psym = NULL;
+	CORE_ADDR best_addr = pst->textlow;
 
 	/* An objfile that has its functions reordered might have
 	   many partial symbol tables containing the PC, but
@@ -820,36 +820,42 @@ find_pc_sect_psymtab (CORE_ADDR pc, asec
 	    if (pc >= tpst->textlow && pc < tpst->texthigh)
 	      {
 		struct partial_symbol *p;
+		CORE_ADDR this_addr;
 
+		/* NOTE: This assumes that every psymbol has a
+		   corresponding msymbol, which is not necessarily
+		   true; the debug info might be much richer than the
+		   object's symbol table.  */
 		p = find_pc_sect_psymbol (tpst, pc, section);
 		if (p != NULL
 		    && SYMBOL_VALUE_ADDRESS (p)
 		    == SYMBOL_VALUE_ADDRESS (msymbol))
 		  return (tpst);
+
+		/* Also accept the textlow value of a psymtab as a
+		   "symbol", to provide some support for partial
+		   symbol tables with line information but no debug
+		   symbols (e.g. those produced by an assembler).  */
 		if (p != NULL)
+		  this_addr = SYMBOL_VALUE_ADDRESS (p);
+		else
+		  this_addr = tpst->textlow;
+
+		/* Check whether it is closer than our current
+		   BEST_ADDR.  Since this symbol address is
+		   necessarily lower or equal to PC, the symbol closer
+		   to PC is the symbol which address is the highest.
+		   This way we return the psymtab which contains such
+		   best match symbol. This can help in cases where the
+		   symbol information/debuginfo is not complete, like
+		   for instance on IRIX6 with gcc, where no debug info
+		   is emitted for statics. (See also the nodebug.exp
+		   testcase.) */
+		if (this_addr > best_addr)
 		  {
-		    /* We found a symbol in this partial symtab which
-		       matches (or is closest to) PC, check whether it
-		       is closer than our current BEST_PSYM.  Since
-		       this symbol address is necessarily lower or
-		       equal to PC, the symbol closer to PC is the
-		       symbol which address is the highest.  */
-		    /* This way we return the psymtab which contains
-		       such best match symbol. This can help in cases
-		       where the symbol information/debuginfo is not
-		       complete, like for instance on IRIX6 with gcc,
-		       where no debug info is emitted for
-		       statics. (See also the nodebug.exp
-		       testcase.)  */
-		    if (best_psym == NULL
-			|| SYMBOL_VALUE_ADDRESS (p)
-			> SYMBOL_VALUE_ADDRESS (best_psym))
-		      {
-			best_psym = p;
-			best_pst = tpst;
-		      }
+		    best_addr = this_addr;
+		    best_pst = tpst;
 		  }
-
 	      }
 	  }
 	return (best_pst);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]