This is the mail archive of the 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]

Re: #line directives (bug?)

On Mar 9,  7:31pm, Edward Peschko wrote:

> I was debugging a c-module attached to perl, and got the following weird 
> behaviour:
> I break on one of the XS subroutines, XS_String__DiffLine_diffrevpos, for 
> example, and then proceed to step through the code.
> Unfortunately, it seems that as soon as I hit a 'line' directive, the file gets
> screwed up as far as gdb is concerned... I step through the code, and it skips
> statements that are after the line directives. Remove the line directives
> and everything works fine...
> So what's going on? why doesn't gdb handle #line? Is this a bug or is there a 
> way to get around it?


You've found a bug.  From time to time, I debug XS modules too and
I've been annoyed by this also.  The patch, below, should fix the
problems that you're seeing.  Try it out and let me know how it goes.

I've tested on i386-unknown-freebsd4.2 and i686-pc-linux-gnu (both
native) and see no regressions.  In addition, I've run the patched gdb
on an XS module that I maintain and it certainly fixes the problems
that I had been seeing.

Hmm.  I should probably create a test case for the testsuite...


	* symtab.c (find_pc_sect_line): Revise method used for finding
	the ending pc.

Index: symtab.c
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.32
diff -u -p -r1.32 symtab.c
--- symtab.c	2001/03/06 08:21:17	1.32
+++ symtab.c	2001/03/10 08:22:11
@@ -1759,11 +1759,18 @@ find_pc_sect_line (CORE_ADDR pc, struct 
 	  best = prev;
 	  best_symtab = s;
-	  /* If another line is in the linetable, and its PC is closer
-	     than the best_end we currently have, take it as best_end.  */
-	  if (i < len && (best_end == 0 || best_end > item->pc))
-	    best_end = item->pc;
+	  /* Discard BEST_END if it's before the PC of the current BEST.  */
+	  if (best_end <= best->pc)
+	    best_end = 0;
+      /* If another line (denoted by ITEM) is in the linetable and its
+         PC is after BEST's PC, but before the current BEST_END, then
+	 use ITEM's PC as the new best_end.  */
+      if (best && i < len && item->pc > best->pc
+          && (best_end == 0 || best_end > item->pc))
+	best_end = item->pc;
   if (!best_symtab)

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