* [RFA] gdbadmin/ss/gdb_ari.sh update UCASE rule
@ 2009-04-14 21:49 Pierre Muller
2009-04-15 7:25 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Pierre Muller @ 2009-04-14 21:49 UTC (permalink / raw)
To: gdb-patches
The current UCASE rule
triggers lost of false warnings
as for instance
gdb/breakpoint.c:8522: code: UCASE function: Function name is uppercase.
gdb/breakpoint.c:8520: /* Create a vector of all tracepoints. */
gdb/breakpoint.c:8521:
gdb/breakpoint.c:8522: VEC(breakpoint_p) *
gdb/breakpoint.c:8523: all_tracepoints ()
gdb/breakpoint.c:8524: {
I propose a rule that only looks for:
a function name starting with a capital letter at the start
of the line, followed by a open brace, optionally parameters, a closing
brace
and nothing else (apart from spaces)
This decreases the number of UCASE code warnings from 66 to 15.
The test is still not perfect but at least,
most VEC.* related problems are gone.
Is this OK?
Pierre Muller
Pascal language support maintainer for GDB
Index: gdb_ari.sh
===================================================================
RCS file: /cvs/gdbadmin/ss/gdb_ari.sh,v
retrieving revision 1.85
diff -u -r1.85 gdb_ari.sh
--- gdb_ari.sh 14 Apr 2009 21:19:19 -0000 1.85
+++ gdb_ari.sh 14 Apr 2009 21:42:28 -0000
@@ -461,7 +461,7 @@
Function name is uppercase."
category["UCASE function"] = ari_code
}
-/^[A-Z][[:alnum:]_]*[[:space:]]*\(/ {
+/^[A-Z][[:alnum:]_]*[[:space:]]*\([^()]*\)[[:space:]]*$/ {
if (is_yacc_or_lex == 0) {
fail("UCASE function")
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] gdbadmin/ss/gdb_ari.sh update UCASE rule
2009-04-14 21:49 [RFA] gdbadmin/ss/gdb_ari.sh update UCASE rule Pierre Muller
@ 2009-04-15 7:25 ` Eli Zaretskii
2009-04-20 16:01 ` [PATCH] gdbadmin/ss/gdb_ari.sh modify editCase/UCASE rules Pierre Muller
0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2009-04-15 7:25 UTC (permalink / raw)
To: Pierre Muller; +Cc: gdb-patches
> From: "Pierre Muller" <muller@ics.u-strasbg.fr>
> Date: Tue, 14 Apr 2009 23:49:33 +0200
>
> The current UCASE rule
> triggers lost of false warnings
> as for instance
>
> gdb/breakpoint.c:8522: code: UCASE function: Function name is uppercase.
>
> gdb/breakpoint.c:8520: /* Create a vector of all tracepoints. */
> gdb/breakpoint.c:8521:
> gdb/breakpoint.c:8522: VEC(breakpoint_p) *
> gdb/breakpoint.c:8523: all_tracepoints ()
> gdb/breakpoint.c:8524: {
>
> I propose a rule that only looks for:
> a function name starting with a capital letter at the start
> of the line, followed by a open brace, optionally parameters, a closing
> brace and nothing else (apart from spaces)
Wouldn't it be better to apply this test only on lines immediately
preceding a line that begins with a left brace? I believe we already
have a rule whereby each function needs to begin as follows:
TYPE
NAME (PARAMETERS)
{
So we want to have the second line, and only that line, be subject to
the "UCASE function" test, right? The false positive that you are
trying to resolve trips on the first line, which is not what we want.
OTOH, the replacement you suggest:
> -/^[A-Z][[:alnum:]_]*[[:space:]]*\(/ {
> +/^[A-Z][[:alnum:]_]*[[:space:]]*\([^()]*\)[[:space:]]*$/ {
seems to catch cases such
NAME (PARAMETERS)
without any context, so it could easily trip on unrelated source
lines, because it does not guarantee that this is a function
definition.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] gdbadmin/ss/gdb_ari.sh modify editCase/UCASE rules
2009-04-15 7:25 ` Eli Zaretskii
@ 2009-04-20 16:01 ` Pierre Muller
2009-04-20 17:15 ` Andreas Schwab
0 siblings, 1 reply; 4+ messages in thread
From: Pierre Muller @ 2009-04-20 16:01 UTC (permalink / raw)
To: 'Eli Zaretskii'; +Cc: gdb-patches
Following Eli's suggestion
I rewrote the editCase/UCASE awk script
to only catch real function implementations.
It seems to only catch real cases, at least for editCase.
The only risk is that it doesn't find function, if the
do not follow the rule of having the open brace at next line.
Pierre Muller
Pascal language support maintainer for GDB
trying to improve the gdb ARI script.
PS: tell me if I am wrong, but I had to use
/complicated pattern/ {
instructions for match
}
! /same complicated pattern/ {
instructions if no match
}
"else" does not seem to accepted at that level in gawk.
Committed patch:
Index: gdb_ari.sh
===================================================================
RCS file: /cvs/gdbadmin/ss/gdb_ari.sh,v
retrieving revision 1.88
diff -r1.88 gdb_ari.sh
181a182,183
> possible_UCASE = 0
> possible_editCase = 0
466,468c468,479
< /^[A-Z][[:alnum:]_]*[[:space:]]*\(/ {
< if (is_yacc_or_lex == 0) {
< fail("UCASE function")
---
> /^[A-Z][[:alnum:]_]*[[:space:]]*\([^()]*\)[[:space:]]*$/ {
> possible_UCASE = 1
> possible_FNR = FNR
> }
> ! /^[A-Z][[:alnum:]_]*[[:space:]]*\([^()]*\)[[:space:]]*$/ {
> if (possible_UCASE == 1) {
> if (($0 ~ /^\{/) && (is_yacc_or_lex == 0)) {
> store_FNR = FNR
> FNR = possible_FNR
> fail("UCASE function")
> FNR = store_FNR
> }
469a481
> possible_UCASE = 0
476,478c488,499
< /^[a-z][a-z0-9_]*[A-Z][a-z0-9A-Z_]*[[:space:]]*\(/ {
< if (is_yacc_or_lex == 0) {
< fail("editCase function")
---
> /^[a-z][a-z0-9_]*[A-Z][a-z0-9A-Z_]*[[:space:]]*\([^()]*\)[[:space:]]*$/ {
> possible_editCase = 1
> possible_FNR = FNR
> }
> ! /^[a-z][a-z0-9_]*[A-Z][a-z0-9A-Z_]*[[:space:]]*\([^()]*\)[[:space:]]*$/
{
> if (possible_editCase == 1) {
> if (($0 ~ /^\{/) && (is_yacc_or_lex == 0)) {
> store_FNR = FNR
> FNR = possible_FNR
> fail("editCase function")
> FNR = store_FNR
> }
479a501
> possible_editCase = 0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gdbadmin/ss/gdb_ari.sh modify editCase/UCASE rules
2009-04-20 16:01 ` [PATCH] gdbadmin/ss/gdb_ari.sh modify editCase/UCASE rules Pierre Muller
@ 2009-04-20 17:15 ` Andreas Schwab
0 siblings, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2009-04-20 17:15 UTC (permalink / raw)
To: Pierre Muller; +Cc: 'Eli Zaretskii', gdb-patches
"Pierre Muller" <muller@ics.u-strasbg.fr> writes:
> PS: tell me if I am wrong, but I had to use
> /complicated pattern/ {
> instructions for match
> }
> ! /same complicated pattern/ {
> instructions if no match
> }
You can put the match test in the action part:
{ if (/complicated pattern/) {
instructions for match
}
else {
instructions if no match
}
}
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-04-20 17:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-14 21:49 [RFA] gdbadmin/ss/gdb_ari.sh update UCASE rule Pierre Muller
2009-04-15 7:25 ` Eli Zaretskii
2009-04-20 16:01 ` [PATCH] gdbadmin/ss/gdb_ari.sh modify editCase/UCASE rules Pierre Muller
2009-04-20 17:15 ` Andreas Schwab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox