From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26934 invoked by alias); 20 Oct 2013 13:17:24 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 26908 invoked by uid 89); 20 Oct 2013 13:17:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.3 required=5.0 tests=AWL,BAYES_20,MSGID_MULTIPLE_AT autolearn=no version=3.3.2 X-HELO: mailhost.u-strasbg.fr Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.222.218) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 20 Oct 2013 13:17:20 +0000 Received: from mailhost.u-strasbg.fr (localhost [127.0.0.1]) by antispam (Postfix) with ESMTP id EFD5F2215B5; Sun, 20 Oct 2013 15:17:16 +0200 (CEST) Received: from mailhost.u-strasbg.fr (localhost [127.0.0.1]) by antivirus (Postfix) with ESMTP id DE4E12218D3; Sun, 20 Oct 2013 15:17:16 +0200 (CEST) Received: from md16.u-strasbg.fr (md16.u-strasbg.fr [130.79.200.206]) by mr8.u-strasbg.fr (Postfix) with ESMTP id 815732215B5; Sun, 20 Oct 2013 15:17:12 +0200 (CEST) Received: from ms12.u-strasbg.fr (ms12.u-strasbg.fr [130.79.204.112]) by md16.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id r9KDHBCk031904 ; Sun, 20 Oct 2013 15:17:11 +0200 (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (lec67-4-82-230-53-140.fbx.proxad.net [82.230.53.140]) (Authenticated sender: mullerp) by ms12.u-strasbg.fr (Postfix) with ESMTPSA id 72B2A1FD92; Sun, 20 Oct 2013 15:17:07 +0200 (CEST) From: "Pierre Muller" To: "'Jan Kratochvil'" , "'Keith Seitz'" Cc: , "'Sergio Durigan Junior'" References: <5249C987.50809@redhat.com> <87d2no4uim.fsf@fleche.redhat.com> <524BA344.2070802@redhat.com> <20131016095743.GA17072@host2.jankratochvil.net> <52602A08.4020705@redhat.com> <20131018193445.GA12496@host2.jankratochvil.net> In-Reply-To: <20131018193445.GA12496@host2.jankratochvil.net> Subject: RE: Regression for gdb.pascal/* [Re: [RFA 4/4] Constify parse_linesepc] Date: Sun, 20 Oct 2013 13:17:00 -0000 Message-ID: <008901cecd96$adc96ad0$095c4070$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-SW-Source: 2013-10/txt/msg00606.txt.bz2 > -----Message d'origine----- > De=A0: gdb-patches-owner@sourceware.org [mailto:gdb-patches- > owner@sourceware.org] De la part de Jan Kratochvil > Envoy=E9=A0: vendredi 18 octobre 2013 21:35 > =C0=A0: Keith Seitz > Cc=A0: gdb-patches@sourceware.org ml; Sergio Durigan Junior > Objet=A0: Re: Regression for gdb.pascal/* [Re: [RFA 4/4] Constify > parse_linesepc] >=20 > On Thu, 17 Oct 2013 20:18:48 +0200, Keith Seitz wrote: > > There are two little sections of code, though, which violate > > const-ness of the input, and I've removed those, since they don't > > seem necessary. [This is the two loops that deal with changing the > > case of `tokstart' -- which can easily be removed because we already > > have a temporary buffer that is used for this.] > > > > I could not think of any reasons why pascal_lex would need to change > > the input. The only thing that came to mind was completion, and the > > behavior for that is, as far as I can tell, identical to how 7.0, > > 7.3, 7.4, 7.5, and 7.6 behave. [both case-sensitive 'on' and 'off'] >=20 > Maybe we could juse use > [pascal patch] Use case_sensitive_off [Re: Regression for > gdb.pascal/* [Re: [RFA 4/4] Constify parse_linesepc]] > https://sourceware.org/ml/gdb-patches/2013-10/msg00581.html >=20 > and forget about all the case changes then. >=20 >=20 > > @@ -1369,11 +1368,8 @@ yylex (void) > > break; > > case '\\': > > { > > - const char *s, *o; > > - > > - o =3D s =3D ++tokptr; > > - c =3D parse_escape (parse_gdbarch, &s); > > - *tokptr +=3D s - o; > > + ++tokptr; > > + c =3D parse_escape (parse_gdbarch, &tokptr); > > if (c =3D=3D -1) > > { > > continue; >=20 > coding/patch style: > This change is a bit unfortunate that together with your previous patch it > just reformats the code, moreover not simplifying it. >=20 >=20 > diff --git a/gdb/p-exp.y b/gdb/p-exp.y > index da8d5f7..8cb98c0 100644 > --- a/gdb/p-exp.y > +++ b/gdb/p-exp.y > @@ -1361,13 +1367,15 @@ yylex (void) > /* Do nothing, loop will terminate. */ > break; > case '\\': > - tokptr++; > - c =3D parse_escape (parse_gdbarch, &tokptr); > - if (c =3D=3D -1) > - { > - continue; > - } > - tempbuf[tempbufindex++] =3D c; > + { > + ++tokptr; > + c =3D parse_escape (parse_gdbarch, &tokptr); > + if (c =3D=3D -1) > + { > + continue; > + } > + tempbuf[tempbufindex++] =3D c; > + } > break; > default: > tempbuf[tempbufindex++] =3D *tokptr++; >=20 >=20 > Pierre's reply would be great to check in the case changes removal with the > case_sensitive_off patch. Otherwise it is not clear to me it is safe. Just a quick reply to tell you that I did read this thread, and that I am quite lost in the parser/completion coupling ... I did see indeed problems related to access of alloca'ted=20 memory outside the function in current trunk. But I don't understand anymore how completion works=20 in context of language expression parser. The completion doesn't seem to work at all anymore for pascal language, but it does work correctly for C language, and I did not yet understand why it behaves differently... I also found some internal error generated by the pascal expression parser triggered if you try to print out a non-existing field=20 of a record (struct in C language) or object/class... I at least managed to get completion to work partially again with the patch below... I hope I will be able to really understand the whole problem... Pierre =20 Index: p-exp.y =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/p-exp.y,v retrieving revision 1.69 diff -u -p -r1.69 p-exp.y --- p-exp.y 2 Oct 2013 00:46:06 -0000 1.69 +++ p-exp.y 20 Oct 2013 11:34:34 -0000 @@ -125,7 +125,7 @@ static int yylex (void); =20 void yyerror (char *); =20 -static char * uptok (char *, int); +static char *uptok (const char *, int); %} =20 /* Although the yacc "value" of an expression is not used, @@ -316,8 +316,7 @@ exp : field_exp FIELDNAME =20 =20 exp : field_exp name - { mark_struct_expression (); - write_exp_elt_opcode (STRUCTOP_STRUCT); + { write_exp_elt_opcode (STRUCTOP_STRUCT); write_exp_string ($2); write_exp_elt_opcode (STRUCTOP_STRUCT); search_field =3D 0; @@ -332,7 +331,12 @@ exp : field_exp name } } ; - +exp : field_exp name COMPLETE + { mark_struct_expression (); + write_exp_elt_opcode (STRUCTOP_STRUCT); + write_exp_string ($2); + write_exp_elt_opcode (STRUCTOP_STRUCT); } + ; exp : field_exp COMPLETE { struct stoken s; mark_struct_expression (); @@ -1105,7 +1109,7 @@ static const struct token tokentab2[] =3D /* Allocate uppercased var: */ /* make an uppercased copy of tokstart. */ static char * -uptok (char *tokstart, int namelen) +uptok (const char *tokstart, int namelen) { int i; char *uptokstart =3D (char *)malloc(namelen+1); @@ -1120,11 +1124,6 @@ uptok (char *tokstart, int namelen) return uptokstart; } =20 -/* This is set if the previously-returned token was a structure - operator '.'. This is used only when parsing to - do field name completion. */ -static int last_was_structop; - /* Read one token, getting characters through lexptr. */ =20 static int @@ -1133,22 +1132,19 @@ yylex (void) int c; int namelen; unsigned int i; - char *tokstart; + const char *tokstart; char *uptokstart; - char *tokptr; + const char *tokptr; int explen, tempbufindex; static char *tempbuf; static int tempbufsize; - int saw_structop =3D last_was_structop; =20 - last_was_structop =3D 0; retry: =20 prev_lexptr =3D lexptr; =20 + tokstart =3D lexptr; explen =3D strlen (lexptr); - tokstart =3D alloca (explen + 1); - memcpy (tokstart, lexptr, explen + 1); =20 /* See if it is a special token of length 3. */ if (explen > 2) @@ -1179,7 +1175,7 @@ yylex (void) switch (c =3D *tokstart) { case 0: - if (saw_structop && search_field) + if (search_field && parse_completion) return COMPLETE; else return 0; @@ -1244,8 +1240,6 @@ yylex (void) /* Might be a floating point number. */ if (lexptr[1] < '0' || lexptr[1] > '9') { - if (parse_completion) - last_was_structop =3D 1; goto symbol; /* Nope, must be a symbol. */ } =20 @@ -1264,7 +1258,7 @@ yylex (void) { /* It's a number. */ int got_dot =3D 0, got_e =3D 0, toktype; - char *p =3D tokstart; + const char *p =3D tokstart; int hex =3D input_radix > 10; =20 if (c =3D=3D '0' && (p[1] =3D=3D 'x' || p[1] =3D=3D 'X')) @@ -1369,11 +1363,8 @@ yylex (void) break; case '\\': { - const char *s, *o; - - o =3D s =3D ++tokptr; - c =3D parse_escape (parse_gdbarch, &s); - *tokptr +=3D s - o; + ++tokptr; + c =3D parse_escape (parse_gdbarch, &tokptr); if (c =3D=3D -1) { continue; @@ -1511,17 +1502,17 @@ yylex (void) =20 if (*tokstart =3D=3D '$') { - char c; + char *tmp; + /* $ is the normal prefix for pascal hexadecimal values but this conflicts with the GDB use for debugger variables so in expression to enter hexadecimal values we still need to use C syntax with 0xff */ write_dollar_variable (yylval.sval); - c =3D tokstart[namelen]; - tokstart[namelen] =3D 0; - intvar =3D lookup_only_internalvar (++tokstart); - --tokstart; - tokstart[namelen] =3D c; + tmp =3D alloca (namelen + 1); + memcpy (tmp, tokstart, namelen); + tmp[namelen] =3D '\0'; + intvar =3D lookup_only_internalvar (tmp + 1); free (uptokstart); return VARIABLE; } @@ -1541,7 +1532,7 @@ yylex (void) =20 if (search_field && current_type) is_a_field =3D (lookup_struct_elt_type (current_type, tmp, 1) !=3D N= ULL); - if (is_a_field || parse_completion) + if (is_a_field/* || parse_completion*/) sym =3D NULL; else sym =3D lookup_symbol (tmp, expression_context_block, @@ -1556,17 +1547,11 @@ yylex (void) } if (search_field && current_type) is_a_field =3D (lookup_struct_elt_type (current_type, tmp, 1) !=3D NULL); - if (is_a_field || parse_completion) + if (is_a_field /*|| parse_completion*/) sym =3D NULL; else sym =3D lookup_symbol (tmp, expression_context_block, VAR_DOMAIN, &is_a_field_of_this); - if (sym || is_a_field_of_this.type !=3D NULL || is_a_field) - for (i =3D 0; i <=3D namelen; i++) - { - if ((tokstart[i] >=3D 'a' && tokstart[i] <=3D 'z')) - tokstart[i] -=3D ('a'-'A'); - } } /* Third chance Capitalized (as GPC does). */ if (!sym && is_a_field_of_this.type =3D=3D NULL && !is_a_field) @@ -1584,29 +1569,18 @@ yylex (void) } if (search_field && current_type) is_a_field =3D (lookup_struct_elt_type (current_type, tmp, 1) !=3D NULL); - if (is_a_field || parse_completion) + if (is_a_field /*|| parse_completion*/) sym =3D NULL; else sym =3D lookup_symbol (tmp, expression_context_block, VAR_DOMAIN, &is_a_field_of_this); - if (sym || is_a_field_of_this.type !=3D NULL || is_a_field) - for (i =3D 0; i <=3D namelen; i++) - { - if (i =3D=3D 0) - { - if ((tokstart[i] >=3D 'a' && tokstart[i] <=3D 'z')) - tokstart[i] -=3D ('a'-'A'); - } - else - if ((tokstart[i] >=3D 'A' && tokstart[i] <=3D 'Z')) - tokstart[i] -=3D ('A'-'a'); - } } =20 if (is_a_field) { tempbuf =3D (char *) realloc (tempbuf, namelen + 1); - strncpy (tempbuf, tokstart, namelen); tempbuf [namelen] =3D 0; + strncpy (tempbuf, tmp, namelen); + tempbuf [namelen] =3D 0; yylval.sval.ptr =3D tempbuf; yylval.sval.length =3D namelen; free (uptokstart);