From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 9D2643857C7B for ; Tue, 12 Nov 2024 13:07:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9D2643857C7B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9D2643857C7B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731416845; cv=none; b=g9f/774swHIGvDKVECuUvLqJgY5EXgffrY+EdgUgco+maN6IcbPrUth8PaZZf1gNp7QuXx5JLPUM7kfyFc94cdTJ+r9COqyr+L+KLqgGDDwWMGdpI0u9O7IMiNLHxILhOyKFZKrqK4cSf9FJG2LAGM6YnvfmVUwQBhLjS6WRnMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731416845; c=relaxed/simple; bh=7qccm+vjXuiuAprtwRxNdKkXVvtA7WQvl0uyd4c38OM=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:From:To; b=K1PmQi0nB5b/OjhlUKF4FHhyyze4UrdZDoB6XR0whNx00idgBDnFzWcZHyb0T+5YRsXYCZH1kyr/3J80sRtyIqeGX2jVFxEjQjvZmPDJ8xxHQecdNDUNbMnB6CxYoZZiI+6b7zHeLa3m2Tm6Zq5KNAdjEqWyu0C4C1b686Al3KE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 608111F451; Tue, 12 Nov 2024 13:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1731416841; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sja+KfUU8fKRrNOJiD1VmBjDpJzySpzqOYTSTdH9wYU=; b=Y4Fh/DRE+IUCgot1S+RACkIDFTBrpM/nlYrm/ttHAi3GBel9l4OHbFkeW00uZGKOLNJBc7 bhdgd18dzbnvi0/eKjXts0bHwbFo+scwmJDKDa0UUgST//grQhQyUQGy5brgEq8L6DSJDM AdHmAbQWK1RmENgNrdeHBmw2GrBNgrU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1731416841; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sja+KfUU8fKRrNOJiD1VmBjDpJzySpzqOYTSTdH9wYU=; b=M1Bt0kwvf7yLCM7JDf+j9OI37Uau1ipwuAsst3LVvkNABG2aBxJ1uS/s/ebK2VRGUuDRBO RzxGDhL8zXdyN7AQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="Y4Fh/DRE"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=M1Bt0kwv DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1731416841; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sja+KfUU8fKRrNOJiD1VmBjDpJzySpzqOYTSTdH9wYU=; b=Y4Fh/DRE+IUCgot1S+RACkIDFTBrpM/nlYrm/ttHAi3GBel9l4OHbFkeW00uZGKOLNJBc7 bhdgd18dzbnvi0/eKjXts0bHwbFo+scwmJDKDa0UUgST//grQhQyUQGy5brgEq8L6DSJDM AdHmAbQWK1RmENgNrdeHBmw2GrBNgrU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1731416841; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sja+KfUU8fKRrNOJiD1VmBjDpJzySpzqOYTSTdH9wYU=; b=M1Bt0kwvf7yLCM7JDf+j9OI37Uau1ipwuAsst3LVvkNABG2aBxJ1uS/s/ebK2VRGUuDRBO RzxGDhL8zXdyN7AQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 4667913A8C; Tue, 12 Nov 2024 13:07:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id dHaVDwlTM2enZAAAD6G6ig (envelope-from ); Tue, 12 Nov 2024 13:07:21 +0000 Message-ID: Date: Tue, 12 Nov 2024 14:07:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PING][PATCH 3/3] [gdb] Add spell check pre-commit hook From: Tom de Vries To: Tom Tromey Cc: gdb-patches@sourceware.org References: <20241008074402.10374-1-tdevries@suse.de> <20241008074402.10374-3-tdevries@suse.de> <7863c1a5-e4d1-4414-a93d-ac24fbe990f6@suse.de> <87y11v147q.fsf@tromey.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 608111F451 X-Spam-Score: -4.51 X-Rspamd-Action: no action X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; MID_RHS_MATCH_FROM(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:dkim,suse.de:mid,suse.de:email]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Level: X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 11/12/24 11:15, Tom de Vries wrote: > On 11/7/24 15:57, Tom Tromey wrote: >>>>>>> "Tom" == Tom de Vries writes: >> >> Tom> I've committed the other patches from this series, but this one >> Tom> remains in review, so ... ping. >> >> Ah, now I see the others already went in. >> Totally fine of course, I just should have read the whole thread first. >> >> I am in favor of this change.  I think it's a good improvement. >> However I wonder -- how long does it take to run the script? > > It depends. > > Let's take the largest file in gdb* in terms of lines, that's gdb/doc/ > gdb.texinfo with ~51k lines: > ... > $ time ./gdb/contrib/spellcheck.sh --check gdb/doc/gdb.texinfo > > real    0m4.613s > user    0m4.405s > sys    0m0.215s > ... > > Now, let's take a small file with just 39 lines: > ... > $ time ./gdb/contrib/spellcheck.sh --check gdb/gdb.c > > real    0m0.445s > user    0m0.314s > sys    0m0.137s > ... > > This is with .git/wikipedia-common-misspellings.txt already downloaded, > and .git/spell-check.pat1.$md5sum already generated. > >> I ask because it seems like it will be run on essentially every commit. > > Agreed, speed matters for this. > >> Also, I can't recall how pre-commit works -- is the script run on the >> entire tree or just the files being modified? > > Just on the files being modified. > > [ Running it on the entire tree is slow: > > $ time ./gdb/contrib/spellcheck.sh --check gdb* > > real    1m9.906s > user    1m7.710s > sys    0m1.899s ] > > I think it may be possible to speed up the check to only check the > modified lines (see the line counter example below). > > This works for checks that don't require context, or require a fixed > amount of lines of context. > > Currently, spellcheck.sh works on line-at-a-time basis, so no context used. > > The question is, should it be sensitive to context? > > The current implementation does not differentiate between comments and > code, so when running it on directory sim we get: > ... > diff --git a/sim/arm/armsupp.c b/sim/arm/armsupp.c > index 1a5eeaff1d6..1b92a3abc3e 100644 > --- a/sim/arm/armsupp.c > +++ b/sim/arm/armsupp.c > @@ -390,9 +390,9 @@ ARMul_NthReg (ARMword instr, unsigned number) >  { >    unsigned bit, upto; > > -  for (bit = 0, upto = 0; upto <= number; bit ++) > +  for (bit = 0, up to = 0; up to <= number; bit ++) >      if (BIT (bit)) > -      upto ++; > +      up to ++; > >    return (bit - 1); >  } > ... > >> Assuming everything is ok though I think this should go in. >> Approved-By: Tom Tromey > > Thanks for the review, and I'm glad you're supporting the idea. > > I think the potential 4.5 seconds delay is too long, so I'll hold off on > committing this. > > I'll work on a --pre-commit switch that only checks modified lines, and > resubmit together with this patch. > Submitted here ( https://sourceware.org/pipermail/gdb-patches/2024-November/213249.html ). Thanks, - Tom > Patch: > ... > diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml > index 87726aeb758..0b94dcc4744 100644 > --- a/.pre-commit-config.yaml > +++ b/.pre-commit-config.yaml > @@ -22,3 +22,10 @@ repos: >      - id: isort >        types_or: [file] >        files: 'gdb/.*\.py(\.in)?$' > +  - repo: local > +    hooks: > +    - id: line-counter > +      name: line counter > +      language: script > +      entry: ./gdb/contrib/line-counter.sh > +      files: ^(gdb|gdbsupport|gdbserver)/ > diff --git a/gdb/contrib/line-counter.sh b/gdb/contrib/line-counter.sh > new file mode 100755 > index 00000000000..257ec3793bb > --- /dev/null > +++ b/gdb/contrib/line-counter.sh > @@ -0,0 +1,5 @@ > +#!/bin/sh > + > +git diff --staged > DIFF > + > +git diff --staged | egrep -v "^\+\+\+" | egrep "^\+" | wc -l >> DIFF > ... > > Example output: > ... > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > index 53f41e67444..e08ee7fb675 100644 > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -51432,6 +51432,8 @@ Richard M. Stallman and Roland H. Pesch, July 1991. > >  @printindex cp > > +BLA > + >  @node Command and Variable Index >  @unnumbered Command, Variable, and Function Index > > 2 > ...