public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [fortran,patch] Fix PR 33739, emitting calls to debug_hooks->end_source_file
@ 2007-11-07 16:57 Paul Richard Thomas
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Richard Thomas @ 2007-11-07 16:57 UTC (permalink / raw)
  To: FX Coudert, gcc-patches, fortran

FX,

:REVIEWMAIL:

> Regtested on x86_64-linux with dwarf and stabs, and regtested on powerpc-apple-darwin8 (stabs) with -m32 and -m64. OK to commit?

OK to commit

Thanks

Paul

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [fortran,patch] Fix PR 33739, emitting calls to debug_hooks->end_source_file
@ 2007-11-03 23:02 FX Coudert
  0 siblings, 0 replies; 2+ messages in thread
From: FX Coudert @ 2007-11-03 23:02 UTC (permalink / raw)
  To: Fortran List; +Cc: gcc-patches list, Dominique Dhumieres

[-- Attachment #1: Type: text/plain, Size: 1098 bytes --]

Attached patch fixes PR 33739, a debug-info problem which is only  
seen with stabs and the darwin 64-bit linker, but is nonetheless an  
issue in the front-end. Each time we enter an included source file,  
we emit a call to debug_hooks->start_source_file; we call debug_hooks- 
 >end_source_file when returning to the original file; my recent  
patch to scanner.c made sure of that.

Unfortunately, there is one situation that was not yet addressed.  
When the inclusion line is the last line of the outer file, like this:

> $ cat b.F
>   print *, 42
> #include "b.inc"
> $ cat b.inc
>   end

In that case, the problem is that when we come into gfc_advance_line,  
it's too late; and during parsing, it's too early to emit calls to  
the debug_hooks functions. But it happens to be simple: I added  
functions to keep track of files entered and exited, so be able to  
emit exit calls for each remaining file when we reach the end of the  
main source file.

Regtested on x86_64-linux with dwarf and stabs, and regtested on  
powerpc-apple-darwin8 (stabs) with -m32 and -m64. OK to commit?

FX


[-- Attachment #2: pr33739.ChangeLog --]
[-- Type: application/octet-stream, Size: 196 bytes --]

2007-11-03  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

	* scanner.c (start_source_file, end_source_file,
	exit_remaining_files): New functions.
	(gfc_advance_line): Use the new functions.


[-- Attachment #3: pr33739.diff --]
[-- Type: application/octet-stream, Size: 2319 bytes --]

Index: gcc/fortran/scanner.c
===================================================================
--- gcc/fortran/scanner.c	(revision 129869)
+++ gcc/fortran/scanner.c	(working copy)
@@ -300,13 +300,59 @@ gfc_at_eol (void)
 }
 
 
+struct file_entered_chainon
+{
+  gfc_file *file;
+  struct file_entered_chainon *prev;
+};
+
+static struct file_entered_chainon *last_file_entered = NULL;
+
+static void
+start_source_file (int line, gfc_file *file)
+{
+  struct file_entered_chainon *f = gfc_getmem (sizeof
+                                       (struct file_entered_chainon));
+
+  f->file = file;
+  f->prev = last_file_entered;
+  last_file_entered = f;
+
+  (*debug_hooks->start_source_file) (line, file->filename);
+}
+
+static void
+end_source_file (int line)
+{
+  gcc_assert (last_file_entered);
+  last_file_entered = last_file_entered->prev;
+  (*debug_hooks->end_source_file) (line);
+}
+
+static void
+exit_remaining_files (void)
+{
+  struct file_entered_chainon *f = last_file_entered;
+  while (f)
+    {
+      /* The line number doesn't matter much, because we're at the end of
+         the toplevel file anyway.  */
+      (*debug_hooks->end_source_file) (0);
+
+      f = f->prev;
+    }
+}
+
 /* Advance the current line pointer to the next line.  */
 
 void
 gfc_advance_line (void)
 {
   if (gfc_at_end ())
-    return;
+    {
+      exit_remaining_files ();
+      return;
+    }
 
   if (gfc_current_locus.lb == NULL) 
     {
@@ -322,17 +368,15 @@ gfc_advance_line (void)
 	  && gfc_current_locus.lb->file->up == gfc_current_locus.lb->next->file)
 	{
 	  /* We exit from an included file. */
-	  (*debug_hooks->end_source_file)
-		(gfc_linebuf_linenum (gfc_current_locus.lb->next));
+	  end_source_file (gfc_linebuf_linenum (gfc_current_locus.lb->next));
 	  gfc_current_locus.lb->next->dbg_emitted = true;
 	}
       else if (gfc_current_locus.lb->next->file != gfc_current_locus.lb->file
 	       && !gfc_current_locus.lb->next->dbg_emitted)
 	{
 	  /* We enter into a new file.  */
-	  (*debug_hooks->start_source_file)
-		(gfc_linebuf_linenum (gfc_current_locus.lb),
-		 gfc_current_locus.lb->next->file->filename);
+	  start_source_file (gfc_linebuf_linenum (gfc_current_locus.lb),
+			     gfc_current_locus.lb->next->file);
 	  gfc_current_locus.lb->next->dbg_emitted = true;
 	}
     }

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-11-07 16:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-07 16:57 [fortran,patch] Fix PR 33739, emitting calls to debug_hooks->end_source_file Paul Richard Thomas
  -- strict thread matches above, loose matches on Subject: below --
2007-11-03 23:02 FX Coudert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).