Commit 60332588 by Jakub Jelinek Committed by Jakub Jelinek

re PR debug/33739 (Failure of gfortran.dg/literal_character_constant_1_*.F with -m64 -g on Darwin)

	PR debug/33739
	* gfortran.h (gfc_file): Remove included_by field, add sibling and
	down.
	(gfc_start_source_files, gfc_end_source_files): New prototypes.
	* parse.c (gfc_parse_file): Call gfc_start_source_files and
	gfc_end_source_files instead of calling the debugging hooks directly.
	* error.c (show_locus): Use up field instead of included_by.
	* scanner.c (change_file, gfc_start_source_files,
	gfc_end_source_files): New functions.
	(gfc_advance_line): Call change_file instead of calling debug hooks
	directly.
	(get_file): Set up rather than included_by.  Initialize down and
	sibling.
	(preprocessor_line, load_file): Don't set up field here.

	* gfortran.dg/debug_2.f: New test.

From-SVN: r130629
parent bce62343
2007-12-05 Jakub Jelinek <jakub@redhat.com>
PR debug/33739
* gfortran.h (gfc_file): Remove included_by field, add sibling and
down.
(gfc_start_source_files, gfc_end_source_files): New prototypes.
* parse.c (gfc_parse_file): Call gfc_start_source_files and
gfc_end_source_files instead of calling the debugging hooks directly.
* error.c (show_locus): Use up field instead of included_by.
* scanner.c (change_file, gfc_start_source_files,
gfc_end_source_files): New functions.
(gfc_advance_line): Call change_file instead of calling debug hooks
directly.
(get_file): Set up rather than included_by. Initialize down and
sibling.
(preprocessor_line, load_file): Don't set up field here.
2007-12-05 Tobias Burnus <burnus@net-b.de> 2007-12-05 Tobias Burnus <burnus@net-b.de>
PR fortran/34333 PR fortran/34333
......
...@@ -207,7 +207,7 @@ show_locus (locus *loc, int c1, int c2) ...@@ -207,7 +207,7 @@ show_locus (locus *loc, int c1, int c2)
{ {
i = f->inclusion_line; i = f->inclusion_line;
f = f->included_by; f = f->up;
if (f == NULL) break; if (f == NULL) break;
error_printf (" Included at %s:%d:", f->filename, i); error_printf (" Included at %s:%d:", f->filename, i);
......
...@@ -706,7 +706,7 @@ symbol_attribute; ...@@ -706,7 +706,7 @@ symbol_attribute;
typedef struct gfc_file typedef struct gfc_file
{ {
struct gfc_file *included_by, *next, *up; struct gfc_file *next, *up, *sibling, *down;
int inclusion_line, line; int inclusion_line, line;
char *filename; char *filename;
} gfc_file; } gfc_file;
...@@ -1938,6 +1938,9 @@ extern gfc_source_form gfc_current_form; ...@@ -1938,6 +1938,9 @@ extern gfc_source_form gfc_current_form;
extern const char *gfc_source_file; extern const char *gfc_source_file;
extern locus gfc_current_locus; extern locus gfc_current_locus;
void gfc_start_source_files (void);
void gfc_end_source_files (void);
/* misc.c */ /* misc.c */
void *gfc_getmem (size_t) ATTRIBUTE_MALLOC; void *gfc_getmem (size_t) ATTRIBUTE_MALLOC;
void gfc_free (void *); void gfc_free (void *);
......
...@@ -3289,10 +3289,7 @@ gfc_parse_file (void) ...@@ -3289,10 +3289,7 @@ gfc_parse_file (void)
gfc_statement st; gfc_statement st;
locus prog_locus; locus prog_locus;
/* If the debugger wants the name of the main source file, gfc_start_source_files ();
we give it. */
if (debug_hooks->start_end_main_source_file)
(*debug_hooks->start_source_file) (0, gfc_source_file);
top.state = COMP_NONE; top.state = COMP_NONE;
top.sym = NULL; top.sym = NULL;
...@@ -3404,9 +3401,7 @@ loop: ...@@ -3404,9 +3401,7 @@ loop:
goto loop; goto loop;
done: done:
if (debug_hooks->start_end_main_source_file) gfc_end_source_files ();
(*debug_hooks->end_source_file) (0);
return SUCCESS; return SUCCESS;
duplicate_main: duplicate_main:
......
...@@ -299,6 +299,65 @@ gfc_at_eol (void) ...@@ -299,6 +299,65 @@ gfc_at_eol (void)
return (*gfc_current_locus.nextc == '\0'); return (*gfc_current_locus.nextc == '\0');
} }
static void
change_file (gfc_file *to)
{
if (current_file == NULL)
return;
while (current_file != to)
if (current_file->down)
{
gfc_file *f = current_file->down;
/* Ensure we don't enter it ever again. */
current_file->down = NULL;
current_file = f;
(*debug_hooks->start_source_file) (current_file->inclusion_line,
current_file->filename);
}
else if (current_file->sibling)
current_file = current_file->sibling;
else
{
gcc_assert (current_file->up);
(*debug_hooks->end_source_file) (current_file->inclusion_line + 1);
current_file = current_file->up;
}
}
void
gfc_start_source_files (void)
{
/* If the debugger wants the name of the main source file,
we give it. */
if (debug_hooks->start_end_main_source_file)
(*debug_hooks->start_source_file) (0, gfc_source_file);
if (gfc_current_locus.lb && gfc_current_locus.lb->file)
{
current_file = gfc_current_locus.lb->file;
while (current_file->up)
current_file = current_file->up;
change_file (gfc_current_locus.lb->file);
}
else
current_file = NULL;
}
void
gfc_end_source_files (void)
{
if (current_file != NULL)
{
gfc_file *to = current_file;
while (to->up)
to = to->up;
change_file (to);
}
if (debug_hooks->start_end_main_source_file)
(*debug_hooks->end_source_file) (0);
}
/* Advance the current line pointer to the next line. */ /* Advance the current line pointer to the next line. */
...@@ -315,27 +374,12 @@ gfc_advance_line (void) ...@@ -315,27 +374,12 @@ gfc_advance_line (void)
} }
if (gfc_current_locus.lb->next if (gfc_current_locus.lb->next
&& gfc_current_locus.lb->next->file != gfc_current_locus.lb->file) && gfc_current_locus.lb->next->file != gfc_current_locus.lb->file
{
if (gfc_current_locus.lb->next->file
&& !gfc_current_locus.lb->next->dbg_emitted
&& 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));
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) && !gfc_current_locus.lb->next->dbg_emitted)
{ {
/* We enter into a new file. */ change_file (gfc_current_locus.lb->next->file);
(*debug_hooks->start_source_file)
(gfc_linebuf_linenum (gfc_current_locus.lb),
gfc_current_locus.lb->next->file->filename);
gfc_current_locus.lb->next->dbg_emitted = true; gfc_current_locus.lb->next->dbg_emitted = true;
} }
}
gfc_current_locus.lb = gfc_current_locus.lb->next; gfc_current_locus.lb = gfc_current_locus.lb->next;
...@@ -1219,9 +1263,24 @@ get_file (const char *name, enum lc_reason reason ATTRIBUTE_UNUSED) ...@@ -1219,9 +1263,24 @@ get_file (const char *name, enum lc_reason reason ATTRIBUTE_UNUSED)
f->next = file_head; f->next = file_head;
file_head = f; file_head = f;
f->included_by = current_file; f->up = current_file;
/* Already cleared by gfc_getmem.
f->down = NULL;
f->sibling = NULL; */
if (current_file != NULL) if (current_file != NULL)
{
f->inclusion_line = current_file->line; f->inclusion_line = current_file->line;
if (current_file->down == NULL)
current_file->down = f;
else
{
gfc_file *s;
for (s = current_file->down; s->sibling; s = s->sibling)
;
s->sibling = f;
}
}
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
linemap_add (line_table, reason, false, f->filename, 1); linemap_add (line_table, reason, false, f->filename, 1);
...@@ -1331,7 +1390,6 @@ preprocessor_line (char *c) ...@@ -1331,7 +1390,6 @@ preprocessor_line (char *c)
if (flag[1]) /* Starting new file. */ if (flag[1]) /* Starting new file. */
{ {
f = get_file (filename, LC_RENAME); f = get_file (filename, LC_RENAME);
f->up = current_file;
current_file = f; current_file = f;
} }
...@@ -1499,7 +1557,6 @@ load_file (const char *filename, bool initial) ...@@ -1499,7 +1557,6 @@ load_file (const char *filename, bool initial)
/* Load the file. */ /* Load the file. */
f = get_file (filename, initial ? LC_RENAME : LC_ENTER); f = get_file (filename, initial ? LC_RENAME : LC_ENTER);
f->up = current_file;
current_file = f; current_file = f;
current_file->line = 1; current_file->line = 1;
line = NULL; line = NULL;
......
2007-12-05 Jakub Jelinek <jakub@redhat.com>
PR debug/33739
* gfortran.dg/debug_2.f: New test.
2007-12-05 Eric Botcazou <ebotcazou@adacore.com> 2007-12-05 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/specs/elab1.ads: New test. * gnat.dg/specs/elab1.ads: New test.
# 1 "debug_2.F"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "debug_2.F"
# 3 "debug_2.inc1" 1
# 4 "debug_2.inc2" 1
! The above lines must be present as is.
! PR fortran/34084
! { dg-do compile }
! { dg-options "-g" }
subroutine foo
end subroutine foo
# 4 "debug_2.inc1" 2
# 2 "debug_2.F" 2
program bar
end program bar
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment