Article View: gnu.gdb.bug
Article #393yacc problem with c-exp.y
From: Peggy Fieland
Date: Tue, 25 Aug 1992 19:38
Date: Tue, 25 Aug 1992 19:38
51 lines
2082 bytes
2082 bytes
I used gdb-4.6 on a Stratus i860 (svr4).
The version of yacc is:
yacc:Standard C Development Environment , (SCDE) 5.0 12/08/89
As the comment in c-exp.y states, the redefine of malloc and realloc
have to appear in the generated c-exp.tab.c AFTER the include of
malloc.h generated by the svr4 YACC. Unfortunately, at least
with the version of yacc on our system, the version of c-exp.y distributed
with gdb-4.6 generates them in the wrong order as the following
error message from the make demonstrates:
cc -c -g -I. -I. -I./../include -I./../readline c-exp.tab.c
"/usr/include/malloc.h", line 46: identifier redeclared: xmalloc
"/usr/include/malloc.h", line 48: identifier redeclared: xrealloc
The fix is to include the redefinition at the TOP of the rules
section rather than at the BOTTOM of the declaration section, as
it seems that yacc is generating the includes when the declaration
section is finished. Here is a fix:
diff -c /home/tools/gnu/gdb-4.6/gdb/c-exp.y gdb-4.6/gdb-4.6/gdb/c-exp.y
*** /home/tools/gnu/gdb-4.6/gdb/c-exp.y Tue Jul 14 03:34:19 1992
--- gdb-4.6/gdb-4.6/gdb/c-exp.y Tue Aug 25 15:24:03 1992
***************
*** 193,198 ****
--- 193,202 ----
%type <bval> block
%left COLONCOLON
+
+
+ %%
+
%{
/* Ensure that if the generated parser contains any calls to malloc/realloc,
that they get mapped to xmalloc/xrealloc. We have to do this here
***************
*** 204,212 ****
#define malloc xmalloc
#define realloc xrealloc
%}
-
-
- %%
start : exp1
| type_exp
--- 208,213 ----
Technical Details
Message-ID:
<9208251938.AA01011@citron.sw.stratus.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!rutgers!att!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!citron.sw.stratus.com!pfielandShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!rutgers!att!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!citron.sw.stratus.com!pfieland From: pfieland@citron.sw.stratus.com (Peggy Fieland) Newsgroups: gnu.gdb.bug Subject: yacc problem with c-exp.y Message-ID: <9208251938.AA01011@citron.sw.stratus.com> Date: 25 Aug 92 19:38:28 GMT Sender: gnulists@ai.mit.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 51 Approved: bug-gdb@prep.ai.mit.edu