From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 3sa+FtNtump41xEAWB0awg (envelope-from ) for ; Mon, 28 Sep 2026 09:38:27 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=xMx3lMrd; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=hJZMLkcW; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=v7Lx/YFw; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=uPuzqWwX; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4AC101E01F; Mon, 28 Sep 2026 09:38:27 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id A9A1C1E01F for ; Mon, 28 Sep 2026 09:38:26 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F40304BAE7CB for ; Mon, 28 Sep 2026 13:38:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F40304BAE7CB Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=xMx3lMrd; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=hJZMLkcW; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=v7Lx/YFw; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=uPuzqWwX Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id EF0DD4B9DB71 for ; Mon, 28 Sep 2026 13:37:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF0DD4B9DB71 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 EF0DD4B9DB71 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790602679; cv=none; b=xVBPurfevcjfapG+HIPef9iJ+/cEvwxWgnmawJ12UYeEG3g8tHrFYZFchHUzCuz0HbmUw+kRcNyP8uxmSn8P7g+mj4+T5sFc3W4SkhdewcannEtj22k2WG64F2Wphws03ShXgKikrsyTATT1w9bEVQo9/O8jEv5SUTIEyiEJa5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790602679; c=relaxed/simple; bh=68W5u7EAHDOTD9PzGfEnDdVZnlmm4ZwsoWPODmRswVo=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:From:To; b=J89Eapisn9weIqQnOdfBobJtmFM2K0RtUqf/NCEIUYUkdgmfuumQLDuKJtp6fcfruXtf8eSoy8VdYspvTMZI2dOMPhDjPT/axbhobWo07fS5kwcx73imOKx2b+Am/kgTvJjTJ6rpMMjg81ZoENc0HHmSz4fpLNxv5+NJ89l59AE= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=xMx3lMrd; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=hJZMLkcW; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=v7Lx/YFw; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=uPuzqWwX DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF0DD4B9DB71 Received: from imap1.dmz-prg2.suse.org (unknown [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 CEA141FB14 for ; Mon, 28 Sep 2026 13:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790602674; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dCxpRZB2p+lptQDeq3do6FBTRBhw+dODULZ/hPUnYCQ=; b=xMx3lMrd2MBZ7UyIbzLgEvoKOH57Ya1592FO6dwgrv1p/k3MG6jVPgc9PmFKR2On0eSnpG HT4woE3/0vfvMEKBED+r8E/5XYuUElMxBqxHLGLEdlAYBmgd4gtg3K4z0okJOfLi37JgNP L4J7+xs1RBiH8ZSGNJgPmyFLlPTIWQw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790602674; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dCxpRZB2p+lptQDeq3do6FBTRBhw+dODULZ/hPUnYCQ=; b=hJZMLkcWQef3n/5+ZxM0Tt2c3+I7Q/j/cR/2hY70ZeoMNt1+MJKc3ExzckVN/Fo0uLExHN zTRS+FZusxrYkfDg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790602669; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dCxpRZB2p+lptQDeq3do6FBTRBhw+dODULZ/hPUnYCQ=; b=v7Lx/YFwFWtvrwO/nnKmy4iGVniLrIFmuRgL4km0rbEAHeZ3j7ucyFzkqkx5/8dmfwI8Rw TJdoNizlbG1AmDcfAFn/SL53EN5pN0Ouj0Ty16ovxjr0+A1FiaB6bO9n2D/apXlCxN1GMT G2o+QKQ1V2v7+Y9dGaXir5LzfRMhpZY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790602669; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dCxpRZB2p+lptQDeq3do6FBTRBhw+dODULZ/hPUnYCQ=; b=uPuzqWwXUsNnT8PflJ5u1R79uf2+cBJLqVX1YB5Ku4nHBuo6V7TvUAeJf7cCu/I+Mk4NK3 eaBkijm9j3pWZxCw== 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 9CBE2133F3 for ; Mon, 28 Sep 2026 13:37:49 +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 zlABHK1tumpgRgAAD6G6ig (envelope-from ) for ; Mon, 28 Sep 2026 13:37:49 +0000 Message-ID: <0275d14a-d063-4310-92da-d5d8ac728169@suse.de> Date: Mon, 28 Sep 2026 15:37:49 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC 2/5] [gdb/testsuite] Make lib/gdb.exp emacs indent compatible From: Tom de Vries To: gdb-patches@sourceware.org References: <20260904093858.359604-1-tdevries@suse.de> <20260904093858.359604-2-tdevries@suse.de> Content-Language: en-US In-Reply-To: <20260904093858.359604-2-tdevries@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-0.996]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 9/4/26 11:38 AM, Tom de Vries wrote: > There are cases in gdb/testsuite/lib/gdb.exp where we have inline C sources. > > Say we start out by writing something like this: > ... > set src { > int main (int argc) { > if (argc == 3) > return 0; > } > } > ... > > When editing with emacs, and using tcl-mode, auto indent will change this to: > ... > set src { > int main (int argc) { > if (argc == 3) > return 0; > } > } > ... > > The 2 vs 4 spacing is fine, but removing indentation is not. We can fix this > by adding braces: > ... > set src { > int main (int argc) { > if (argc == 3) { > return 0; > } > } > } > ... > > But that approach breaks down when we have a for loop. Auto indent gives us: > ... > set src { > int main (int argc) { > for (int i = 0; i < 1) { > argc++; > } > return argc; > } > } > ... > > This can be fixed with a trick: adding an if: > ... > set src { > int main (int argc) { > for (int i = 0; i < 1) if (1) { > argc++; > } > return argc; > } > } > ... > > Use these methods to make the inline sources in lib/gdb.exp compatible with > emacs auto indent. > > Note: this does not yet use emacs indentation. I've pushed this. Thanks, - Tom > --- > gdb/testsuite/lib/gdb.exp | 30 ++++++++++++++++++++---------- > 1 file changed, 20 insertions(+), 10 deletions(-) > > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index ea8bffc9e89..d4a471ff7c4 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -3134,6 +3134,9 @@ gdb_caching_proc allow_dlmopen_tests {} { > return 42; > } > } > + > + # Note: we use a "for ... if (1) ..." trick to make emacs tcl-mode indent > + # the for loop as if it was an if. > set src { > #define _GNU_SOURCE > #include > @@ -3155,9 +3158,11 @@ gdb_caching_proc allow_dlmopen_tests {} { > > r_debug = 0; > /* Taken from /usr/include/link.h. */ > - for (dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn) > - if (dyn->d_tag == DT_DEBUG) > + for (dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn) if (1) { > + if (dyn->d_tag == DT_DEBUG) { > r_debug = (struct r_debug *) dyn->d_un.d_ptr; > + } > + } > > if (!r_debug) { > printf ("r_debug not found.\n"); > @@ -11487,14 +11492,16 @@ gdb_caching_proc have_avx {} { > int main() { > unsigned int eax, ebx, ecx, edx; > > - if (!x86_cpuid (1, &eax, &ebx, &ecx, &edx)) > + if (!x86_cpuid (1, &eax, &ebx, &ecx, &edx)) { > return 0; > + } > > - if ((ecx & (bit_AVX | bit_OSXSAVE)) == (bit_AVX | bit_OSXSAVE)) > + if ((ecx & (bit_AVX | bit_OSXSAVE)) == (bit_AVX | bit_OSXSAVE)) { > return 1; > - else > + } else { > return 0; > } > + } > } > set compile_flags "incdir=${srcdir}/.." > if {![gdb_simple_compile $me $src executable $compile_flags]} { > @@ -11532,14 +11539,16 @@ gdb_caching_proc have_avx2 {} { > int main() { > unsigned int eax, ebx, ecx, edx; > > - if (!x86_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) > - return 0; > + if (!x86_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) { > + return 0; > + } > > - if ((ebx & bit_AVX2) == bit_AVX2) > + if ((ebx & bit_AVX2) == bit_AVX2) { > return 1; > - else > + } else { > return 0; > } > + } > } > set compile_flags "incdir=${srcdir}/.." > if {![gdb_simple_compile $me $src executable $compile_flags]} { > @@ -11642,8 +11651,9 @@ gdb_caching_proc has_hw_wp_support {} { > int main (void) { > volatile int local; > local = 1; > - if (local == 1) > + if (local == 1) { > return 1; > + } > return 0; > } > }