This is the mail archive of the gdb-patches@sourceware.org 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]
Other format: [Raw text]

Patch: fix #line directives in bison output


I am checking this in.

This is another patch we've been carrying in Fedora for quite some time.

Right now the #line directives in a .c file created from a .y file are
rewritten by ylwrap to not have any directory information.  Due to how
the Makefile rule is written, the .c file also refers to the .tmp file
as well.  This is not very nice for debugging; it is better to use the
real source paths.

This patch fixes these problems.

Due to how the new rule is written, I had to remove the .PHONY targets
referring to the intermediate .c files.  I tested this in various ways
(including inserting sleeps and C-c'ing make) and as far as I can tell
it works just as well this way.

Tom

2010-11-19  Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Tom Tromey  <tromey@redhat.com>

	* Makefile.in (.y.c): Directly create $@ from YLWRAP.
	(.PHONY): Remove for .y outputs.

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.1139
diff -u -r1.1139 Makefile.in
--- Makefile.in	5 Nov 2010 14:31:25 -0000	1.1139
+++ Makefile.in	19 Nov 2010 18:09:47 -0000
@@ -1615,8 +1615,10 @@
 
 .SUFFIXES: .y .l
 .y.c:
-	$(SHELL) $(YLWRAP) $< y.tab.c $@.tmp -- $(YACC) $(YFLAGS)
-	-sed -e '/extern.*malloc/d' \
+	rm -f $@ $@.tmp
+	$(SHELL) $(YLWRAP) $< y.tab.c $@ -- $(YACC) $(YFLAGS) && mv $@ $@.tmp \
+		|| (rm -f $@; false)
+	sed -e '/extern.*malloc/d' \
 	     -e '/extern.*realloc/d' \
 	     -e '/extern.*free/d' \
 	     -e '/include.*malloc.h/d' \
@@ -1625,9 +1627,9 @@
 	     -e 's/\([ \t;,(]\)free\([ \t]*[&(),]\)/\1xfree\2/g' \
 	     -e 's/\([ \t;,(]\)free$$/\1xfree/g' \
 	     -e '/^#line.*y.tab.c/d' \
-	  < $@.tmp > $@.new
-	-rm $@.tmp
-	mv $@.new ./$*.c
+	     -e "s/^\(#line.*\)`basename $<`/\1`echo $<|sed 's/\//\\\\\//g'`/" \
+	  < $@.tmp > $@
+	rm -f $@.tmp
 .l.c:
 	if [ "$(FLEX)" ] && $(FLEX) --version >/dev/null 2>&1; then \
 	    $(FLEX) -o$@ $< && \
@@ -1651,13 +1653,7 @@
 	    false; \
 	fi
 
-.PRECIOUS: ada-exp.c ada-lex.c
-.PRECIOUS: c-exp.c
-.PRECIOUS: f-exp.c
-.PRECIOUS: jv-exp.c
-.PRECIOUS: m2-exp.c
-.PRECIOUS: objc-exp.c
-.PRECIOUS: p-exp.c
+.PRECIOUS: ada-exp.c
 
 # XML rules
 


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