This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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]

Re: #line numbers in insn-recog.c


On Wed, May 03, 2006 at 12:29:17PM +0200, Bernd Schmidt wrote:
> Does anyone find the use of #line in insn-recog.c actually useful?  It 
> seems to make debugging recog() impossible.

Try this patch. It adds #line directives to insn-recog.c and other generated
files to revert the ones already there. It should improve debugging. A few
notes, though:

1) The line numbers are limited to 32767. I simply haven't found a trivially
easy way of fixing that.
2) The change to genrecog.c was added when I saw your message.
3) No testing on other backends than i386 and my ongoing i8086 one.
4) Lines longer than 80 chars.
5) The paperwork isn't done yet.


Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(revision 112877)
+++ gcc/Makefile.in	(working copy)
@@ -2711,7 +2713,9 @@
 $(simple_generated_c:insn-%.c=s-%): s-%: build/gen%$(build_exeext) \
   $(MD_DEPS) insn-conditions.md
 	$(RUN_GEN) build/gen$*$(build_exeext) $(md_file) \
-	  insn-conditions.md > tmp-$*.c
+	  insn-conditions.md \
+	  | awk '/^LINE$$/ { if (FNR < 32767) print "#line", FNR + 1, "\"'$(objdir)'/insn-'$*'.c\""; next; } { print; }' \
+	  > tmp-$*.c
 	$(SHELL) $(srcdir)/../move-if-change tmp-$*.c insn-$*.c
 	$(STAMP) s-$*
 
@@ -2786,7 +2790,9 @@
 tm-constrs.h: s-constrs-h; @true
 
 s-preds: $(MD_DEPS) build/genpreds$(build_exeext)
-	$(RUN_GEN) build/genpreds$(build_exeext) $(md_file) > tmp-preds.c
+	$(RUN_GEN) build/genpreds$(build_exeext) $(md_file) \
+	  | awk '/^LINE$$/ { if (FNR < 32767) print "#line", FNR + 1, "\"'$(objdir)'/insn-preds.c\""; next; } { print; }' \
+	  > tmp-preds.c
 	$(SHELL) $(srcdir)/../move-if-change tmp-preds.c insn-preds.c
 	$(STAMP) s-preds
 
@@ -2796,7 +2802,9 @@
 	$(STAMP) s-preds-h
 
 s-constrs-h: $(MD_DEPS) build/genpreds$(build_exeext)
-	$(RUN_GEN) build/genpreds$(build_exeext) -c $(md_file) > tmp-constrs.h
+	$(RUN_GEN) build/genpreds$(build_exeext) -c $(md_file) \
+	  | awk '/^LINE$$/ { if (FNR < 32767) print "#line", FNR + 1, "\"'$(objdir)'/tm-constrs.h\""; next; } { print; }' \
+	  > tmp-constrs.h
 	$(SHELL) $(srcdir)/../move-if-change tmp-constrs.h tm-constrs.h
 	$(STAMP) s-constrs-h
 
Index: gcc/genattrtab.c
===================================================================
--- gcc/genattrtab.c	(revision 112877)
+++ gcc/genattrtab.c	(working copy)
@@ -3770,7 +3770,7 @@
 	  printf ("%sif ", first_if ? "" : "else ");
 	  first_if = 0;
 	  write_test_expr (testexp, 0);
-	  printf ("\n");
+	  printf ("\nLINE\n");
 	  write_indent (indent + 2);
 	  printf ("{\n");
 
Index: gcc/genemit.c
===================================================================
--- gcc/genemit.c	(revision 112877)
+++ gcc/genemit.c	(working copy)
@@ -511,6 +511,7 @@
 	 is generated.  */
       print_rtx_ptr_loc (XSTR (expand, 3));
       printf ("%s\n", XSTR (expand, 3));
+      puts ("LINE");
 
       /* Output code to copy the arguments back out of `operands'
 	 (unless we aren't going to use them at all).  */
@@ -634,6 +635,7 @@
     {
       print_rtx_ptr_loc (XSTR (split, 3));
       printf ("%s\n", XSTR (split, 3));
+      puts ("LINE");
     }
 
   /* Output code to copy the arguments back out of `operands'  */
Index: gcc/genoutput.c
===================================================================
--- gcc/genoutput.c	(revision 112877)
+++ gcc/genoutput.c	(working copy)
@@ -674,6 +674,7 @@
       puts ("{");
       print_rtx_ptr_loc (template);
       puts (template + 1);
+      puts ("LINE");
       puts ("}");
     }
 
Index: gcc/genpreds.c
===================================================================
--- gcc/genpreds.c	(revision 112877)
+++ gcc/genpreds.c	(working copy)
@@ -188,7 +188,7 @@
     fputs (p->c_block, stdout);
   else
     printf ("{\n  %s\n}", p->c_block);
-  fputs ("\n\n", stdout);
+  fputs ("\nLINE\n\n", stdout);
 }
 
 /* Given a predicate expression EXP, from form NAME, determine whether
@@ -536,7 +536,7 @@
 	  "{\n  return ",
 	  p->name);
   write_predicate_expr (p->exp);
-  fputs (";\n}\n\n", stdout);
+  fputs (";\nLINE\n}\n\n", stdout);
 }
 
 /* Constraints fall into two categories: register constraints
@@ -998,7 +998,7 @@
 	  
 	fputs ("  return ", stdout);
 	write_predicate_expr (c->exp);
-	fputs (";\n}\n", stdout);
+	fputs (";\nLINE\n}\n", stdout);
       }
   puts ("#endif /* tm-constrs.h */");
 }
@@ -1049,7 +1049,7 @@
       {
 	printf ("    case CONSTRAINT_%s:\n      return ", c->c_name);
 	write_predicate_expr (c->exp);
-	fputs (";\n\n", stdout);
+	fputs (";\nLINE\n\n", stdout);
       }
 
   puts ("    default: break;\n"
Index: gcc/genrecog.c
===================================================================
--- gcc/genrecog.c	(revision 112877)
+++ gcc/genrecog.c	(working copy)
@@ -2129,6 +2129,7 @@
 
     case DT_c_test:
       print_c_condition (p->u.c_test);
+      puts ("\nLINE");
       break;
 
     case DT_accept_insn:


-- 
Rask Ingemann Lambertsen


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