This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, Fortran] PR 34153 - Allow setting a breakpoint in the END PROGRAM/SUBROUTE line
- From: Tobias Burnus <burnus at net-b dot de>
- To: "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 12 May 2009 23:54:19 +0200
- Subject: [Patch, Fortran] PR 34153 - Allow setting a breakpoint in the END PROGRAM/SUBROUTE line
Hello all,
debugging of code such as
subroutine foo(x)
external
integer, intent(out) :: x
x = f()
! some comment
end subroutine foo
had the problem that you could not set a break pointer after "x = f(x)".
And then a "step" would return into the calling procedure - thus one
could not "print x" after the assignment.
The problem became clear for the short program
subroutine foo()
end subroutine foo
using "readelf --debug-dump=decodedline". The result was:
File name Line number Starting address
test.f90 1 0
test.f90 1 0x4
while "ifort" had the line numbers "1" and "2". The problem is that the
input_line remained at "subroutine foo()" instead of jumping to "end
subroutine foo()". The simplest solution for me was too add the new
EXEC_END_PROCEDURE which is a NOOP but sets in trans.c the line number.
Bootstrapped and being regtested on x86-64-linux. OK for the trunk?
Tobias
PS: Please note that the compiler is to aggressive with -O0 and thus
printing "i" for the original example in the bugreport will not work as
the assignment is optimized away ... (Ditto for the analogous C program.)
2009-05-12 Tobias Burnus <burnus@net-b.de>
PR fortran/34153
* gfortran.h (gfc_exec_op): Add EXEC_END_PROCEDURE.
* dump-parse-tree.c (show_code_node): Use EXEC_END_PROCEDURE.
* trans.c (gfc_trans_code): Ditto.
* resolve.c (resolve_code): Ditto.
* st.c (gfc_free_statement): Ditto.
* parse.c (accept_statement): Ditto.
Index: gcc/fortran/dump-parse-tree.c
===================================================================
--- gcc/fortran/dump-parse-tree.c (Revision 147445)
+++ gcc/fortran/dump-parse-tree.c (Arbeitskopie)
@@ -1148,6 +1148,9 @@ show_code_node (int level, gfc_code *c)
switch (c->op)
{
+ case EXEC_END_PROCEDURE:
+ break;
+
case EXEC_NOP:
fputs ("NOP", dumpfile);
break;
Index: gcc/fortran/gfortran.h
===================================================================
--- gcc/fortran/gfortran.h (Revision 147445)
+++ gcc/fortran/gfortran.h (Arbeitskopie)
@@ -1893,7 +1893,7 @@ typedef enum
EXEC_ENTRY, EXEC_PAUSE, EXEC_STOP, EXEC_CONTINUE, EXEC_INIT_ASSIGN,
EXEC_IF, EXEC_ARITHMETIC_IF, EXEC_DO, EXEC_DO_WHILE, EXEC_SELECT,
EXEC_FORALL, EXEC_WHERE, EXEC_CYCLE, EXEC_EXIT, EXEC_CALL_PPC,
- EXEC_ALLOCATE, EXEC_DEALLOCATE,
+ EXEC_ALLOCATE, EXEC_DEALLOCATE, EXEC_END_PROCEDURE,
EXEC_OPEN, EXEC_CLOSE, EXEC_WAIT,
EXEC_READ, EXEC_WRITE, EXEC_IOLENGTH, EXEC_TRANSFER, EXEC_DT_END,
EXEC_BACKSPACE, EXEC_ENDFILE, EXEC_INQUIRE, EXEC_REWIND, EXEC_FLUSH,
Index: gcc/fortran/trans.c
===================================================================
--- gcc/fortran/trans.c (Revision 147445)
+++ gcc/fortran/trans.c (Arbeitskopie)
@@ -1056,6 +1056,7 @@ gfc_trans_code (gfc_code * code)
{
case EXEC_NOP:
case EXEC_END_BLOCK:
+ case EXEC_END_PROCEDURE:
res = NULL_TREE;
break;
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c (Revision 147445)
+++ gcc/fortran/resolve.c (Arbeitskopie)
@@ -6938,6 +6938,7 @@ resolve_code (gfc_code *code, gfc_namesp
break;
case EXEC_INIT_ASSIGN:
+ case EXEC_END_PROCEDURE:
break;
case EXEC_ASSIGN:
Index: gcc/fortran/st.c
===================================================================
--- gcc/fortran/st.c (Revision 147445)
+++ gcc/fortran/st.c (Arbeitskopie)
@@ -94,6 +94,7 @@ gfc_free_statement (gfc_code *p)
case EXEC_GOTO:
case EXEC_CYCLE:
case EXEC_RETURN:
+ case EXEC_END_PROCEDURE:
case EXEC_IF:
case EXEC_PAUSE:
case EXEC_STOP:
Index: gcc/fortran/parse.c
===================================================================
--- gcc/fortran/parse.c (Revision 147445)
+++ gcc/fortran/parse.c (Arbeitskopie)
@@ -1496,6 +1496,11 @@ accept_statement (gfc_statement st)
new_st.op = EXEC_RETURN;
add_statement ();
}
+ else
+ {
+ new_st.op = EXEC_END_PROCEDURE;
+ add_statement ();
+ }
break;